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:

2 Likes

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

1 Like

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:

3 Likes

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

1 Like

You’re right, PR updated with the fix!

1 Like

Omg thanks a lot :heart:

1 Like