Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2008-05-16 17:13:20 +0400
committerMartin Poirier <theeth@yahoo.com>2008-05-16 17:13:20 +0400
commit952a0042eae2ea3efda1ad757382fd2936b0b5d1 (patch)
tree0d23be7d011644da6214e09b1066305e6c5105d0 /source/blender/src/transform.c
parent58e6861aea5da8e5f08ca72443042178eb6dcec1 (diff)
[#5743] Rotate dosnt work at high zoom
More precision added to previous fix through linear approximation of the angle at really small angle values.
Diffstat (limited to 'source/blender/src/transform.c')
-rw-r--r--source/blender/src/transform.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c
index 0b3cd92c565..b462422a408 100644
--- a/source/blender/src/transform.c
+++ b/source/blender/src/transform.c
@@ -245,12 +245,12 @@ float InputVerticalAbsolute(TransInfo *t, short mval[2]) {
float InputDeltaAngle(TransInfo *t, short mval[2])
{
- double dx2 = t->center2d[0] - mval[0];
- double dy2 = t->center2d[1] - mval[1];
+ double dx2 = mval[0] - t->center2d[0];
+ double dy2 = mval[1] - t->center2d[1];
double B = sqrt(dx2*dx2+dy2*dy2);
- double dx1 = t->center2d[0] - t->imval[0];
- double dy1 = t->center2d[1] - t->imval[1];
+ double dx1 = t->imval[0] - t->center2d[0];
+ double dy1 = t->imval[1] - t->center2d[1];
double A = sqrt(dx1*dx1+dy1*dy1);
double dx3 = mval[0] - t->imval[0];
@@ -265,6 +265,28 @@ float InputDeltaAngle(TransInfo *t, short mval[2])
dphi = saacos((float)deler);
if( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi;
+
+ /* If the angle is zero, because of lack of precision close to the 1.0 value in acos
+ * approximate the angle with the oposite side of the normalized triangle
+ * This is a good approximation here since the smallest acos value seems to be around
+ * 0.02 degree and lower values don't even have a 0.01% error compared to the approximation
+ * */
+ if (dphi == 0)
+ {
+ double dx, dy;
+
+ dx2 /= A;
+ dy2 /= A;
+
+ dx1 /= B;
+ dy1 /= B;
+
+ dx = dx1 - dx2;
+ dy = dy1 - dy2;
+
+ dphi = sqrt(dx*dx + dy*dy);
+ if( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi;
+ }
if(t->flag & T_SHIFT_MOD) dphi = dphi/30.0f;