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:
authorCampbell Barton <ideasman42@gmail.com>2016-12-17 11:12:07 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-12-17 11:14:02 +0300
commit6c3d8fbeb399c394831137b511c02df642fade92 (patch)
tree4094146b0116afc898ccb1875a6e01b5289b8008 /source/blender/editors
parent2e15618f498c5a64c012f559bbb95273e729999a (diff)
Cleanup: trackball logic
Used SQRT2 and SQRT1_2 to calculate the same value, harmless but a little confusing, set once and check instead.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c10
1 files 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;
}