[Bf-blender-cvs] [701f2dfd5bc] master: Revert "Revert "Revert "Transform: interactive mode for editing a 'Snap Source'"""

Germano Cavalcante noreply at git.blender.org
Thu Nov 18 17:55:33 CET 2021


Commit: 701f2dfd5bc61c0f37603880fa21abfe8b1d9620
Author: Germano Cavalcante
Date:   Thu Nov 18 13:55:24 2021 -0300
Branches: master
https://developer.blender.org/rB701f2dfd5bc61c0f37603880fa21abfe8b1d9620

Revert "Revert "Revert "Transform: interactive mode for editing a 'Snap Source'"""

This reverts commit 25fa6c74b977ac983a34b9adf5ab2f20fe2f4932.

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
M	source/blender/editors/space_view3d/view3d_cursor_snap.c
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_input.c
M	source/blender/editors/transform/transform_snap.c
M	source/blender/editors/transform/transform_snap.h
M	source/blender/editors/transform/transform_snap_object.c
M	source/blender/gpu/GPU_immediate_util.h
M	source/blender/gpu/intern/gpu_immediate_util.c

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index a7e33c83403..dbc93cb6caa 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -5606,7 +5606,6 @@ def km_transform_modal_map(_params):
         ("AUTOCONSTRAINPLANE", {"type": 'MIDDLEMOUSE', "value": 'ANY', "shift": True}, None),
         ("PRECISION", {"type": 'LEFT_SHIFT', "value": 'ANY', "any": True}, None),
         ("PRECISION", {"type": 'RIGHT_SHIFT', "value": 'ANY', "any": True}, None),
-        ("EDIT_SNAP_SOURCE", {"type": 'B', "value": 'PRESS'}, None),
     ])
 
     return keymap
diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index dd4e0afc869..37cd554e872 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -3997,7 +3997,6 @@ def km_transform_modal_map(_params):
         ("AUTOCONSTRAINPLANE", {"type": 'MIDDLEMOUSE', "value": 'ANY', "shift": True}, None),
         ("PRECISION", {"type": 'LEFT_SHIFT', "value": 'ANY', "any": True}, None),
         ("PRECISION", {"type": 'RIGHT_SHIFT', "value": 'ANY', "any": True}, None),
-        ("EDIT_SNAP_SOURCE", {"type": 'B', "value": 'PRESS'}, None),
     ])
 
     return keymap
