Page 1 of 1

how do implement a collision shape that constantly change?

Posted: Thu Nov 15, 2012 5:35 am
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?

Re: how do implement a collision shape that constantly chang

Posted: Thu Nov 15, 2012 1:11 pm
by MaxDZ8
Sorry, I have no real data for this case.
I'm replying so I get notifications as I'm interested as well.

Re: how do implement a collision shape that constantly chang

Posted: Thu Nov 15, 2012 9:21 pm
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 .

Re: how do implement a collision shape that constantly chang

Posted: Fri Nov 16, 2012 5:22 pm
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());