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?
how do implement a collision shape that constantly change?
-
- Posts: 43
- Joined: Fri Jun 15, 2012 7:11 am
-
- Posts: 149
- Joined: Fri Jun 24, 2011 8:53 am
Re: how do implement a collision shape that constantly chang
Sorry, I have no real data for this case.
I'm replying so I get notifications as I'm interested as well.
I'm replying so I get notifications as I'm interested as well.
-
- Posts: 66
- Joined: Tue Mar 02, 2010 6:13 am
Re: how do implement a collision shape that constantly chang
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 .
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 .
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: how do implement a collision shape that constantly chang
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:
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());