From 803f0dd62d0c4c5e1a0f54f2e1c386ae00fd1c2e Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 18 Aug 2018 20:24:59 -0400 Subject: [PATCH] Fix #106 Given that the Plasma World (read: age) is defined per scene, it seems appropriate to limit the export to the current scene. Other scenes could potentially have other age definitions... --- korman/exporter/convert.py | 7 ++++--- korman/exporter/etlight.py | 2 +- korman/exporter/mesh.py | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/korman/exporter/convert.py b/korman/exporter/convert.py index 8bf5da0..ffb4459 100644 --- a/korman/exporter/convert.py +++ b/korman/exporter/convert.py @@ -112,12 +112,13 @@ class Exporter: oven.bake_static_lighting(self._objects) def _collect_objects(self): + scene = bpy.context.scene self.report.progress_advance() - self.report.progress_range = len(bpy.data.objects) + self.report.progress_range = len(scene.objects) inc_progress = self.report.progress_increment # Grab a naive listing of enabled pages - age = bpy.context.scene.world.plasma_age + age = scene.world.plasma_age pages_enabled = frozenset([page.name for page in age.pages if page.enabled]) all_pages = frozenset([page.name for page in age.pages]) @@ -139,7 +140,7 @@ class Exporter: # - Any arbitrary page can be disabled, so check our frozenset. # - Also, someone might have specified an invalid page, so keep track of that. error = explosions.UndefinedPageError() - for obj in bpy.data.objects: + for obj in scene.objects: if obj.plasma_object.enabled: page = obj.plasma_object.page if not page and not default_inited: diff --git a/korman/exporter/etlight.py b/korman/exporter/etlight.py index fec2c2f..42b067d 100644 --- a/korman/exporter/etlight.py +++ b/korman/exporter/etlight.py @@ -167,7 +167,7 @@ class LightBaker(_MeshManager): if user_lg is None: if not lg or bool(lg.objects) is False: - source = [i for i in bpy.data.objects if i.type == "LAMP"] + source = [i for i in bpy.context.scene.objects if i.type == "LAMP"] else: source = lg.objects dest = bpy.data.groups.new("_LIGHTMAPGEN_{}_{}".format(bo.name, mat_name)) diff --git a/korman/exporter/mesh.py b/korman/exporter/mesh.py index c107ac9..df7752c 100644 --- a/korman/exporter/mesh.py +++ b/korman/exporter/mesh.py @@ -128,15 +128,15 @@ class _MeshManager: return props def __enter__(self): + scene = bpy.context.scene self._report.progress_advance() - self._report.progress_range = len(bpy.data.objects) + self._report.progress_range = len(scene.objects) # Some modifiers like "Array" will procedurally generate new geometry that will impact # lightmap generation. The Blender Internal renderer does not seem to be smart enough to # take this into account. Thus, we temporarily apply modifiers to ALL meshes (even ones that # are not exported) such that we can generate proper lighting. - scene = bpy.context.scene - for i in bpy.data.objects: + for i in scene.objects: if i.type == "MESH" and i.is_modified(scene, "RENDER"): # Remember, storing actual pointers to the Blender objects can cause bad things to # happen because Blender's memory management SUCKS!