[Bf-blender-cvs] [4160da187c9] master: Fix T103670: correct seam calculation when finding unique uvs
Chris Blackbourn
noreply at git.blender.org
Fri Jan 13 23:50:15 CET 2023
Commit: 4160da187c9ed003354c08d3be2a4cbd504cd973
Author: Chris Blackbourn
Date: Sat Jan 14 10:46:19 2023 +1300
Branches: master
https://developer.blender.org/rB4160da187c9ed003354c08d3be2a4cbd504cd973
Fix T103670: correct seam calculation when finding unique uvs
Fixes bugs where UV islands with `mark seam` would tear at boundaries.
Modify seam_connected to search both it's edges instead of only one,
as this could fail if the edge was a seam or did not fan to the other loop.
Also fixes bug in `seam_connected_recursive`:
- `loop->prev == needle` changed to `loop == needle`
Maniphest Tasks: T103787
Reviewed By: Campbell Barton
Differential Revision: https://developer.blender.org/D16992
Test File: F14145477, F14137755, T79304
===================================================================
M source/blender/editors/mesh/editmesh_utils.c
===================================================================
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 99aa256b3d0..21fb223e1de 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -927,7 +927,7 @@ static bool seam_connected_recursive(BMEdge *edge,
continue; /* `loop` is disjoint in UV space. */
}
- if (loop->prev == needle) {
+ if (loop == needle) {
return true; /* Success. */
}
@@ -971,9 +971,17 @@ static bool seam_connected(BMLoop *loop_a, BMLoop *loop_b, GSet *visited, int cd
BLI_gset_clear(visited, NULL);
const float *luv_anchor = BM_ELEM_CD_GET_FLOAT_P(loop_a, cd_loop_uv_offset);
- const float *luv_fan = BM_ELEM_CD_GET_FLOAT_P(loop_a->next, cd_loop_uv_offset);
- const bool result = seam_connected_recursive(
- loop_a->e, luv_anchor, luv_fan, loop_b, visited, cd_loop_uv_offset);
+ const float *luv_next_fan = BM_ELEM_CD_GET_FLOAT_P(loop_a->next, cd_loop_uv_offset);
+ bool result = seam_connected_recursive(
+ loop_a->e, luv_anchor, luv_next_fan, loop_b, visited, cd_loop_uv_offset);
+ if (!result) {
+ /* Search around `loop_a` in the opposite direction, as one of the edges may be delimited by
+ * a boundary, seam or disjoint UV, or itself be one of these. See: T103670, T103787. */
+ float *luv_prev_fan = BM_ELEM_CD_GET_FLOAT_P(loop_a->prev, cd_loop_uv_offset);
+ result = seam_connected_recursive(
+ loop_a->prev->e, luv_anchor, luv_prev_fan, loop_b, visited, cd_loop_uv_offset);
+ }
+
return result;
}
More information about the Bf-blender-cvs
mailing list