[Fixed] removeAnimator in animateNode()

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
denisw
Posts: 1
Joined: Fri Feb 06, 2009 5:42 pm

[Fixed] removeAnimator in animateNode()

Post by denisw »

Hi,

I'd like to point out an issue with ISceneNodeAnimators: if you have an animator that is only meant to persist for a specific time (for instance, I have created a small animator to follow a defined path), you cannot call directly call removeAnimator() from the animator class' animateNode() method to get rid of the animator. This will cause a segfault due to the way ISceneNode::OnAnimate() is written. Instead, you have to remove "finished" animators in some other part in the code, which is unnecessarily complicated, or just let them sit there wasting memory.

There is a pretty simple fix for this. If the following lines in ISceneNode::OnAnimate():

Code: Select all

core::list<ISceneNodeAnimator*>::Iterator ait = Animators.begin();
for (; ait != Animators.end(); ++ait)
     (*ait)->animateNode(this, timeMs);
are replaced with this:

Code: Select all

core::list<ISceneNodeAnimator*>::Iterator ait = Animators.begin();
while (ait != Animators.end())
{
    // continue to the next node before calling animateNode()
    // so that the animator may remove itself from the scene
    // node without the iterator becoming invalid
    ISceneNodeAnimator* anim = *ait;
    ++ait;
    anim->animateNode(this, timeMs);
}
then calling removeAnimator() from animateNode() works just fine.

I hope this fix can be added to Irrlicht trunk. It would be also useful for some built-in animators, like unlooped FlyStraightAnimators and the like.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

None of the built-in animators remove themselves, but I can see your point about a custom animator wanting to do it. I'll pick this up, and since it's a potential crash and doesn't change the functionality, then I'll do it as a "bugfix" on the 1.5 branch first.

[Time passes]

OK, fix and unit test committed to 1.5 in SVN 2202, and it'll come down to the trunk later. Thanks for the report and the fix.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
h.a.n.d
Posts: 15
Joined: Fri Feb 13, 2009 1:38 pm

Post by h.a.n.d »

Hi guys,

Is there a way you can send me the w32-gcc compiled dll with your fix.
I would really appreciate this cause I'm unable to compile the trunk or the branch version with code::blocks or VS C++ 2008.

(I can compile them but the throw diffrent errors.)

Compiled with code::blocks I get an crash at application start time.
Compiled with VS I get some reference errors while building my application.

Or is there a HOWTO compile with code::blocks for dummies? ;-)
The source folder already has a code::blocks configuration/project file but why does it not compile?
Where do I have to set the DirectX SDK includes?
Under build options.../search directories?
Do I have to set some more compiler options which aren't already set by the project configuration file?

I've searched the forum for any nightly build provider but I've got no luck at all...

Thank you!
Post Reply