[Bf-blender-cvs] [5727f7132ed] tracking_tools: MCE: Trying to add mask handle props into toolbar

Sebastian Koenig noreply at git.blender.org
Fri Jul 16 11:39:54 CEST 2021


Commit: 5727f7132ed0da605ca2ee9ba7e2b93b4dd3dc94
Author: Sebastian Koenig
Date:   Fri Jul 16 11:33:55 2021 +0200
Branches: tracking_tools
https://developer.blender.org/rB5727f7132ed0da605ca2ee9ba7e2b93b4dd3dc94

MCE: Trying to add mask handle props into toolbar

I tried implementing this https://developer.blender.org/P1923
To get the properties to do anything, I would need to change
add_vertex_slide to just add_vertex. add_vertex_slide is a macro, and
apparently the properties of MASK_OT_add_vertex do not have any
influence on the tool if it is set to use the macro.
But even then it only updates the handle type when activating the tool
(after switching to a different tool before). So some update thingy is
still missing.

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

M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	source/blender/editors/mask/mask_add.c

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

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 13869b2a0fe..acdb4ac7e92 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -2501,9 +2501,12 @@ class _defs_mask_tools:
     @ToolDef.from_fn
     def add_vertex_slide():
         def draw_settings(_context, layout, tool):
+            tool_settings = _context.tool_settings
+            props = tool.operator_properties("mask.add_vertex")
             row = layout.row()
             row.label(text="Mask Settings")
