From b709db140a9f63406f4c107a36bcc2d3ed79e067 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 5 Jul 2015 22:49:09 -0400 Subject: [PATCH] Allow the user to spec'd lightmap regeneration This is slow on nontrivial meshes and can take up most of the export time... --- korman/operators/op_export.py | 5 +++++ korman/operators/op_lightmap.py | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/korman/operators/op_export.py b/korman/operators/op_export.py index b4f1787..ae2e1bc 100644 --- a/korman/operators/op_export.py +++ b/korman/operators/op_export.py @@ -37,6 +37,10 @@ class ExportOperator(bpy.types.Operator): "description": "Profiles the exporter using cProfile", "default": False}), + "regenerate_lightmaps": (BoolProperty, {"name": "Regenerate Lightmaps", + "description": "(Re-)Bake all lightmaps on export", + "default": True}), + "version": (EnumProperty, {"name": "Version", "description": "Version of the Plasma Engine to target", "default": "pvPots", # This should be changed when moul is easier to target! @@ -58,6 +62,7 @@ class ExportOperator(bpy.types.Operator): # The crazy mess we're doing with props on the fly means we have to explicitly draw them :( layout.prop(age, "version") + layout.prop(age, "regenerate_lightmaps") layout.prop(age, "use_texture_page") layout.prop(age, "profile_export") diff --git a/korman/operators/op_lightmap.py b/korman/operators/op_lightmap.py index 8cf7518..d2b8d9d 100644 --- a/korman/operators/op_lightmap.py +++ b/korman/operators/op_lightmap.py @@ -88,6 +88,7 @@ class LightmapAutobakeOperator(_LightingOperator, bpy.types.Operator): bl_options = {"INTERNAL"} light_group = StringProperty(name="Light Group") + force = BoolProperty(name="Force Lightmap Generation", default=False) def __init__(self): super().__init__() @@ -122,11 +123,15 @@ class LightmapAutobakeOperator(_LightingOperator, bpy.types.Operator): im = data_images.get(im_name) if im is None: im = data_images.new(im_name, width=size, height=size) - elif im.size != (size, size): + elif im.size[0] != size: # Force delete and recreate the image because the size is out of date im.user_clear() data_images.remove(im) im = data_images.new(im_name, width=size, height=size) + elif not (context.scene.world.plasma_age.regenerate_lightmaps or self.force): + # we have a lightmap that matches our specs, so what gives??? + # this baking process is one slow thing. only do it if the user wants us to! + return {"CANCELLED"} # If there is a cached LIGHTMAPGEN uvtexture, nuke it uvtex = uv_textures.get("LIGHTMAPGEN", None) @@ -196,7 +201,7 @@ class LightmapAutobakePreviewOperator(_LightingOperator, bpy.types.Operator): super().__init__() def execute(self, context): - bpy.ops.object.plasma_lightmap_autobake(light_group=self.light_group) + bpy.ops.object.plasma_lightmap_autobake(light_group=self.light_group, force=True) tex = bpy.data.textures.get("LIGHTMAPGEN_PREVIEW") if tex is None: