SoftBody is slipping through RigidBody.

Post Reply
uknown_user123
Posts: 1
Joined: Tue Sep 24, 2019 3:59 pm

SoftBody is slipping through RigidBody.

Post by uknown_user123 » Tue Sep 24, 2019 4:24 pm

Hey guys,
I've recently started doing stuff with bullet and can't figure out something.

I have got a simple soft body (a square patch) and a mesh that I load myself with tiny_obj_loader. I throw the patch on the mesh and expect it to get stuck on top of it.

Here's what I get: https://www.youtube.com/watch?v=VSS-G48 ... e=youtu.be

I can see that there's some kind of collision, since the patch is being pulled up a bit in the center when it goes through the mesh.
When I use the box primitive instead of a mesh, everything works fine.

So, here's the question:
How do I create a mesh properly and what am I doing wrong?

Code: Select all

    btTriangleMesh* triangleMeshTerrain = new btTriangleMesh();
    // here I parse the .obj file and add triangles via 'triangleMeshTerrain->addTriangle(vertex1, vertex2, vertex3);'
    btCollisionShape* collisionShapeTerrain = new btBvhTriangleMeshShape(triangleMeshTerrain, true);

    btTransform meshTransform;
    meshTransform.setIdentity();
    meshTransform.setOrigin(btVector3(0.0, 0.0, 0.0));
    btDefaultMotionState* motionState = new btDefaultMotionState(meshTransform);

    btRigidBody::btRigidBodyConstructionInfo rigidBodyConstructionInfo(0.0f, motionState, collisionShapeTerrain, btVector3(0.0, 0.0, 0.0));
    btRigidBody* rigidBodyTerrain = new btRigidBody(rigidBodyConstructionInfo);
    rigidBodyTerrain->setFriction(btScalar(0.9));

    getDynamicsWorld()->addRigidBody(rigidBodyTerrain);
I believe the mesh is alright and I parse it correctly, since it's rendered okay.


Thanks,
Denis

Post Reply