Skip to content

Commit bd6187c

Browse files
committed
fixed editor selection overlay
1 parent 4d4fa09 commit bd6187c

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

kool-editor/src/commonMain/kotlin/de/fabmax/kool/editor/overlays/SelectionOverlay.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import de.fabmax.kool.scene.Mesh
1818
import de.fabmax.kool.scene.Node
1919
import de.fabmax.kool.util.Color
2020
import de.fabmax.kool.util.launchDelayed
21-
import de.fabmax.kool.util.logD
2221
import de.fabmax.kool.util.logT
2322
import kotlin.math.max
2423
import kotlin.math.roundToInt
@@ -85,6 +84,7 @@ class SelectionOverlay(editor: KoolEditor) : Node("Selection overlay") {
8584
}
8685

8786
inner class SelectionPass(editor: KoolEditor) : OffscreenRenderPass2d(
87+
// drawNode will be replaced by content scene, once it is loaded
8888
Node(),
8989
renderPassConfig {
9090
name = "SelectionPass"
@@ -103,26 +103,22 @@ class SelectionOverlay(editor: KoolEditor) : Node("Selection overlay") {
103103
isUpdateDrawNode = false
104104
isEnabled = true
105105

106-
mainView.drawFilter = { it in meshSelection }
107-
108106
onAfterCollectDrawCommands += { ev ->
109107
// replace regular object shaders by selection shader
110108
val q = ev.view.drawQueue
111109
for (i in q.commands.indices) {
112110
setupDrawCommand(i, q.commands[i], ev)
113111
}
114-
if (q.commands.size != meshSelection.size) {
115-
logD { "Invalidating selection overlay: draw queue size (${q.commands.size}) != selection size (${meshSelection.size})" }
116-
invalidateSelection()
117-
}
118112
}
119113
}
120114

121115
private fun setupDrawCommand(i: Int, cmd: DrawCommand, updateEvent: UpdateEvent) {
122116
cmd.pipeline = null
123-
getPipeline(cmd.mesh, updateEvent)?.let { (shader, pipeline) ->
124-
shader.color = selectionColors[i % selectionColors.size]
125-
cmd.pipeline = pipeline
117+
if (cmd.mesh in meshSelection) {
118+
getPipeline(cmd.mesh, updateEvent)?.let { (shader, pipeline) ->
119+
shader.color = selectionColors[i % selectionColors.size]
120+
cmd.pipeline = pipeline
121+
}
126122
}
127123
}
128124

0 commit comments

Comments
 (0)