isInside not working for btConvexHullShape of Bullet Physics library

343 views Asked by At

I have created a btConvexHullShape using a .obj file. I have checked its other properties and it seems created properly.

Now I have to perform a collision detection check. for that I need to use the isInside function. But its returning False whether the point is inside or outside.

Can any one help?

human = new btConvexHullShape();
 for (int i = 0; i < av->vertI; i++)
 {
  human->addPoint(btVector3(btScalar(av->vertices[i][0]), btScalar(av->vertices[i][1]), btScalar(av->vertices[i][2])));

 }

 CString s;
 btVector3 cx(0, -2, 1);
 if (human->isInside(cx, btScalar(1)))
 {
  OutputDebugString(L"True\n");
 }
 else
  OutputDebugString(L"False\n");

1

There are 1 answers

0
Nic On

I reproduced the same issue using BulletSharp in C#. Here is my code:

    // test isInside
    ConvexHullShape hull = new ConvexHullShape();
    hull.AddPoint(new Vector3(100,0,0));
    hull.AddPoint(new Vector3(100, 100, 0));
    hull.AddPoint(new Vector3(0, 100, 0))
    hull.AddPoint(new Vector3(0,0, 0));
    hull.AddPoint(new Vector3(50,50,100));
    bool checkInside = hull.IsInside(new Vector3(50, 50, 50), 1);

checkInside is false, whereas the point {50,50,50} is inside the convex hull. I looked up the BtConvexHullShape class implemententation. It seems that the IsInside function is not implemented yet and always returns false.

    //not yet
    bool btConvexHullShape::isInside(const btVector3& ,btScalar ) const
    {
         btAssert(0);
         return false;
    }

I did some googling on my own and found an IsInside() implementation for triangular mesh objects. The proposed solution uses ray-casting. I haven't tested the code yet, but it looks promising.