Selection outliner bug with instances

Hey I’m integrating selection outliner in Babylon.js Editor and I noticed a small bug.
When creating an instance of a mesh which contains LODs, the outline disappears when the first LOD level awakes. This behavior is the same when outline is applied on source mesh or the instance ifself. If you remove the instance, you’ll see that everything works fine

Link to the playground, unzoom to trigger new LOD levels and you’ll see the outline disappears: https://playground.babylonjs.com/#QE7KM#246

Thanks a lot for your help :heart:

Ohhh thanks a ton for the repro, let me add @Evgeni_Popov to have a look

Hey @julien-moreau, thanks for the great repro!

This turned out to be a bug in SelectionOutlineLayer._renderSubMesh. When LOD switches to a different mesh, two things went wrong:

  1. The LOD mesh inherited world-matrix instance buffers from the scene render, which incorrectly forced it into the hardware instanced rendering path — but without the selection ID attribute, so
    the outline data was lost.
  2. The selection ID lookup never checked the master (source) mesh when rendering a LOD mesh.

Fix PR:

What a quick fix!!
Thanks for the explanations!!

Just in case, I found something weird also: selectionOutliner.hasMesh(anyMesh) always returns true even if I just cleared selection.

Is that something you can see right now? I can create a repro but I’m not on my PC anymore

You’re right, PR updated with the fix!

Omg thanks a lot :heart:

Hey @Evgeni_Popov !

I catched a last issue, else it looks perfect: when selecting the source mesh everything works as expected thanks to your fix. But I instead of the source mesh I put the instance, the outline disappears :frowning:

Link to the modified PG: https://playground.babylonjs.com/#QE7KM#247

Thanks a lot ! :heart:

Thanks for reporting, here’s the fix:

Thanks a lot !!!