Browse Source

Attempt to fix leftover light groups

Doobes has reported that _LIGHTMAPGEN groups can be intermittently left
attached to some lamps. This is similar to a UnicodeDecodeError we were
having before in which a cached Blender object pointer became trashed
somehow. I think in this case our cached copy of the light group is no
longer equal to what is found in bpy.data.groups, so the removal fails...
Or something along those lines.

So, we now find the group again from the list and erase that. As a final
sanity test, on blend file save, we nuke all _LIGHTMAPGEN groups.
pull/43/head
Adam Johnson 8 years ago
parent
commit
7e53b165c3
  1. 22
      korman/exporter/etlight.py

22
korman/exporter/etlight.py

@ -203,14 +203,20 @@ class LightBaker:
return bake
def _pop_lightgroups(self):
groups, materials = bpy.data.groups, bpy.data.materials
for mat_name, lg in self._lightgroups.items():
material = bpy.data.materials[mat_name]
material = materials[mat_name]
_fake = material.light_group
if _fake is not None and _fake.name.startswith("_LIGHTMAPGEN"):
for i in _fake.objects:
_fake.objects.unlink(i)
_fake.user_clear()
bpy.data.groups.remove(_fake)
if _fake is not None:
# I have seen issues where the light group is not always removed correctly if we
# just call groups.remove(_fake) -- so let's search for this LG's name and remove
# that result. Should actually fix the problem... I hope.
group_name = "_LIGHTMAPGEN_{}".format(mat_name)
_hack_lg = groups.get(group_name, None)
if _hack_lg is not None:
groups.remove(_hack_lg)
else:
print(" TITS! Group '{}' will be left over...".format(group_name))
material.light_group = lg
self._lightgroups.clear()
@ -340,6 +346,10 @@ class LightBaker:
@persistent
def _toss_garbage(scene):
"""Removes all LIGHTMAPGEN and autocolor garbage before saving"""
for i in bpy.data.groups:
if i.name.startswith("_LIGHTMAPGEN"):
i.user_clear()
bpy.data.groups.remove(i)
for i in bpy.data.images:
if i.name.endswith("_LIGHTMAPGEN.png"):
i.user_clear()

Loading…
Cancel
Save