how do implement a collision shape that constantly change?

Post Reply
khoowaikeong
Posts: 43
Joined: Fri Jun 15, 2012 7:11 am

how do implement a collision shape that constantly change?

Post by khoowaikeong »

one can just keep replacing the shape with the new one each frame, but i am wondering if there is a "correct" way of approaching this problem...

basically our design side wants the ability to define several collision meshes in the model tool, how to extract the data i have figure out, but what to do with the data and feed it into bullet, I need some opinions... how expensive is it to recreate the shape every frame?
MaxDZ8
Posts: 149
Joined: Fri Jun 24, 2011 8:53 am

Re: how do implement a collision shape that constantly chang

Post by MaxDZ8 »

Sorry, I have no real data for this case.
I'm replying so I get notifications as I'm interested as well.
User avatar
majestik666
Posts: 66
Joined: Tue Mar 02, 2010 6:13 am

Re: how do implement a collision shape that constantly chang

Post by majestik666 »

I implemented that in our version, basically recomputing a collision shape
on every frame based on the input mesh.
It's not that efficient but really the only way to do it if you don't know
if the topology of the mesh is changing per frame or not.

Every frame I do
compute new collision shape
remove old col shape from rbd
add new col shape to rbd
recalculate inertia, mass,etc .
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: how do implement a collision shape that constantly chang

Post by Erwin Coumans »

The best is if you remove the body from the world, before replacing/changing the collision shape, and then re-insert the body back into the world. This makes sure that the cached (potentially invalid) contact points get removed.

As majestik666 mentions you need to update the inertia tensor.

You can also keep the body into the world, but then you need to manually update the contact points:

Code: Select all

world->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(body->getBroadphaseHandle(),world->getDispatcher());
Post Reply