I know this has been asked, and I have red the posts.
But I have a litllte doubt.
When we are adding animators to a node either the animator is created by me or a defual animator from irrlicht, should I drop them /delete them?
Or because the fuction has an "add" at the beggining is will handle it?
In practice, I have:
particleSystem->addAnimator(new MyAnimator);
and I have too:
partileSystem->addAnimtor(smgr->createDeleteAnimtor);
this way will generate any memory leaks? or because is it and "add" function it will call the corresponding "delete" for each one before it got destructed?
Thanks.
Another about when deleting.
what u have to do is this:
Code: Select all
ISceneNodeAnimator* myAnimator=smgr->createDeleteAnimator(u32 timeMs);
//this animator will delete the scene node its atached to...more like set invisible
mySceneNode->addAnimator(myAnimator);
//this attatch the animator to a scene node(camera, mesh, light or whatever)
myAnimator->drop();
//this will delete the animator... it has to be called cause it was created with a
//create method
Not sure what your comments are on about there... I don't believe the delete animator sets a node to invisible, it actually deletes it...
And drop would not delete the animator in that case, just reduce its reference count so that when the node is done with it (i.e. after timeMs countdown) it then gets deleted safely.
And drop would not delete the animator in that case, just reduce its reference count so that when the node is done with it (i.e. after timeMs countdown) it then gets deleted safely.
Thanks both, but I don'¡t know understand finaly what to do.
The thing is that I have tow kind of animators
-The one created by me (inherited from where it should, don't remember who now
).
-The one that are already for default in irrlicht api.
So, if understend well both of you, instead of doing this:
I should do this right?:
It is correct?
So, in this way do I have garanted that when "myA" is not used no more, its delete operator will be call automaticly?
I am worry casue I am having ungle memory lost
.
Thanks again.
The thing is that I have tow kind of animators
-The one created by me (inherited from where it should, don't remember who now
-The one that are already for default in irrlicht api.
So, if understend well both of you, instead of doing this:
Code: Select all
particleSystem->addAnimator(new MyAnimator);
and I have too:
partileSystem->addAnimtor(smgr->createDeleteAnimtor);
Code: Select all
ISceneNodeAnamitor * myA = new MyAnimaotr(...);
particleSystem->addAnimator(myA);
myA->drop;
ISceneNodeAnamitor * defaultIrrlichtA = smgr->createdDeleteAnimator();
particleSystem->addAnimator(defaltIrrlichtA);
defaultIrrlichtA->drop;So, in this way do I have garanted that when "myA" is not used no more, its delete operator will be call automaticly?
I am worry casue I am having ungle memory lost
Thanks again.
about the.. DeleteAnimator thing... i was just guessing... cause...i havent worked with this one yet... and it seemed a little... haky to use an animator to remove a scene node when u can actually remove it when the time comes....
and about the ->drop thing... thats what i meant... but for the look of what he asked it seemed easyer to understand what i said that what u said... taking that it wasnt clear afther reading other posts about this...
in both cases... my bad
Anyway u should check the Api doc included with the engine (this one is to Vsk) look for ISceneNodeAnimator class in the api and
ISceneManager::add<some circle, line, delete or whatever>animator()
it should give u enough info about when do delete an animator ( or any other thing created with a create<something>() method)
I hope i cleared my thoughs on this
and about the ->drop thing... thats what i meant... but for the look of what he asked it seemed easyer to understand what i said that what u said... taking that it wasnt clear afther reading other posts about this...
in both cases... my bad
Anyway u should check the Api doc included with the engine (this one is to Vsk) look for ISceneNodeAnimator class in the api and
ISceneManager::add<some circle, line, delete or whatever>animator()
it should give u enough info about when do delete an animator ( or any other thing created with a create<something>() method)
I hope i cleared my thoughs on this
Yes, this is correct except for the missing parens on the drop calls. You should write myA->drop() because you are calling the function.It is correct?Code: Select all
ISceneNodeAnamitor * myA = new MyAnimaotr(...); particleSystem->addAnimator(myA); myA->drop; ISceneNodeAnamitor * defaultIrrlichtA = smgr->createdDeleteAnimator(); particleSystem->addAnimator(defaltIrrlichtA); defaultIrrlichtA->drop;
Yes. This properly decrements the reference count. The rule is that if you call createXXX() or a new expression [new MyThing] to make an object, then you need to call drop() on it when you're done. Any other code that wants to use the object should call grab() when they want to make sure it isn't deleted, and then drop() when they are done.So, in this way do I have garanted that when "myA" is not used no more, its delete operator will be call automaticly?
Travis
