Fix Automatic Constraint using mouse position from before navigation

Axis "selection" gets messy if it doesn't use the same offset value
that is updated after navigating.
This commit is contained in:
Germano Cavalcante
2023-06-28 14:14:33 -03:00
parent 2dac20e35f
commit ce7ee791b0
3 changed files with 4 additions and 8 deletions

View File

@@ -330,9 +330,6 @@ typedef struct TransCon {
char text[50];
/** Projection constraint matrix (same as #imtx with some axis == 0). */
float pmtx[3][3];
/** Initial mouse value for visual calculation
* the one in #TransInfo is not guarantee to stay the same (Rotates change it). */
int imval[2];
/** Mode flags of the constraint. */
eTConstraint mode;
void (*drawExtra)(struct TransInfo *t);

View File

@@ -823,7 +823,7 @@ void drawConstraint(TransInfo *t)
if (tc->mode & CON_SELECT) {
float vec[3];
convertViewVec(t, vec, (t->mval[0] - t->con.imval[0]), (t->mval[1] - t->con.imval[1]));
convertViewVec(t, vec, (t->mval[0] - t->mouse.imval[0]), (t->mval[1] - t->mouse.imval[1]));
add_v3_v3(vec, t->center_global);
drawLine(t, t->center_global, t->spacemtx[0], 'X', 0);
@@ -1071,7 +1071,7 @@ static void setNearestAxis2d(TransInfo *t)
t->con.mode &= ~(CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
/* no correction needed... just use whichever one is lower */
if (abs(t->mval[0] - t->con.imval[0]) < abs(t->mval[1] - t->con.imval[1])) {
if (abs(t->mval[0] - t->mouse.imval[0]) < abs(t->mval[1] - t->mouse.imval[1])) {
t->con.mode |= CON_AXIS1;
STRNCPY(t->con.text, TIP_(" along Y axis"));
}
@@ -1092,8 +1092,8 @@ static void setNearestAxis3d(TransInfo *t)
int i;
/* calculate mouse movement */
mvec[0] = (float)(t->mval[0] - t->con.imval[0]);
mvec[1] = (float)(t->mval[1] - t->con.imval[1]);
mvec[0] = (float)(t->mval[0] - t->mouse.imval[0]);
mvec[1] = (float)(t->mval[1] - t->mouse.imval[1]);
mvec[2] = 0.0f;
/* We need to correct axis length for the current zoom-level of view,

View File

@@ -184,7 +184,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
copy_v2_v2_int(t->mval, mval);
copy_v2_v2_int(t->mouse.imval, mval);
copy_v2_v2_int(t->con.imval, mval);
t->mode_info = NULL;