Files
AnyImage/src/anyimage/operators/cutout_tool/interaction.py
nan dc000e50b1 feat: Implement weight cutout boundary smoothing for image depth cutout
- Added a new proposal for boundary smoothing in the weight cutout process, differentiating between Split edges and Outline smoothing requirements.
- Introduced a new capability `cutout-boundary-smoothing` to control smoothing strength and default values.
- Updated specifications to define the behavior of boundary-specific smoothing strength and default settings.
- Created tasks to verify the implementation of boundary behavior and asset updates.
- Developed comprehensive tests for depth symmetry and normal scaling to ensure expected behavior and performance.
- Introduced new attributes for normal mapping to facilitate persistent face attributes sharing between depth symmetry and image materials.
- Built a new node group for O Image Depth Symmetry, integrating the new smoothing capabilities and ensuring compatibility with existing workflows.
2026-09-14 12:44:20 +08:00

85 lines
2.1 KiB
Python

"""Cutout Selection validation and Shape-menu interaction helpers."""
from ...properties import ai_ready
from .shape import CUTOUT_SHAPE_LABELS
CUTOUT_SHAPE_BUTTONS = (
("FLAT", "MESH_GRID"),
("SOLID", "MESH_UVSPHERE"),
("DEPTH_SYMMETRY", "META_BALL"),
("DEPTH_SOLID", "SURFACE_NCURVE"),
)
def _pie_button(
pie,
shape,
label,
icon,
source_name,
selection_path_json,
generate_normal,
edge_length,
alpha_threshold,
fine_outline,
gesture,
):
operator = pie.operator(
"anyimage.cutout_selection_to_shape",
text=label,
icon=icon,
)
operator.source_object_name = source_name
operator.selection_path_json = selection_path_json
operator.shape = shape
operator.generate_normal = generate_normal
operator.edge_length = edge_length
operator.alpha_threshold = alpha_threshold
operator.fine_outline = fine_outline
operator.gesture = gesture
def open_shape_pie(
context,
event,
source_object,
selection_path,
*,
gesture="LASSO",
):
source_name = source_object.name
selection_path_json = selection_path.to_json()
settings = context.scene.anyimage_settings
edge_length = settings.cutout_edge_length
ready = ai_ready()
generate_normal = ready and bool(
getattr(settings, "cutout_generate_normal", False)
)
alpha_threshold = settings.cutout_alpha_threshold
fine_outline = settings.cutout_fine_outline
def draw(menu, _context):
pie = menu.layout.menu_pie()
buttons = CUTOUT_SHAPE_BUTTONS if ready else CUTOUT_SHAPE_BUTTONS[:2]
for shape, icon in buttons:
_pie_button(
pie,
shape,
CUTOUT_SHAPE_LABELS[shape],
icon,
source_name,
selection_path_json,
generate_normal,
edge_length,
alpha_threshold,
fine_outline,
gesture,
)
context.window_manager.popup_menu_pie(
event,
draw,
title="Cutout Shape",
icon="MESH_DATA",
)