[Bf-blender-cvs] [cb7fdf4] master: EdgeSlide: fix divide by zero

Campbell Barton noreply at git.blender.org
Thu May 7 13:32:01 CEST 2015


Commit: cb7fdf45cd66b65d11b930ad0140b9457c7d401b
Author: Campbell Barton
Date:   Thu May 7 19:50:46 2015 +1000
Branches: master
https://developer.blender.org/rBcb7fdf45cd66b65d11b930ad0140b9457c7d401b

EdgeSlide: fix divide by zero

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

M	source/blender/editors/transform/transform.c

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

diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 7d80044..3e7fefe 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -5460,7 +5460,7 @@ static BMEdge *get_other_edge(BMVert *v, BMEdge *e)
 }
 
 /* interpoaltes along a line made up of 2 segments (used for edge slide) */
-static void interp_line_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float t)
+static void interp_line_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], float t)
 {
 	float t_mid, t_delta;
 
@@ -5468,17 +5468,28 @@ static void interp_line_v3_v3v3v3(float p[3], const float v1[3], const float v2[
 	t_mid = line_point_factor_v3(v2, v1, v3);
 
 	t_delta = t - t_mid;
-	if (fabsf(t_delta) < FLT_EPSILON) {
-		copy_v3_v3(p, v2);
-	}
-	else if (t_delta < 0.0f) {
-		interp_v3_v3v3(p, v1, v2, t / t_mid);
+	if (t_delta < 0.0f) {
+		if (UNLIKELY(fabsf(t_mid) < FLT_EPSILON)) {
+			copy_v3_v3(p, v2);
+		}
+		else {
+			interp_v3_v3v3(p, v1, v2, t / t_mid);
+		}
 	}
 	else {
-		interp_v3_v3v3(p, v2, v3, (t - t_mid) / (1.0f - t_mid));
+		t = t - t_mid;
+		t_mid = 1.0f - t_mid;
+
+		if (UNLIKELY(fabsf(t_mid) < FLT_EPSILON)) {
+			copy_v3_v3(p, v3);
+		}
+		else {
+			interp_v3_v3v3(p, v2, v3, t / t_mid);
+		}
 	}
 }
 
+
 static void len_v3_ensure(float v[3], const float length)
 {
 	normalize_v3(v);




More information about the Bf-blender-cvs mailing list