[Bf-blender-cvs] [e4feadde903] tracking_proportional_editing_v2: Tracking: Implement proportional editing

Sergey Sharybin noreply at git.blender.org
Thu Jan 21 12:41:23 CET 2021


Commit: e4feadde90375222858989a600fbc40a4627150b
Author: Sergey Sharybin
Date:   Thu Dec 31 15:13:50 2020 +0100
Branches: tracking_proportional_editing_v2
https://developer.blender.org/rBe4feadde90375222858989a600fbc40a4627150b

Tracking: Implement proportional editing

Disclaimer: This is a work-in-progress, to find best and optimal
workflow, user interface, defaults, and so on.

To test the new functionality:
1. Enable proportional editing.
2. Grab marker.

The expected behavior is that in this configuration the transform
will be smoothly propagated up to keyframe or up to end of tracked
segment (whatever happens sooner).

Allows to address issue of sudden jump in track when correcting
sliding marker.

Differential Revision: https://developer.blender.org/D2771

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/space_clip.py
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_constraints.c
M	source/blender/editors/transform/transform_convert.c
M	source/blender/editors/transform/transform_convert_tracking.c
M	source/blender/editors/transform/transform_generics.c
M	source/blender/editors/transform/transform_mode.c
M	source/blender/editors/transform/transform_mode_translate.c

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 287322e9a29..86c9efb5851 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -2897,6 +2897,8 @@ def km_clip_editor(params):
         ("clip.copy_tracks", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
         ("clip.paste_tracks", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
         *_template_items_context_menu("CLIP_MT_tracking_context_menu", params.context_menu_event),
+        *_template_items_proportional_editing(
+            params, connected=False, toggle_data_path='tool_settings.use_proportional_edit'),
     ])
 
     if not params.legacy:
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index 96920af1c7e..3e40eab519d 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -125,6 +125,21 @@ class CLIP_PT_clip_display(Panel):
             col.prop(clip, "display_aspect", text="Display Aspect Ratio")
 
 
+class CLIP_PT_proportional_edit(Panel):
+    bl_space_type = 'CLIP_EDITOR'
+    bl_region_type = 'HEADER'
+    bl_label = "Proportional Editing"
+    bl_ui_units_x = 8
+
+    def draw(self, context):
+        layout = self.layout
+        tool_settings = context.tool_settings
+        col = layout.column()
+        col.active = tool_settings.use_proportional_edit
+
+        col.prop(tool_settings, "proportional_edit_falloff", expand=True)
+
+
 class CLIP_HT_header(Header):
     bl_space_type = 'CLIP_EDITOR'
 
@@ -181,6 +196,7 @@ class CLIP_HT_header(Header):
 
             if sc.view == 'CLIP':
                 r = active_object.reconstruction
