Inheriting btCollisionObject & using btPersistentManifol

waffler
Posts: 3
Joined: Wed Jul 18, 2007 12:10 am

Inheriting btCollisionObject & using btPersistentManifol

Post by waffler »

I wanted to create inherited versions of btCollisionObject and btRigidObject that have a pointer to my GameEntity class that created that collision object. I have been trying to get this to work with btPersistentManifold::getBody0 and getBody1 (in a similar manner as in CollisionInterfaceDemo.cpp,) but I cannot get it to work -- a lot of crashing occurs.

How can I inherit from both btCollisionObject and btRigidObject properly and be able to get the game entity pointers of the objects that are touching? Is using getManifoldByIndexInternal the best way of handling this?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Inheriting btCollisionObject & using btPersistentMan

Post by Erwin Coumans »

It is recommended to simple store a pointer to your game entity inside the Bullet object. See setUserPointer and getUserPointer in btCollisionObject.

Hope this helps,
Erwin
waffler
Posts: 3
Joined: Wed Jul 18, 2007 12:10 am

Post by waffler »

Thanks! This would definitely remedy that huge headache I have developed! I didn't notice those functions when I looked at the Doxygen earlier.