From 7e387fda481b143d59c7962169682fc3adf63935 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 20 Jun 2016 18:54:04 -0400 Subject: [PATCH] Don't bake shadows for objects with no drawables I fail to understand why Blender thinks this is legit, but oh well... Also, as a bonus, we no longer clobber values in the GoodNeighbor tracker. I wonder how many bugs this will fix? --- korman/exporter/etlight.py | 9 ++++++++- korman/helpers.py | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/korman/exporter/etlight.py b/korman/exporter/etlight.py index 9cbf113..678c0fe 100644 --- a/korman/exporter/etlight.py +++ b/korman/exporter/etlight.py @@ -163,7 +163,10 @@ class LightBaker: return None def _has_valid_material(self, bo): - for material in bo.data.materials: + data = bo.data + if data is None or not isinstance(data, bpy.types.Mesh): + return False + for material in data.materials: if material is not None: return True return False @@ -318,11 +321,15 @@ class LightBaker: toggle.track(objs, "hide_render", False) for i in bpy.data.objects: i.select = i == objs + if not self._has_valid_material(i): + toggle.track(i, "hide_render", True) else: for i in bpy.data.objects: value = i in objs if value: toggle.track(i, "hide_render", False) + elif not self._has_valid_material(i): + toggle.track(i, "hide_render", True) i.select = value @persistent diff --git a/korman/helpers.py b/korman/helpers.py index efc1fb4..1bc0151 100644 --- a/korman/helpers.py +++ b/korman/helpers.py @@ -24,7 +24,8 @@ class GoodNeighbor: return self def track(self, cls, attr, value): - self._tracking[(cls, attr)] = getattr(cls, attr) + if (cls, attr) not in self._tracking: + self._tracking[(cls, attr)] = getattr(cls, attr) setattr(cls, attr, value) def __exit__(self, type, value, traceback):