How to replace a mesh/node for another mesh/node, freeing memory (so the old triangles will be thrown out)?
i got globbaly:
Code: Select all
IAnimatedMesh* mesh;
ISceneManager* smgr;
IAnimatedMeshSceneNode* node = 0;
Code: Select all
void mapChange(int mapnum)
{
/*switch(mapnum){
case 1:{mesh->drop(); mesh = smgr->getMesh("room01.obj"); break;}
case 2:{mesh->drop(); mesh = smgr->getMesh("terrain06.obj"); break;}
case 3:{mesh->drop(); mesh = smgr->getMesh("terrain01.obj"); break;}
}*/
//smgr->getMeshCache()->removeMesh(mesh);
mesh->drop();
//node->drop();
if(mapnum == 1){mesh = smgr->getMesh("room01.obj");node = smgr->addAnimatedMeshSceneNode(mesh);}
if(mapnum == 2){mesh = smgr->getMesh("terrain06.obj");node = smgr->addAnimatedMeshSceneNode(mesh);}
if(mapnum == 3){mesh = smgr->getMesh("terrain01.obj");node = smgr->addAnimatedMeshSceneNode(mesh);}
}
I think (i am not sure i'm right) that memory of a node isn't deleted, but when i add node->drop() the program is crashing
It is releted to terrain. I want swiching the terrain to be fast and simple, and to load a mesh on place of the old one.
I think maybe someone done this before so i'd be happy for a solution
If not i will try myself...