[Bf-blender-cvs] [61a9f41cf52] master: UI: bake panel layout improvements

William Reynish noreply at git.blender.org
Mon Feb 18 04:51:08 CET 2019


Commit: 61a9f41cf5285cea60106a441d08172b5f9ec0df
Author: William Reynish
Date:   Mon Feb 18 14:47:51 2019 +1100
Branches: master
https://developer.blender.org/rB61a9f41cf5285cea60106a441d08172b5f9ec0df

UI: bake panel layout improvements

All the controls were just really thrown in there without any proper
organization.
This gives it more structure.

- Correct use of sub-panels to communicate hierarchy and sections.
- Use flow layout for toggles.
- Use consistent names for "Bake Type".

===================================================================

M	intern/cycles/blender/addon/ui.py
M	source/blender/makesrna/intern/rna_scene.c

===================================================================

diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index ea2b257a12c..b6751ebc12c 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -1753,76 +1753,140 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
         cbk = scene.render.bake
         rd = scene.render
 
-        col = layout.column()
-        col.prop(rd, "use_bake_multires")
         if rd.use_bake_multires:
-            col.prop(rd, "bake_type")
+            layout.operator("object.bake_image", icon='RENDER_STILL')
+            layout.prop(rd, "use_bake_multires")
+            layout.prop(rd, "bake_type")
 
-            col = layout.column()
-            col.prop(rd, "bake_margin")
-            col.prop(rd, "use_bake_clear")
+        else:
+            layout.operator("object.bake", icon='RENDER_STILL').type = cscene.bake_type
+            layout.prop(rd, "use_bake_multires")
+            layout.prop(cscene, "bake_type")
 
-            if rd.bake_type == 'DISPLACEMENT':
-                col.prop(rd, "use_bake_lores_mesh")
 
-            col.operator("object.bake_image", icon='RENDER_STILL')
+class CYCLES_RENDER_PT_bake_influence(CyclesButtonsPanel, Panel):
+    bl_label = "Influence"
+    bl_context = "render"
+    bl_parent_id = "CYCLES_RENDER_PT_bake"
+    COMPAT_ENGINES = {'CYCLES'}
+    @classmethod
+    def poll(cls, context):
+        scene = context.scene
+        cscene = scene.cycles
+        rd = scene.render
+        if rd.use_bake_multires == False and cscene.bake_type in {
+                'NORMAL', 'COMBINED', 'DIFFUSE', 'GLOSSY', 'TRANSMISSION', 'SUBSURFACE'}:
+            return True
 
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False  # No animation.
+
+        scene = context.scene
+        cscene = scene.cycles
+        cbk = scene.render.bake
+        rd = scene.render
+
+        col = layout.column()
+
+        if cscene.bake_type == 'NORMAL':
+            col.prop(cbk, "normal_space", text="Space")
+
+            sub = col.column(align=True)
+            sub.prop(cbk, "normal_r", text="Swizzle R")
+            sub.prop(cbk, "normal_g", text="G")
+            sub.prop(cbk, "normal_b", text="B")
+
+        elif cscene.bake_type == 'COMBINED':
+            row = col.row(align=True)
+            row.use_property_split = False
+            row.prop(cbk, "use_pass_direct", toggle=True)
+            row.prop(cbk, "use_pass_indirect", toggle=True)
+
+            flow = col.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=True)
+
+            flow.active = cbk.use_pass_direct or cbk.use_pass_indirect
+            flow.prop(cbk, "use_pass_diffuse")
+            flow.prop(cbk, "use_pass_glossy")
+            flow.prop(cbk, "use_pass_transmission")
+            flow.prop(cbk, "use_pass_subsurface")
+            flow.prop(cbk, "use_pass_ambient_occlusion")
+            flow.prop(cbk, "use_pass_emit")
+
+        elif cscene.bake_type in {'DIFFUSE', 'GLOSSY', 'TRANSMISSION', 'SUBSURFACE'}:
+            row = col.row(align=True)
+            row.use_property_split = False
+            row.prop(cbk, "use_pass_direct", toggle=True)
+            row.prop(cbk, "use_pass_indirect", toggle=True)
+            row.prop(cbk, "use_pass_color", toggle=True)
+
+
+class CYCLES_RENDER_PT_bake_selected_to_active(CyclesButtonsPanel, Panel):
+    bl_label = "Selected to Active"
+    bl_context = "render"
+    bl_parent_id = "CYCLES_RENDER_PT_bake"
+    bl_options = {'DEFAULT_CLOSED'}
+    COMPAT_ENGINES = {'CYCLES'}
+
+    @classmethod
+    def poll(cls, context):
+        scene = context.scene
+        rd = scene.render
+        return rd.use_bake_multires == False
+
+    def draw_header(self, context):
+        scene = context.scene
+        cbk = scene.render.bake
+        self.layout.prop(cbk, "use_selected_to_active", text="")
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False  # No animation.
+
+        scene = context.scene
+        cscene = scene.cycles
+        cbk = scene.render.bake
+        rd = scene.render
+
+        layout.active = cbk.use_selected_to_active
+        col = layout.column()
+
+        col.prop(cbk, "use_cage", text="Cage")
+        if cbk.use_cage:
+            col.prop(cbk, "cage_extrusion", text="Extrusion")
+            col.prop(cbk, "cage_object", text="Cage Object")
         else:
