Here is how i generate the convex hull.
Code: Select all
btConvexHullShape *hullShape = new btConvexHullShape;
hullShape->calculateLocalInertia(mass, inertia);
for (int i = 0; i < indices.size(); i++) {
int index = indices[i];
btVector3 point = btVector3(vertices[index].x, vertices[index].y, vertices[index].z);
hullShape->addPoint(point);
}
btShapeHull* hull = new btShapeHull(hullShape);
btScalar margin = hullShape->getMargin();
hull->buildHull(margin);
btConvexHullShape* simplifiedConvexShape = new btConvexHullShape((btScalar*)hull->getVertexPointer(), hull->numVertices());
btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(mass, motionstate, simplifiedConvexShape, inertia);
btRigidBody *RigidBody = new btRigidBody(rigidBodyCI);
return RigidBody;
Another Note: When i start the program i get slow (not laggy) performance, after 3-4 seconds it goes away and no performance drops are present, is this normal ?