Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Blackbourn <chrisbblend@gmail.com>2022-06-28 01:46:10 +0300
committerChris Blackbourn <chrisbblend@gmail.com>2022-06-28 01:46:10 +0300
commit7a44f62bdb60b1fb302e7948ef661f076364d3f2 (patch)
tree544ea20e2a38a4de569646108a086d5672acbc28 /source/blender/editors/uvedit/uvedit_unwrap_ops.c
parent317dfc17358fd4ee0c7f19be62112d7037b6c6f2 (diff)
Fix T99156: UV parameterizer respects both Pins and Seams
Rgression from: e6e9f1ac5a2d Reviewed By: Brecht Van Lommel Differential Revision: D15292
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_unwrap_ops.c')
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c64
1 files changed, 42 insertions, 22 deletions
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 3618286ec01..c9d4694081d 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -367,6 +367,45 @@ static void construct_param_handle_face_add(ParamHandle *handle,
GEO_uv_parametrizer_face_add(handle, face_index, i, vkeys, co, uv, pin, select);
}
+/* Set seams on UV Parametrizer based on options. */
+static void construct_param_edge_set_seams(ParamHandle *handle,
+ BMesh *bm,
+ const UnwrapOptions *options)
+{
+ if (options->topology_from_uvs && !options->topology_from_uvs_use_seams) {
+ return; /* Seams are not required with these options. */
+ }
+
+ const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
+ if (cd_loop_uv_offset == -1) {
+ return; /* UVs aren't present on BMesh. Nothing to do. */
+ }
+
+ BMEdge *edge;
+ BMIter iter;
+ BM_ITER_MESH (edge, &iter, bm, BM_EDGES_OF_MESH) {
+ if (!BM_elem_flag_test(edge, BM_ELEM_SEAM)) {
+ continue; /* No seam on this edge, nothing to do. */
+ }
+
+ /* Pinned vertices might have more than one ParamKey per BMVert.
+ * Check all the BM_LOOPS_OF_EDGE to find all the ParamKeys.
+ */
+ BMLoop *l;
+ BMIter liter;
+ BM_ITER_ELEM (l, &liter, edge, BM_LOOPS_OF_EDGE) {
+ MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ MLoopUV *luv_next = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset);
+ ParamKey vkeys[2];
+ vkeys[0] = GEO_uv_find_pin_index(handle, BM_elem_index_get(l->v), luv->uv);
+ vkeys[1] = GEO_uv_find_pin_index(handle, BM_elem_index_get(l->next->v), luv_next->uv);
+
+ /* Set the seam. */
+ GEO_uv_parametrizer_edge_set_seam(handle, vkeys);
+ }
+ }
+}
+
/* See: construct_param_handle_multi to handle multiple objects at once. */
static ParamHandle *construct_param_handle(const Scene *scene,
Object *ob,
@@ -375,7 +414,6 @@ static ParamHandle *construct_param_handle(const Scene *scene,
UnwrapResultInfo *result_info)
{
BMFace *efa;
- BMEdge *eed;
BMIter iter;
int i;
@@ -407,16 +445,7 @@ static ParamHandle *construct_param_handle(const Scene *scene,
}
}
- if (!options->topology_from_uvs || options->topology_from_uvs_use_seams) {
- BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(eed, BM_ELEM_SEAM)) {
- ParamKey vkeys[2];
- vkeys[0] = (ParamKey)BM_elem_index_get(eed->v1);
- vkeys[1] = (ParamKey)BM_elem_index_get(eed->v2);
- GEO_uv_parametrizer_edge_set_seam(handle, vkeys);
- }
- }
- }
+ construct_param_edge_set_seams(handle, bm, options);
GEO_uv_parametrizer_construct_end(handle,
options->fill_holes,
@@ -436,7 +465,6 @@ static ParamHandle *construct_param_handle_multi(const Scene *scene,
int *count_fail)
{
BMFace *efa;
- BMEdge *eed;
BMIter iter;
int i;
@@ -480,16 +508,8 @@ static ParamHandle *construct_param_handle_multi(const Scene *scene,
}
}
- if (!options->topology_from_uvs || options->topology_from_uvs_use_seams) {
- BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(eed, BM_ELEM_SEAM)) {
- ParamKey vkeys[2];
- vkeys[0] = (ParamKey)BM_elem_index_get(eed->v1);
- vkeys[1] = (ParamKey)BM_elem_index_get(eed->v2);
- GEO_uv_parametrizer_edge_set_seam(handle, vkeys);
- }
- }
- }
+ construct_param_edge_set_seams(handle, bm, options);
+
offset += bm->totface;
}