I try to use btBvhTriangleMeshShape for static geometry, that is basically my non-moving environment, and it is created like this:
Code: Select all
mTriangleIndexVertexArray = new btTriangleIndexVertexArray( (int)(mVertexIndexes.size()/3), //number of triangle faces
(int*)&mVertexIndexes[0], //index array
(int)(3*sizeof(vInt)), //index stride
(int)mVertexPositions.size(), //number of vertexes
(btScalar*)&mVertexPositions[0].x, //vertex array
(int)sizeof(cVec3) );
mCollisionShape = new btBvhTriangleMeshShape( mTriangleIndexVertexArray, true, true );
Code: Select all
mMotionState = new btDefaultMotionState( btTransform( btQuaternion( orientation.x, orientation.y, orientation.z, orientation.w),
btVector3(translation.x, translation.y, translation.z) ) );
btScalar mass = 0;
btVector3 btInertia = btVector3(0,0,0);
btBvhTriangleMeshShape* triMeshShape = dynamic_cast<btBvhTriangleMeshShape*>(hull->getCollisionShape());
triMeshShape->calculateLocalInertia( mass, btInertia);//HERE THE BULLETT ASSERT KICKS IN
btRigidBody::btRigidBodyConstructionInfo rigidBodyConstructionInfo( mass, mMotionState, triMeshShape, btInertia);
mRigidBody = new btRigidBody( rigidBodyConstructionInfo );
mRigidBody->setFriction(1.5);
dynamicsWorld->getPhysicsWorld()->addRigidBody( mRigidBody );
If I am not mistaken, I need to call calculateLocalInertia with 0 mass, and 0 inertia, to flag it as a non-moving shape.
My issue is that whenever I call calculateLocalInertia function (see above) an assert triggers in the following bullet code:
Code: Select all
void btTriangleMeshShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
{
(void)mass;
//moving concave objects not supported
btAssert(0);
inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
}
Well, I do want to use it for static environment, but have no idea how to tell it to bullet then.
How can I tell bullett that, my btBvhTriangleMeshShape is a non-moving shape?
In which line of my code confuses Bullett?
Any help is greatly appreciated.
Thank you,
A