In bounding volume hierarchy building function, I believe there is a condition in one if-statement which prevents us to use the maximum number of primitives in node properly. The code is as follows:
// Either create leaf or split primitives at selected SAH bucket
if (nPrimitives > maxPrimsInNode || minCost < nPrimitives) split the node
else create leaf node
The minCost < nPrimitives is usually fulfilled and a leaf node with maximum primitives in that leaf node is created in very rare cases but as we all knows, when the number of primitives per node is less than maxPrimsInNode, it is better to not split in most cases. Have a look on the attached image. The SAH cost function returns 2.625 for all possible split and it is less than 4 (number of triangles), so the triangles are split. But, it is not give us any performance improvement (it even can adds some overheads).

In bounding volume hierarchy building function, I believe there is a condition in one if-statement which prevents us to use the maximum number of primitives in node properly. The code is as follows:
The minCost < nPrimitives is usually fulfilled and a leaf node with maximum primitives in that leaf node is created in very rare cases but as we all knows, when the number of primitives per node is less than maxPrimsInNode, it is better to not split in most cases. Have a look on the attached image. The SAH cost function returns 2.625 for all possible split and it is less than 4 (number of triangles), so the triangles are split. But, it is not give us any performance improvement (it even can adds some overheads).