[Bf-blender-cvs] [e5a572157d8] master: Fix T80899: Crash on editing multiple UVs of multiple different objects at the same time

Sebastian Parborg noreply at git.blender.org
Mon Sep 21 16:09:55 CEST 2020


Commit: e5a572157d8cd5947a0b4b7420e728d57d6965ff
Author: Sebastian Parborg
Date:   Mon Sep 21 16:07:24 2020 +0200
Branches: master
https://developer.blender.org/rBe5a572157d8cd5947a0b4b7420e728d57d6965ff

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

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

M	source/blender/blenlib/intern/math_geom.c
M	source/blender/editors/transform/transform_convert_mesh_uv.c

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

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++;



More information about the Bf-blender-cvs mailing list