diff --git a/source/blender/editors/space_view3d/view3d_cursor_snap.c b/source/blender/editors/space_view3d/view3d_cursor_snap.c
index 961b0bd6862..ac80a70011a 100644
--- a/source/blender/editors/space_view3d/view3d_cursor_snap.c
+++ b/source/blender/editors/space_view3d/view3d_cursor_snap.c
@@ -414,13 +414,37 @@ void ED_view3d_cursor_snap_draw_util(RegionView3D *rv3d,
   }
 
   if (loc_prev) {
+    /* Draw an "X" indicating where the previous snap point is.
+     * This is useful for indicating perpendicular snap. */
+
+    /* v1, v2, v3 and v4 indicate the coordinates of the ends of the "X". */
+    float vx[3], vy[3], v1[3], v2[3], v3[3], v4[4];
+
     /* Multiply by 0.75f so that the final size of the "X" is close to that of
      * the circle.
      * (A closer value is 0.7071f, but we don't need to be exact here). */
     float x_size = 0.75f * radius * ED_view3d_pixel_size(rv3d, loc_prev);
 
+    mul_v3_v3fl(vx, view_inv[0], x_size);
+    mul_v3_v3fl(vy, view_inv[1], x_size);
+
+    add_v3_v3v3(v1, vx, vy);
+    sub_v3_v3v3(v2, vx, vy);
+    negate_v3_v3(v3, v1);
+    negate_v3_v3(v4, v2);
+
+    add_v3_v3(v1, loc_prev);
+    add_v3_v3(v2, loc_prev);
+    add_v3_v3(v3, loc_prev);
+    add_v3_v3(v4, loc_prev);
+
     immUniformColor4ubv(color_line);
-    imm_drawX(loc_prev, x_size, view_inv, pos);
+    immBegin(GPU_PRIM_LINES, 4);
+    immVertex3fv(pos, v3);
+    immVertex3fv(pos, v1);
+    immVertex3fv(pos, v4);
+    immVertex3fv(pos, v2);
+    immEnd();
 
     if (loc_curr && (snap_elem_type & SCE_SNAP_MODE_EDGE_PERPENDICULAR)) {
       /* Dashed line. */
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index c376c718245..ae4c3f02c46 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -578,21 +578,6 @@ static void viewRedrawPost(bContext *C, TransInfo *t)
 static bool transform_modal_item_poll(const wmOperator *op, int value)
 {
   const TransInfo *t = op->customdata;
-  if (t->modifiers & MOD_EDIT_SNAP_SOURCE) {
-    if (value == TFM_MODAL_EDIT_SNAP_SOURCE) {
-      return true;
-    }
-    else if (!ELEM(value,
-                   TFM_MODAL_CANCEL,
-                   TFM_MODAL_CONFIRM,
-                   TFM_MODAL_SNAP_INV_ON,
-                   TFM_MODAL_SNAP_INV_OFF,
-                   TFM_MODAL_ADD_SNAP,
-                   TFM_MODAL_REMOVE_SNAP)) {
-      return false;
-    }
-  }
-
   switch (value) {
     case TFM_MODAL_CANCEL: {
       /* TODO: Canceling with LMB is not possible when the operator is activated
@@ -608,13 +593,6 @@ static bool transform_modal_item_poll(const wmOperator *op, int value)
       }
       break;
     }
-    case TFM_MODAL_SNAP_INV_ON:
-    case TFM_MODAL_SNAP_INV_OFF: {
-      if (t->modifiers & MOD_SNAP_TEMP) {
-        return false;
-      }
-      break;
-    }
     case TFM_MODAL_ADD_SNAP:
     case TFM_MODAL_REMOVE_SNAP: {
       if (t->spacetype != SPACE_VIEW3D) {
@@ -686,19 +664,6 @@ static bool transform_modal_item_poll(const wmOperator *op, int value)
       }
       break;
     }
-    case TFM_MODAL_EDIT_SNAP_SOURCE: {
-      if (t->spacetype != SPACE_VIEW3D) {
-        return false;
-      }
-      if (t->flag & T_RELEASE_CONFIRM) {
-        return false;
-      }
-      if (!ELEM(t->mode, TFM_TRANSLATION, TFM_ROTATION, TFM_RESIZE)) {
-        /* More modes can be added over time if this feature proves useful for them. */
-        return false;
-      }
-      break;
-    }
   }
   return true;
 }
@@ -749,7 +714,6 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
       {TFM_MODAL_AUTOCONSTRAINT, "AUTOCONSTRAIN", 0, "Automatic Constraint", ""},
       {TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint Plane", ""},
       {TFM_MODAL_PRECISION, "PRECISION", 0, "Precision Mode", ""},
-      {TFM_MODAL_EDIT_SNAP_SOURCE, "EDIT_SNAP_SOURCE", 0, "Snap Source Toggle", ""},
       {0, NULL, 0, NULL, NULL},
   };
 
@@ -927,12 +891,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
         handled = true;
         break;
       case TFM_MODAL_CONFIRM:
-        if (t->modifiers & MOD_EDIT_SNAP_SOURCE) {
-          tranform_snap_source_mod_confirm(t);
-        }
-        else {
-          t->state = TRANS_CONFIRM;
-        }
+        t->state = TRANS_CONFIRM;
         handled = true;
         break;
       case TFM_MODAL_TRANSLATE:
@@ -1197,9 +1156,6 @@ int transformEvent(TransInfo *t, const wmEvent *event)
           t->redraw |= TREDRAW_HARD;
         }
         break;
-      case TFM_MODAL_EDIT_SNAP_SOURCE:
-        tranform_snap_source_mod_toggle(t);
-        break;
       /* Those two are only handled in transform's own handler, see T44634! */
       case TFM_MODAL_EDGESLIDE_UP:
       case TFM_MODAL_EDGESLIDE_DOWN:
