I'm removing and immediately re-adding some rigid bodies in order to change their collision group, which seems to be the best way to immediately change it. (I tried getting the BroadphaseProxy and changing the group directly through there, but it doesn't seem to have any effect, or at least not straight away)
The problem I'm now having is that I'm using a btPairCachingGhostObject to set some properties when RigidBodies are colliding with it, and it seems that the ghost object doesn't detect a rigid body on the frame it's removed and re-added. I assume not keeping objects that have been removed in the cache is intentional to avoid accessing objects which aren't in the simulation anymore, so I tried calling dispatchAllCollisionPairs() to get back the collision (since the object is removed and then immediately re-added) but that still doesn't find the rigid body.
Since I'm using the ghost object to alter some properties of the objects, having it think the object has quickly left the object then returned on the next frame causes some weird behaviour. I've managed to work around this already, so it's not a major issue, but I'm just wondering if this is unavoidable, or if there's a way I can force the ghost object to recognise the rigid body as soon as it's added, 'cause that would obviously be preferable :3
GhostObject doesn't detect RigidBody on frame it's added?
-
- Posts: 13
- Joined: Fri Sep 07, 2012 9:50 pm
-
- Posts: 7
- Joined: Wed Mar 06, 2013 9:12 pm
Re: GhostObject doesn't detect RigidBody on frame it's added
Ran into the same problem, glad to get confirmation that it is a Bullet limitation and not a bug of my own...
My current thought is to keep track of removed/readded bodies per frame and then supplement the overlapping pairs with the results of a few manual contactPairTest() calls. Or perhaps I could try doing two physics steps always with shorter timesteps. What was your workaround?
Of course a proper solution would be nice, some magical flag that needs set...
My current thought is to keep track of removed/readded bodies per frame and then supplement the overlapping pairs with the results of a few manual contactPairTest() calls. Or perhaps I could try doing two physics steps always with shorter timesteps. What was your workaround?
Of course a proper solution would be nice, some magical flag that needs set...
-
- Posts: 7
- Joined: Wed Mar 06, 2013 9:12 pm
Re: GhostObject doesn't detect RigidBody on frame it's added
Actually, I'm now having success with updateAabbs(). Calling that after I add the object but before I step the simulation appears to solve my problems.
a similar topic: http://www.bulletphysics.org/Bullet/php ... f=9&t=4611
though I haven't found it necessary to calculateOverlappingPairs().
a similar topic: http://www.bulletphysics.org/Bullet/php ... f=9&t=4611
though I haven't found it necessary to calculateOverlappingPairs().