Fix for memory leak at btCreateCompoundFromGimpactShape

This is an fix for issue #1213
This commit is contained in:
Wugand 2017-07-03 11:08:36 +02:00 committed by GitHub
parent afd6db7c40
commit b7011a864b

View File

@ -5,6 +5,22 @@
#include "btGImpactShape.h"
#include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h"
ATTRIBUTE_ALIGNED16(class) btCompoundFromGimpactShape : public btCompoundShape
{
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
virtual ~btCompoundFromGimpactShape()
{
/*delete all the btBU_Simplex1to4 ChildShapes*/
for (int i = 0; i < m_children.size(); i++)
{
delete m_children[i].m_childShape;
}
}
};
struct MyCallback : public btTriangleRaycastCallback
{
int m_ignorePart;
@ -77,7 +93,7 @@ struct MyCallback : public btTriangleRaycastCallback
btCompoundShape* btCreateCompoundFromGimpactShape(const btGImpactMeshShape* gimpactMesh, btScalar depth)
{
btCompoundShape* colShape = new btCompoundShape();
btCompoundShape* colShape = new btCompoundFromGimpactShape();
btTransform tr;
tr.setIdentity();
@ -90,4 +106,4 @@ btCompoundShape* btCreateCompoundFromGimpactShape(const btGImpactMeshShape* gimp
return colShape;
}
#endif //BT_COMPOUND_FROM_GIMPACT
#endif //BT_COMPOUND_FROM_GIMPACT