Best way to implement 'buffer zone' around btRigidBody

User avatar
sinoth
Posts: 13
Joined: Tue Apr 07, 2009 8:27 pm
Location: USA

Best way to implement 'buffer zone' around btRigidBody

Post by sinoth »

I have a spherical player object and I'm wanting a 'buffer zone' around the player (a larger sphere) to pick up collisions with walls even if the player isn't touching them. The reason for this is to allow the player to 'suck' toward the nearest wall with a button, so I need to keep a list of vectors pointing toward close surfaces.

Currently, I am syncing up a btPairCachingGhostObject with the player btRigidBody through a motionState, which seems okay but I read something in another topic that made me reconsider. It's my understanding that this is what happens: the ghost object is synced up after the physics tick and after all the contacts are processed, so the ghost object will always be one frame behind the actual rigid body it is following.

Is this the case? If so, is there some better way to sync up the ghost object (instead of a motionState) so it isn't lagging behind? Do I need to do something completely different like btCollisionWorld::contactTest?

Thanks :)
User avatar
sinoth
Posts: 13
Joined: Tue Apr 07, 2009 8:27 pm
Location: USA

Re: Best way to implement 'buffer zone' around btRigidBody

Post by sinoth »

After some playing I've found a strange behavior with contactTest. If I do a contactTest (using a btRigidBody with btSphereShape) inside the tick callback, the performance is terrible and returns incorrect results. If I use the same code outside the tick callback, the results are fine and performance is great.

Is there an issue with calling contactTest within the post-tick callback?