[Bf-blender-cvs] [30b2db0be71] soc-2019-npr: LANPR: Add enable and auto update switches

YimingWu noreply at git.blender.org
Tue Jun 18 10:23:39 CEST 2019


Commit: 30b2db0be71ccc2bf32e89abf0f66ce2bad23952
Author: YimingWu
Date:   Tue Jun 18 15:00:28 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rB30b2db0be71ccc2bf32e89abf0f66ce2bad23952

LANPR: Add enable and auto update switches

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

M	release/scripts/startup/bl_ui/properties_render.py
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 5724e724289..6fa0d011c79 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -702,15 +702,6 @@ class LANPR_linesets(UIList):
             layout.alignment = 'CENTER'
             layout.label("", icon_value=icon)
 
-def lanpr_get_composition_scene(scene):
-    n = scene.name+'_lanpr_comp'
-    for s in bpy.data.scenes:
-        if s.name == n: return s
-    return None
-
-def lanpr_is_composition_scene(scene):
-    return scene.name.endswith('_lanpr_comp')
-
 class RENDER_PT_lanpr(RenderButtonsPanel, Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_LANPR', 'BLENDER_OPENGL', 'BLENDER_EEVEE'}
     bl_label = "LANPR"
@@ -720,84 +711,60 @@ class RENDER_PT_lanpr(RenderButtonsPanel, Panel):
     def poll(cls, context):
         return True
 
+    def draw_header(self, context):
+        self.layout.prop(context.scene.lanpr, "enabled", text="")
+
     def draw(self, context):
         layout = self.layout
         scene = context.scene
         lanpr = scene.lanpr
         active_layer = lanpr.layers.active_layer 
+        mode = lanpr.master_mode
+
 
-        # make LANPR main panel now visible under all engines.
-        # composition method yet to be deteremined.
-        
-        #sc = lanpr_get_composition_scene(scene)
-        
-        #if sc is not None:
-        #    layout.label(text = 'You are adjusting values for LANPR compostion scene.')
-        #    row = layout.row()
-        #    row.scale_y=1.5
-        #    row.operator("lanpr.goto_composition_scene")
-        #    layout.operator("lanpr.remove_composition_scene")
-        #    scene = sc
-        #    lanpr = scene.lanpr
-        #    active_layer = lanpr.layers.active_layer
-        #    return
-        #elif scene.render.engine!='BLENDER_LANPR':
-        #    layout.label(text = 'Select LANPR engine or use composition scene.')
-        #    layout.operator("lanpr.make_composition_scene")
-        #    return
-
-        #if lanpr_is_composition_scene(scene):
-        #   row = layout.row()
-        #    row.scale_y=1.5
-        #    row.operator("lanpr.goto_original_scene") 
-        #    
-        #    layout.label(text='LANPR Composition')
-        #    row = layout.row()
-        #    row.scale_y=1.5
-        #    row.scale_x=4
-        #    row.operator("lanpr.render_composited", icon = 'RENDER_STILL')
-        #    row.scale_x=1
-        #    row.prop(lanpr,"composite_render_animation", toggle=True, icon = 'RENDER_ANIMATION')
         
         if scene.render.engine!='BLENDER_LANPR':
-            layout.label(text='Mode:')
             layout.prop(lanpr, "master_mode", expand=True) 
         else:
             layout.label(text='Only Software mode result is used to generate GP stroke.')
 
-        if lanpr.master_mode == "DPIX" or lanpr.master_mode == "SOFTWARE":
+        if mode == "SOFTWARE":
+            row=layout.row(align=True)
+            row.prop(lanpr,'auto_update',toggle=True,text='Auto')
+            if not lanpr.auto_update:
+                row.operator("scene.lanpr_calculate", icon='RENDER_STILL', text='Update')
+
+        if mode == "DPIX" or mode == "SOFTWARE":
             
             layout.prop(lanpr, "background_color")
             layout.prop(lanpr, "crease_threshold")
 
             if lanpr.master_mode == "SOFTWARE":
-                layout.label(text="Enable On Demand:")
                 row = layout.row()
                 row.prop(lanpr,"enable_intersections", text = "Intersection Lines")
-                row.prop(lanpr,"enable_chaining", text = "Chaining (SLOW!)")
-                layout.label(text="RUN:")
-                layout.operator("scene.lanpr_calculate", icon='RENDER_STILL')
-
-                split = layout.split(factor=0.7)
+                row.prop(lanpr,"enable_chaining", text = "Chaining")
+                
+                split = layout.split(factor=0.4)
                 col = split.column()
-                col.label(text="Layer Composition:")
+                col.label(text="Line Layers:")
                 col = split.column()
-                col.operator("scene.lanpr_auto_create_line_layer", text = "Default")#, icon = "ZOOMIN")
-                layout.template_list("LANPR_linesets", "", lanpr, "layers", lanpr.layers, "active_layer_index", rows=4)
+                col.operator("scene.lanpr_auto_create_line_layer", text = "Default", icon = "ADD")
+                row=layout.row()
+                row.template_list("LANPR_linesets", "", lanpr, "layers", lanpr.layers, "active_layer_index", rows=4)
+                col=row.column(align=True)
                 if active_layer:
-                    split = layout.split()
-                    col = split.column()
-                    col.operator("scene.lanpr_add_line_layer")#icon="ZOOMIN")
-                    col.operator("scene.lanpr_delete_line_layer")#, icon="ZOOMOUT")
-                    col = split.column()
-                    col.operator("scene.lanpr_move_line_layer").direction = "UP"
-                    col.operator("scene.lanpr_move_line_layer").direction = "DOWN"
-                    layout.operator("scene.lanpr_rebuild_all_commands")
+                    col.operator("scene.lanpr_add_line_layer", icon="ADD", text='')
+                    col.operator("scene.lanpr_delete_line_layer", icon="REMOVE", text='')
+                    col.separator()
+                    col.operator("scene.lanpr_move_line_layer",icon='TRIA_UP', text='').direction = "UP"
+                    col.operator("scene.lanpr_move_line_layer",icon='TRIA_DOWN', text='').direction = "DOWN"
+                    col.separator()
+                    col.operator("scene.lanpr_rebuild_all_commands",icon="FILE_REFRESH", text='')
                 else:
-                    layout.operator("scene.lanpr_add_line_layer")
+                    col.operator("scene.lanpr_add_line_layer", icon="ADD", text='')
             
             if active_layer:
-                layout.label(text= "Normal:")
+                layout.label(text= "Normal controlled line weight:")
                 layout.prop(active_layer,"normal_mode", expand = True)
                 if active_layer.normal_mode != "DISABLED":
                     layout.prop(active_layer,"normal_control_object")
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index c2a0a2c7cc4..ef0e864b7a2 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1639,13 +1639,14 @@ struct LANPR_LineLayer;
 
 typedef struct SceneLANPR {
 
+  int enabled;
+  int auto_update; // for LANPR->GP to update automatically
+
   int master_mode;
 
   int enable_vector_trace;
   int display_thinning_result;
 
-  // int SizeCompensate;
-
   float depth_clamp;
   float depth_strength;
   float normal_clamp;
@@ -1693,7 +1694,9 @@ typedef struct SceneLANPR {
 
   /* composite utility */
   int composite_render_animation;
-  int what;
+
+  int _pad1;
+  
 
 } SceneLANPR;
 
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 86ca1e21bb3..34c8eed211f 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -7137,9 +7137,9 @@ static void rna_def_scene_lanpr(BlenderRNA *brna)
       {0, NULL, 0, NULL, NULL}};
 
   static const EnumPropertyItem rna_enum_lanpr_master_mode[] = {
-      {LANPR_MASTER_MODE_SOFTWARE, "SOFTWARE", 0, "Software", "Software edge calculation"},
-      {LANPR_MASTER_MODE_DPIX, "DPIX", 0, "DPIX", "DPIX GPU edge calculation"},
-      {LANPR_MASTER_MODE_SNAKE, "SNAKE", 0, "Snake", "Image filter and GPU tracing method"},
+      {LANPR_MASTER_MODE_SOFTWARE, "SOFTWARE", 0, "CPU", "Software edge calculation"},
+      {LANPR_MASTER_MODE_DPIX, "DPIX", 0, "GPU", "DPIX GPU edge extraction"},
+      {LANPR_MASTER_MODE_SNAKE, "SNAKE", 0, "Edge Detection", "Edge detection filter and tracing"},
       {0, NULL, 0, NULL, NULL}};
 
   static const EnumPropertyItem rna_enum_lanpr_enable_post_processing[] = {
@@ -7190,6 +7190,14 @@ static void rna_def_scene_lanpr(BlenderRNA *brna)
   RNA_def_struct_sdna(srna, "SceneLANPR");
   RNA_def_struct_ui_text(srna, "Scene LANPR Config", "LANPR global config");
 
+  prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_default(prop, 0);
+  RNA_def_property_ui_text(prop, "Enabled", "Is LANPR enabled");
+
+  prop = RNA_def_property(srna, "auto_update", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_default(prop, 0);
+  RNA_def_property_ui_text(prop, "Auto Update", "Automatically update LANPR cache when scene changes");
+
   prop = RNA_def_property(srna, "reloaded", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_items(prop, DEBUG_rna_enum_lanpr_reload);
   RNA_def_property_enum_default(prop, 0);



More information about the Bf-blender-cvs mailing list