I am currently trying to implement a traffic simulator, and detect where the users vehicle is located (which side of road, inside intersection, parking lot, etc). I also need to detect collisions with other vehicles.
So currently I have one raycast vehicle that has a ghost object attached which follows the movement of the car (so that I can efficiently detect overlaps/collisions with other rigid bodies). This works very well. I also have ghost objects that I want to use as triggers, but the ghost object attached to the vehicle does not seem to be able to detect these triggers.
In other words, I want to detect overlaps between two ghost objects.
This is how I create the ghost objects (both triggers and the one following the vehicle):
Code: Select all
btConvexShape* collisionShape = ...;
m_ghostObject = new btPairCachingGhostObject();
m_ghostObject->setWorldTransform(startTransform);
m_ghostObject->setCollisionShape(collisionShape);
m_ghostObject->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE);
m_ghostObject->setUserPointer(...);
m_dynamicsWorld->addCollisionObject(m_ghostObject, btBroadphaseProxy::SensorTrigger, btBroadphaseProxy::AllFilter & ~btBroadphaseProxy::SensorTrigger);
Code: Select all
btBroadphasePairArray& pairArray = m_vehicleGhostObject->getOverlappingPairCache()->getOverlappingPairArray();
int numPairs = pairArray.size();
Does anybody have any pointers or advice on how to get this to work?
Thanks