diff --git a/korman/operators/op_lightmap.py b/korman/operators/op_lightmap.py index fc70d8e..87119a1 100644 --- a/korman/operators/op_lightmap.py +++ b/korman/operators/op_lightmap.py @@ -44,10 +44,14 @@ class LightmapAutobakePreviewOperator(_LightingOperator, bpy.types.Operator): self.report({"INFO"}, "No valid lights found to bake.") return {"FINISHED"} - tex = bpy.data.textures.get("LIGHTMAPGEN_PREVIEW") - if tex is None: - tex = bpy.data.textures.new("LIGHTMAPGEN_PREVIEW", "IMAGE") - tex.extension = "CLIP" - tex.image = bpy.data.images["{}_LIGHTMAPGEN.png".format(context.active_object.name)] + if context.object.plasma_modifiers.lightmap.bake_type == "lightmap": + tex = bpy.data.textures.get("LIGHTMAPGEN_PREVIEW") + if tex is None: + tex = bpy.data.textures.new("LIGHTMAPGEN_PREVIEW", "IMAGE") + tex.extension = "CLIP" + tex.image = bpy.data.images["{}_LIGHTMAPGEN.png".format(context.active_object.name)] + else: + for i in context.object.data.vertex_colors: + i.active = i.name == "autocolor" return {"FINISHED"} diff --git a/korman/ui/modifiers/render.py b/korman/ui/modifiers/render.py index 6df9fe7..a454512 100644 --- a/korman/ui/modifiers/render.py +++ b/korman/ui/modifiers/render.py @@ -202,18 +202,18 @@ def lightmap(modifier, layout, context): layout.label("Transparent objects cannot be lightmapped.", icon="ERROR") else: col = layout.column() - col.active = is_texture - operator = col.operator("object.plasma_lightmap_preview", "Preview Lightmap", icon="RENDER_STILL") + col.operator("object.plasma_lightmap_preview", "Preview Lightmap" if is_texture else "Preview Vertex Colors", icon="RENDER_STILL") # Kind of clever stuff to show the user a preview... # We can't show images, so we make a hidden ImageTexture called LIGHTMAPGEN_PREVIEW. We check # 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 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) + if is_texture: + tex = bpy.data.textures.get("LIGHTMAPGEN_PREVIEW") + 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) def rtshadow(modifier, layout, context): split = layout.split()