Destroying TreeCollision

HexiDave

03-03-2006 18:51:08

I probably missed it, but can I destroy TreeCollision data and have it removed from memory? I've got OgreNewt integrated with PLSM2 and it creates a TreeCollision from the terrain. That all works fine, but when I unload the tile I do this:

tile->getSceneNode()->removeAndDestroyAllChildren();

I've confirmed that it does indeed detach everything from the node, but I get no resources back. Each of the TreeCollisions take about 500k space on the harddrive, so I'd expect to see SOME memory returned, yet I don't get any back at all. It is my assumtion that the TreeCollision data is packed into the world and staying there. I keep trying to check the collision lines with the Debugger, but there's so much on screen that I get "out of video memory" errors.

Any suggestions?

walaber

03-03-2006 21:52:06

to destroy the TreeCollision from memory, make sure it is referenced by no rigid bodies in the scene, and call delete on the OgreNewt::TreeCollision object.

HexiDave

04-03-2006 17:30:46

Now that I'm working on it, I think I was wrong in my wording. I'm trying to delete the Body information - I delete the collision object right after I make the Body.

I've tried using the NewtonDestroyBody function but I get a runtime error. The line looks like this:

Body *body = tilesBodies[tileData];
NewtonDestroyBody(mWorld->getNewtonWorld(),body->getNewtonBody());


In the above, tileBodies[] is a

map<String,OgreNewt::Body*> tilesBodies;

Nothing should be referencing the Body as there are no physics objects in the scene aside from the TreeCollision bodies.

Just using delete throws the runtime error as well - any ideas?

HexiDave

04-03-2006 23:21:33

Nevermind, I'm retarded. tileData had an extra ".collision" at the end so it was calling invalid pointers - whoops.