Hello,
I have googled and for quite some time now and i seem to only find the same type of answer.
And the result im getting is so strange.
The goal is to create a trigger volume (for now a box) that should trigger events whenever something enters it.
According to the Bullet, btGhostObject is the way to go for simple triggers.
This is my code for setting up bullet.
m_BulletBroadphase = new btDbvtBroadphase();
m_BulletConfiguration = new btDefaultCollisionConfiguration();
m_BulletDispatcher = new btCollisionDispatcher( m_BulletConfiguration );
m_BulletSolver = new btSequentialImpulseConstraintSolver;
m_BulletDynamicsWorld = new btDiscreteDynamicsWorld( m_BulletDispatcher, m_BulletBroadphase, m_BulletSolver, m_BulletConfiguration );
m_BulletDynamicsWorld->setGravity( btVector3(0.0f, -50.0f, 0.0f) );
m_BulletDynamicsWorld->getPairCache()->setInternalGhostPairCallback( new btGhostPairCallback() ); btGhostObject
// create trigger volume
btTransform world( btQuaternion(rotation.yaw, rotation.pitch, rotation.roll), btVector3(location.x, location.y, location.z) );
m_GhostObject = new btGhostObject();
m_GhostObject->setCollisionShape( new btBoxShape(btVector3(10.0f, 5.0f, 10.0f)) );
m_GhostObject->setWorldTransform( world );
getGameWorld()->getBulletDynamicWorld()->addCollisionObject( m_GhostObject );
....
// check for intersections
btAlignedObjectArray< btCollisionObject * > & pairs = m_GhostObject->getOverlappingPairs();
for( pmInt32 i=0; i<pairs.size(); ++i )
{
....
} And finally, the object that i use to test the trigger with
btDefaultMotionState * motionState = new btDefaultMotionState();
btVector3 inertia;
m_Shape = new btBoxShape(btVector3(5.0f, 5.0f, 5.0f));
m_Shape->calculateLocalInertia( m_Mass, inertia );
btRigidBody::btRigidBodyConstructionInfo rigidBodyCI( m_Mass, motionState, m_Shape, inertia );
m_Body = new btRigidBody( rigidBodyCI ); The simulation looks correct, the rigid body spawns highup in the air and falls down correctly.
The btRigidBody is transformed to location(0.0f, 40.0f, 0.0f)
And the trigger is transformed to location(0.0f, 5.0f, 0.0)
The problem im getting is that in the triggers intersection check i instantly get a overlapping pair.
Even though they are really far apart and their AABBs cant intersect.
I also checked their worldTransforms, they indicate that they are positioned correctly. I went as far to even set the interpolatedWorldTransform but
it dident help.
Have anyone else had this problem or am i just missing something basic here?