Fix T103237: Prevent UV Unwrap from packing hidden UV islands

When migrating to the new packing API, pin_unselected was not
implemented correctly.

Regression from rB143e74c0b8eb, rBe3075f3cf7ce, rB0ce18561bc82.

Differential Revision: https://developer.blender.org/D16788

Reviewed By: Campbell Barton
This commit is contained in:
Chris Blackbourn 2022-12-16 16:20:11 +13:00
parent fd3943dbd5
commit 3dcd999267
Notes: blender-bot 2023-02-14 11:00:17 +01:00
Referenced by commit a6c30e1a0c, Fix T103237: Prevent UV Unwrap from packing hidden UV islands
Referenced by issue #103237, UV Unwrap changes nonselected uvs
1 changed files with 11 additions and 3 deletions

View File

@ -600,13 +600,21 @@ static BoxPack *pack_islands_params(const blender::Vector<FaceIsland *> &island_
return box_array;
}
static bool island_has_pins(const Scene *scene, FaceIsland *island, const bool pin_unselected)
static bool island_has_pins(const Scene *scene,
FaceIsland *island,
const UVPackIsland_Params *params)
{
const bool pin_unselected = params->pin_unselected;
const bool only_selected_faces = params->only_selected_faces;
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) {
BMFace *efa = island->faces[i];
if (pin_unselected && only_selected_faces && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
return true;
}
BM_ITER_ELEM (l, &iter, efa, 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;
@ -679,7 +687,7 @@ void ED_uvedit_pack_islands_multi(const Scene *scene,
/* 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(scene, island, params->pin_unselected)) {
if (params->ignore_pinned && island_has_pins(scene, island, params)) {
MEM_freeN(island->faces);
MEM_freeN(island);
continue;