Whenever I change the collision shape of a rigid body, the collisions with this body aren't updated.
Say, there is a body with a large shape with some other bodies lying on it. This this large shape is changed to a smaller one by setCollisionShape(). Then the bodies which were lying on top of it won't fall down. Instead, they remain in their position which is in the middle of air now.
I already tried to activate() the body with the updated shape, but it didn't help. I think I would have to active the bodies lying on top. How can I get a list of them? Is there a better way to recalculate collisions with the updated body?
How to refresh collisions after changing a body's shape?
-
- Posts: 6
- Joined: Sat May 04, 2013 3:18 pm
-
- Posts: 109
- Joined: Tue May 01, 2012 10:42 am
Re: How to refresh collisions after changing a body's shape?
I don't think there is an easy way to find the contacts with a body, besides looping trough the pair collision cache.
Maybe there is another way of solving your problem too, but going to the pair collision cache should work I think.
Maybe there is another way of solving your problem too, but going to the pair collision cache should work I think.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: How to refresh collisions after changing a body's shape?
Before you make any change to the collision shape (replace shape, resize etc) you need to
1) remove the rigid body from the world
2) make the change (resize etc)
3) re-insert the body into the world
Alternatively you can flush the contact points manually for the object involved:
dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(body->getBroadphaseHandle(), dynamicsWorld->getDispatcher());
1) remove the rigid body from the world
2) make the change (resize etc)
3) re-insert the body into the world
Alternatively you can flush the contact points manually for the object involved:
dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(body->getBroadphaseHandle(), dynamicsWorld->getDispatcher());
-
- Posts: 6
- Joined: Sat May 04, 2013 3:18 pm