Add new_scenes
to prevent modifying the currently iterated scenes.
This commit is contained in:
parent
3ff1d663a2
commit
c731c3c5ab
|
@ -165,6 +165,12 @@ proc myou_main_loop*(self: MyouEngine) =
|
|||
##
|
||||
## You usually don't need to call this. Use `run <#run,MyouEngine>`_
|
||||
## instead.
|
||||
# TODO: make a table object that can be iterated while changing, e.g. with a
|
||||
# seq and a dirty flag to update the seq
|
||||
if self.new_scenes.len != 0:
|
||||
for name,scene in self.new_scenes.pairs:
|
||||
self.scenes[name] = scene
|
||||
self.new_scenes.clear()
|
||||
let time = getmonotime().ticks.float/1000000000
|
||||
let delta_seconds = time - last_time
|
||||
for _,scene in self.scenes.pairs:
|
||||
|
|
|
@ -95,7 +95,7 @@ proc initScene*(self: Scene, engine: MyouEngine, name: string = "Scene",
|
|||
while self.name in engine.scenes:
|
||||
collision_seq += 1
|
||||
self.name = name & "$" & $collision_seq
|
||||
engine.scenes[self.name] = self
|
||||
engine.new_scenes[self.name] = self
|
||||
self.mesh_passes.setLen 3
|
||||
self.world = newWorld(self)
|
||||
self.background_color = vec4(0, 0, 0, 1)
|
||||
|
|
|
@ -85,6 +85,7 @@ type
|
|||
loaders_by_ext*: Table[string, seq[proc(e: MyouEngine): Loader]]
|
||||
glsl_version*: string
|
||||
all_framebuffers*: seq[Framebuffer] ## private
|
||||
new_scenes*: Table[string, Scene] ## private
|
||||
|
||||
# gameobject.nim
|
||||
|
||||
|
|
Loading…
Reference in a new issue