Fix (unreported) uv unwrap selected was splitting selection
Add support for `pin_unselected` in new UV Packing API. Regression introduced by API change in rBe3075f3cf7ce. Duplicate change to rB0ce18561bc82 in master.
This commit is contained in:
parent
e010890e82
commit
143e74c0b8
|
@ -353,6 +353,7 @@ struct UVPackIsland_Params {
|
|||
uint use_seams : 1;
|
||||
uint correct_aspect : 1;
|
||||
bool ignore_pinned; /* Ignore islands which have any pinned UVs. */
|
||||
bool pin_unselected; /* Treat unselected UVs as if they were pinned. */
|
||||
eUVPackIsland_MarginMethod margin_method; /* Which formula to use when scaling island margin. */
|
||||
float margin; /* Additional space to add around each island. */
|
||||
};
|
||||
|
|
|
@ -600,7 +600,7 @@ static BoxPack *pack_islands_params(const blender::Vector<FaceIsland *> &island_
|
|||
return box_array;
|
||||
}
|
||||
|
||||
static bool island_has_pins(FaceIsland *island)
|
||||
static bool island_has_pins(const Scene *scene, FaceIsland *island, const bool pin_unselected)
|
||||
{
|
||||
BMLoop *l;
|
||||
BMIter iter;
|
||||
|
@ -611,6 +611,9 @@ static bool island_has_pins(FaceIsland *island)
|
|||
if (luv->flag & MLOOPUV_PINNED) {
|
||||
return true;
|
||||
}
|
||||
if (pin_unselected && !uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -657,12 +660,18 @@ void ED_uvedit_pack_islands_multi(const Scene *scene,
|
|||
}
|
||||
}
|
||||
|
||||
bool only_selected_faces = params->only_selected_faces;
|
||||
bool only_selected_uvs = params->only_selected_uvs;
|
||||
if (params->ignore_pinned && params->pin_unselected) {
|
||||
only_selected_faces = false;
|
||||
only_selected_uvs = false;
|
||||
}
|
||||
ListBase island_list = {nullptr};
|
||||
bm_mesh_calc_uv_islands(scene,
|
||||
bm,
|
||||
&island_list,
|
||||
params->only_selected_faces,
|
||||
params->only_selected_uvs,
|
||||
only_selected_faces,
|
||||
only_selected_uvs,
|
||||
params->use_seams,
|
||||
aspect_y,
|
||||
cd_loop_uv_offset);
|
||||
|
@ -670,7 +679,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(island)) {
|
||||
if (params->ignore_pinned && island_has_pins(scene, island, params->pin_unselected)) {
|
||||
MEM_freeN(island->faces);
|
||||
MEM_freeN(island);
|
||||
continue;
|
||||
|
|
|
@ -1101,6 +1101,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
|
|||
.use_seams = !options.topology_from_uvs || options.topology_from_uvs_use_seams,
|
||||
.correct_aspect = options.correct_aspect,
|
||||
.ignore_pinned = false,
|
||||
.pin_unselected = options.pin_unselected,
|
||||
.margin_method = RNA_enum_get(op->ptr, "margin_method"),
|
||||
.margin = RNA_float_get(op->ptr, "margin"),
|
||||
};
|
||||
|
@ -1879,6 +1880,7 @@ void ED_uvedit_live_unwrap(const Scene *scene, Object **objects, int objects_len
|
|||
.use_seams = !options.topology_from_uvs || options.topology_from_uvs_use_seams,
|
||||
.correct_aspect = options.correct_aspect,
|
||||
.ignore_pinned = true,
|
||||
.pin_unselected = options.pin_unselected,
|
||||
.margin_method = ED_UVPACK_MARGIN_SCALED,
|
||||
.margin = scene->toolsettings->uvcalc_margin,
|
||||
};
|
||||
|
@ -2026,6 +2028,7 @@ static int unwrap_exec(bContext *C, wmOperator *op)
|
|||
.use_seams = !options.topology_from_uvs || options.topology_from_uvs_use_seams,
|
||||
.correct_aspect = options.correct_aspect,
|
||||
.ignore_pinned = true,
|
||||
.pin_unselected = options.pin_unselected,
|
||||
.margin_method = RNA_enum_get(op->ptr, "margin_method"),
|
||||
.margin = RNA_float_get(op->ptr, "margin"),
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue