mickey
02-02-2009 09:41:06
Hi
Strange - when I make a call to:
gGrass->update();
When I terminate my application, I get a memory leak.
My grass init code looks like the ff:
And on my destructor:
I don't get any memory leak if i don't make a call to gGrass->update(...).
Any idea?
Strange - when I make a call to:
gGrass->update();
When I terminate my application, I get a memory leak.
My grass init code looks like the ff:
//-------------------------------------- LOAD gGrass --------------------------------------
//Create and configure a new PagedGeometry instance for grass
gGrass = new PagedGeometry(mCamera, 100);
gGrass->addDetailLevel<GrassPage>(500);
//Create a GrassLoader object
GrassLoader *grassLoader = new GrassLoader(gGrass);
gGrass->setPageLoader(grassLoader); //Assign the "treeLoader" to be used to load geometry for the PagedGeometry instance
//Supply a height function to gGrassLoader so it can calculate gGrass Y values
//HeightFunction::initialize(mSceneMgr);
grassLoader->setHeightFunction(&getTerrainHeight);
//Add some grass to the scene with gGrassLoader::addLayer()
GrassLayer *l = grassLoader->addLayer("3D-Diggers/plant1sprite");
//Configure the grass layer properties (size, density, animation properties, fade settings, etc.)
l->setMinimumSize(2.5f, 2.5f);
l->setMaximumSize(6.0f, 6.0f);
l->setAnimationEnabled(true); //Enable animations
l->setSwayDistribution(10.0f); //Sway fairly unsynchronized
l->setSwayLength(0.5f); //Sway back and forth 0.5 units in length
l->setSwaySpeed(0.5f); //Sway 1/2 a cycle every second
l->setDensity(0.7f); //Relatively dense grass
l->setFadeTechnique(FADETECH_GROW); //Distant gGrass should slowly raise out of the ground when coming in range
l->setRenderTechnique(GRASSTECH_QUAD); //Draw gGrass as scattered quads
//This sets a color map to be used when determining the color of each grass quad. setMapBounds()
//is used to set the area which is affected by the color map. Here, "terrain_texture.jpg" is used
//to color the grass to match the terrain under it.
l->setColorMap("terrain_texture.jpg");
l->setMapBounds(TBounds(0, 0, 1500, 1500)); //(0,0)-(1500,1500) is the full boundaries of the terrain
And on my destructor:
if( gGrass )
{
delete gGrass->getPageLoader();
SAFE_DELETE(gGrass);
}
I don't get any memory leak if i don't make a call to gGrass->update(...).
Any idea?