Bug with Rigid Body

iisystem

16-10-2009 23:14:25

addRigidBody() crashes when RigidBody has mass > 0.


// barrel
Vector3 pos(710, HeightFunction::getTerrainHeight(710,710)+6, 710);
Entity *barrel = sceneMgr->createEntity("barrel1", "barrel.mesh");
SceneNode *barrelNode = sceneMgr->getRootSceneNode()->createChildSceneNode(pos);
barrelNode->attachObject(barrel);

CylinderCollisionShape *barrelShape = new CylinderCollisionShape(Vector3(2,2,2), Vector3(0,0,0));
RigidBody *barrelBody = new RigidBody("barrel1body", mWorld);
barrelBody->setShape(barrelNode, barrelShape, 1,1,10, pos); // here mass is 10
barrelBody->getBulletObject()->getWorldTransform().setOrigin(V3toB3(pos));
mWorld->addRigidBody(barrelBody, btBroadphaseProxy::KinematicFilter, btBroadphaseProxy::AllFilter); // here will die

Fish

17-10-2009 02:02:33

These lines of code are not needed:

//barrelBody->getBulletObject()->getWorldTransform().setOrigin(V3toB3(pos));
//mWorld->addRigidBody(barrelBody, btBroadphaseProxy::KinematicFilter, btBroadphaseProxy::AllFilter);

Your call to setShape() will set the objects origin based upon the provided position and the optional quaternion and then add the RigidBody to the dynamics world for you (among other things).

-Fish