removing scene nodes mid-simulation

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
cheesyPoof
Posts: 10
Joined: Mon Oct 10, 2005 4:38 am

removing scene nodes mid-simulation

Post by cheesyPoof »

quick question...

during the course of a simulation i have, there are some entities, (with underlying scene nodes), which have a finite "lifespan". when thier time is up i call node->drop(), or node->remove().

right there i get a segfault (in linux).

probably the scenemanager is trying to reference that node still?

is there a proper way to remove a scene node from the graph without causing a crash?
Conquistador
Posts: 340
Joined: Wed Sep 28, 2005 4:38 pm
Location: Canada, Eh!

Post by Conquistador »

If it's not too big an issue, you could just put setVisible(false), but I'm sure there's actuall;y a way to remove a scene node and free the memory without a crash.
Royal Hamilton Light Infantry - http://www.rhli.ca
Paris/Port Dover Pipes'n Drums - http://www.parisdover.ca
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

There is, its called node->remove(); Do not call drop on nodes, only call drop on anything allocated with a function with 'create' in its name (like createFileList(), or createXMLReader() ).
cheesyPoof
Posts: 10
Joined: Mon Oct 10, 2005 4:38 am

Post by cheesyPoof »

i get a segfault on the node->remove() call itself.
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

where are you removing the node at in your code? Are you sure the poiinter is valid?
cheesyPoof
Posts: 10
Joined: Mon Oct 10, 2005 4:38 am

Post by cheesyPoof »

nevermind. my code is trying to call node->remove() multiple times on the same node, which after the first time does not exits in the scenegraph anymore.

my bad. thx for the help though!
Post Reply