Irrlicht culling problem

By , last updated December 16, 2019

We’ve recently had major performance issues while testing the game. Debug information has shown that it was the graphics that was taking from 60 and up to 300 milliseconds per second to redraw all nodes. One of the issues that was discovered in analysis is that terrain ISceneNode had automatic culling EAC_OFF:

terrainNode->setAutomaticCulling( EAC_OFF );

It means that all triangles were rendered even if they were not visible. Several thousands triangles.

To fix it we remove the line code above which leaves us with default culling method, in Irrlicht it’s EAC_BOX. Enabling automatic culling introduces a new bug. Terrain around the player is not visible anymore:

Recall, that EAC_BOX culling mode culls objects outside the frustum bounding box. The frustum box is as deep as the view frustum (distance from the far to the near plane), and is as wide as the view frustum (the height and width of the view frustum at the far plane).

So, if you are experiencing such strange behavior, then the first thing you need to think about is: Are all the bounding boxes correct? Call the following function on scene nodes to check bounding boxes:


In our case we had a triangle mesh that was created as follows:

SMesh *mesh = new SMesh();

Default bounding boxes looked like this:

Recalculation of bounding boxes needs to take place after the mesh is created (and remember to do it on mesh, not mesh buffer!)

SMesh *mesh = new SMesh();

The result is as follows:

Senior Software Engineer developing all kinds of stuff.