Browse Source

Lightmap Mod: Don't expose tracebacks to the user

Rather, inform the user in a standardized way when nothing was baked.
Beats the heck out of seeing a random traceback!
pull/38/head
Adam Johnson 9 years ago
parent
commit
46a094057f
  1. 6
      korman/exporter/etlight.py
  2. 4
      korman/operators/op_lightmap.py
  3. 2
      korman/ui/modifiers/render.py

6
korman/exporter/etlight.py

@ -69,11 +69,12 @@ class LightBaker:
with GoodNeighbor() as toggle:
try:
# reduce the amount of indentation
self._bake_static_lighting(bake, toggle)
result = self._bake_static_lighting(bake, toggle)
finally:
# this stuff has been observed to be problematic with GoodNeighbor
self._pop_lightgroups()
self._restore_uvtexs()
return result
def _bake_static_lighting(self, bake, toggle):
# Step 0.9: Make all layers visible.
@ -112,6 +113,9 @@ class LightBaker:
else:
raise RuntimeError(key[0])
# Return how many thingos we baked
return sum(map(sum, bake.values()))
def _generate_lightgroup(self, mesh, user_lg=None):
"""Makes a new light group for the baking process that excludes all Plasma RT lamps"""

4
korman/operators/op_lightmap.py

@ -42,7 +42,9 @@ class LightmapAutobakePreviewOperator(_LightingOperator, bpy.types.Operator):
toggle.track(context.scene, "layers", tuple(context.scene.layers))
bake = LightBaker()
bake.bake_static_lighting([context.active_object,])
if not bake.bake_static_lighting([context.active_object,]):
self.report({"INFO"}, "No valid lights found to bake.")
return {"FINISHED"}
tex = bpy.data.textures.get("LIGHTMAPGEN_PREVIEW")
if tex is None:

2
korman/ui/modifiers/render.py

@ -59,7 +59,7 @@ def lightmap(modifier, layout, context):
# the backing image name to see if it's for this lightmap. If so, you have a preview. If not,
# well... It was nice knowing you!
tex = bpy.data.textures.get("LIGHTMAPGEN_PREVIEW")
if tex is not None:
if tex is not None and tex.image is not None:
im_name = "{}_LIGHTMAPGEN.png".format(context.active_object.name)
if tex.image.name == im_name:
layout.template_preview(tex, show_buttons=False)

Loading…
Cancel
Save