Page 1 of 1

[Fixed] removeAnimator in animateNode()

Posted: Fri Feb 06, 2009 5:55 pm
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.

Posted: Sat Feb 07, 2009 10:28 am
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.

Posted: Mon Feb 16, 2009 10:22 pm
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!