Here is how I'm initializing everything:
Code: Select all
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
btVector3 worldAabbMin(-1000,-1000,-1000);
btVector3 worldAabbMax(1000,1000,1000);
btAxisSweep3* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax);
// Create the collision world.
collisionWorld = new btCollisionWorld(dispatcher,broadphase,collisionConfiguration);
Code: Select all
// Convert AABB to extents.
btVector3 aabbMin(BBox->Min.x - Pos.x, BBox->Min.y - Pos.y, BBox->Min.z - Pos.z),
aabbMax(BBox->Max.x - Pos.x, BBox->Max.y - Pos.y, BBox->Max.z - Pos.z);
btTriangleMesh *m_indexVertexArrays= new btTriangleMesh(TRUE, FALSE);
// Add triangles to Mesh Shape.
for (int i=0; i<Mesh.nNumFaces; i++)
{
btVector3 v1= btVector3(pVertex->x, pVertex->y, pVertex->z);
pVertex = (PVRTVECTOR3*)( (unsigned char*)(pVertex) + Mesh.sVertex.nStride);
btVector3 v2= btVector3(pVertex->x, pVertex->y, pVertex->z);
pVertex = (PVRTVECTOR3*)( (unsigned char*)(pVertex) + Mesh.sVertex.nStride);
btVector3 v3= btVector3(pVertex->x, pVertex->y, pVertex->z);
pVertex = (PVRTVECTOR3*)( (unsigned char*)(pVertex) + Mesh.sVertex.nStride);
m_indexVertexArrays->addTriangle(v1,v2,v3, TRUE);
}
// Create new mesh shape from triangles
*hullShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression,aabbMin,aabbMax);
Something I thought of that might cause it could be that I'm using addTriangle to add them to btBvhTriangleMeshShape instead of btTriangleIndexVertexArray. Maybe that causes spacing between each triangle?
Any help would be appreciated!
Thanks!!