Removing scene nodes.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
WToma
Posts: 70
Joined: Tue Aug 09, 2005 8:38 am
Location: Szeged, Hungary

Removing scene nodes.

Post by WToma »

I know that it will be trivial again :) But I just can't get it.

Code: Select all

struct A {
vector<ISceneNode*> nodes(0); //std lib vector
void update();
void run();
};

void A::run() {
while(device->run()) {
update();
}
}

void A::update() {
if(really_need_update) {
for(int i=0;i<nodes.size();i++) {
nodes[i]->remove(); //(1)
}
nodes.clear();
//fill 'nodes' with new scene nodes
}
driver->beginScene(...);
smgr->drawAll();
driver->endScene();
}
It should do the following: if the scene is need to be updated (a new car created, etc.) it deletes all scene nodes and fills 'nodes' with new ones. (I know that it is a bad idea anywy, but when I did this it wasn't possible to change anything but the visualisation code.)
But I cannot see anything. If remove line (1), it works, but those scene nodes that should not be seen, are still visible. I could solve this by replacing (1) with

Code: Select all

nodes[i]->setPosition(10000.0f,10000.0f,10000.0f);
but it is again a bad thing, because if I would use those part of the scene, there would be a problem, and it slows down the system.

So, what could be wrong with the code? (Nice question, isn't it ;))

Toma
"This is not a bug, this is a feature!"
Post Reply