DanielChappuis / reactphysics3d

Open source C++ physics engine library in 3D

Home Page:http://www.reactphysics3d.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ConvexMeshShape colliders not colliding properly

frcandela opened this issue · comments

ConvexMeshShape colliders don't collide properly overlap/go through each others.
I have an example here with a mesh shaped like a wedge that I generated in blender. I made sure there are no coplanar faces and it is convex. All triangles are all oriented in the same direction.
You can reproduce the problem using the following steps.

-In the testbed, open ConvexMesh.cpp and generate the polygon vertex array using the following code:

    openglframework::Vector3* vertices = new openglframework::Vector3[6];
    vertices[0] = {-2.992055, -1.803289, -0.496232};
    vertices[1] = {-2.992055, -1.803289, 0.496232};
    vertices[2] = {-2.992055, 1.803289, -0.496232};
    vertices[3] = {-2.992055, 1.803289, 0.496232};
    vertices[4] = {2.992055, -1.803289, 0.000000};
    vertices[5] = {2.992055, 1.803289, 0.000000};

      int* indices = new int[18];
      indices[0] = 0;  indices[1] = 1;  indices[2] = 3;  indices[3] = 2;
      indices[4] = 2;  indices[5] = 3;  indices[6] = 5;
      indices[7] = 4;  indices[8] = 1;  indices[9] = 0;
      indices[10] = 2; indices[11] = 5; indices[12] = 4; indices[13] = 0;
      indices[14] = 5; indices[15] = 3; indices[16] = 1; indices[17] = 4;

      rp3d::PolygonVertexArray::PolygonFace* faces = new rp3d::PolygonVertexArray::PolygonFace[5];
      faces[0] = {4,0};
      faces[1] = {3,4};
      faces[2] = {3,7};
      faces[3] = {4,10};
      faces[4] = {4,14};

      mPolygonVertexArray =
              new rp3d::PolygonVertexArray(6, vertices, sizeof(openglframework::Vector3),
                                           indices, sizeof(int),
                                           5, faces,
                                           rp3d::PolygonVertexArray::VertexDataType::VERTEX_FLOAT_TYPE,
                                           rp3d::PolygonVertexArray::IndexDataType::INDEX_INTEGER_TYPE);

-Set testbed/meshes/convexmesh.obj with the following data (same vertices and indices as the previous step)

o Wedge
v -2.992055 -1.803289 -0.496232
v -2.992055 -1.803289 0.496232
v -2.992055 1.803289 -0.496232
v -2.992055 1.803289 0.496232
v 2.992055 -1.803289 0.000000
v 2.992055 1.803289 0.000000
s 1
f 1 2 4 3
f 3 4 6
f 5 2 1
f 3 6 5 1
f 6 4 2 5
  • Set the NB_MESHES=50 in ConcaveMeshScene.h. Set the other collisions shapes numbers to zero
  • Start the testbed, open the ConcaveMesh Scene
  • Play the simulation and observe the wedge convex shape overlapping with the terrain

wedge_bug