[Bf-blender-cvs] [748d06ae5ad] custom-manipulators: Fix divide by zero dragging the arrow

Campbell Barton noreply at git.blender.org
Thu Jun 15 12:17:35 CEST 2017


Commit: 748d06ae5adb7c7739405351f0937145bc0ef550
Author: Campbell Barton
Date:   Thu Jun 15 06:06:45 2017 +1000
Branches: custom-manipulators
https://developer.blender.org/rB748d06ae5adb7c7739405351f0937145bc0ef550

Fix divide by zero dragging the arrow

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

M	source/blender/editors/manipulator_library/arrow3d_manipulator.c

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

diff --git a/source/blender/editors/manipulator_library/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/arrow3d_manipulator.c
index ef35430ca5d..c856374661f 100644
--- a/source/blender/editors/manipulator_library/arrow3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/arrow3d_manipulator.c
@@ -326,14 +326,17 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
 
 	normalize_v3(viewvec);
 	if (!use_vertical) {
-		float fac;
 		/* now find a plane parallel to the view vector so we can intersect with the arrow direction */
 		cross_v3_v3v3(tangent, viewvec, offset);
 		cross_v3_v3v3(plane, tangent, viewvec);
-		fac = dot_v3v3(plane, offset) / dot_v3v3(arrow->direction, plane);
 
+		const float plane_offset = dot_v3v3(plane, offset);
+		const float plane_dir = dot_v3v3(plane, arrow->direction);
+		const float fac = (plane_dir != 0.0f) ? (plane_offset / plane_dir) : 0.0f;
 		facdir = (fac < 0.0) ? -1.0 : 1.0;
-		mul_v3_v3fl(offset, arrow->direction, fac);
+		if (isfinite(fac)) {
+			mul_v3_v3fl(offset, arrow->direction, fac);
+		}
 	}
 	else {
 		facdir = (m_diff[1] < 0.0) ? -1.0 : 1.0;




More information about the Bf-blender-cvs mailing list