Animated meshes and fps

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
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

Animated meshes and fps

Post by Sfortza »

Have 1 character animated mesh and 5 enemies
the same animated meshes (800 poly-count each mesh) in my mobile game.

When only 1 character loaded I have fps = 17 - 21 and 13500 poly - count for entire map.
If 6 meshes loaded fps = 13 - 15 and 18500 poly - count.
If I make 5 meshes invisible poly - count = 13500, but fps = 14 - 17.
What's wrong?

Thank you!
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Re: Animated meshes and fps

Post by polylux »

Not sure but my first guess would be that the anims are still calculated independently from the model being visible or not.
beer->setMotivationCallback(this);
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Re: Animated meshes and fps

Post by Lonesome Ducky »

Transformations and such have to be calculated even if they're off screen to at the least tell if they are. This could be a cpu bottleneck, though I doubt it with so few meshes
Insomniacp
Posts: 288
Joined: Wed Apr 16, 2008 1:45 am
Contact:

Re: Animated meshes and fps

Post by Insomniacp »

if you are worried about it simply tell it to stop animating when you set it to invisible? that should make it so it has very little effect on the application speed (will always have a little since it must check if the node is visible or not among other things that will happen just because the scene node has been created and you can only stop those by removing the node)
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Animated meshes and fps

Post by CuteAlien »

Animations are not calculated when the nodes are invisible, transformations are still needed. Although those are usually not so expensive. But you can also remove nodes completely from the scenegraph. Just put them into some other structure which contains 2 ISceneNode pointers. One for the parent and one for the node. Grab them both and then you can remove the node with remove() or by setting the parent to 0. So you still have it in memory but no longer in the scenegraph. To put them back you just have to set the parent again (and drop pointers again for correct ref-counting).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

Re: Animated meshes and fps

Post by Sfortza »

Thank you very much to all!
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

Re: Animated meshes and fps

Post by Sfortza »

CuteAlien wrote:Animations are not calculated when the nodes are invisible, transformations are still needed. Although those are usually not so expensive. But you can also remove nodes completely from the scenegraph. Just put them into some other structure which contains 2 ISceneNode pointers. One for the parent and one for the node. Grab them both and then you can remove the node with remove() or by setting the parent to 0. So you still have it in memory but no longer in the scenegraph. To put them back you just have to set the parent again (and drop pointers again for correct ref-counting).
CuteAlien, could you give me some code snippet where I can see correct node management as you described above.
Thanks, in advance.
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Animated meshes and fps

Post by CuteAlien »

Why don't you try it yourself? I help if you get stuck and have specific questions.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

Re: Animated meshes and fps

Post by Sfortza »

CuteAlien wrote:Why don't you try it yourself? I help if you get stuck and have specific questions.
Ok.
So, I create two nodes

ISceneNode* parent = smgr->addEmptySceneNode(0, 100);
IAnimatedMeshSceneNode* child = smgr->addAnimatedMeshSceneNode(smgr->getMesh(workingDirectory + modelPath), parent);

I want to remove animated node from the scene graph while it's not necessary.

parent->grab();
child->grab();
parent = 0;

Nodes are removed.
How can I add them again to the scene graph without mesh loading?

Thank you.
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Animated meshes and fps

Post by CuteAlien »

You don't remove a node from the scene by setting a pointer to 0 (all you do by that is filling the place in memory holding the pointer with 0, the object the pointer points to is not affected by that). If you want to remove a node from the scenemanager you use the remove function for the node. Doing a grab() first is there to ensure you still can access that memory as it would be deleted otherwise if the scenemanager is the only object with a reference to the node. And then you should just keep it around in some structure - a struct with a pointer to the object (and to be safe to it's parent although you maybe don't even need this if you have a flat scenegraph).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

Re: Animated meshes and fps

Post by Sfortza »

I'm sorry, but my last question was

"How can I add removed node to the scene graph again without mesh loading?"

How can I return saved pointer (*IAnimatedSceneNode) to the scene graph?
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Animated meshes and fps

Post by CuteAlien »

You just restore the parent. The parent is still in the scenegraph (supposedly - otherwise you wouln't know how to add it anyway) so when you set it as parent the node is back in the scenegraph. So node->setParent( oldParent ).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Sfortza
Posts: 39
Joined: Thu Mar 17, 2011 12:40 pm
Location: 184

Re: Animated meshes and fps

Post by Sfortza »

Ok!
Now it's clear.

Thank you very much!
Post Reply