[Bf-blender-cvs] [3e146e3a71e] transform-snap-base: Enable modes according to the number of times the button is pressed
Germano Cavalcante
noreply at git.blender.org
Tue Nov 17 14:39:38 CET 2020
Commit: 3e146e3a71ece5570d96bbc5fcd384a6b29caa81
Author: Germano Cavalcante
Date: Mon Nov 9 18:11:47 2020 -0300
Branches: transform-snap-base
https://developer.blender.org/rB3e146e3a71ece5570d96bbc5fcd384a6b29caa81
Enable modes according to the number of times the button is pressed
===================================================================
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/include/ED_transform_snap_object_context.h
M source/blender/editors/transform/transform.c
M source/blender/editors/transform/transform.h
M source/blender/editors/transform/transform_mode_edge_slide.c
M source/blender/editors/transform/transform_mode_resize.c
M source/blender/editors/transform/transform_mode_rotate.c
M source/blender/editors/transform/transform_mode_translate.c
M source/blender/editors/transform/transform_mode_vert_slide.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
===================================================================
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index f8090625bf2..902a20f5327 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -5039,7 +5039,7 @@ def km_transform_modal_map(_params):
("INSERTOFS_TOGGLE_DIR", {"type": 'T', "value": 'PRESS'}, None),
("AUTOCONSTRAIN", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
("AUTOCONSTRAINPLANE", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None),
- ("EDIT_SNAPWITH", {"type": 'B', "value": 'PRESS', "repeat": True}, None),
+ ("EDIT_SNAPWITH", {"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 337ee0b4fef..1c91d9ef6ed 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -3944,7 +3944,7 @@ def km_transform_modal_map(_params):
("INSERTOFS_TOGGLE_DIR", {"type": 'T', "value": 'PRESS'}, None),
("AUTOCONSTRAIN", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
("AUTOCONSTRAINPLANE", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None),
- ("EDIT_SNAPWITH", {"type": 'B', "value": 'PRESS', "repeat": True}, None),
+ ("EDIT_SNAPWITH", {"type": 'B', "value": 'PRESS'}, None),
])
return keymap
diff --git a/source/blender/editors/include/ED_transform_snap_object_context.h b/source/blender/editors/include/ED_transform_snap_object_context.h
index ebaa32941f2..fa8d61bf7a9 100644
--- a/source/blender/editors/include/ED_transform_snap_object_context.h
+++ b/source/blender/editors/include/ED_transform_snap_object_context.h
@@ -44,6 +44,7 @@ typedef enum eSnapSelect {
SNAP_ALL = 0,
SNAP_NOT_SELECTED = 1,
SNAP_NOT_ACTIVE = 2,
+ SNAP_SELECTED_ONLY = 3,
} eSnapSelect;
/** used for storing multiple hits */
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 4419cd6fa9f..452a01a8f23 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -640,9 +640,6 @@ static bool transform_modal_item_poll(const wmOperator *op, int value)
if (t->spacetype != SPACE_VIEW3D) {
return false;
}
- if (!(t->tsnap.mode & ~(SCE_SNAP_MODE_GRID | SCE_SNAP_MODE_INCREMENT))) {
- return false;
- }
break;
}
}
@@ -822,7 +819,9 @@ int transformEvent(TransInfo *t, const wmEvent *event)
t->state = TRANS_RUNNING;
}
- applyMouseInput(t, &t->mouse, t->mval, t->values);
+ if (!(t->modifiers & (MOD_EDIT_BASEPOINT_IN_OBJECT | MOD_EDIT_BASEPOINT_IN_SCENE))) {
+ applyMouseInput(t, &t->mouse, t->mval, t->values);
+ }
/* Snapping mouse move events. */
t->redraw |= handleSnapping(t, event);
@@ -837,7 +836,12 @@ int transformEvent(TransInfo *t, const wmEvent *event)
handled = true;
break;
case TFM_MODAL_CONFIRM:
- t->state = TRANS_CONFIRM;
+ if (t->modifiers & (MOD_EDIT_BASEPOINT_IN_OBJECT | MOD_EDIT_BASEPOINT_IN_SCENE)) {
+ tranform_snap_editbasepoint_confirm(t);
+ }
+ else {
+ t->state = TRANS_CONFIRM;
+ }
handled = true;
break;
case TFM_MODAL_TRANSLATE:
@@ -1119,7 +1123,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
}
break;
case TFM_MODAL_EDIT_SNAPWITH:
- tranform_snap_snapwith_init(t);
+ tranform_snap_editbasepoint_set_mode(t);
break;
/* Those two are only handled in transform's own handler, see T44634! */
case TFM_MODAL_EDGESLIDE_UP:
@@ -1219,15 +1223,9 @@ int transformEvent(TransInfo *t, const wmEvent *event)
default: {
/* Disable modifiers. */
int modifiers = t->modifiers;
- modifiers &= ~(MOD_CONSTRAINT_SELECT | MOD_CONSTRAINT_PLANE | MOD_EDIT_SNAPWITH);
+ modifiers &= ~(MOD_CONSTRAINT_SELECT | MOD_CONSTRAINT_PLANE);
if (modifiers != t->modifiers) {
- if (t->modifiers & (MOD_CONSTRAINT_SELECT | MOD_CONSTRAINT_PLANE)) {
- postSelectConstraint(t);
- }
- else {
- BLI_assert(t->modifiers & MOD_EDIT_SNAPWITH);
- tranform_snap_snapwith_end(t);
- }
+ postSelectConstraint(t);
t->modifiers = modifiers;
t->redraw |= TREDRAW_HARD;
handled = true;
@@ -1536,6 +1534,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
}
+#ifdef USE_SAVE_SCE_SNAP
if (t->flag & T_MODAL) {
/* do we check for parameter? */
if (transformModeUseSnap(t)) {
@@ -1549,7 +1548,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
WM_msg_publish_rna_prop(t->mbus, &t->scene->id, ts, ToolSettings, use_snap);
}
}
- }
+#endif
if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
RNA_property_boolean_set(op->ptr, prop, use_prop_edit);
@@ -1929,8 +1928,8 @@ 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_SNAPWITH) {
- tranform_snap_snapwith_update(t);
+ if (t->modifiers & (MOD_EDIT_BASEPOINT_IN_OBJECT | MOD_EDIT_BASEPOINT_IN_SCENE)) {
+ tranform_snap_editbasepoint_update(t);
}
else if (t->transform) {
t->transform(t, t->mval); /* calls recalcData() */
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 97541add558..6f0aa7823e4 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -36,6 +36,11 @@
#include "transform_data.h"
+/* use node center for transform instead of upper-left corner.
+ * disabled since it makes absolute snapping not work so nicely
+ */
+// #define USE_NODE_CENTER
+
/* -------------------------------------------------------------------- */
/** \name Types/
* \{ */
@@ -60,6 +65,10 @@ struct wmKeyConfig;
struct wmKeyMap;
struct wmTimer;
+/* -------------------------------------------------------------------- */
+/** \name Enums
+ * \{ */
+
/** #TransInfo.redraw */
typedef enum {
TREDRAW_NOTHING = 0,
@@ -67,6 +76,130 @@ typedef enum {
TREDRAW_SOFT = 2,
} eRedrawFlag;
+/** #TransInfo.state */
+typedef enum {
+ TRANS_STARTING = 0,
+ TRANS_RUNNING = 1,
+ TRANS_CONFIRM = 2,
+ TRANS_CANCEL = 3,
+} eTransState;
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Flags
+ * \{ */
+
+/** #TransInfo.flag */
+typedef enum {
+ T_OBJECT = 1 << 0,
+ /** \note We could remove 'T_EDIT' and use 'obedit_type', for now ensure they're in sync. */
+ T_EDIT = 1 << 1,
+ T_POSE = 1 << 2,
+ T_TEXTURE = 1 << 3,
+ /** Transforming the 3d view. */
+ T_CAMERA = 1 << 4,
+ /** Transforming the 3D cursor. */
+ T_CURSOR = 1 << 5,
+ /** Transform points, having no rotation/scale. */
+ T_POINTS = 1 << 6,
+ /** restrictions flags */
+ T_NO_CONSTRAINT = 1 << 7,
+ T_NULL_ONE = 1 << 8,
+ T_NO_ZERO = 1 << 9,
+ T_ALL_RESTRICTIONS = T_NO_CONSTRAINT | T_NULL_ONE | T_NO_ZERO,
+
+ 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_V3D_ALIGN = 1 << 13,
+ /** For 2D views such as UV or f-curve. */
+ T_2D_EDIT = 1 << 14,
+ T_CLIP_UV = 1 << 15,
+
+ /** Auto-IK is on. */
+ T_AUTOIK = 1 << 16,
+
+ /** Don't use mirror even if the data-block option is set. */
+ T_NO_MIRROR = 1 << 17,
+
+ /** 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,
+
+ /** To specify if we save back settings at the end. */
+ T_MODAL = 1 << 19,
+
+ /** No re-topology (projection). */
+ T_NO_PROJECT = 1 << 20,
+
+ T_RELEASE_CONFIRM = 1 << 21,
+
+ /** Alternative transformation. used to add offset to tracking markers. */
+ T_ALT_TRANSFORM = 1 << 22,
+
+ /** #TransInfo.center has been set, don't change it. */
+ T_OVERRIDE_CENTER = 1 << 23,
+
+ T_MODAL_CURSOR_SET = 1 << 24,
+
+ T_CLNOR_REBUILD = 1 << 25,
+
+ /** Merges unselected into selected after transforming (runs after transforming). */
+ T_AUTOMERGE = 1 << 26,
+ /** Runs auto-merge & splits. */
+ T_AUTOSPLIT = 1 << 27,
+} eTransFlag;
+
+/** #TransInfo.modifiers */
+typedef enum {
+ MOD_CONSTRAINT_SELECT = 1 << 0,
+ MOD_CONSTRAINT_PLANE = 1 << 1,
+ MOD_PRECISION = 1 << 2,
+ MOD_SNAP = 1 << 3,
+ MOD_SNAP_INVERT = 1 << 4,
+ MOD_FORCE_SNAP = MOD_SNAP | (1 << 5),
+ MOD_EDIT_BASEPOINT_IN_OBJECT = 1 << 6,
+ MOD_EDIT_BASEPOINT_IN_SCENE = 1 << 7,
+} eTransModifiers;
+
+/** #TransInfo.helpline */
+typedef enum {
+ HLP_NONE = 0,
+ HLP_SPRING = 1,
+ HLP_ANGLE = 2,
+ HLP_HARROW = 3,
+ HLP_VARROW = 4,
+ HLP_CARROW = 5,
+ HLP_TRACKBALL = 6,
+} eTrasHelpLine;
+
+/** #TransCon.mode, #TransInfo.con.mode */
+typedef enum {
+ /** When set constraints are in use. */
+ CON_APPLY = 1 << 0,
+ /** These are only used for modal execution. */
+ CON_AXIS0 = 1 << 1,
+ CON_AXIS1 = 1 << 2,
+ CON_AXIS2 = 1 << 3,
+ CON_SELECT = 1 << 4,
+ /** Does not reorient vector to face viewport when on. */
+ CON_NOFLIP = 1 << 5,
+ CON_USER = 1 << 6,
+} eTrasConMode;
+
+/** #TransSnap.status */
+typedef enum {
+ SNAP_FORCED = 1 << 0,
+ TARGET_INIT = 1 << 1,
+ POINT_INIT = 1 << 2,
+ MULTI_POINTS = 1 << 3,
+} eTrasSnapStatus;
+
+/** \} */
+
typedef struct TransSnapPoint {
struct TransSnapPoint *next, *prev;
float co[3];
@@ -82,7 +215,7 @@ typedef struct TransSnap {
bool snap_self;
bool peel;
bool use_backface_culling;
- char status;
+ eTrasSnapStatus status;
/* Snapped Element Type (currently for objects on
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list