Inline animator - recommended or not?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
weeix
Posts: 23
Joined: Fri Jul 09, 2010 5:07 am

Inline animator - recommended or not?

Post by weeix »

I wonder if we change:

Code: Select all

        scene::IAnimatedMeshSceneNode* anms =
                smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/ninja.b3d"));

        if (anms)
        {
                scene::ISceneNodeAnimator* anim =
                        smgr->createFlyStraightAnimator(core::vector3df(100,0,60),
                        core::vector3df(-100,0,60), 3500, true);
                if (anim)
                {
                        anms->addAnimator(anim);
                        anim->drop();
                }
To this form instead:

Code: Select all

        scene::IAnimatedMeshSceneNode* anms =
                smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/ninja.b3d"));
        anms->addAnimator(smgr->addAnimatedMeshSceneNode(
                smgr->createFlyStraightAnimator(core::vector3df(100,0,60),
                        core::vector3df(-100,0,60), 3500, true)));
So we don't have to create and then drop the animator anymore. Would this cause any problem later?
Last edited by weeix on Thu Sep 09, 2010 5:19 am, edited 1 time in total.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

Your code shouldn't even compile....
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
weeix
Posts: 23
Joined: Fri Jul 09, 2010 5:07 am

Post by weeix »

Sudi wrote:Your code shouldn't even compile....
Sorry, I copied the wrong code :lol:
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

well that code will still not compile but is see what you wanna do.

that code will leak memory since you are not dropping the pointer of the animator.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Post Reply