Search code examples
c++visual-studio-2012bulletbulletphysics

Bullet Physics, Collision between btBvhTriangleMeshShape and btStaticPlaneShape wont work


First some facts: I try to realise Collision Detection with Bullet in C++ using Visual Studio 2012. So far i have a Sphere:

    btCollisionShape* fallShape = new btSphereShape(100); 
    btDefaultMotionState* fallMotionState =
            new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,500,0)));
    btScalar mass = 1000;
    btVector3 fallInertia(0,0,0);
    fallShape->calculateLocalInertia(mass,fallInertia);
    btRigidBody::btRigidBodyConstructionInfo fallRigidBodyCI(mass,fallMotionState,fallShape,fallInertia);
    btRigidBody* fallRigidBody = new btRigidBody(fallRigidBodyCI);
    physicsWorld->addRigidBody(fallRigidBody);

and my level, realised as btBvhTriangleMeshShape:

    triangles.addTriangle(btVector3 (0, 0, 0),btVector3 (0, 0, 0),btVector3 (0, 0, 0));

btCollisionShape* levelShape = new btBvhTriangleMeshShape(&triangles, true, true);
    btDefaultMotionState* levelMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,0,0)));
  btRigidBody::btRigidBodyConstructionInfo
      levelRigidBodyCI(0,levelMotionState,levelShape,btVector3(0,0,0));
   btRigidBody* levelRigidBody = new btRigidBody(levelRigidBodyCI);
    physicsWorld->addRigidBody(levelRigidBody);

I know that in triangles is only one triangle but they collide.

My Problem is now, that when they collide, my program shuts down with no specific error, simply a unhandle exception window from visual studio.

Anyone an idea?


Solution

  • In this line

    triangles.addTriangle(btVector3 (0, 0, 0),btVector3 (0, 0, 0),btVector3 (0, 0, 0));
    

    You are giving all coordinates the zero value, so the triangle is not correct and maybe that is the cause of the problem.