Page 1 of 1

Removing scene nodes.

Posted: Wed Oct 26, 2005 6:22 pm
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