[Bf-blender-cvs] [6f28e6998b3] blender-v2.90-release: 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:14:31 CEST 2020


Commit: 6f28e6998b36f09b70fec059ad6bdc6bbfd175c6
Author: Sebastian Parborg
Date:   Mon Sep 21 16:07:24 2020 +0200
Branches: blender-v2.90-release
https://developer.blender.org/rB6f28e6998b36f09b70fec059ad6bdc6bbfd175c6

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 83750277bf6..46db33283c3 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -3335,10 +3335,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;
@@ -3353,12 +3359,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