comparison src/zamikongine/thing.nim @ 19:b55d6ecde79d

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
comparison
equal deleted inserted replaced
18:90e117952f74 19:b55d6ecde79d
1 {.experimental: "codeReordering".}
2
3 type
4 Part* = object of RootObj
5 thing: ref Thing
6
7 Thing* = object of RootObj
8 parent*: ref Thing
9 children*: seq[ref Thing]
10 parts*: seq[ref Part]
11
12 iterator partsOfType*[T: ref Part](root: ref Thing): T =
13 var queue = @[root]
14 while queue.len > 0:
15 let thing = queue.pop
16 for part in thing.parts:
17 if part of T:
18 yield T(part)
19 for child in thing.children:
20 queue.insert(child, 0)