Im implementing a ghost object so I could get contact added and contact removed callbacks to notify my engine.
Y used a btGhostPairCallback and implemented the addOverlappingPair and removeOverlappingPair
and now I get the collision pair additions and removal, BUT they appear to use the AABB of the ghost and not the Capsule i gave to the GhostObject:
this is my Initialization :
Code: Select all
btDynamicsWorld *phyWorld;
btCollisionWorld *collisionWorld;
BtOgre::DebugDrawer *dbgdraw;
btAxisSweep3 *mBroadphase;
btDefaultCollisionConfiguration *mCollisionConfig;
btCollisionDispatcher *mDispatcher;
btSequentialImpulseConstraintSolver *mSolver;
mBroadphase = new btAxisSweep3(btVector3(-10000,-10000,-10000), btVector3(10000,10000,10000), 1024);
BtGhostPairCallback * GhostCallback=new BtGhostPairCallback(); //uses B capital, because is my Implementation of it (class BtGhostPairCallback : public btGhostPairCallback)
mCollisionConfig = new btDefaultCollisionConfiguration();
mDispatcher = new btCollisionDispatcher(mCollisionConfig);
mSolver = new btSequentialImpulseConstraintSolver();
collisionWorld = new btCollisionWorld(
mDispatcher,
mBroadphase,
mCollisionConfig);
phyWorld = new btDiscreteDynamicsWorld(
mDispatcher,
mBroadphase,
mSolver,
mCollisionConfig);
phyWorld->setGravity(btVector3(0,(float)-9.80,0));
phyWorld->getPairCache()->setInternalGhostPairCallback(GhostCallback);
Code: Select all
if (shape=="ghost")
{
BtGhost * Ghost=new BtGhost(obj); //again BtGhost is mine and contains a btGhostObject
Ghost->m_ghostObject = new BtGhostObject();
Ghost->m_ghostObject->setUserPointer(Ghost);
btTransform startTransform;
startTransform=btTransform::getIdentity();
startTransform.setOrigin (BtOgre::Convert::toBullet(obj->Node->getPosition()));
startTransform.setRotation (BtOgre::Convert::toBullet(obj->Node->getOrientation()));
Ghost->m_ghostObject->setWorldTransform(startTransform);
btScalar characterHeight=obj->Entity->getBoundingBox().getSize().y;
btScalar characterWidth =obj->Entity->getBoundingBox().getSize().x;
btConvexShape* capsule = new btCapsuleShape
( characterWidth/2, characterHeight/2);
Ghost->m_ghostObject->setCollisionShape (capsule);
Ghost->m_ghostObject->setCollisionFlags (btCollisionObject::CF_CHARACTER_OBJECT);
btScalar stepHeight = btScalar(0.1);
Ghost->m_character = new BtGhostController (
Ghost->m_ghostObject,
capsule,
stepHeight);
Ghost->m_character->setGravity(9.8);
Ghost->Obj=static_cast<OOBJECT*>(pobj);
Ghost->ShapeName=shape;
Ghost->Shape=capsule;
Ghost->Body=Ghost->m_ghostObject;
Ghost->Body->setUserPointer((void*)Ghost);
this->phyWorld->addCollisionObject(
Ghost->m_ghostObject,
btBroadphaseProxy::CharacterFilter,
btBroadphaseProxy::StaticFilter |
btBroadphaseProxy::DefaultFilter);
this->phyWorld->addAction(Ghost->m_character);
Ghost->m_character->setJumpSpeed(20.0);
this->Bodies.push_back(Ghost);
std::string name=pobj->GetName();
this->mBodies[name]=Ghost;
this->dBodies[Ghost]=pobj;
this->UpdateList.push_back(Ghost);
return Ghost;
}
So, that's the code... what im missing? why i get contact with the ghost but not the capsule?
thanks!