Skip to content

Commit

Permalink
New filter system for Node.scanTree
Browse files Browse the repository at this point in the history
  • Loading branch information
Twometer committed Oct 8, 2021
1 parent 9bf1f3c commit 71bb31a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ open class Node(
parent = null
}

fun scanTree(filter: (Node) -> Boolean, consumer: (Node) -> Unit) {
children.forEach { it.scanTree(filter, consumer) }
if (filter(this)) consumer(this)
}

fun scanTree(consumer: (Node) -> Unit) {
children.forEach { it.scanTree(consumer) }
consumer(this)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package de.twometer.neko.scene.nodes

object ScanFilters {

val MODEL = { node: Node -> node is ModelNode }
val RENDERABLE = { node: Node -> node is RenderableNode }
val GEOMETRY = { node: Node -> node is Geometry }
val LIGHT = { node: Node -> node is Light }

}

0 comments on commit 71bb31a

Please sign in to comment.