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);
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);
}
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.