[Bf-blender-cvs] [ca523175d01] temp-gpencil-interpolate: GPencil: Basic Interpolate Tool

Antonio Vazquez noreply at git.blender.org
Mon Dec 21 20:15:21 CET 2020


Commit: ca523175d01f2f50ab3da06c2aeb369783c465ef
Author: Antonio Vazquez
Date:   Mon Dec 21 20:15:16 2020 +0100
Branches: temp-gpencil-interpolate
https://developer.blender.org/rBca523175d01f2f50ab3da06c2aeb369783c465ef

GPencil: Basic Interpolate Tool

Still more work pending

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/editors/gpencil/gpencil_interpolate.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index b6768087c86..59ac550929c 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -6769,6 +6769,17 @@ def km_3d_view_tool_edit_gpencil_transform_fill(params):
     )
 
 
+def km_3d_view_tool_edit_gpencil_interpolate(params):
+    return (
+        "3D View Tool: Edit Gpencil, Interpolate",
+        {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+        {"items": [
+            ("gpencil.interpolate", {"type": params.tool_tweak, "value": 'ANY'},
+             {"properties": [("release_confirm", True)]}),
+        ]},
+    )
+
+
 def km_3d_view_tool_sculpt_gpencil_select(params):
     return (
         "3D View Tool: Sculpt Gpencil, Tweak",
@@ -7094,6 +7105,7 @@ def generate_keymaps(params=None):
         km_3d_view_tool_edit_gpencil_shear(params),
         km_3d_view_tool_edit_gpencil_to_sphere(params),
         km_3d_view_tool_edit_gpencil_transform_fill(params),
+        km_3d_view_tool_edit_gpencil_interpolate(params),
         km_3d_view_tool_sculpt_gpencil_select(params),
         km_3d_view_tool_sculpt_gpencil_select_box(params),
         km_3d_view_tool_sculpt_gpencil_select_circle(params),
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 0411d5c64bc..f8c27e330ac 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -2112,6 +2112,25 @@ class _defs_gpencil_edit:
             draw_settings=draw_settings,
         )
 
+    @ToolDef.from_fn
+    def interpolate():
+        def draw_settings(context, layout, tool):
+            props = tool.operator_properties("gpencil.interpolate")
+            row = layout.row()
+            row.prop(props, "interpolate_all_layers")
+            row.prop(props, "interpolate_selected_only")
+            row.prop(props, "flip")
+
+        return dict(
+            idname="builtin.interpolate",
+            label="Interpolate",
+            icon="ops.pose.breakdowner",
+            cursor='DEFAULT',
+            widget=None,
+            keymap=(),
+            draw_settings=draw_settings,
+        )
+
 
 class _defs_gpencil_sculpt:
 
@@ -2817,6 +2836,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
             None,
             _defs_gpencil_edit.transform_fill,
             None,
+            _defs_gpencil_edit.interpolate,
+            None,
             *_tools_annotate,
         ],
         'SCULPT_GPENCIL': [
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 7946117ba3b..c7aa293f06d 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1692,24 +1692,16 @@ class VIEW3D_PT_tools_grease_pencil_interpolate(Panel):
         settings = context.tool_settings.gpencil_interpolate
 
         col = layout.column(align=True)
-        col.label(text="Interpolate Strokes")
-        col.operator("gpencil.interpolate", text="Interpolate")
-        col.operator("gpencil.interpolate_sequence", text="Sequence")
-        col.operator("gpencil.interpolate_reverse", text="Remove Breakdowns")
+        # col.label(text="Interpolate Strokes")
+        # col.operator("gpencil.interpolate_sequence", text="Sequence")
+        # col.operator("gpencil.interpolate_reverse", text="Remove Breakdowns")
 
         col = layout.column(align=True)
-        col.label(text="Options:")
-        col.prop(settings, "interpolate_all_layers")
-
+        # col.label(text="Options:")
         gpd = context.gpencil_data
-        if gpd.use_stroke_edit_mode:
-            col.prop(settings, "interpolate_selected_only")
-            if settings.interpolate_selected_only:
-                col.operator("gpencil.interpolate_set", text="Set")
 
         col = layout.column(align=True)
         col.label(text="Sequence Options:")
-        col.prop(settings, "step")
         col.prop(settings, "type")
         if settings.type == 'CUSTOM':
             # TODO: Options for loading/saving curve presets?
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index 7d6a71f45bc..9cdc2737207 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -375,6 +375,10 @@ static void gpencil_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
         BKE_gpencil_stroke_uniform_subdivide(gpd, gps_from, gps_to->totpoints, true);
       }
 
+      if (tgpi->flag & GP_TOOLFLAG_INTERPOLATE_FLIP) {
+        BKE_gpencil_stroke_flip(gps_to);
+      }
+
       /* Create new stroke. */
       bGPDstroke *new_stroke = BKE_gpencil_stroke_duplicate(gps_from, true, true);
       new_stroke->flag |= GP_STROKE_TAG;
