Browse Source

Actually fix leftover light groups

So, the previous hypothesis was absolutely WRONG. The real issue was the
appending of .001s and such when you have a material on many objects. Each
object-material pair has its own light group now because object Plasma
modifiers can change the rules a bit.

w00t for fixage
pull/43/head
Adam Johnson 8 years ago
parent
commit
c6ea93fe3b
  1. 35
      korman/exporter/etlight.py

35
korman/exporter/etlight.py

@ -132,17 +132,16 @@ class LightBaker:
continue
# Already done it?
name = material.name
lg = material.light_group
if name not in self._lightgroups:
self._lightgroups[name] = lg
lg, mat_name = material.light_group, material.name
if mat_name not in self._lightgroups:
self._lightgroups[mat_name] = lg
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"]
else:
source = lg.objects
dest = bpy.data.groups.new("_LIGHTMAPGEN_{}".format(name))
dest = bpy.data.groups.new("_LIGHTMAPGEN_{}_{}".format(bo.name, mat_name))
# Rules:
# 1) No animated lights, period.
@ -203,23 +202,17 @@ class LightBaker:
return bake
def _pop_lightgroups(self):
groups, materials = bpy.data.groups, bpy.data.materials
materials = bpy.data.materials
for mat_name, lg in self._lightgroups.items():
material = materials[mat_name]
_fake = material.light_group
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
materials[mat_name].light_group = lg
self._lightgroups.clear()
groups = bpy.data.groups
for i in groups:
if i.name.startswith("_LIGHTMAPGEN_"):
i.user_clear()
bpy.data.groups.remove(i)
def _prep_for_lightmap(self, bo, toggle):
mesh = bo.data
modifier = bo.plasma_modifiers.lightmap
@ -346,10 +339,6 @@ 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