From 6c3d8fbeb399c394831137b511c02df642fade92 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Dec 2016 19:12:07 +1100 Subject: [PATCH] Cleanup: trackball logic Used SQRT2 and SQRT1_2 to calculate the same value, harmless but a little confusing, set once and check instead. --- source/blender/editors/space_view3d/view3d_edit.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index eb4d1b3819b..620bbf03f32 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -566,22 +566,20 @@ typedef struct ViewOpsData { static void calctrackballvec(const rcti *rect, int mx, int my, float vec[3]) { - float x, y, radius, d, z, t; - - radius = TRACKBALLSIZE; + const float radius = TRACKBALLSIZE; + const float t = radius / (float)M_SQRT2; + float x, y, z, d; /* normalize x and y */ x = BLI_rcti_cent_x(rect) - mx; x /= (float)(BLI_rcti_size_x(rect) / 4); y = BLI_rcti_cent_y(rect) - my; y /= (float)(BLI_rcti_size_y(rect) / 2); - d = sqrtf(x * x + y * y); - if (d < radius * (float)M_SQRT1_2) { /* Inside sphere */ + if (d < t) { /* Inside sphere */ z = sqrtf(radius * radius - d * d); } else { /* On hyperbola */ - t = radius / (float)M_SQRT2; z = t * t / d; }