Do I delete an IAnimatedMeshSceneNode when I'm done with it?

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
Rocko Bonaparte
Posts: 48
Joined: Tue Aug 31, 2010 6:27 am

Do I delete an IAnimatedMeshSceneNode when I'm done with it?

Post by Rocko Bonaparte »

I see in the documentation I'm not supposed to drop one of these when I use the addAnimatedMeshScene node call--since the name does not start with "create." But now I have a pointer for one, so what do I do? I assume if I don't want to work with that mesh anymore, then I can just delete it.

BTW -- I'm asking just to verify here. I was getting some segfaults when I was previously trying to delete it, but not now that I've reigned in a lot of my code. So I am assuming the deletes I was doing before were not a source of the problem. Still I just want to be sure.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Do I delete an IAnimatedMeshSceneNode when I'm done with

Post by CuteAlien »

If you have not grab()'ed a reference to it then it will be automatically be deleted when it's no longer used. Assuming you didn't do anything special that means when you remove it from the scenemanager the node will be removed. Note that the mesh might still be in the mesh-cache as well as textures can still be in the texture-cache.
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
Rocko Bonaparte
Posts: 48
Joined: Tue Aug 31, 2010 6:27 am

Re: Do I delete an IAnimatedMeshSceneNode when I'm done with

Post by Rocko Bonaparte »

CuteAlien wrote:If you have not grab()'ed a reference to it then it will be automatically be deleted when it's no longer used. Assuming you didn't do anything special that means when you remove it from the scenemanager the node will be removed. Note that the mesh might still be in the mesh-cache as well as textures can still be in the texture-cache.
Woah there. There's something in ISceneManager for removing the node? I don't see it in the method list:

http://irrlicht.sourceforge.net/docu/cl ... _node.html

I assume I'm just missing this, since it has occurred to me this would be kind of important :) . I don't know if I understand the automatic removal rules for the animated node. I saw in the source that when I add an animated mesh scene node, there is implicitly a drop() call done on the reference before it's given to me. Am I supposed to grab it upon reception of it? I am assuming not since I don't think I've ever had a reference to one dropped out from under me, so I am as. I get reference counting generally; I just got confused with how it was applying it in addAnimatedMeshSceneNode.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Do I delete an IAnimatedMeshSceneNode when I'm done with

Post by serengeor »

Rocko Bonaparte wrote:
CuteAlien wrote:If you have not grab()'ed a reference to it then it will be automatically be deleted when it's no longer used. Assuming you didn't do anything special that means when you remove it from the scenemanager the node will be removed. Note that the mesh might still be in the mesh-cache as well as textures can still be in the texture-cache.
Woah there. There's something in ISceneManager for removing the node? I don't see it in the method list:

http://irrlicht.sourceforge.net/docu/cl ... _node.html
You're looking in the wrong place, that url only shows methods specific to IAnimatedMeshSceneNode. ISceneNode has remove function.
http://irrlicht.sourceforge.net/docu/cl ... _node.html
Working on game: Marrbles (Currently stopped).
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Do I delete an IAnimatedMeshSceneNode when I'm done with

Post by CuteAlien »

The implicit drop is because addAnimatedMeshSceneNode created the element with new and then passed it on to the scenemanager. New already creates one reference in Irrlicht. Adding to the scenemanger is done (wrongly) in the constructor of the scenenode, so that adds a second reference. Should be 2 commands (also for more important other reasons) then it would be more obvious.

For now - you have don't have to grab() - the scenemanager is already holding one reference.
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
Post Reply