UI: change the UV packing pin option into a toggle & drop-down
Exposing both the option not to use pinned islands and to skip pinned islands in the same drop-down was confusing. Now there is a checkbox "Pin", when disabled, pinned UV's don't have any impact on the packed result. When enabled, the pin-method selects how pinned islands are handled. Also remove the "ignore" option from the UI as this didn't fit well with other methods of handling pinned islands. Instead, islands to be ignored can be de-selected by the user. Ref !108733.
This commit is contained in:
@@ -1511,7 +1511,13 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
pack_island_params.scale_to_fit = RNA_boolean_get(op->ptr, "scale");
|
||||
pack_island_params.merge_overlap = RNA_boolean_get(op->ptr, "merge_overlap");
|
||||
pack_island_params.pin_method = eUVPackIsland_PinMethod(RNA_enum_get(op->ptr, "pin"));
|
||||
|
||||
if (RNA_boolean_get(op->ptr, "pin")) {
|
||||
pack_island_params.pin_method = eUVPackIsland_PinMethod(RNA_enum_get(op->ptr, "pin_method"));
|
||||
}
|
||||
else {
|
||||
pack_island_params.pin_method = ED_UVPACK_PIN_NONE;
|
||||
}
|
||||
|
||||
pack_island_params.margin_method = eUVPackIsland_MarginMethod(
|
||||
RNA_enum_get(op->ptr, "margin_method"));
|
||||
@@ -1591,17 +1597,21 @@ static const EnumPropertyItem pack_shape_method_items[] = {
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
/**
|
||||
* \note #ED_UVPACK_PIN_NONE is exposed as a boolean "pin".
|
||||
* \note #ED_UVPACK_PIN_IGNORE is intentionally not exposed as it is confusing from the UI level
|
||||
* (users can simply not select these islands).
|
||||
* The option is kept kept internally because it's used for live unwrap.
|
||||
*/
|
||||
static const EnumPropertyItem pinned_islands_method_items[] = {
|
||||
{ED_UVPACK_PIN_PACK, "PACK", 0, "Pack", "Pinned islands are packed normally"},
|
||||
{ED_UVPACK_PIN_LOCK_SCALE, "SCALE", 0, "Lock Scale", "Pinned islands won't rescale"},
|
||||
{ED_UVPACK_PIN_LOCK_ROTATION, "ROTATION", 0, "Lock Rotation", "Pinned islands won't rotate"},
|
||||
{ED_UVPACK_PIN_LOCK_SCALE, "SCALE", 0, "Scale", "Pinned islands won't rescale"},
|
||||
{ED_UVPACK_PIN_LOCK_ROTATION, "ROTATION", 0, "Rotation", "Pinned islands won't rotate"},
|
||||
{ED_UVPACK_PIN_LOCK_ROTATION_SCALE,
|
||||
"ROTATION_SCALE",
|
||||
0,
|
||||
"Lock Rotation and Scale",
|
||||
"Rotation and Scale",
|
||||
"Pinned islands will translate only"},
|
||||
{ED_UVPACK_PIN_LOCK_ALL, "LOCKED", 0, "Lock in Place", "Pinned islands are locked in place"},
|
||||
{ED_UVPACK_PIN_IGNORE, "IGNORE", 0, "Ignore", "Pinned islands are not packed"},
|
||||
{ED_UVPACK_PIN_LOCK_ALL, "LOCKED", 0, "All", "Pinned islands are locked in place"},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
@@ -1612,15 +1622,23 @@ static void uv_pack_islands_ui(bContext * /*C*/, wmOperator *op)
|
||||
uiLayoutSetPropDecorate(layout, false);
|
||||
uiItemR(layout, op->ptr, "shape_method", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, op->ptr, "scale", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, op->ptr, "rotate", 0, nullptr, ICON_NONE);
|
||||
uiLayout *sub = uiLayoutRow(layout, true);
|
||||
uiLayoutSetActive(sub, RNA_boolean_get(op->ptr, "rotate"));
|
||||
uiItemR(sub, op->ptr, "rotate_method", 0, nullptr, ICON_NONE);
|
||||
uiItemS(layout);
|
||||
{
|
||||
uiItemR(layout, op->ptr, "rotate", 0, nullptr, ICON_NONE);
|
||||
uiLayout *sub = uiLayoutRow(layout, true);
|
||||
uiLayoutSetActive(sub, RNA_boolean_get(op->ptr, "rotate"));
|
||||
uiItemR(sub, op->ptr, "rotate_method", 0, nullptr, ICON_NONE);
|
||||
uiItemS(layout);
|
||||
}
|
||||
uiItemR(layout, op->ptr, "margin_method", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, op->ptr, "margin", 0, nullptr, ICON_NONE);
|
||||
uiItemS(layout);
|
||||
uiItemR(layout, op->ptr, "pin", 0, nullptr, ICON_NONE);
|
||||
{
|
||||
uiItemR(layout, op->ptr, "pin", 0, nullptr, ICON_NONE);
|
||||
uiLayout *sub = uiLayoutRow(layout, true);
|
||||
uiLayoutSetActive(sub, RNA_boolean_get(op->ptr, "pin"));
|
||||
uiItemR(sub, op->ptr, "pin_method", 0, IFACE_("Lock Method"), ICON_NONE);
|
||||
uiItemS(layout);
|
||||
}
|
||||
uiItemR(layout, op->ptr, "merge_overlap", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, op->ptr, "udim_source", 0, nullptr, ICON_NONE);
|
||||
uiItemS(layout);
|
||||
@@ -1686,8 +1704,17 @@ void UV_OT_pack_islands(wmOperatorType *ot)
|
||||
"");
|
||||
RNA_def_float_factor(
|
||||
ot->srna, "margin", 0.001f, 0.0f, 1.0f, "Margin", "Space between islands", 0.0f, 1.0f);
|
||||
RNA_def_enum(
|
||||
ot->srna, "pin", pinned_islands_method_items, ED_UVPACK_PIN_PACK, "Pinned Islands", "");
|
||||
RNA_def_boolean(ot->srna,
|
||||
"pin",
|
||||
false,
|
||||
"Lock Pinned Islands",
|
||||
"Constrain islands containing any pinned UV's");
|
||||
RNA_def_enum(ot->srna,
|
||||
"pin_method",
|
||||
pinned_islands_method_items,
|
||||
ED_UVPACK_PIN_LOCK_ALL,
|
||||
"Pin Method",
|
||||
"");
|
||||
RNA_def_enum(ot->srna,
|
||||
"shape_method",
|
||||
pack_shape_method_items,
|
||||
|
||||
@@ -47,12 +47,18 @@ enum eUVPackIsland_ShapeMethod {
|
||||
};
|
||||
|
||||
enum eUVPackIsland_PinMethod {
|
||||
ED_UVPACK_PIN_IGNORE = 0,
|
||||
ED_UVPACK_PIN_PACK,
|
||||
/** Pin has no impact on packing. */
|
||||
ED_UVPACK_PIN_NONE = 0,
|
||||
/**
|
||||
* Ignore islands containing any pinned UV's.
|
||||
* \note Not exposed in the UI, used only for live-unwrap.
|
||||
*/
|
||||
ED_UVPACK_PIN_IGNORE,
|
||||
ED_UVPACK_PIN_LOCK_ROTATION,
|
||||
ED_UVPACK_PIN_LOCK_ROTATION_SCALE,
|
||||
ED_UVPACK_PIN_LOCK_SCALE,
|
||||
ED_UVPACK_PIN_LOCK_ALL, /* Lock translation, rotation and scale. */
|
||||
/** Lock the island in-place (translation, rotation and scale). */
|
||||
ED_UVPACK_PIN_LOCK_ALL,
|
||||
};
|
||||
|
||||
namespace blender::geometry {
|
||||
|
||||
@@ -337,7 +337,7 @@ UVPackIsland_Params::UVPackIsland_Params()
|
||||
only_selected_faces = false;
|
||||
use_seams = false;
|
||||
correct_aspect = false;
|
||||
pin_method = ED_UVPACK_PIN_PACK;
|
||||
pin_method = ED_UVPACK_PIN_NONE;
|
||||
pin_unselected = false;
|
||||
merge_overlap = false;
|
||||
margin = 0.001f;
|
||||
|
||||
Reference in New Issue
Block a user