I'm setting up a character controller in my Bullet/Ogre application. Currently I'm starting the character 50 meters above the ground for various debugging purposes. As the character falls towards the ground, everything is fine. But the instant the character hits the static plane I'm using as a floor, the application crashes. I've managed to pinpoint the problem to a single line of code, dynamicsWorld->stepSimulation, right when the ghost object capsule hits the static plane.
Code:
Code: Select all
void setup() {
//...
ghostObject = new btPairCachingGhostObject();
ghostObject->setWorldTransform(btTransform(btQuaternion().getIdentity(), btVector3(x, y, z)));
broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
btConvexShape* capsule = new btCapsuleShape(.8f, 1.8f);
ghostObject->setCollisionShape(capsule);
ghostObject->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT);
character = new btKinematicCharacterController(ghostObject,capsule,0.35f);
dynamicsWorld->addCollisionObject(ghostObject,btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter|btBroadphaseProxy::DefaultFilter);
dynamicsWorld->addAction(character);
//...
}
void update() {
//...
dynamicsWorld->stepSimulation(((float)elapsedTime)/1000.f); <<<<<<<<<<< this line causes the crash
dynamicsWorld->debugDrawWorld();
btVector3 o = ghostObject->getWorldTransform().getOrigin();
float x = o.x();
float y = o.y();
float z = o.z();
ogreCharacter->setPosition(x, y, z);
//...
}
Thanks,
Kukanani