@@ -1576,7 +1532,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 
   if (t->flag & T_MODAL) {
     /* do we check for parameter? */
-    if (transformModeUseSnap(t) && !(t->modifiers & MOD_SNAP_TEMP)) {
+    if (transformModeUseSnap(t)) {
       if (!(t->modifiers & MOD_SNAP) != !(ts->snap_flag & SCE_SNAP)) {
         if (t->modifiers & MOD_SNAP) {
           ts->snap_flag |= SCE_SNAP;
@@ -1964,17 +1920,14 @@ void transformApply(bContext *C, TransInfo *t)
 
   if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT))) {
     selectConstraint(t);
-    if (t->modifiers & MOD_EDIT_SNAP_SOURCE) {
-      tranform_snap_source_mod_update(t);
-    }
-    else if (t->transform) {
+    if (t->transform) {
       t->transform(t, t->mval); /* calls recalcData() */
+      viewRedrawForce(C, t);
     }
+    t->redraw = TREDRAW_NOTHING;
   }
-
-  if (t->redraw & (TREDRAW_HARD | TREDRAW_SOFT)) {
+  else if (t->redraw & TREDRAW_SOFT) {
     viewRedrawForce(C, t);
-    t->redraw = TREDRAW_NOTHING;
   }
 
   /* If auto confirm is on, break after one pass */
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 6219bdba6b7..d78cd13f8b8 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -163,9 +163,7 @@ typedef enum {
   MOD_PRECISION = 1 << 1,
   MOD_SNAP = 1 << 2,
   MOD_SNAP_INVERT = 1 << 3,
-  MOD_SNAP_TEMP = 1 << 4,
-  MOD_CONSTRAINT_SELECT_PLANE = 1 << 5,
-  MOD_EDIT_SNAP_SOURCE = 1 << 6,
+  MOD_CONSTRAINT_SELECT_PLANE = 1 << 4,
 } eTModifier;
 
 /** #TransSnap.status */
@@ -296,8 +294,6 @@ enum {
   TFM_MODAL_AUTOCONSTRAINTPLANE = 29,
 
   TFM_MODAL_PRECISION = 30,
-
-  TFM_MODAL_EDIT_SNAP_SOURCE = 31,
 };
 
 /** \} */
@@ -765,7 +761,6 @@ void applyMouseInput(struct TransInfo *t,
                      struct MouseInput *mi,
                      const int mval[2],
                      float output[3]);
-void transform_input_reset(MouseInput *mi, const int mval[2]);
 
 void setCustomPoints(TransInfo *t, MouseInput *mi, const int start[2], const int end[2]);
 void setCustomPointsFromDirection(TransInfo *t, MouseInput *mi, const float dir[2]);
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index d9a29b8d6b7..0b46d0b9a13 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -418,10 +418,6 @@ void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *t, float val
 
 void applyMouseInput(TransInfo *t, MouseInput *mi, const int mval[2], float output[3])
 {
-  if (t->modifiers & MOD_EDIT_SNAP_SOURCE) {
-    return;
-  }
-
   double mval_db[2];
 
   if (mi->use_virtual_mval) {
@@ -459,15 +455,4 @@ void applyMouseInput(TransInfo *t, MouseInput *mi, const int mval[2], float outp
   }
 }
 
-void transform_input_reset(MouseInput *mi, const int mval[2])
-{
-  copy_v2_v2_int(mi->imval, mval);
-  if (ELEM(mi->apply, InputAngle, InputAngleSpring)) {
-    struct InputAngle_Data *data = mi->data;
-    data->mval_prev[0] = mi->imval[0];
-    data->mval_prev[1] = mi->imval[1];
-    data->angle = 0.0f;
-  }
-}
-
 /** \} */
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index f52061f8910..71f26ef0594 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -136,10 +136,6 @@ bool validSnap(const TransInfo *t)
 
 bool activeSnap(const TransInfo *t)
 {
-  if (t->modifiers & MOD_SNAP_TEMP) {
-    return true;
-  }
-
   return ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP) ||
          ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT);
 }
@@ -182,7 +178,7 @@ bool transformModeUseSnap(const 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list