Fix T76935: Current orientation not taken in account when using "Align to transform orientation"
This commit is contained in:
parent
de7d32bb7d
commit
a39ca327bc
Notes:
blender-bot
2023-02-13 22:27:33 +01:00
Referenced by issue #76974, GPencil – Shear Tool Misses Orientation/Can't Shear Along X in Default Setup Referenced by issue #76935, Current orientation not taken in account when using "Align to transform orientation"
|
@ -896,12 +896,46 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
|||
break;
|
||||
case TFM_MODAL_TRANSLATE:
|
||||
/* only switch when... */
|
||||
if (ELEM(t->mode,
|
||||
TFM_ROTATION,
|
||||
TFM_RESIZE,
|
||||
TFM_TRACKBALL,
|
||||
TFM_EDGE_SLIDE,
|
||||
TFM_VERT_SLIDE)) {
|
||||
if (t->mode == TFM_TRANSLATION) {
|
||||
if ((t->obedit_type == OB_MESH) && (t->spacetype == SPACE_VIEW3D)) {
|
||||
restoreTransObjects(t);
|
||||
resetTransModal(t);
|
||||
resetTransRestrictions(t);
|
||||
|
||||
/* first try edge slide */
|
||||
transform_mode_init(t, NULL, TFM_EDGE_SLIDE);
|
||||
/* if that fails, do vertex slide */
|
||||
if (t->state == TRANS_CANCEL) {
|
||||
resetTransModal(t);
|
||||
t->state = TRANS_STARTING;
|
||||
transform_mode_init(t, NULL, TFM_VERT_SLIDE);
|
||||
}
|
||||
/* vert slide can fail on unconnected vertices (rare but possible) */
|
||||
if (t->state == TRANS_CANCEL) {
|
||||
resetTransModal(t);
|
||||
t->state = TRANS_STARTING;
|
||||
restoreTransObjects(t);
|
||||
resetTransRestrictions(t);
|
||||
transform_mode_init(t, NULL, TFM_TRANSLATION);
|
||||
}
|
||||
initSnapping(t, NULL); // need to reinit after mode change
|
||||
t->redraw |= TREDRAW_HARD;
|
||||
handled = true;
|
||||
}
|
||||
else if (t->options & (CTX_MOVIECLIP | CTX_MASK)) {
|
||||
restoreTransObjects(t);
|
||||
|
||||
t->flag ^= T_ALT_TRANSFORM;
|
||||
t->redraw |= TREDRAW_HARD;
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
else if (t->mode == TFM_SEQ_SLIDE) {
|
||||
t->flag ^= T_ALT_TRANSFORM;
|
||||
t->redraw |= TREDRAW_HARD;
|
||||
handled = true;
|
||||
}
|
||||
else if (transform_mode_is_changeable(t->mode)) {
|
||||
restoreTransObjects(t);
|
||||
resetTransModal(t);
|
||||
resetTransRestrictions(t);
|
||||
|
@ -910,60 +944,11 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
|||
t->redraw |= TREDRAW_HARD;
|
||||
handled = true;
|
||||
}
|
||||
else if (t->mode == TFM_SEQ_SLIDE) {
|
||||
t->flag ^= T_ALT_TRANSFORM;
|
||||
t->redraw |= TREDRAW_HARD;
|
||||
handled = true;
|
||||
}
|
||||
else {
|
||||
if (t->obedit_type == OB_MESH) {
|
||||
if ((t->mode == TFM_TRANSLATION) && (t->spacetype == SPACE_VIEW3D)) {
|
||||
restoreTransObjects(t);
|
||||
resetTransModal(t);
|
||||
resetTransRestrictions(t);
|
||||
|
||||
/* first try edge slide */
|
||||
transform_mode_init(t, NULL, TFM_EDGE_SLIDE);
|
||||
/* if that fails, do vertex slide */
|
||||
if (t->state == TRANS_CANCEL) {
|
||||
resetTransModal(t);
|
||||
t->state = TRANS_STARTING;
|
||||
transform_mode_init(t, NULL, TFM_VERT_SLIDE);
|
||||
}
|
||||
/* vert slide can fail on unconnected vertices (rare but possible) */
|
||||
if (t->state == TRANS_CANCEL) {
|
||||
resetTransModal(t);
|
||||
t->state = TRANS_STARTING;
|
||||
restoreTransObjects(t);
|
||||
resetTransRestrictions(t);
|
||||
transform_mode_init(t, NULL, TFM_TRANSLATION);
|
||||
}
|
||||
initSnapping(t, NULL); // need to reinit after mode change
|
||||
t->redraw |= TREDRAW_HARD;
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
else if (t->options & (CTX_MOVIECLIP | CTX_MASK)) {
|
||||
if (t->mode == TFM_TRANSLATION) {
|
||||
restoreTransObjects(t);
|
||||
|
||||
t->flag ^= T_ALT_TRANSFORM;
|
||||
t->redraw |= TREDRAW_HARD;
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TFM_MODAL_ROTATE:
|
||||
/* only switch when... */
|
||||
if (!(t->options & CTX_TEXTURE) && !(t->options & (CTX_MOVIECLIP | CTX_MASK))) {
|
||||
if (ELEM(t->mode,
|
||||
TFM_ROTATION,
|
||||
TFM_RESIZE,
|
||||
TFM_TRACKBALL,
|
||||
TFM_TRANSLATION,
|
||||
TFM_EDGE_SLIDE,
|
||||
TFM_VERT_SLIDE)) {
|
||||
if (transform_mode_is_changeable(t->mode)) {
|
||||
restoreTransObjects(t);
|
||||
resetTransModal(t);
|
||||
resetTransRestrictions(t);
|
||||
|
@ -982,13 +967,21 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
|||
break;
|
||||
case TFM_MODAL_RESIZE:
|
||||
/* only switch when... */
|
||||
if (ELEM(t->mode,
|
||||
TFM_ROTATION,
|
||||
TFM_TRANSLATION,
|
||||
TFM_TRACKBALL,
|
||||
TFM_EDGE_SLIDE,
|
||||
TFM_VERT_SLIDE)) {
|
||||
if (t->mode == TFM_RESIZE) {
|
||||
if (t->options & CTX_MOVIECLIP) {
|
||||
restoreTransObjects(t);
|
||||
|
||||
t->flag ^= T_ALT_TRANSFORM;
|
||||
t->redraw |= TREDRAW_HARD;
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
else if (t->mode == TFM_SHRINKFATTEN) {
|
||||
t->flag ^= T_ALT_TRANSFORM;
|
||||
t->redraw |= TREDRAW_HARD;
|
||||
handled = true;
|
||||
}
|
||||
else if (transform_mode_is_changeable(t->mode)) {
|
||||
/* Scale isn't normally very useful after extrude along normals, see T39756 */
|
||||
if ((t->con.mode & CON_APPLY) && (t->con.orientation == V3D_ORIENT_NORMAL)) {
|
||||
stopConstraint(t);
|
||||
|
@ -1002,20 +995,6 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
|||
t->redraw |= TREDRAW_HARD;
|
||||
handled = true;
|
||||
}
|
||||
else if (t->mode == TFM_SHRINKFATTEN) {
|
||||
t->flag ^= T_ALT_TRANSFORM;
|
||||
t->redraw |= TREDRAW_HARD;
|
||||
handled = true;
|
||||
}
|
||||
else if (t->mode == TFM_RESIZE) {
|
||||
if (t->options & CTX_MOVIECLIP) {
|
||||
restoreTransObjects(t);
|
||||
|
||||
t->flag ^= T_ALT_TRANSFORM;
|
||||
t->redraw |= TREDRAW_HARD;
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TFM_MODAL_SNAP_INV_ON:
|
||||
|
@ -1229,7 +1208,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
|||
break;
|
||||
}
|
||||
/* only switch when... */
|
||||
if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) {
|
||||
if (t->mode != TFM_TRANSLATION && transform_mode_is_changeable(t->mode)) {
|
||||
restoreTransObjects(t);
|
||||
resetTransModal(t);
|
||||
resetTransRestrictions(t);
|
||||
|
@ -1244,7 +1223,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
|||
break;
|
||||
}
|
||||
/* only switch when... */
|
||||
if (ELEM(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL)) {
|
||||
if (t->mode != TFM_RESIZE && transform_mode_is_changeable(t->mode)) {
|
||||
restoreTransObjects(t);
|
||||
resetTransModal(t);
|
||||
resetTransRestrictions(t);
|
||||
|
@ -1260,7 +1239,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
|||
}
|
||||
/* only switch when... */
|
||||
if (!(t->options & CTX_TEXTURE)) {
|
||||
if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION)) {
|
||||
if (transform_mode_is_changeable(t->mode)) {
|
||||
restoreTransObjects(t);
|
||||
resetTransModal(t);
|
||||
resetTransRestrictions(t);
|
||||
|
|
|
@ -1660,8 +1660,15 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||
orient_type_scene += index_custom;
|
||||
}
|
||||
|
||||
short orient_type_default = V3D_ORIENT_VIEW;
|
||||
short orient_type_default;
|
||||
short orient_type_constraint[2];
|
||||
if ((t->flag & T_MODAL) && transform_mode_is_changeable(t->mode)) {
|
||||
/* During modal, rotation starts with the View orientation. */
|
||||
orient_type_default = V3D_ORIENT_VIEW;
|
||||
}
|
||||
else {
|
||||
orient_type_default = orient_type_scene;
|
||||
}
|
||||
|
||||
if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
|
||||
t->orient_axis = RNA_property_enum_get(op->ptr, prop);
|
||||
|
|
|
@ -61,6 +61,18 @@ bool transdata_check_local_center(TransInfo *t, short around)
|
|||
(t->options & (CTX_MOVIECLIP | CTX_MASK | CTX_PAINT_CURVE))));
|
||||
}
|
||||
|
||||
/* Informs if the mode can be switched during modal. */
|
||||
bool transform_mode_is_changeable(const int mode)
|
||||
{
|
||||
return ELEM(mode,
|
||||
TFM_ROTATION,
|
||||
TFM_RESIZE,
|
||||
TFM_TRACKBALL,
|
||||
TFM_TRANSLATION,
|
||||
TFM_EDGE_SLIDE,
|
||||
TFM_VERT_SLIDE);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Transform Locks
|
||||
* \{ */
|
||||
|
|
|
@ -41,6 +41,7 @@ typedef struct TransDataGenericSlideVert {
|
|||
|
||||
/* transform_mode.c */
|
||||
bool transdata_check_local_center(TransInfo *t, short around);
|
||||
bool transform_mode_is_changeable(const int mode);
|
||||
void protectedTransBits(short protectflag, float vec[3]);
|
||||
void constraintTransLim(TransInfo *t, TransData *td);
|
||||
void postInputRotation(TransInfo *t, float values[3]);
|
||||
|
|
Loading…
Reference in New Issue