[Bf-blender-cvs] [224ae23443] master: GP Interpolate: Move settings from "gp_sculpt" to a new toolsettings struct - "gp_interpolate"

Joshua Leung noreply at git.blender.org
Wed Jan 18 07:43:19 CET 2017


Commit: 224ae234439727628ec5c260d1fd4e22e6566e29
Author: Joshua Leung
Date:   Wed Jan 18 16:43:17 2017 +1300
Branches: master
https://developer.blender.org/rB224ae234439727628ec5c260d1fd4e22e6566e29

GP Interpolate: Move settings from "gp_sculpt" to a new toolsettings struct - "gp_interpolate"

The "gp_sculpt" settings should be strictly for stroke sculpting, and not abused by
other tools. (Similarly, if other general GP tools need one-off options, those should
go into the normal toolsettings->gpencil_flag)

Furthermore, this paves the way for introducing new settings for controlling the way
that GP interpolation takes place (e.g. with easing equations, or a custom curvemap)

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	source/blender/editors/gpencil/gpencil_interpolate.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index f8ee7c9a85..c43f56acb3 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -227,12 +227,7 @@ class GreasePencilStrokeEditPanel:
 
         if is_3d_view:
             layout.separator()
-            col = layout.column(align=True)
-            col.operator("gpencil.interpolate", text="Interpolate")
-            col.operator("gpencil.interpolate_sequence", text="Sequence")
-            settings = context.tool_settings.gpencil_sculpt
-            col.prop(settings, "interpolate_all_layers")
-            col.prop(settings, "interpolate_selected_only")
+            
 
         layout.separator()
         col = layout.column(align=True)
@@ -249,6 +244,35 @@ class GreasePencilStrokeEditPanel:
             layout.separator()
             layout.operator("gpencil.reproject")
 
