Mercurial > games > semicongine
diff src/zamikongine/thing.nim @ 480:14e5151f68d1
did: introduce scene graph, meshs and generic vertex buffers
author | Sam <sam@basx.dev> |
---|---|
date | Mon, 09 Jan 2023 11:04:19 +0700 |
parents | |
children | b1b05d4efb52 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/zamikongine/thing.nim Mon Jan 09 11:04:19 2023 +0700 @@ -0,0 +1,20 @@ +{.experimental: "codeReordering".} + +type + Part* = object of RootObj + thing: ref Thing + + Thing* = object of RootObj + parent*: ref Thing + children*: seq[ref Thing] + parts*: seq[ref Part] + +iterator partsOfType*[T: ref Part](root: ref Thing): T = + var queue = @[root] + while queue.len > 0: + let thing = queue.pop + for part in thing.parts: + if part of T: + yield T(part) + for child in thing.children: + queue.insert(child, 0)