Hi! I'm trying to integrate the Bullet physics library into engine.
But some collisions are weird. Also, sometimes I get an assertion, because the W component of some objects in the scene become 0. I don't know why -.-"
This is how I start the physics simulation:
config = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(config);
broadphase = new btDbvtBroadphase();
solver = new btSequentialImpulseConstraintSolver();
world = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, config);
world->setGravity(btVector3(0.0, -9.81, 0.0));
And this is how I create a mesh made of triangles (I know there are other efficient meshes, but it's just to see if it works):
collisionShape = new btConvexHullShape();
const unsigned int size = model->vertices.size();
for (unsigned int i = 0; i != size; i++)
collisionShape->addPoint(btVector3(model->vertices[i].x, model->vertices[i].y, model->vertices[i].z));
motionstate = new btDefaultMotionState(btTransform(
btQuaternion(rotation.x, rotation.y, rotation.z, 1.0),
btVector3(position.x, position.y, position.z)
));
btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(
mass, // mass, in kg. 0 -> Static object, will never move.
motionstate,
collisionShape, // collision shape of body
btVector3(position.x, position.y, position.z) // local inertia
);
rigidBody = new btRigidBody(rigidBodyCI);
Physics::world->addRigidBody(rigidBody);
And this is what happens:
https://www.youtube.com/embed/sNFf4Gx_CNM
I have also tried btBvhTriangleMeshShape, creating the object and giving all the triangles of my mesh, but it doesn't even collide with anything.
I followed the official documentation, but it does not work. Am I missing something?
I am new to physic engine, so I think I'm missing something.
I also tried scaling my models, because some people said that physic engine work better with large geometry... but nothing.
Any ideas?