-            # props = tool.operator_properties("mask.add_vertex_slide")
+            row.prop(props, "type")
+
         return dict(
             idname="builtin.add_vertex_slide",
             label="Draw a Mask",
@@ -2517,7 +2520,6 @@ class _defs_mask_tools:
         def draw_settings(_context, layout, tool):
             row = layout.row()
             row.label(text="Feather Vertex")
-            # props = tool.operator_properties("mask.add_vertex_slide")
         return dict(
             idname="builtin.add_feather_vertex_slide",
             label="Add a Feather Vertex",
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index 880d27e1615..466bd7606cf 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -56,7 +56,8 @@ static void setup_vertex_point(Mask *mask,
                                const float u,
                                const float ctime,
                                const MaskSplinePoint *reference_point,
-                               const bool reference_adjacent)
+                               const bool reference_adjacent,
+                               int handle_type)
 {
   const MaskSplinePoint *reference_parent_point = NULL;
   BezTriple *bezt;
@@ -68,7 +69,7 @@ static void setup_vertex_point(Mask *mask,
   /* point coordinate */
   bezt = &new_point->bezt;
 
-  bezt->h1 = bezt->h2 = HD_ALIGN;
+  bezt->h1 = bezt->h2 = handle_type;
 
   if (reference_point) {
     if (reference_point->bezt.h1 == HD_VECT && reference_point->bezt.h2 == HD_VECT) {
@@ -133,14 +134,14 @@ static void setup_vertex_point(Mask *mask,
       }
 
       /* handle type */
-      char handle_type = 0;
+      char handle_type_referenced = 0;
       if (prev_point) {
-        handle_type = prev_point->bezt.h2;
+        handle_type_referenced = prev_point->bezt.h2;
       }
       if (next_point) {
-        handle_type = MAX2(next_point->bezt.h2, handle_type);
+        handle_type_referenced = MAX2(next_point->bezt.h2, handle_type_referenced);
       }
-      bezt->h1 = bezt->h2 = handle_type;
+      bezt->h1 = bezt->h2 = handle_type_referenced;
 
       /* parent */
       reference_parent_point = close_point;
@@ -241,7 +242,7 @@ static void mask_spline_add_point_at_index(MaskSpline *spline, int point_index)
   spline->tot_point++;
 }
 
-static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2])
+static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2], int handle_type)
 {
   MaskLayer *mask_layer;
   MaskSpline *spline;
@@ -275,7 +276,7 @@ static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2
 
     new_point = &spline->points[point_index + 1];
 
-    setup_vertex_point(mask, spline, new_point, co, u, ctime, NULL, true);
+    setup_vertex_point(mask, spline, new_point, co, u, ctime, NULL, true, handle_type);
 
     /* TODO: we could pass the spline! */
     BKE_mask_layer_shape_changed_add(mask_layer,
@@ -298,7 +299,7 @@ static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2
 static bool add_vertex_extrude(const bContext *C,
                                Mask *mask,
                                MaskLayer *mask_layer,
-                               const float co[2])
+                               const float co[2], int handle_type)
 {
   Scene *scene = CTX_data_scene(C);
   const float ctime = CFRA;
@@ -379,7 +380,7 @@ static bool add_vertex_extrude(const bContext *C,
 
   mask_layer->act_point = new_point;
 
-  setup_vertex_point(mask, spline, new_point, co, 0.5f, ctime, ref_point, false);
+  setup_vertex_point(mask, spline, new_point, co, 0.5f, ctime, ref_point, false, handle_type);
 
   if (mask_layer->splines_shapes.first) {
     point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);
@@ -395,7 +396,7 @@ static bool add_vertex_extrude(const bContext *C,
   return true;
 }
 
-static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *mask_layer, const float co[2])
+static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *mask_layer, const float co[2], int handle_type)
 {
   Scene *scene = CTX_data_scene(C);
   const float ctime = CFRA;
@@ -418,7 +419,7 @@ static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *mask_layer,
 
   mask_layer->act_point = new_point;
 
-  setup_vertex_point(mask, spline, new_point, co, 0.5f, ctime, ref_point, false);
+  setup_vertex_point(mask, spline, new_point, co, 0.5f, ctime, ref_point, false, handle_type);
 
   {
     int point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);
@@ -510,6 +511,7 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
 {
   MaskViewLockState lock_state;
   ED_mask_view_lock_state_store(C, &lock_state);
+  const int handle_type = RNA_enum_get(op->ptr, "type");
 
   Mask *mask = CTX_data_edit_mask(C);
   if (mask == NULL) {
@@ -536,15 +538,15 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
       return cyclic_result;
     }
 
-    if (!add_vertex_subdivide(C, mask, co)) {
-      if (!add_vertex_extrude(C, mask, mask_layer, co)) {
+    if (!add_vertex_subdivide(C, mask, co, handle_type)) {
+      if (!add_vertex_extrude(C, mask, mask_layer, co, handle_type)) {
         return OPERATOR_CANCELLED;
       }
     }
   }
   else {
-    if (!add_vertex_subdivide(C, mask, co)) {
-      if (!add_vertex_new(C, mask, mask_layer, co)) {
+    if (!add_vertex_subdivide(C, mask, co, handle_type)) {
+      if (!add_vertex_new(C, mask, mask_layer, co, handle_type)) {
         return OPERATOR_CANCELLED;
       }
     }
@@ -568,11 +570,20 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 
   RNA_float_set_array(op->ptr, "location", co);
 
-  return add_vertex_exec(C, op);
+return add_vertex_exec(C, op);
 }
 
 void MASK_OT_add_vertex(wmOperatorType *ot)
 {
+ 	static const EnumPropertyItem editcurve_handle_type_items[] = {
+	    {HD_AUTO, "AUTO", 0, "Auto", ""},
+	    {HD_VECT, "VECTOR", 0, "Vector", ""},
+	    {HD_ALIGN, "ALIGNED", 0, "Aligned Single", ""},
+	    {HD_ALIGN_DOUBLESIDE, "ALIGNED_DOUBLESIDE", 0, "Aligned", ""},
+	    {HD_FREE, "FREE", 0, "Free", ""},
+	    {0, NULL, 0, NULL, NULL},
+	};
+
   /* identifiers */
   ot->name = "Add Vertex";
   ot->description = "Add vertex to active spline";
@@ -597,6 +608,8 @@ void MASK_OT_add_vertex(wmOperatorType *ot)
                        "Location of vertex in normalized space",
                        -1.0f,
                        1.0f);
+
+  ot->prop = RNA_def_enum(ot->srna, "type", editcurve_handle_type_items, 1, "Type", "Spline type");
 }
 
 /******************** add feather vertex *********************/



More information about the Bf-blender-cvs mailing list