This is not really a request for help, because I solved the issue already. I just would like to get some comments in order to find out whether my solution is a good one.
The Task:
Im currently programming a CnC-like RTS game. I needed an animator that followed some waypoints on a virtual two dimensional map. After the animation is done, the animator should be removed automatically. I think the reaseon for this is obvious, if you just keep the animator attached it wastes memory(not so bad) and cpu time during each animation loop(very bad).
My first approach was to write a custom animator and hold a reference to its SceneNode within the animator. After the animation was done, I tried to call
Code: Select all
mSceneNode->removeAnimator( this );
Ok my solution for this involved changing the irrlicht engine. In ISceneNodeAnimator.h i introduced a bool flag.
Code: Select all
class ISceneNodeAnimator : public io::IAttributeExchangingObject
{
public:
ISceneNodeAnimator() : IsDead( false ) {}
//! destructor
virtual ~ISceneNodeAnimator() {}
virtual ESCENE_NODE_ANIMATOR_TYPE getType()
{
return ESNAT_UNKNOWN;
}
bool isDead() const { return IsDead; }
protected:
bool IsDead;
};
Code: Select all
for (; ait != Animators.end(); ++ait)
{
if( (*ait)->isDead() )
{
(*ait)->drop();
ait = Animators.erase( ait );
if( ait == Animators.end() )
break;
}
else
{
(*ait)->animateNode(this, timeMs);
}
}
PS: My first post to this issue can be found here: http://irrlicht.sourceforge.net/phpBB2/ ... p?p=110906