Fixed memory leaks in ConvexDecomposition and ColladaConverter libraries
Added ConvexDecompositionDemo to CMake build
This commit is contained in:
@@ -176,6 +176,19 @@ ColladaConverter::~ColladaConverter ()
|
||||
|
||||
m_collada = NULL;
|
||||
m_dom = NULL;
|
||||
|
||||
for(int i=0;i<m_rbUserInfoHashMap.size();i++)
|
||||
{
|
||||
btRigidBodyColladaInfo* rbci = *(m_rbUserInfoHashMap.getAtIndex(i));
|
||||
delete rbci;
|
||||
}
|
||||
|
||||
for(int i=0;i<m_constraintUserInfoHashMap.size();i++)
|
||||
{
|
||||
btRigidConstraintColladaInfo* rcci = *(m_constraintUserInfoHashMap.getAtIndex(i));
|
||||
delete rcci;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -226,6 +239,18 @@ bool ColladaConverter::load(const char* orgfilename)
|
||||
// resets the collada converter state
|
||||
void ColladaConverter::reset ()
|
||||
{
|
||||
for(int i=0;i<m_rbUserInfoHashMap.size();i++)
|
||||
{
|
||||
btRigidBodyColladaInfo* rbci = *(m_rbUserInfoHashMap.getAtIndex(i));
|
||||
delete rbci;
|
||||
}
|
||||
|
||||
for(int i=0;i<m_constraintUserInfoHashMap.size();i++)
|
||||
{
|
||||
btRigidConstraintColladaInfo* rcci = *(m_constraintUserInfoHashMap.getAtIndex(i));
|
||||
delete rcci;
|
||||
}
|
||||
|
||||
// clear the maps
|
||||
m_rbUserInfoHashMap.clear ();
|
||||
m_constraintUserInfoHashMap.clear ();
|
||||
@@ -2808,27 +2833,24 @@ void ColladaConverter::ConvertRigidBodyRef( btRigidBodyInput& rbInput,btRigidBod
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (rbOutput.m_isDynamics)
|
||||
{
|
||||
printf("moving concave <mesh> not supported, transformed into convex\n");
|
||||
rbOutput.m_colShape = new btConvexTriangleMeshShape(trimesh);
|
||||
} else
|
||||
{
|
||||
printf("static concave triangle <mesh> added\n");
|
||||
bool useQuantizedAabbCompression = true;
|
||||
rbOutput.m_colShape = new btBvhTriangleMeshShape(trimesh,useQuantizedAabbCompression);
|
||||
//rbOutput.m_colShape = new btBvhTriangleMeshShape(trimesh);
|
||||
//rbOutput.m_colShape = new btConvexTriangleMeshShape(trimesh);
|
||||
|
||||
//btTriangleMeshShape
|
||||
}
|
||||
//rbOutput.m_colShape->setTypedUserInfo (new btShapeColladaInfo (geom));
|
||||
|
||||
}
|
||||
|
||||
if (rbOutput.m_isDynamics)
|
||||
{
|
||||
printf("moving concave <mesh> not supported, transformed into convex\n");
|
||||
rbOutput.m_colShape = new btConvexTriangleMeshShape(trimesh);
|
||||
} else
|
||||
{
|
||||
printf("static concave triangle <mesh> added\n");
|
||||
bool useQuantizedAabbCompression = true;
|
||||
rbOutput.m_colShape = new btBvhTriangleMeshShape(trimesh,useQuantizedAabbCompression);
|
||||
//rbOutput.m_colShape = new btBvhTriangleMeshShape(trimesh);
|
||||
//rbOutput.m_colShape = new btConvexTriangleMeshShape(trimesh);
|
||||
|
||||
//btTriangleMeshShape
|
||||
}
|
||||
//rbOutput.m_colShape->setTypedUserInfo (new btShapeColladaInfo (geom));
|
||||
|
||||
} else
|
||||
{
|
||||
|
||||
|
||||
@@ -150,7 +150,10 @@ CHull * ConvexBuilder::canMerge(CHull *a,CHull *b)
|
||||
|
||||
//don't do anything if hull is empty
|
||||
if (!tcount)
|
||||
{
|
||||
Vl_releaseVertexLookup (vc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
HullResult hresult;
|
||||
HullLibrary hl;
|
||||
@@ -323,6 +326,8 @@ unsigned int ConvexBuilder::process(const DecompDesc &desc)
|
||||
mCallback->ConvexDecompResult(r);
|
||||
}
|
||||
|
||||
hl.ReleaseResult (result);
|
||||
|
||||
|
||||
delete cr;
|
||||
}
|
||||
|
||||
@@ -204,6 +204,7 @@ void calcConvexDecomposition(unsigned int vcount,
|
||||
}
|
||||
#endif
|
||||
|
||||
hl.ReleaseResult (result);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
@@ -816,8 +816,8 @@ WavefrontObj::WavefrontObj(void)
|
||||
|
||||
WavefrontObj::~WavefrontObj(void)
|
||||
{
|
||||
delete mIndices;
|
||||
delete mVertices;
|
||||
delete [] mIndices;
|
||||
delete [] mVertices;
|
||||
}
|
||||
|
||||
unsigned int WavefrontObj::loadObj(const char *fname) // load a wavefront obj returns number of triangles that were loaded. Data is persists until the class is destructed.
|
||||
@@ -825,9 +825,9 @@ unsigned int WavefrontObj::loadObj(const char *fname) // load a wavefront obj re
|
||||
|
||||
unsigned int ret = 0;
|
||||
|
||||
delete mVertices;
|
||||
delete [] mVertices;
|
||||
mVertices = 0;
|
||||
delete mIndices;
|
||||
delete [] mIndices;
|
||||
mIndices = 0;
|
||||
mVertexCount = 0;
|
||||
mTriCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user