Change new_scenes
to new_del_scenes
to avoid issues when deleting a scene.
This commit is contained in:
parent
2caf78c88a
commit
bb4f8e1c00
4 changed files with 12 additions and 10 deletions
|
@ -628,7 +628,7 @@ method loadScene*(self: BlendLoader, name: string="", scene: Scene=nil, callback
|
||||||
callback(getCurrentExceptionMsg(), nil)
|
callback(getCurrentExceptionMsg(), nil)
|
||||||
return
|
return
|
||||||
callback("", scene)
|
callback("", scene)
|
||||||
if scene.name notin self.engine.new_scenes:
|
if self.engine.new_del_scenes.getOrDefault(scene.name).isNil:
|
||||||
# it was deleted
|
# it was deleted
|
||||||
return
|
return
|
||||||
# TODO: when loading is async, move this stuff after loading has
|
# TODO: when loading is async, move this stuff after loading has
|
||||||
|
|
|
@ -173,11 +173,14 @@ proc myou_main_loop*(self: MyouEngine) =
|
||||||
updateLoadableWorkerThreads()
|
updateLoadableWorkerThreads()
|
||||||
# TODO: make a table object that can be iterated while changing, e.g. with a
|
# TODO: make a table object that can be iterated while changing, e.g. with a
|
||||||
# seq and a dirty flag to update the seq
|
# seq and a dirty flag to update the seq
|
||||||
if self.new_scenes.len != 0:
|
if self.new_del_scenes.len != 0:
|
||||||
for name,scene in self.new_scenes.pairs:
|
for name,scene in self.new_del_scenes.pairs:
|
||||||
|
if scene.nonNil:
|
||||||
self.scenes[name] = scene
|
self.scenes[name] = scene
|
||||||
self.new_scenes.clear()
|
else: # nil means that the scene is meant to be deleted
|
||||||
let time = getmonotime().ticks.float/1000000000
|
self.scenes.del(name)
|
||||||
|
self.new_del_scenes.clear()
|
||||||
|
let time = getmonotime().ticks.float/1_000_000_000
|
||||||
let delta_seconds = time - last_time
|
let delta_seconds = time - last_time
|
||||||
for _,scene in self.scenes.pairs:
|
for _,scene in self.scenes.pairs:
|
||||||
if not scene.enabled:
|
if not scene.enabled:
|
||||||
|
|
|
@ -96,7 +96,7 @@ proc initScene*(self: Scene, engine: MyouEngine, name: string = "Scene",
|
||||||
while self.name in engine.scenes:
|
while self.name in engine.scenes:
|
||||||
collision_seq += 1
|
collision_seq += 1
|
||||||
self.name = name & "$" & $collision_seq
|
self.name = name & "$" & $collision_seq
|
||||||
engine.new_scenes[self.name] = self
|
engine.new_del_scenes[self.name] = self
|
||||||
self.mesh_passes.setLen 3
|
self.mesh_passes.setLen 3
|
||||||
self.world = newWorld(self)
|
self.world = newWorld(self)
|
||||||
self.background_color = vec4(0, 0, 0, 1)
|
self.background_color = vec4(0, 0, 0, 1)
|
||||||
|
@ -379,8 +379,7 @@ proc destroy*(self: Scene) =
|
||||||
for cube in self.cubemaps:
|
for cube in self.cubemaps:
|
||||||
cube.destroy()
|
cube.destroy()
|
||||||
self.cubemaps = @[]
|
self.cubemaps = @[]
|
||||||
self.engine.scenes.del(self.name)
|
self.engine.new_del_scenes[self.name] = nil
|
||||||
self.engine.new_scenes.del(self.name)
|
|
||||||
# bound textures can linger
|
# bound textures can linger
|
||||||
unbindAllTextures()
|
unbindAllTextures()
|
||||||
# probably none of this is actually necessary
|
# probably none of this is actually necessary
|
||||||
|
|
|
@ -86,7 +86,7 @@ type
|
||||||
glsl_version*: string
|
glsl_version*: string
|
||||||
cache_settings*: CacheSettings
|
cache_settings*: CacheSettings
|
||||||
all_framebuffers*: seq[Framebuffer] ## private
|
all_framebuffers*: seq[Framebuffer] ## private
|
||||||
new_scenes*: Table[string, Scene] ## private
|
new_del_scenes*: Table[string, Scene] ## private
|
||||||
|
|
||||||
# gameobject.nim
|
# gameobject.nim
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue