[ODE] Patch for QuadTreeSpace
Nguyen Binh
ngbinh at glassegg.com
Mon Sep 29 11:49:04 MST 2003
Hi Erwin,
I found a peoblem in dxQuadTreeSpace which may result in mem leaks.
Here is my description and solution
-----------------------------------------------
// line 380 in collision_quadtreespace.cpp
dxQuadTreeSpace::~dxQuadTreeSpace(){
int Depth = 0;
Block* Current = &Blocks[0];
while (Current){
Depth++;
Current = Current->Children;
}
int BlockCount = 0;
int i = 0;
for ( i = 0; i < Depth; i++){
BlockCount += (int)pow(SPLITS, i);
}
// Add code to delete all geoms in blocks
Block* currentBlock = NULL;
dxGeom *g,*n;
for (i = 0; i < BlockCount; i ++)
{
currentBlock = &Blocks[i];
for (g = currentBlock->First; g; g=n)
{
n = g->next;
dGeomDestroy (g);
}
}
// End
dFree(Blocks, BlockCount * sizeof(Block));
dFree(CurrentChild, (Depth + 1) * sizeof(int));
}
---------------------------------------------------------------------
With this patch, all geoms attached to QuadTreeSpace will
automatically destroy when we call dSpaceDestroy().
--
Best regards,
---------------------------------------------------------------------
Nguyen Binh
Software Engineer
Glass Egg Digital Media
E.Town Building
7th Floor, 364 CongHoa Street
Tan Binh District,
HoChiMinh City,
VietNam,
Phone : +84 8 8109018
Fax : +84 8 8109013
www.glassegg.com
---------------------------------------------------------------------
More information about the ODE
mailing list