diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 14 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_convert_mesh_uv.c | 3 |
2 files changed, 13 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; diff --git a/source/blender/editors/transform/transform_convert_mesh_uv.c b/source/blender/editors/transform/transform_convert_mesh_uv.c index 92447c257da..b54c45e2ab2 100644 --- a/source/blender/editors/transform/transform_convert_mesh_uv.c +++ b/source/blender/editors/transform/transform_convert_mesh_uv.c @@ -301,6 +301,9 @@ void createTransUVs(bContext *C, TransInfo *t) BM_elem_flag_enable(efa, BM_ELEM_TAG); BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { + /* Make sure that the loop element flag is cleared for when we use it in + * uv_set_connectivity_distance later. */ + BM_elem_flag_disable(l, BM_ELEM_TAG); if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { countsel++; |