Raycast misses body after position is changed

Starfox
Posts: 37
Joined: Wed Jul 27, 2011 12:01 am

Raycast misses body after position is changed

Post by Starfox »

I have a frozen scene with a bunch of objects. I ray cast to get the nearest one, and that works. Now after I manipulate its position using rigid_body->getWorldTransform().setOrigin(Vector); future ray-casts miss it completely. The visualized ray goes right through it but no points are generated. If I step the world once this problem is fixed. Am I doing something wrong there?
Starfox
Posts: 37
Joined: Wed Jul 27, 2011 12:01 am

Re: Raycast misses body after position is changed

Post by Starfox »

Here's a video showing that bug in action - am I abusing the API or did I come across a bug in Bullet?

http://www.youtube.com/watch?v=g_jDwJz3Bes
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Raycast misses body after position is changed

Post by Erwin Coumans »

You need to make sure the broadphase acceleration structures are up-to-date.

If you are not calling 'stepSimulation' or performDiscreteCollisionDetection, you might want to try this:

Code: Select all

	world->updateAabbs();
	broadphasePairCache->calculateOverlappingPairs(dispatcher);
Thanks,
Erwin
Starfox
Posts: 37
Joined: Wed Jul 27, 2011 12:01 am

Re: Raycast misses body after position is changed

Post by Starfox »

That fixed it - thanks a lot.