@@ -504,15 +508,12 @@ static void gpencil_interpolate_exit(bContext *C, wmOperator *op)
 /* Init new temporary interpolation data */
 static bool gpencil_interpolate_set_init_values(bContext *C, wmOperator *op, tGPDinterpolate *tgpi)
 {
-  ToolSettings *ts = CTX_data_tool_settings(C);
-
   /* set current scene and window */
   tgpi->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
   tgpi->scene = CTX_data_scene(C);
   tgpi->area = CTX_wm_area(C);
   tgpi->region = CTX_wm_region(C);
   tgpi->ob = CTX_data_active_object(C);
-  tgpi->flag = ts->gp_interpolate.flag;
 
   /* set current frame number */
   tgpi->cframe = tgpi->scene->r.cfra;
@@ -522,6 +523,13 @@ static bool gpencil_interpolate_set_init_values(bContext *C, wmOperator *op, tGP
 
   /* set interpolation weight */
   tgpi->shift = RNA_float_get(op->ptr, "shift");
+  SET_FLAG_FROM_TEST(tgpi->flag,
+                     RNA_boolean_get(op->ptr, "interpolate_all_layers"),
+                     GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS);
+  SET_FLAG_FROM_TEST(tgpi->flag,
+                     RNA_boolean_get(op->ptr, "interpolate_selected_only"),
+                     GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED);
+  SET_FLAG_FROM_TEST(tgpi->flag, RNA_boolean_get(op->ptr, "flip"), GP_TOOLFLAG_INTERPOLATE_FLIP);
 
   /* Untag strokes to be sure nothing is pending due any canceled process. */
   LISTBASE_FOREACH (bGPDlayer *, gpl, &tgpi->gpd->layers) {
@@ -739,6 +747,8 @@ static void gpencil_interpolate_cancel(bContext *C, wmOperator *op)
 
 void GPENCIL_OT_interpolate(wmOperatorType *ot)
 {
+  PropertyRNA *prop;
+
   /* identifiers */
   ot->name = "Grease Pencil Interpolation";
   ot->idname = "GPENCIL_OT_interpolate";
@@ -764,6 +774,27 @@ void GPENCIL_OT_interpolate(wmOperatorType *ot)
       "Bias factor for which frame has more influence on the interpolated strokes",
       -0.9f,
       0.9f);
+
+  RNA_def_boolean(ot->srna,
+                  "interpolate_all_layers",
+                  0,
+                  "All Layers",
+                  "Interpolate all layers, not only active");
+
+  RNA_def_boolean(ot->srna,
+                  "interpolate_selected_only",
+                  0,
+                  "Only Selected",
+                  "Interpolate only selected strokes");
+
+  RNA_def_boolean(ot->srna,
+                  "flip",
+                  0,
+                  "Flip",
+                  "Invert destination stroke to match start and end with source stroke");
+
+  prop = RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "");
+  RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
 }
 
 /* ****************** Interpolate Sequence *********************** */
@@ -982,10 +1013,10 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
   int cfra = CFRA;
 
   GP_Interpolate_Settings *ipo_settings = &ts->gp_interpolate;
-  eGP_Interpolate_SettingsFlag flag = ipo_settings->flag;
-  const int step = ipo_settings->step;
+  const int step = RNA_int_get(op->ptr, "step");
   const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
-  const bool only_selected = ((flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) != 0);
+  const bool all_layers = RNA_boolean_get(op->ptr, "interpolate_all_layers");
+  const bool only_selected = RNA_boolean_get(op->ptr, "interpolate_selected_only");
 
   /* Cannot interpolate if not between 2 frames. */
   bGPDframe *gpf_prv = gpencil_get_previous_keyframe(active_gpl, cfra);
@@ -1001,7 +1032,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
   /* loop all layer to check if need interpolation */
   LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
     /* all layers or only active */
-    if (((flag & GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS) == 0) && (gpl != active_gpl)) {
+    if ((!all_layers) && (gpl != active_gpl)) {
       continue;
     }
     /* only editable and visible layers are considered */
@@ -1141,6 +1172,28 @@ void GPENCIL_OT_interpolate_sequence(wmOperatorType *ot)
   ot->exec = gpencil_interpolate_seq_exec;
   ot->poll = gpencil_view3d_poll;
 
+  RNA_def_int(ot->srna,
+              "step",
+              1,
+              1,
+              MAXFRAME,
+              "Step",
+              "Number of frames between generated interpolated frames",
+              1,
+              MAXFRAME);
+
+  RNA_def_boolean(ot->srna,
+                  "interpolate_all_layers",
+                  0,
+                  "All Layers",
+                  "Interpolate all layers, not only active");
+
+  RNA_def_boolean(ot->srna,
+                  "interpolate_selected_only",
+                  0,
+                  "Only Selected",
+                  "Interpolate only selected strokes");
+
   /* flags */
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index f73f99eb4e7..6e07fce99ea 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1151,6 +1151,8 @@ typedef enum eGP_Interpolate_SettingsFlag {
   GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS = (1 << 0),
   /* apply interp

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list