+class GreasePencilInterpolatePanel:
+    # subclass must set
+    bl_space_type = 'VIEW_3D'
+    bl_label = "Interpolate..."
+    bl_category = "Grease Pencil"
+    bl_region_type = 'TOOLS'
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        if context.gpencil_data is None:
+            return False
+        elif context.space_data.type != 'VIEW_3D':
+            return False
+
+        gpd = context.gpencil_data
+        return bool(context.editable_gpencil_strokes) and bool(gpd.use_stroke_edit_mode)
+
+    @staticmethod
+    def draw(self, context):
+        layout = self.layout
+        settings = context.tool_settings.gpencil_interpolate
+
+        col = layout.column(align=True)
+        col.operator("gpencil.interpolate", text="Interpolate")
+        col.operator("gpencil.interpolate_sequence", text="Sequence")
+        col.prop(settings, "interpolate_all_layers")
+        col.prop(settings, "interpolate_selected_only")
+
 
 class GreasePencilBrushPanel:
     # subclass must set
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index 0b04e86363..ca51149353 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -160,12 +160,12 @@ static void gp_interpolate_update_strokes(bContext *C, tGPDinterpolate *tgpi)
 static bool gp_interpolate_check_todo(bContext *C, bGPdata *gpd)
 {
 	ToolSettings *ts = CTX_data_tool_settings(C);
-	int flag = ts->gp_sculpt.flag;
+	eGP_Interpolate_SettingsFlag flag = ts->gp_interpolate.flag;
 	
 	/* get layers */
 	for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
 		/* all layers or only active */
-		if (!(flag & GP_BRUSHEDIT_FLAG_INTERPOLATE_ALL_LAYERS) && !(gpl->flag & GP_LAYER_ACTIVE)) {
+		if (!(flag & GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS) && !(gpl->flag & GP_LAYER_ACTIVE)) {
 			continue;
 		}
 		/* only editable and visible layers are considered */
@@ -179,7 +179,7 @@ static bool gp_interpolate_check_todo(bContext *C, bGPdata *gpd)
 			int fFrame;
 			
 			/* only selected */
-			if ((flag & GP_BRUSHEDIT_FLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
+			if ((flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
 				continue;
 			}
 			/* skip strokes that are invalid for current view */
@@ -223,7 +223,7 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
 		tGPDinterpolate_layer *tgpil;
 		
 		/* all layers or only active */
-		if (!(tgpi->flag & GP_BRUSHEDIT_FLAG_INTERPOLATE_ALL_LAYERS) && (gpl != active_gpl)) {
+		if (!(tgpi->flag & GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS) && (gpl != active_gpl)) {
 			continue;
 		}
 		/* only editable and visible layers are considered */
@@ -257,7 +257,7 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
 			
 			
 			/* only selected */
-			if ((tgpi->flag & GP_BRUSHEDIT_FLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
+			if ((tgpi->flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
 				valid = false;
 			}
 			/* skip strokes that are invalid for current view */
@@ -424,7 +424,7 @@ static bool gp_interpolate_set_init_values(bContext *C, wmOperator *op, tGPDinte
 	tgpi->scene = CTX_data_scene(C);
 	tgpi->sa = CTX_wm_area(C);
 	tgpi->ar = CTX_wm_region(C);
-	tgpi->flag = ts->gp_sculpt.flag;
+	tgpi->flag = ts->gp_interpolate.flag;
 	
 	/* set current frame number */
 	tgpi->cframe = tgpi->scene->r.cfra;
@@ -689,7 +689,8 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
 	
 	Scene *scene = CTX_data_scene(C);
 	ToolSettings *ts = CTX_data_tool_settings(C);
-	int flag = ts->gp_sculpt.flag;
+	GP_Interpolate_Settings *ipo_settings = &ts->gp_interpolate;
+	eGP_Interpolate_SettingsFlag flag = ipo_settings->flag;
 	
 	/* cannot interpolate if not between 2 frames */
 	if (ELEM(NULL, actframe, actframe->next)) {
@@ -709,7 +710,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
 		int cframe, fFrame;
 		
 		/* all layers or only active */
-		if (((flag & GP_BRUSHEDIT_FLAG_INTERPOLATE_ALL_LAYERS) == 0) && (gpl != active_gpl)) {
+		if (((flag & GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS) == 0) && (gpl != active_gpl)) {
 			continue;
 		}
 		/* only editable and visible layers are considered */
@@ -734,7 +735,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
 				bGPDstroke *new_stroke;
 				
 				/* only selected */
-				if ((flag & GP_BRUSHEDIT_FLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
+				if ((flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
 					continue;
 				}
 				/* skip strokes that are invalid for current view */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index f5e71ae59a..4d09457b3c 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1212,12 +1212,22 @@ typedef enum eGP_BrushEdit_SettingsFlag {
 	GP_BRUSHEDIT_FLAG_APPLY_STRENGTH = (1 << 2),
 	/* apply brush to thickness */
 	GP_BRUSHEDIT_FLAG_APPLY_THICKNESS = (1 << 3),
+} eGP_BrushEdit_SettingsFlag;
+
+
+/* Settings for GP Interpolation Operators */
+typedef struct GP_Interpolate_Settings {
+	short flag;                        /* eGP_Interpolate_SettingsFlag */
+} GP_Interpolate_Settings;
+
+/* GP_Interpolate_Settings.flag */
+typedef enum eGP_Interpolate_SettingsFlag {
 	/* apply interpolation to all layers */
-	GP_BRUSHEDIT_FLAG_INTERPOLATE_ALL_LAYERS = (1 << 4),
+	GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS    = (1 << 0),
 	/* apply interpolation to only selected */
-	GP_BRUSHEDIT_FLAG_INTERPOLATE_ONLY_SELECTED = (1 << 5)
+	GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED = (1 << 1),
+} eGP_Interpolate_SettingsFlag;
 
-} eGP_BrushEdit_SettingsFlag;
 
 /* *************************************************************** */
 /* Transform Orientations */
@@ -1435,7 +1445,10 @@ typedef struct ToolSettings {
 	
 	/* Grease Pencil Sculpt */
 	struct GP_BrushEdit_Settings gp_sculpt;
-
+	
+	/* Grease Pencil Interpolation Tool(s) */
+	struct GP_Interpolate_Settings gp_interpolate;
+	
 	/* Grease Pencil Drawing Brushes (bGPDbrush) */
 	ListBase gp_brushes; 
 
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index f97a5735c9..66e6f30fee 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -262,6 +262,7 @@ extern StructRNA RNA_GPencilLayer;
 extern StructRNA RNA_GPencilPalette;
 extern StructRNA RNA_GPencilPaletteColor;
 extern StructRNA RNA_GPencilBrush;
+extern StructRNA RNA_GPencilInterpolateSettings;
 extern StructRNA RNA_GPencilStroke;
 extern StructRNA RNA_GPencilStrokePoint;
 extern StructRNA RNA_GPencilSculptSettings;
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 6947a4104c..8f5304c8f0 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -447,6 +447,12 @@ EnumPropertyItem rna_enum_bake_pass_filter_type_items[] = {
 #include "FRS_freestyle.h"
 #endif
 
+/* Grease Pencil Interpolation settings */
+static char *rna_GPencilInterpolateSettings_path(PointerRNA *UNUSED(ptr))
+{
+	return BLI_strdup("tool_settings.gpencil_interpolate");
+}
+
 /* Grease pencil Drawing Brushes */
 static bGPDbrush *rna_GPencil_brush_new(ToolSettings *ts, const char *name, int setactive)
 {
@@ -2138,6 +2144,30 @@ static int rna_gpu_is_hq_supported_get(PointerRNA *UNUSED(ptr))
 
 #else
 
+/* Grease Pencil Interpolation tool settings */
+static void rna_def_gpencil_interpolate(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+	
+	srna = RNA_def_struct(brna, "GPencilInterpolateSettings", NULL);
+	RNA_def_struct_sdna(srna, "GP_Interpolate_Settings");
+	RNA_def_struct_path_func(srna, "rna_GPencilInterpolateSettings_path");
+	RNA_def_struct_ui_text(srna, "Grease Pencil Interpolate Settings",
+	                       "Settings for Grease Pencil interpolation tools");
+	
+	/* flags */
+	prop = RNA_def_property(srna, "interpolate_all_layers", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS);
+	RNA_def_property_ui_text(prop, "Interpolate All Layers", "Interpolate all layers, not only active");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
+
+	prop = RNA_def_property(srna, "interpolate_selected_only", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED);
+	RNA_def_property_ui_text(prop, "Interpolate Selected Strokes", "Interpolate only selected strokes in the original frame");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
+}
+
 /* Grease Pencil Drawing Brushes */
 static void rna_def_gpencil_brush(BlenderRNA *brna)
 {
@@ -2673,7 +2703,14 @@ static void rna_def_tool_settings(BlenderRNA  *brna)
 	prop = RNA_def_property(srna, "gpencil_sculpt", PROP_POINT

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list