Merge pull request #1221 from Wugand/patch-1

Fix for memory leak at btCreateCompoundFromGimpactShape
This commit is contained in:
erwincoumans
2017-08-25 08:30:07 -07:00
committed by GitHub

View File

@@ -5,6 +5,22 @@
#include "btGImpactShape.h" #include "btGImpactShape.h"
#include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.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 struct MyCallback : public btTriangleRaycastCallback
{ {
int m_ignorePart; int m_ignorePart;
@@ -77,7 +93,7 @@ struct MyCallback : public btTriangleRaycastCallback
btCompoundShape* btCreateCompoundFromGimpactShape(const btGImpactMeshShape* gimpactMesh, btScalar depth) btCompoundShape* btCreateCompoundFromGimpactShape(const btGImpactMeshShape* gimpactMesh, btScalar depth)
{ {
btCompoundShape* colShape = new btCompoundShape(); btCompoundShape* colShape = new btCompoundFromGimpactShape();
btTransform tr; btTransform tr;
tr.setIdentity(); tr.setIdentity();
@@ -90,4 +106,4 @@ btCompoundShape* btCreateCompoundFromGimpactShape(const btGImpactMeshShape* gimp
return colShape; return colShape;
} }
#endif //BT_COMPOUND_FROM_GIMPACT #endif //BT_COMPOUND_FROM_GIMPACT