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-10-20 02:35:17 +0300
committerChris Blackbourn <chrisbblend@gmail.com>2022-10-20 02:44:56 +0300
commite3075f3cf7ce2fae086f3cd09867e4f0455e4115 (patch)
treefad8d58eee7346e0e8b80da2a77b05e82359a220 /source/blender/editors/uvedit/uvedit_islands.cc
parent21a1c332b00a63afaa82cce00ca5175b1b8dbd96 (diff)
Cleanup: simplify uv packing api
Part of a wider set of changes to migrate UV packing from uv_parametrizer.cc to uvedit_islands.cc. This allows UV packing improvements including margin calculation, correctness fixes such as support for non-manifold geometry, and new packing algorithms including speed and quality improvements. See for example c2256bf7f714, T82637 This change migrates UV.unwrap and Live UV Unwrap. Differential Revision: https://developer.blender.org/D16296
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_islands.cc')
-rw-r--r--source/blender/editors/uvedit/uvedit_islands.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc
index bdd05b06d94..92745667505 100644
--- a/source/blender/editors/uvedit/uvedit_islands.cc
+++ b/source/blender/editors/uvedit/uvedit_islands.cc
@@ -600,6 +600,22 @@ static BoxPack *pack_islands_params(const blender::Vector<FaceIsland *> &island_
return box_array;
}
+static bool island_has_pins(FaceIsland *island)
+{
+ BMLoop *l;
+ BMIter iter;
+ const int cd_loop_uv_offset = island->cd_loop_uv_offset;
+ for (int i = 0; i < island->faces_len; i++) {
+ BM_ITER_ELEM (l, &iter, island->faces[i], BM_LOOPS_OF_FACE) {
+ MLoopUV *luv = static_cast<MLoopUV *>(BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset));
+ if (luv->flag & MLOOPUV_PINNED) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
/* -------------------------------------------------------------------- */
/** \name Public UV Island Packing
*
@@ -651,8 +667,14 @@ void ED_uvedit_pack_islands_multi(const Scene *scene,
aspect_y,
cd_loop_uv_offset);
- int index;
- LISTBASE_FOREACH_INDEX (struct FaceIsland *, island, &island_list, index) {
+ /* Remove from linked list and append to blender::Vector. */
+ LISTBASE_FOREACH_MUTABLE (struct FaceIsland *, island, &island_list) {
+ BLI_remlink(&island_list, island);
+ if (params->ignore_pinned && island_has_pins(island)) {
+ MEM_freeN(island->faces);
+ MEM_freeN(island);
+ continue;
+ }
island_vector.append(island);
}
}