Skip to content

Commit c186cc6

Browse files
committed
Do not store loader in scene
1 parent e481b3e commit c186cc6

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

demosys/resources/scenes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def _load(self, meta) -> Scene:
7474
raise ImproperlyConfigured("Cannot find scene file {}".format(meta.path))
7575

7676
print("Loading: {}".format(meta.path))
77-
scene = Scene(meta.path, loader=meta.loader_cls(meta.path), **meta.kwargs)
78-
scene.load(found_path)
77+
scene = Scene(meta.path, **meta.kwargs)
78+
scene.load(meta.loader_cls(meta.path), found_path)
7979

8080
self.file_map[meta.path] = scene
8181
return scene

demosys/scene/scene.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010

1111
class Scene:
1212
"""Generic scene"""
13-
def __init__(self, name, loader=None, mesh_shaders=None, **kwargs):
13+
def __init__(self, name, mesh_shaders=None, **kwargs):
1414
"""
1515
:param name: Unique name or path for the scene
1616
:param loader: Loader class for the scene if relevant
1717
"""
1818
self.name = name
19-
self.loader = loader
2019
self.root_nodes = []
2120

2221
# References resources in the scene
@@ -31,7 +30,7 @@ def __init__(self, name, loader=None, mesh_shaders=None, **kwargs):
3130
self.diagonal_size = 1.0
3231

3332
self.bbox_vao = geometry.bbox()
34-
self.bbox_shader = shaders.get('scene_default/bbox.glsl', create=True)
33+
self.bbox_shader = shaders.get('scene_default/bbox.glsl')
3534

3635
self._view_matrix = matrix44.create_identity()
3736

@@ -122,17 +121,17 @@ def calc_scene_bbox(self):
122121

123122
self.diagonal_size = vector3.length(self.bbox_max - self.bbox_min)
124123

125-
def load(self, path):
124+
def load(self, loader, path):
126125
"""Deferred loading if a loader is specified"""
127-
if not hasattr(self, 'loader'):
128-
return
129-
130-
if self.loader:
131-
self.loader.load(self, path=path)
132-
126+
loader.load(self, path=path)
133127
self.apply_mesh_shaders()
134128
self.view_matrix = matrix44.create_identity()
135129

130+
def destroy(self):
131+
"""Destroy the scene data and deallocate buffers"""
132+
for mesh in self.meshes:
133+
mesh.vao.release()
134+
136135
def __str__(self):
137136
return "<Scene: {}>".format(self.name)
138137

0 commit comments

Comments
 (0)