UV_OT_lightmap_pack: Distinction between edit and object modes
authorDalai Felinto <dfelinto@gmail.com>
Wed, 5 Sep 2018 20:20:33 +0000 (17:20 -0300)
committerDalai Felinto <dfelinto@gmail.com>
Wed, 5 Sep 2018 20:24:07 +0000 (17:24 -0300)
I don't even know why this operator was ever made to work in object mode.
That said, since it does, we should have different options for it
(or rather, always do all faces for it).

release/scripts/startup/bl_operators/uvcalc_lightmap.py

index 0db63576920c7dc6f71d706f6db58e1582d0b028..360a11dccca5a4c2f42916573e6ffb569ca68df5 100644 (file)
@@ -647,11 +647,35 @@ class LightMapPack(Operator):
         default=0.1,
     )
 
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+
+        is_editmode = context.active_object.mode == 'EDIT'
+        if is_editmode:
+            layout.prop(self, "PREF_CONTEXT")
+
+        layout.prop(self, "PREF_PACK_IN_ONE")
+        layout.prop(self, "PREF_NEW_UVLAYER")
+        layout.prop(self, "PREF_APPLY_IMAGE")
+        layout.prop(self, "PREF_IMG_PX_SIZE")
+        layout.prop(self, "PREF_BOX_DIV")
+        layout.prop(self, "PREF_MARGIN_DIV")
+
+    @classmethod
+    def poll(cls, context):
+        ob = context.active_object
+        return ob and ob.type == 'MESH'
+
     def execute(self, context):
         kwargs = self.as_keywords()
         PREF_CONTEXT = kwargs.pop("PREF_CONTEXT")
 
-        if PREF_CONTEXT == 'SEL_FACES':
+        is_editmode = context.active_object.mode == 'EDIT'
+
+        if not is_editmode:
+            kwargs["PREF_SEL_ONLY"] = False
+        elif PREF_CONTEXT == 'SEL_FACES':
             kwargs["PREF_SEL_ONLY"] = True
         elif PREF_CONTEXT == 'ALL_FACES':
             kwargs["PREF_SEL_ONLY"] = False