Hey.
Im trying to sort out when one of my btGImpactMeshShapes collides with something and process it accordingly. I can do this quite fine right now using:
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
if(obA->getCollisionShape()->getName() == m_GImpactShape->getName() || obB->getCollisionShape()->getName() == m_GImpactShape->getName())
Problem is that this will only work for one btGImpactMeshShape since getName() returns ""GImpactMesh"" and nothing else, hard coded into btGImpactShape.h. I need to know which one of my btGImpactMeshShapes that is colliding in order to process that individual mesh properly. Ive overloaded btGImpactMeshShape just adding set/get debug_ID to enable tagging the shapes, but I still need to set the ID to something. My thought being ofc to set it to the same ID that bullet uses for its rigidbody. I CAN get this ID by doing:
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
btRigidBody* testA = (btRigidBody*)obA; //get the debugID of the rigidBody of the collision object.
btRigidBody* testB = (btRigidBody*)obA; //get the debugID of the rigidBody of the collision object.
testA->m_debugBodyId;
testB->m_debugBodyId;
However, in order to do that I need my btGImpactMeshShape to be a btCollisionObject being used by the btPersistentManifold, aka colliding with something. Im sure theres some way to access the rigidBody of the btGImpactshape in some other way, but I just cant seem to find how. What I would like to do is to access the rigidBody as soon as I creates my btGImpactMeshShape and set its debugBodyId accordingly. Any hints on how to do this? feeling kinda lost here atm
problem with btRigidBody and btGImpact connection
-
- Posts: 1
- Joined: Thu Jan 31, 2008 1:42 pm
- Location: Sweden
-
- Posts: 109
- Joined: Thu Dec 14, 2006 4:27 pm
- Location: Colombia
Re: problem with btRigidBody and btGImpact connection
In Bullet arquitecture, collision classes are missing some Object Oriented features like object names, or identifiers, or introspection (class info).
You must provide a mechanism for storing that meta-information (like names or identifiers) in the btCollisionShape class. Just add an String attribute for that.
I suggest that Bullet should have a base class for all objects (Like btObject) which should has methods for assign-getting its name, identifiers and also class info (runtime type info).
But I think that added functionality could degrade the packed memory structure in Bullet objects, which is necessary for align their memory for SIMD operations.
You must provide a mechanism for storing that meta-information (like names or identifiers) in the btCollisionShape class. Just add an String attribute for that.
I suggest that Bullet should have a base class for all objects (Like btObject) which should has methods for assign-getting its name, identifiers and also class info (runtime type info).
But I think that added functionality could degrade the packed memory structure in Bullet objects, which is necessary for align their memory for SIMD operations.