Hello,
while testing BulletGhostNode i faced the following issue: if there is a BulletPlaneShape in the scene, the ghost object always reports that it’s overlapping with the plane even though they are far apart. is this the default behavior?
any help is appreciated,
best regards,
Here is the code i’m using:
int main(int argc, char *argv[])
{
// Open a new window framework and set the title
framework.open_framework(argc, argv);
framework.set_window_title("My Panda3D Window");
// Open the window
WindowFramework *window = framework.open_window();
NodePath camera = window->get_camera_group();
camera.set_pos(0, 40, 20);
camera.look_at(0, 0, 0);
Thread *current_thread = Thread::get_current_thread();
//=============
// bullet world
PT(BulletWorld) world = new BulletWorld;
world->set_gravity(LVector3f(0, 0, -9.81));
//=============
//plane
PT(BulletPlaneShape) plane_shape = new BulletPlaneShape(LVector3f(0, 0, 1), 0);
PT(BulletRigidBodyNode) plane_node = new BulletRigidBodyNode("plane1");
plane_node->add_shape(plane_shape);
NodePath plane_nodepath = window->get_render().attach_new_node(plane_node);
plane_nodepath.set_pos(0, 0, -2);
world->attach_rigid_body(plane_node);
plane_node->set_into_collide_mask(CollideMask::all_on());
//=============
// bullet debug
PT(BulletDebugNode) debug_node = new BulletDebugNode("debug");
debug_node->set_verbose(false);
NodePath debug_nodepath = window->get_render().attach_new_node(debug_node);
debug_nodepath.show();
world->set_debug_node(debug_node);
//============
// ghost node for collision testing
PT(BulletBoxShape) ghost_box_shape = new BulletBoxShape(LVector3f(1, 1, 1));
PT(BulletGhostNode) ghost_box_node = new BulletGhostNode("ghost_box");
ghost_box_node->add_shape(ghost_box_shape);
NodePath ghost_box_nodepath = window->get_render().attach_new_node(ghost_box_node);
ghost_box_nodepath.set_pos(-3, 3, 10);
ghost_box_nodepath.set_collide_mask(3);
world->attach_ghost(ghost_box_node);
while(framework.do_frame(current_thread))
{
world->do_physics(globalClock->get_dt());
int n = ghost_box_node->get_num_overlapping_nodes();
if( n > 0)
{
for(int z = 0; z < n; z++)
cout << ghost_box_node->get_overlapping_node(z)->get_name() << "\n";
}
}
framework.close_framework();
return (0);
}