I'm trying to make a multi-material tri mesh. For the per-triangle material indices, I'm using an array of uchars rather than the typical array of ints. When I do that, the program crashes during the gContactAddedCallback function. I've tried using ints instead, and everything works perfectly.
Here's the code.
Code: Select all
// Create btIndexedMesh called part
uchar* triangleMaterials = new uchar[part.m_numTriangles];
for (uint i = 0; i < part.m_numTriangles; i++)
{
triangleMaterials[i] = 0;
}
btMaterialProperties mat;
mat.m_numMaterials = numMaterials;
mat.m_materialBase = (const unsigned char*)materials;
mat.m_materialStride = sizeof(btMaterial);
mat.m_materialType = PHY_FLOAT;
mat.m_numTriangles = part.m_numTriangles;
mat.m_triangleMaterialsBase = (const unsigned char*)triangleMaterials;
mat.m_triangleMaterialStride = sizeof(uchar);
mat.m_triangleType = PHY_UCHAR;
btTriangleIndexVertexMaterialArray* meshInterface = new btTriangleIndexVertexMaterialArray();
meshInterface->addIndexedMesh(part, PHY_SHORT);
meshInterface->addMaterialProperties(mat, PHY_UCHAR);
btMultimaterialTriangleMeshShape* trimeshShape = new btMultimaterialTriangleMeshShape(meshInterface, true, aabbMin, aabbMax);