Fix T76935: Current orientation not taken in account when using "Align to transform orientation"
This commit is contained in:
@@ -896,12 +896,46 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
|||||||
break;
|
break;
|
||||||
case TFM_MODAL_TRANSLATE:
|
case TFM_MODAL_TRANSLATE:
|
||||||
/* only switch when... */
|
/* only switch when... */
|
||||||
if (ELEM(t->mode,
|
if (t->mode == TFM_TRANSLATION) {
|
||||||
TFM_ROTATION,
|
if ((t->obedit_type == OB_MESH) && (t->spacetype == SPACE_VIEW3D)) {
|
||||||
TFM_RESIZE,
|
restoreTransObjects(t);
|
||||||
TFM_TRACKBALL,
|
resetTransModal(t);
|
||||||
TFM_EDGE_SLIDE,
|
resetTransRestrictions(t);
|
||||||
TFM_VERT_SLIDE)) {
|
|
||||||
|
/* 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);
|
restoreTransObjects(t);
|
||||||
resetTransModal(t);
|
resetTransModal(t);
|
||||||
resetTransRestrictions(t);
|
resetTransRestrictions(t);
|
||||||
@@ -910,60 +944,11 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
|||||||
t->redraw |= TREDRAW_HARD;
|
t->redraw |= TREDRAW_HARD;
|
||||||
handled = true;
|
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;
|
break;
|
||||||
case TFM_MODAL_ROTATE:
|
case TFM_MODAL_ROTATE:
|
||||||
/* only switch when... */
|
/* only switch when... */
|
||||||
if (!(t->options & CTX_TEXTURE) && !(t->options & (CTX_MOVIECLIP | CTX_MASK))) {
|
if (!(t->options & CTX_TEXTURE) && !(t->options & (CTX_MOVIECLIP | CTX_MASK))) {
|
||||||
if (ELEM(t->mode,
|
if (transform_mode_is_changeable(t->mode)) {
|
||||||
TFM_ROTATION,
|
|
||||||
TFM_RESIZE,
|
|
||||||
TFM_TRACKBALL,
|
|
||||||
TFM_TRANSLATION,
|
|
||||||
TFM_EDGE_SLIDE,
|
|
||||||
TFM_VERT_SLIDE)) {
|
|
||||||
restoreTransObjects(t);
|
restoreTransObjects(t);
|
||||||
resetTransModal(t);
|
resetTransModal(t);
|
||||||
resetTransRestrictions(t);
|
resetTransRestrictions(t);
|
||||||
@@ -982,13 +967,21 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
|||||||
break;
|
break;
|
||||||
case TFM_MODAL_RESIZE:
|
case TFM_MODAL_RESIZE:
|
||||||
/* only switch when... */
|
/* only switch when... */
|
||||||
if (ELEM(t->mode,
|
if (t->mode == TFM_RESIZE) {
|
||||||
TFM_ROTATION,
|
if (t->options & CTX_MOVIECLIP) {
|
||||||
TFM_TRANSLATION,
|
restoreTransObjects(t);
|
||||||
TFM_TRACKBALL,
|
|
||||||
TFM_EDGE_SLIDE,
|
|
||||||
TFM_VERT_SLIDE)) {
|
|
||||||
|
|
||||||
|
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 */
|
/* Scale isn't normally very useful after extrude along normals, see T39756 */
|
||||||
if ((t->con.mode & CON_APPLY) && (t->con.orientation == V3D_ORIENT_NORMAL)) {
|
if ((t->con.mode & CON_APPLY) && (t->con.orientation == V3D_ORIENT_NORMAL)) {
|
||||||
stopConstraint(t);
|
stopConstraint(t);
|
||||||
@@ -1002,20 +995,6 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
|||||||
t->redraw |= TREDRAW_HARD;
|
t->redraw |= TREDRAW_HARD;
|
||||||
handled = true;
|
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;
|
break;
|
||||||
|
|
||||||
case TFM_MODAL_SNAP_INV_ON:
|
case TFM_MODAL_SNAP_INV_ON:
|
||||||
@@ -1229,7 +1208,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only switch when... */
|
/* 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);
|
restoreTransObjects(t);
|
||||||
resetTransModal(t);
|
resetTransModal(t);
|
||||||
resetTransRestrictions(t);
|
resetTransRestrictions(t);
|
||||||
@@ -1244,7 +1223,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only switch when... */
|
/* 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);
|
restoreTransObjects(t);
|
||||||
resetTransModal(t);
|
resetTransModal(t);
|
||||||
resetTransRestrictions(t);
|
resetTransRestrictions(t);
|
||||||
@@ -1260,7 +1239,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
|||||||
}
|
}
|
||||||
/* only switch when... */
|
/* only switch when... */
|
||||||
if (!(t->options & CTX_TEXTURE)) {
|
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);
|
restoreTransObjects(t);
|
||||||
resetTransModal(t);
|
resetTransModal(t);
|
||||||
resetTransRestrictions(t);
|
resetTransRestrictions(t);
|
||||||
|
|||||||
@@ -1660,8 +1660,15 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||||||
orient_type_scene += index_custom;
|
orient_type_scene += index_custom;
|
||||||
}
|
}
|
||||||
|
|
||||||
short orient_type_default = V3D_ORIENT_VIEW;
|
short orient_type_default;
|
||||||
short orient_type_constraint[2];
|
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"))) {
|
if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
|
||||||
t->orient_axis = RNA_property_enum_get(op->ptr, prop);
|
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))));
|
(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
|
/** \name Transform Locks
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ typedef struct TransDataGenericSlideVert {
|
|||||||
|
|
||||||
/* transform_mode.c */
|
/* transform_mode.c */
|
||||||
bool transdata_check_local_center(TransInfo *t, short around);
|
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 protectedTransBits(short protectflag, float vec[3]);
|
||||||
void constraintTransLim(TransInfo *t, TransData *td);
|
void constraintTransLim(TransInfo *t, TransData *td);
|
||||||
void postInputRotation(TransInfo *t, float values[3]);
|
void postInputRotation(TransInfo *t, float values[3]);
|
||||||
|
|||||||
Reference in New Issue
Block a user