From dac3434b03976b101435572559ebba7a6d1fc862 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sun, 22 Jun 2008 20:40:13 +0000 Subject: [PATCH] [#14398] In Object- and EditMode, global rotate manual input is different than mouse The sign of the rotation angle was sometimes different between num input and mouse input. --- source/blender/include/transform.h | 6 +++--- source/blender/src/transform.c | 8 ++++---- source/blender/src/transform_constraints.c | 19 ++++++++++++------- source/blender/src/transform_snap.c | 2 +- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/source/blender/include/transform.h b/source/blender/include/transform.h index 7d497dc05ec..4e3b80134f9 100644 --- a/source/blender/include/transform.h +++ b/source/blender/include/transform.h @@ -102,9 +102,9 @@ typedef struct TransCon { /* Apply function pointer for linear vectorial transformation */ /* The last three parameters are pointers to the in/out/printable vectors */ void (*applySize)(struct TransInfo *, struct TransData *, float [3][3]); - /* Apply function pointer for rotation transformation (prototype will change */ - void (*applyRot)(struct TransInfo *, struct TransData *, float [3]); - /* Apply function pointer for rotation transformation (prototype will change */ + /* Apply function pointer for size transformation */ + void (*applyRot)(struct TransInfo *, struct TransData *, float [3], float *); + /* Apply function pointer for rotation transformation */ } TransCon; typedef struct TransDataIpokey { diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c index 4270ce6a069..705a5f868e7 100644 --- a/source/blender/src/transform.c +++ b/source/blender/src/transform.c @@ -2621,7 +2621,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3]) continue; if (t->con.applyRot) { - t->con.applyRot(t, td, axis); + t->con.applyRot(t, td, axis, NULL); VecRotToMat3(axis, angle * td->factor, mat); } else if (t->flag & T_PROP_EDIT) { @@ -2654,7 +2654,7 @@ int Rotation(TransInfo *t, short mval[2]) snapGrid(t, &final); if (t->con.applyRot) { - t->con.applyRot(t, NULL, axis); + t->con.applyRot(t, NULL, axis, &final); } applySnapping(t, &final); @@ -3314,7 +3314,7 @@ int PushPull(TransInfo *t, short mval[2]) } if (t->con.applyRot && t->con.mode & CON_APPLY) { - t->con.applyRot(t, NULL, axis); + t->con.applyRot(t, NULL, axis, NULL); } for(i = 0 ; i < t->total; i++, td++) { @@ -3326,7 +3326,7 @@ int PushPull(TransInfo *t, short mval[2]) VecSubf(vec, t->center, td->center); if (t->con.applyRot && t->con.mode & CON_APPLY) { - t->con.applyRot(t, td, axis); + t->con.applyRot(t, td, axis, NULL); if (isLockConstraint(t)) { float dvec[3]; Projf(dvec, vec, axis); diff --git a/source/blender/src/transform_constraints.c b/source/blender/src/transform_constraints.c index 2d01c2303fc..796b013cb88 100644 --- a/source/blender/src/transform_constraints.c +++ b/source/blender/src/transform_constraints.c @@ -393,7 +393,7 @@ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3] * (ie: not doing counterclockwise rotations when the mouse moves clockwise). */ -static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3]) +static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], float *angle) { if (!td && t->con.mode & CON_APPLY) { int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2); @@ -413,9 +413,9 @@ static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3]) break; } /* don't flip axis if asked to or if num input */ - if (!(mode & CON_NOFLIP) && hasNumInput(&t->num) == 0) { + if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) { if (Inpf(vec, t->viewinv[2]) > 0.0f) { - VecMulf(vec, -1.0f); + *angle = -(*angle); } } } @@ -435,10 +435,15 @@ static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3]) * (ie: not doing counterclockwise rotations when the mouse moves clockwise). */ -static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3]) +static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3], float *angle) { - if (td && t->con.mode & CON_APPLY) { + if (t->con.mode & CON_APPLY) { int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2); + + /* on setup call, use first object */ + if (td == NULL) { + td= t->data; + } switch(mode) { case CON_AXIS0: @@ -454,9 +459,9 @@ static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3]) VECCOPY(vec, td->axismtx[2]); break; } - if (!(mode & CON_NOFLIP)) { + if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) { if (Inpf(vec, t->viewinv[2]) > 0.0f) { - VecMulf(vec, -1.0f); + *angle = -(*angle); } } } diff --git a/source/blender/src/transform_snap.c b/source/blender/src/transform_snap.c index 295cfa4574c..04ca5b08755 100644 --- a/source/blender/src/transform_snap.c +++ b/source/blender/src/transform_snap.c @@ -412,7 +412,7 @@ float RotationBetween(TransInfo *t, float p1[3], float p2[3]) if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) { float axis[3], tmp[3]; - t->con.applyRot(t, NULL, axis); + t->con.applyRot(t, NULL, axis, NULL); Projf(tmp, end, axis); VecSubf(end, end, tmp);