I've been playing around with Bullet for a bit now but I've mainly used basic shapes for collision detection. I'm now looking at using generic triangular meshes but I'm a bit confused - I've got the convex triangular collision shapes with btConvexTriangleMeshShape working but when I run the convex hull creation algorithm over it to simplify the mesh further, I get quite bizarre results, see below for a basic box mesh (shows the mesh from debugDrawWorld() with DBG_DrawWireframe set):
Here's what I'm doing in code:
Code: Select all
std::unique_ptr<btConvexShape> intermediateShape = std::make_unique<btConvexTriangleMeshShape>(triMesh.get()); // triMesh is a btTriangleMesh with all the vertices
std::unique_ptr<btShapeHull> hull = std::make_unique<btShapeHull>(intermediateShape.get());
hull->buildHull(intermediateShape->getMargin());
collisionShape_ = std::make_unique<btConvexHullShape>(reinterpret_cast<const float*>(hull->getVertexPointer()), hull->numVertices()); // collisionShape_ is the main shape for the rigid body in question
Thanks!