Transform Orientation Refactor

- Use `t->spacemtx` as the orientation matrix instead `t->orient_matrix`.
- Unify constraint behavior between modal and non-modal.
- Simplify code to remove old workarounds and rearrange struct members.

This fix T66142 since the actual `orient_type` (in the case
`V3D_ORIENT_NORMAL`) is used during Redo instead of always using
`V3D_ORIENT_CUSTOM_MATRIX`).

Differential Revision: https://developer.blender.org/D7469
This commit is contained in:
2020-04-29 08:07:25 -03:00
parent 980cebc459
commit c57e4418bb
11 changed files with 178 additions and 257 deletions

View File

@@ -713,7 +713,10 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
break;
case V3D_ORIENT_VIEW:
BLI_snprintf(text, sizeof(text), ftext, TIP_("view"));
setConstraint(t, t->spacemtx, mode, text);
float mtx[3][3];
copy_m3_m3(mtx, t->spacemtx);
negate_v3(mtx[2]);
setConstraint(t, mtx, mode, text);
break;
case V3D_ORIENT_CURSOR:
BLI_snprintf(text, sizeof(text), ftext, TIP_("cursor"));
@@ -984,17 +987,23 @@ void getConstraintMatrix(TransInfo *t)
/*------------------------- MMB Select -------------------------------*/
void initSelectConstraint(TransInfo *t, float mtx[3][3])
void initSelectConstraint(TransInfo *t, bool force_global)
{
copy_m3_m3(t->con.mtx, mtx);
t->con.mode |= CON_APPLY;
t->con.mode |= CON_SELECT;
short orientation;
if (force_global) {
orientation = V3D_ORIENT_GLOBAL;
}
else {
if (t->orientation.index == 0) {
t->orientation.index = 1;
BLI_assert(t->orientation.types[0] != V3D_ORIENT_CUSTOM_MATRIX);
initTransformOrientation(t->context, t, t->orientation.types[t->orientation.index]);
}
orientation = t->orientation.types[t->orientation.index];
}
setUserConstraint(t, orientation, CON_APPLY | CON_SELECT, "");
setNearestAxis(t);
t->con.drawExtra = NULL;
t->con.applyVec = applyAxisConstraintVec;
t->con.applySize = applyAxisConstraintSize;
t->con.applyRot = applyAxisConstraintRot;
}
void selectConstraint(TransInfo *t)