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
This commit is contained in:
Sebastian Parborg 2020-09-21 16:07:24 +02:00 committed by Jeroen Bakker
parent 9743a58f7d
commit 6f28e6998b
Notes: blender-bot 2023-02-14 04:39:18 +01:00
Referenced by issue #80899, Crash on editing multiple UVs of multiple different objects at the same time
2 changed files with 13 additions and 4 deletions

View File

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

View File

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