I was wondering if instancing models (not actors) had an effect on performance during the rendering.
My idea is that using instances, rather than loading-parenting the model several times, prevents nodepath.flattenStrong() to do its job completely. Instances always need a node on top of them in order to have a position in the world, and that position cannot be baked into the instance node.
If this is correct, then I would expect instances to be slightly slower than many loading-parenting.
Am I missing something ?
Indeed, having many instances can be slightly slower than having many duplicate copies. Instancing is not in general a performance tool.
For this reason, flattenStrong() will automatically replicate out instances it encounters (unless they are protected under a ModelRoot or something).
Can you explain me the bit about ModelRoot and protection?
A ModelRoot (which is a specific kind of ModelNode) is automatically created as the root node of any model that you load from an egg or bam file.
One of the purposes of a ModelNode is to prevent flattenStrong() from combining the geometry at this node and below with its siblings, under the assumption that you don’t want to combine unrelated models accidentally.
If you really do want to combine different models (as in the case of optimizing a scene with many copies of the same model), then you can call rootNode.clearModelNodes(), which sets a flag on each of the ModelNodes at rootNode and below, to allow them to be flattened away.
I can use that to squeeze a few percent of performance for the static objects. Doesn’t change much for now though, so I’ll keep it for later. I have other bottlenecks to deal with first.