[Bf-blender-cvs] [6c3d8fb] master: Cleanup: trackball logic

Campbell Barton noreply at git.blender.org
Sat Dec 17 08:58:26 CET 2016


Commit: 6c3d8fbeb399c394831137b511c02df642fade92
Author: Campbell Barton
Date:   Sat Dec 17 19:12:07 2016 +1100
Branches: master
https://developer.blender.org/rB6c3d8fbeb399c394831137b511c02df642fade92

Cleanup: trackball logic

Used SQRT2 and SQRT1_2 to calculate the same value,
harmless but a little confusing, set once and check instead.

===================================================================

M	source/blender/editors/space_view3d/view3d_edit.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index eb4d1b3..620bbf0 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;
 	}




More information about the Bf-blender-cvs mailing list