+                tool_settings = context.tool_settings
 
                 if r.is_valid and sc.view == 'CLIP':
                     layout.label(text="Solve error: %.2f px" %
@@ -188,6 +204,25 @@ class CLIP_HT_header(Header):
 
                 row = layout.row()
                 row.prop(sc, "pivot_point", text="", icon_only=True)
+
+                # Proportional Editing
+                row = layout.row(align=True)
+                row.prop(
+                    tool_settings,
+                    "use_proportional_edit",
+                    icon_only=True,
+                    icon='PROP_CON'
+                )
+                sub = row.row(align=True)
+                sub.active = tool_settings.use_proportional_edit
+                sub.prop_with_popover(
+                    tool_settings,
+                    "proportional_edit_falloff",
+                    text="",
+                    icon_only=True,
+                    panel="CLIP_PT_proportional_edit",
+                )
+
                 row = layout.row(align=True)
                 icon = 'LOCKED' if sc.lock_selection else 'UNLOCKED'
                 row.prop(sc, "lock_selection", icon=icon, text="")
@@ -1869,6 +1904,7 @@ classes = (
     CLIP_PT_tools_scenesetup,
     CLIP_PT_annotation,
     CLIP_PT_tools_grease_pencil_draw,
+    CLIP_PT_proportional_edit,
     CLIP_MT_view_zoom,
     CLIP_MT_view,
     CLIP_MT_clip,
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 2a7c247ff2b..1afd97545d3 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -984,7 +984,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
         break;
       case TFM_MODAL_PROPSIZE:
         /* MOUSEPAN usage... */
-        if (t->flag & T_PROP_EDIT) {
+        if ((t->flag & T_PROP_EDIT) && ((t->flag & T_PROP_FIXED_DISTANCE) == 0)) {
           float fac = 1.0f + 0.005f * (event->y - event->prevy);
           t->prop_size *= fac;
           if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO) {
@@ -1000,7 +1000,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
         }
         break;
       case TFM_MODAL_PROPSIZE_UP:
-        if (t->flag & T_PROP_EDIT) {
+        if ((t->flag & T_PROP_EDIT) && ((t->flag & T_PROP_FIXED_DISTANCE) == 0)) {
           t->prop_size *= (t->modifiers & MOD_PRECISION) ? 1.01f : 1.1f;
           if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO) {
             t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->clip_end);
@@ -1014,7 +1014,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
         }
         break;
       case TFM_MODAL_PROPSIZE_DOWN:
-        if (t->flag & T_PROP_EDIT) {
+        if ((t->flag & T_PROP_EDIT) && ((t->flag & T_PROP_FIXED_DISTANCE) == 0)) {
           t->prop_size /= (t->modifiers & MOD_PRECISION) ? 1.01f : 1.1f;
           t->prop_size = max_ff(t->prop_size, T_PROP_SIZE_MIN);
           calculatePropRatio(t);
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 91bf2bf8aac..8c8f8e3413d 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -455,45 +455,46 @@ enum {
   T_PROP_EDIT = 1 << 10,
   T_PROP_CONNECTED = 1 << 11,
   T_PROP_PROJECTED = 1 << 12,
-  T_PROP_EDIT_ALL = T_PROP_EDIT | T_PROP_CONNECTED | T_PROP_PROJECTED,
+  T_PROP_FIXED_DISTANCE = (1 << 13),
+  T_PROP_EDIT_ALL = T_PROP_EDIT | T_PROP_CONNECTED | T_PROP_PROJECTED | T_PROP_FIXED_DISTANCE,
 
-  T_V3D_ALIGN = 1 << 13,
+  T_V3D_ALIGN = 1 << 14,
   /** For 2D views such as UV or f-curve. */
-  T_2D_EDIT = 1 << 14,
-  T_CLIP_UV = 1 << 15,
+  T_2D_EDIT = 1 << 15,
+  T_CLIP_UV = 1 << 16,
 
   /** Auto-IK is on. */
-  T_AUTOIK = 1 << 16,
+  T_AUTOIK = 1 << 17,
 
   /** Don't use mirror even if the data-block option is set. */
-  T_NO_MIRROR = 1 << 17,
+  T_NO_MIRROR = 1 << 18,
 
   /** To indicate that the value set in the `value` parameter is the final
    * value of the transformation, modified only by the constrain. */
-  T_INPUT_IS_VALUES_FINAL = 1 << 18,
+  T_INPUT_IS_VALUES_FINAL = 1 << 19,
 
   /** To specify if we save back settings at the end. */
-  T_MODAL = 1 << 19,
+  T_MODAL = 1 << 20,
 
   /** No re-topology (projection). */
-  T_NO_PROJECT = 1 << 20,
+  T_NO_PROJECT = 1 << 21,
 
-  T_RELEASE_CONFIRM = 1 << 21,
+  T_RELEASE_CONFIRM = 1 << 22,
 
   /** Alternative transformation. used to add offset to tracking markers. */
-  T_ALT_TRANSFORM = 1 << 22,
+  T_ALT_TRANSFORM = 1 << 23,
 
   /** #TransInfo.center has been set, don't change it. */
-  T_OVERRIDE_CENTER = 1 << 23,
+  T_OVERRIDE_CENTER = 1 << 24,
 
-  T_MODAL_CURSOR_SET = 1 << 24,
+  T_MODAL_CURSOR_SET = 1 << 25,
 
-  T_CLNOR_REBUILD = 1 << 25,
+  T_CLNOR_REBUILD = 1 << 26,
 
   /** Merges unselected into selected after transforming (runs after transforming). */
-  T_AUTOMERGE = 1 << 26,
+  T_AUTOMERGE = 1 << 27,
   /** Runs auto-merge & splits. */
-  T_AUTOSPLIT = 1 << 27,
+  T_AUTOSPLIT = 1 << 28,
 };
 
 /** #TransInfo.modifiers */
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 5abe92b385a..f5d67425728 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -824,6 +824,9 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
     else if (t->spacetype == SPACE_IMAGE) {
       GPU_matrix_scale_2f(1.0f / t->aspect[0], 1.0f / t->aspect[1]);
     }
+    else if (t->spacetype == SPACE_CLIP) {
+      GPU_matrix_scale_2f(1.0f / t->aspect[0], 1.0f / t->aspect[1]);
+    }
     else if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_ACTION)) {
       /* only scale y */
       rcti *mask = &t->region->v2d.mask;
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index fb365da6b43..e606e737a80 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -1258,7 +1258,6 @@ void createTransData(bContext *C, TransInfo *t)
       break;
     case TC_TRACKING_DATA:
       createTransTrackingData(C, t);
-      init_prop_edit = false;
       break;
     case TC_NONE:
     default:
@@ -1295,6 +1294,9 @@ void createTransData(bContext *C, TransInfo *t)
     else if (convert_type == TC_CURVE_VERTS && t->obedit_type == OB_CURVE) {
       set_prop_dist(t, false);
     }
+    else if (convert_type == TC_TRACKING_DATA) {
+      set_prop_dist(t, false);
+    }
     else {
       set_prop_dist(t, true);
     }
diff --git a/source/blender/editors/transform/transform_convert_tracking.c b/source/blender/editors/transform/transform_convert_tracking.c
index be8c2aa5ae3..30a341d5e16 100644
--- a/source/blender/editors/transform/transform_convert_tracking.c
+++ b/source/blender/editors/transform/transform_convert_tracking.c
@@ -95,11 +95,13 @@ typedef struct TransformInitContext {
 static void markerToTransDataInit(TransformInitContext *init_context,
                                   MovieTrackingTrack *track,
                                   MovieTrackingMarker *marker,
+                                  const int framenr,
                                   int area,
                                   float loc[2],
                                   const float rel[2],
                                   const float off[2],
-                                  const float aspect[2])
+                                  const float aspect[2],
+                                  float distance)
 {
   TransData *td = init_context->current.td;
   TransData2D *td2d = init_context->current.td2d;
@@ -166,8 +168,11 @@ static void markerToTransDataInit(TransformInitContext *init_context,
   td->ext = NULL;
   td->val = NULL;
 
-  td->flag |= TD_SELECTED;
-  td->dist = 0.0;
+  if (marker->framenr == framenr) {
+    td->flag |= TD_SELECTED;
+    marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED);
+  }
+  td->dist = distance;
 
   unit_m3(td->mtx);
   unit_m3(td->smtx);
@@ -177,25 +182,35 @@ static void markerToTransDataInit(TransformInitContext *init_context,
   init_context->current.tdt++;
 }
 
-static void trackToTransData(TransformInitContext *init_context,
-          

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list