-            col.prop(cscene, "bake_type")
-
-            col = layout.column()
-
-            if cscene.bake_type == 'NORMAL':
-                col.prop(cbk, "normal_space", text="Space")
-
-                sub = col.column(align=True)
-                sub.prop(cbk, "normal_r", text="Swizzle R")
-                sub.prop(cbk, "normal_g", text="G")
-                sub.prop(cbk, "normal_b", text="B")
-
-            elif cscene.bake_type == 'COMBINED':
-                row = col.row(align=True)
-                row.use_property_split = False
-                row.prop(cbk, "use_pass_direct", toggle=True)
-                row.prop(cbk, "use_pass_indirect", toggle=True)
-
-                col = col.column()
-                col.active = cbk.use_pass_direct or cbk.use_pass_indirect
-                col.prop(cbk, "use_pass_diffuse")
-                col.prop(cbk, "use_pass_glossy")
-                col.prop(cbk, "use_pass_transmission")
-                col.prop(cbk, "use_pass_subsurface")
-                col.prop(cbk, "use_pass_ambient_occlusion")
-                col.prop(cbk, "use_pass_emit")
-
-            elif cscene.bake_type in {'DIFFUSE', 'GLOSSY', 'TRANSMISSION', 'SUBSURFACE'}:
-                row = col.row(align=True)
-                row.use_property_split = False
-                row.prop(cbk, "use_pass_direct", toggle=True)
-                row.prop(cbk, "use_pass_indirect", toggle=True)
-                row.prop(cbk, "use_pass_color", toggle=True)
-
-            layout.separator()
-
-            col = layout.column()
-            col.prop(cbk, "margin")
-            col.prop(cbk, "use_clear", text="Clear Image")
+            col.prop(cbk, "cage_extrusion", text="Ray Distance")
 
-            col.separator()
 
-            col.prop(cbk, "use_selected_to_active")
-            sub = col.column()
-            sub.active = cbk.use_selected_to_active
-            sub.prop(cbk, "use_cage", text="Cage")
-            if cbk.use_cage:
-                sub.prop(cbk, "cage_extrusion", text="Extrusion")
-                sub.prop(cbk, "cage_object", text="Cage Object")
-            else:
-                sub.prop(cbk, "cage_extrusion", text="Ray Distance")
+class CYCLES_RENDER_PT_bake_output(CyclesButtonsPanel, Panel):
+    bl_label = "Output"
+    bl_context = "render"
+    bl_parent_id = "CYCLES_RENDER_PT_bake"
+    COMPAT_ENGINES = {'CYCLES'}
 
-            layout.separator()
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False  # No animation.
 
-            layout.operator("object.bake", icon='RENDER_STILL').type = cscene.bake_type
+        scene = context.scene
+        cscene = scene.cycles
+        cbk = scene.render.bake
+        rd = scene.render
+
+        if rd.use_bake_multires:
+            layout.prop(rd, "bake_margin")
+            layout.prop(rd, "use_bake_clear", text="Clear Image")
+
+            if rd.bake_type == 'DISPLACEMENT':
+                col.prop(rd, "use_bake_lores_mesh")
+        else:
+
+            layout.prop(cbk, "margin")
+            layout.prop(cbk, "use_clear", text="Clear Image")
 
 
 class CYCLES_RENDER_PT_debug(CyclesButtonsPanel, Panel):
@@ -2134,6 +2198,9 @@ classes = (
     CYCLES_MATERIAL_PT_settings_surface,
     CYCLES_MATERIAL_PT_settings_volume,
     CYCLES_RENDER_PT_bake,
+    CYCLES_RENDER_PT_bake_influence,
+    CYCLES_RENDER_PT_bake_selected_to_active,
+    CYCLES_RENDER_PT_bake_output,
     CYCLES_RENDER_PT_debug,
     CYCLES_NODE_PT_settings,
     CYCLES_NODE_PT_settings_surface,
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 78faee958fa..2894cfedc4e 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -5211,7 +5211,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
 	prop = RNA_def_property(srna, "bake_type", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_bitflag_sdna(prop, NULL, "bake_mode");
 	RNA_def_property_enum_items(prop, bake_mode_items);
-	RNA_def_property_ui_text(prop, "Bake Mode", "Choose shading information to bake into the image");
+	RNA_def_property_ui_text(prop, "Bake Type", "Choose shading information to bake into the image");
 	RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
 
 	prop = RNA_def_property(srna, "use_bake_selected_to_active", PROP_BOOLEAN, PROP_NONE);



More information about the Bf-blender-cvs mailing list