fix potential memory leaks for concave triangle meshes (<concave=true> or createCollisionShape with flags=1)

This commit is contained in:
Erwin Coumans
2017-08-24 09:16:11 -07:00
parent f0c32b84c0
commit 5c5993edcb
6 changed files with 53 additions and 4 deletions

View File

@@ -54,6 +54,7 @@ ATTRIBUTE_ALIGNED16(struct) BulletURDFInternalData
int m_bodyId;
btHashMap<btHashInt,UrdfMaterialColor> m_linkColors;
btAlignedObjectArray<btCollisionShape*> m_allocatedCollisionShapes;
mutable btAlignedObjectArray<btTriangleMesh*> m_allocatedMeshInterfaces;
LinkVisualShapesConverter* m_customVisualShapesConverter;
@@ -572,7 +573,7 @@ bool findExistingMeshFile(
}
}
btCollisionShape* convertURDFToCollisionShape(const UrdfCollision* collision, const char* urdfPathPrefix)
btCollisionShape* BulletURDFImporter::convertURDFToCollisionShape(const UrdfCollision* collision, const char* urdfPathPrefix) const
{
BT_PROFILE("convertURDFToCollisionShape");
@@ -775,6 +776,7 @@ upAxisMat.setIdentity();
{
BT_PROFILE("convert trimesh");
btTriangleMesh* meshInterface = new btTriangleMesh();
m_data->m_allocatedMeshInterfaces.push_back(meshInterface);
{
BT_PROFILE("convert vertices");
@@ -1229,6 +1231,19 @@ btCollisionShape* BulletURDFImporter::getAllocatedCollisionShape(int index)
return m_data->m_allocatedCollisionShapes[index];
}
int BulletURDFImporter::getNumAllocatedMeshInterfaces() const
{
return m_data->m_allocatedMeshInterfaces.size();
}
btStridingMeshInterface* BulletURDFImporter::getAllocatedMeshInterface(int index)
{
return m_data->m_allocatedMeshInterfaces[index];
}
class btCompoundShape* BulletURDFImporter::convertLinkCollisionShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame) const
{