[Bf-blender-cvs] [36f916f] master: Math Lib: clamp closest_to_line_segment_v# when segment has no length
Campbell Barton
noreply at git.blender.org
Wed Dec 23 12:17:01 CET 2015
Commit: 36f916f200754c18c7dbeb273583c623812fa4b5
Author: Campbell Barton
Date: Wed Dec 23 22:05:36 2015 +1100
Branches: master
https://developer.blender.org/rB36f916f200754c18c7dbeb273583c623812fa4b5
Math Lib: clamp closest_to_line_segment_v# when segment has no length
For a line this makes sense but segments should clamp,
avoids assert in edge-rip.
===================================================================
M source/blender/blenlib/intern/math_geom.c
===================================================================
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 25d40bc..7ce6022 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -341,12 +341,16 @@ void closest_to_line_segment_v2(float r_close[2], const float p[2], const float
lambda = closest_to_line_v2(cp, p, l1, l2);
- if (lambda <= 0.0f)
+ /* flip checks for !finite case (when segment is a point) */
+ if (!(lambda > 0.0f)) {
copy_v2_v2(r_close, l1);
- else if (lambda >= 1.0f)
+ }
+ else if (!(lambda < 1.0f)) {
copy_v2_v2(r_close, l2);
- else
+ }
+ else {
copy_v2_v2(r_close, cp);
+ }
}
/* point closest to v1 on line v2-v3 in 3D */
@@ -356,12 +360,16 @@ void closest_to_line_segment_v3(float r_close[3], const float p[3], const float
lambda = closest_to_line_v3(cp, p, l1, l2);
- if (lambda <= 0.0f)
+ /* flip checks for !finite case (when segment is a point) */
+ if (!(lambda > 0.0f)) {
copy_v3_v3(r_close, l1);
- else if (lambda >= 1.0f)
+ }
+ else if (!(lambda < 1.0f)) {
copy_v3_v3(r_close, l2);
- else
+ }
+ else {
copy_v3_v3(r_close, cp);
+ }
}
/**
More information about the Bf-blender-cvs
mailing list