Dropping 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
Quantum1982
Posts: 45
Joined: Mon Apr 23, 2012 9:31 am

Dropping nodes

Post by Quantum1982 »

Hi

I am making a maze game in 3D which uses a bunch of CubeSceneNodes. Now I want to be able to delete a specific cube scene node in certain circumstances.

I tried using drop, but then the system crashes. Am I missing something obvious ?

Cheers
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Dropping nodes

Post by CuteAlien »

Works the same as all reference counting in Irrlicht: http://irrlicht.sourceforge.net/docu/cl ... unted.html
If you didn't create it with a function starting with the word "create" or created the object with new or did grab() it at some point you should not drop objects.
What you most likely want to do is remove it from the scenemanager, which you do by calling remove() on your node.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Quantum1982
Posts: 45
Joined: Mon Apr 23, 2012 9:31 am

Re: Dropping nodes

Post by Quantum1982 »

Thanks for the reply

I tried this

Code: Select all

 
if (HumanNode)
                        HumanNode->setPosition(core::vector3df(500+(500*Human.iX),200+(500*Human.iY),500));
 
to try and get rid of the crash that I get when I call this :

Code: Select all

 
else if (receiver.MyEvent.KeyInput.Key==KEY_KEY_R)
                {
                        HumanNode->remove();
                }
 
This was just a test to see if it gets removed, but the program still crashes ?
What else am I missing ?

Cheers
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: Dropping nodes

Post by smso »

Safer way:

Code: Select all

if (HumanNode)
{
    HumanNode->remove();
    HumanNode = 0;
}
 
It's better to run the program with a debugger to see where it crashed.

Regards
smso
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Re: Dropping nodes

Post by greenya »

Also you may try deleting using

Code: Select all

void irr::scene::ISceneManager::addToDeletionQueue(ISceneNode* node)
maybe will help you.
Post Reply