I'm new to Bullet and I was wondering if it's possible to assign custom data pointer to every triangle in a btBvhTriangleMeshShape and then when using btCollisionWorld::ClosestRayResultCallback to ray test I'd like to get the triangle that was hit and use the custom data pointer stored in it?
If the part wit custom data pointer isn't possible, is there at least any way of getting the material data of the triangle that was collided with the btCollisionWorld::ClosestRayResultCallback ray?
The code that I'm currently using to determine if an object was hit is:
Code: Select all
btCollisionWorld::ClosestRayResultCallback ray_callback(ray_from,ray_to);
p_dynamics_world->rayTest(ray_from,ray_to,ray_callback); // btDiscreteDynamicsWorld
if(ray_callback.hasHit())
{
btRigidBody* body = btRigidBody::upcast(ray_callback.m_collisionObject);
if(body)
{
/// get custom data pointer stored inside rigid body and handle the event
}
}
Regards,
Domen