diff --git a/neko-engine/src/main/kotlin/de/twometer/neko/scene/nodes/Node.kt b/neko-engine/src/main/kotlin/de/twometer/neko/scene/nodes/Node.kt index c9f165b..bbe0dcf 100644 --- a/neko-engine/src/main/kotlin/de/twometer/neko/scene/nodes/Node.kt +++ b/neko-engine/src/main/kotlin/de/twometer/neko/scene/nodes/Node.kt @@ -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) diff --git a/neko-engine/src/main/kotlin/de/twometer/neko/scene/nodes/ScanFilters.kt b/neko-engine/src/main/kotlin/de/twometer/neko/scene/nodes/ScanFilters.kt new file mode 100644 index 0000000..7c2d095 --- /dev/null +++ b/neko-engine/src/main/kotlin/de/twometer/neko/scene/nodes/ScanFilters.kt @@ -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 } + +} \ No newline at end of file