diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2020-09-21 17:07:24 +0300 |
---|---|---|
committer | Sebastian Parborg <darkdefende@gmail.com> | 2020-09-21 17:09:51 +0300 |
commit | e5a572157d8cd5947a0b4b7420e728d57d6965ff (patch) | |
tree | 40a2a32e27884983cad894c3d5c221a6c8f91179 /source/blender/blenlib/intern/math_geom.c | |
parent | 9d3550d7819807064dd39365322295ebd8ea0a09 (diff) |
Fix T80899: Crash on editing multiple UVs of multiple different objects at the same time
The issue was two fold.
First something sets the loop element tag and doesn't clear it before
the UV code in question tries to use the tags. Added a sanity clear to
make sure that it operates on a clean tag state.
The next one was that the UV maps in question had quite a few points
that had zero length UV loop edges. This would lead to division by
zero.
Reviewed By: Jeroen Bakker, Brecht
Differential Revision: http://developer.blender.org/D8967
Diffstat (limited to 'source/blender/blenlib/intern/math_geom.c')
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 9cf1341b16a..1bc93a6a229 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -3290,10 +3290,16 @@ float closest_to_line_v3(float r_close[3], const float p[3], const float l1[3], float closest_to_line_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2]) { - float h[2], u[2], lambda; + float h[2], u[2], lambda, denom; sub_v2_v2v2(u, l2, l1); sub_v2_v2v2(h, p, l1); - lambda = dot_v2v2(u, h) / dot_v2v2(u, u); + denom = dot_v2v2(u, u); + if (denom == 0.0f) { + r_close[0] = l1[0]; + r_close[1] = l1[1]; + return 0.0f; + } + lambda = dot_v2v2(u, h) / denom; r_close[0] = l1[0] + u[0] * lambda; r_close[1] = l1[1] + u[1] * lambda; return lambda; @@ -3308,12 +3314,12 @@ double closest_to_line_v2_db(double r_close[2], sub_v2_v2v2_db(u, l2, l1); sub_v2_v2v2_db(h, p, l1); denom = dot_v2v2_db(u, u); - if (denom < DBL_EPSILON) { + if (denom == 0.0) { r_close[0] = l1[0]; r_close[1] = l1[1]; return 0.0; } - lambda = dot_v2v2_db(u, h) / dot_v2v2_db(u, u); + lambda = dot_v2v2_db(u, h) / denom; r_close[0] = l1[0] + u[0] * lambda; r_close[1] = l1[1] + u[1] * lambda; return lambda; |