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>2015-12-23 14:05:36 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-12-23 14:08:15 +0300
commit36f916f200754c18c7dbeb273583c623812fa4b5 (patch)
tree808b40aa830dc46138cd4ebb7bca9bfa9810a156 /source/blender/blenlib/intern/math_geom.c
parentb06f004d5bd3b9a9430b3a6ab4f62a9533b41fa9 (diff)
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.
Diffstat (limited to 'source/blender/blenlib/intern/math_geom.c')
-rw-r--r--source/blender/blenlib/intern/math_geom.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 25d40bc3f5e..7ce602238d3 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);
+ }
}
/**