Lots of scene nodes

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
flip21
Posts: 2
Joined: Tue Feb 02, 2021 2:28 pm

Lots of scene nodes

Post by flip21 »

Hello! I'm trying to do a simple level editor in Irrlicht, but I stumbled upon a problem about performance loss.

In my editor, the map is a matrix of cubes. At runtime, I can assign a texture to each face of each cube.

In order to change the texture for the single face, I must be able to select the face with the mouse. So I decided to create a scene node for every face. This has caused a several reduction of FPS (if the map is big).

I did some tests, and I discovered that the FPS reduction is not caused by the rendering of the faces: if I disable face rendering, FPS are still low.

My question is: how could I avoid performance loss? Are there some settings I could change? Or maybe I need to use a single scene node for the entire map. In this case, how to reference the individual faces?

Thanks in advance!
CuteAlien
Admin
Posts: 9646
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Lots of scene nodes

Post by CuteAlien »

First thing you should always do on speed problems is run some profiler (in release, but with debug-information enabled) to see what's slowing it down. If you are on Windows the simplest to use profiler is Very Sleepy: http://www.codersnotes.com/sleepy
On Linux you can for example use valgrind with callgrind.

Number of nodes is one important reason for slowdowns. After a few thousand things just get slow. Another big reason is texture-switches. Thought those shouldn't happen if you don't render.

For optimizing collisions you can for example write your own triangle selector. They are not that complicated - what they basically all do is create a copy of all triangles in memory and then test a line against them. So your triangle-selectors does not have to be related to your scenenodes and you can add any additional functions you might need to it.

Also when you switch to current Irrlicht svn trunk it's possible get more information from the triangle-selectors. It can now also return the collided meshbuffer - so you don't need extra SceneNodes anymore, but can get the correct meshbuffer you hit already from build in functions (you have to use the new outTriangleInfo for that - the collision example got adapted to use that).

If you have many cubes where each side only uses a single texture - it's probably best to write your own specialized scenenode. Because you should reduce material-switching as much as possible - which you can only do by drawing all meshbuffers using the same texture after each other (no other textures in between). If you use more than one texture per side - it kinda doesn't matter for now (sadly one of the big open problems in Irrlicht).

Hope it helps a bit...
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
Post Reply