From d303faced6f3ea0e3eab10f2d2ca8553e4606dc2 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 13 Jun 2015 16:41:42 -0400 Subject: [PATCH] Fix many "no valid images found to bake to" bugs --- korman/exporter/mesh.py | 10 +++++++++- korman/operators/op_lightmap.py | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/korman/exporter/mesh.py b/korman/exporter/mesh.py index 9a762c1..bb41ae1 100644 --- a/korman/exporter/mesh.py +++ b/korman/exporter/mesh.py @@ -293,7 +293,15 @@ class MeshConverter: return geospans def _export_static_lighting(self, bo): - context = {"active_object": bo, "object": bo} + context = {"active_object": bo, + "area": bpy.context.area, + "blend_data": bpy.context.blend_data, + "object": bo, + "region": bpy.context.region, + "scene": bpy.context.scene, + "screen": bpy.context.screen, + "window": bpy.context.window} + if bo.plasma_modifiers.lightmap.enabled: print(" Baking lightmap...") print("====") diff --git a/korman/operators/op_lightmap.py b/korman/operators/op_lightmap.py index e8fa33e..aaaed46 100644 --- a/korman/operators/op_lightmap.py +++ b/korman/operators/op_lightmap.py @@ -105,11 +105,15 @@ class LightmapAutobakeOperator(_LightingOperator, bpy.types.Operator): for uvtex in mesh.uv_textures: if uvtex.name == "LIGHTMAPGEN": toggle.track(mesh.uv_textures, "active", uvtex) + toggle.track(uvtex, "active_render", True) break + else: + toggle.track(uvtex, "active_render", False) else: # Gotta make it uvtex = mesh.uv_textures.new("LIGHTMAPGEN") toggle.track(mesh.uv_textures, "active", uvtex) + toggle.track(uvtex, "active_render", True) # Now, enter edit mode on this mesh and unwrap. bpy.ops.object.mode_set(mode="EDIT") @@ -177,6 +181,11 @@ class VertexColorLightingOperator(_LightingOperator, bpy.types.Operator): mesh.vertex_colors.new("autocolor") toggle.track(mesh.vertex_colors, "active", autocolor) + # Mark "autocolor" as our active render layer + for vcol_layer in mesh.vertex_colors: + autocol = vcol_layer.name == "autocolor" + toggle.track(vcol_layer, "active_render", autocol) + # Bake settings render = context.scene.render toggle.track(render, "use_bake_to_vertex_color", True)