THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/09/2008 at 07:17, xxxxxxxx wrote:
User Information:
Cinema 4D Version:
Platform:
Language(s) : C++ ;
---------
Hi,
im using the colliderCache in my code and have problems with mem leaks (again ;-) ). the code is based on the api example.
Bool FillColliderCache(GeColliderCache& c, BaseObject* obj,BaseDocument* doc)
{
ModelingCommandData md1;
PolygonObject* poly = NULL;
// create a CSTO'd and joined copy. this function has no mem leaks!
BaseObject* objCopy = getPolyObject(obj,doc);
//triangulate
md1.op = objCopy; md1.doc = doc;
if(!SendModelingCommand(MCOMMAND_TRIANGULATE, md1)) goto Error;
AtomArray::Free(md1.result);AtomArray::Free(md1.arr);
poly = (static_cast<PolygonObject*>(md1.op));
if (!poly) goto Error;
// Get the polygon data
#ifdef C4D_R9
Polygon* tris = poly->GetPolygon();
Vector* points = poly->GetPoint();
#else
CPolygon* tris = poly->GetPolygonW();
Vector* points = poly->GetPointW();
#endif
// Fill the cache with the tri's
// if i comment out this block, the mem leaks are gone..
if (c.BeginInput(poly->GetPolygonCount()) != COL_OK) goto Error;
for (int i = 0; i < poly->GetPolygonCount(); ++i)
if (c.AddTriangle(points[tris _.a], points[tris _.b], points[tris _.c], i) != COL_OK) goto Error;
if (c.EndInput() != COL_OK) goto Error;
BaseObject::Free(objCopy);
//GeFree(points); // crash!
//GeFree(tris); // crash!
//BaseObject::Free(md1.op); // crash!
return TRUE;
Error:
BaseObject::Free(objCopy);
return FALSE;
}
i thought the leaks were due to not freed points, tris and md1.op. But the problem is that cinema crashes when i try to free any of these..
When i outcomment the part were i store the tri's in the collidercache, the leaks are gone..
The collidercache itself is declared outside by autoalloc, so i assumed that all its data would be free'd automatically ?
In that regard I also trie the freePairsList() on the colliderCache, but that made no difference.
thanks,
Daniel