Refactor Cutout Tool to Use World Space Edge Length

- Replaced the Mesh Detail parameter with a new Edge Length property to define cutout sampling in physical units.
- Introduced Minimum Relative Edge Length preference to control effective spacing based on the bounding box of the cutout content.
- Updated tests to validate the new edge length functionality and ensure consistent behavior across different resolutions and canvas sizes.
- Removed deprecated parameters and adjusted related properties to align with the new edge length implementation.
- Enhanced geometry sampling logic to utilize effective world spacing for both standard and fine outline modes.
This commit is contained in:
2026-09-12 23:03:24 +08:00
parent 938d95db0f
commit 18799e8828
28 changed files with 505 additions and 279 deletions

View File

@@ -10,17 +10,6 @@ CUTOUT_SHAPE_BUTTONS = (
("DEPTH_SOLID", "SURFACE_NCURVE"),
)
CUTOUT_MESH_DETAIL_SPACING = {
"LOW": 32,
"MEDIUM": 16,
"HIGH": 8,
"ULTRA": 4,
}
def cutout_mesh_detail_spacing(mesh_detail):
return CUTOUT_MESH_DETAIL_SPACING[str(mesh_detail)]
def _pie_button(
pie,
@@ -30,7 +19,7 @@ def _pie_button(
source_name,
selection_path_json,
generate_normal,
point_spacing,
edge_length,
alpha_threshold,
fine_outline,
gesture,
@@ -44,7 +33,7 @@ def _pie_button(
operator.selection_path_json = selection_path_json
operator.shape = shape
operator.generate_normal = generate_normal
operator.point_spacing = point_spacing
operator.edge_length = edge_length
operator.alpha_threshold = alpha_threshold
operator.fine_outline = fine_outline
operator.gesture = gesture
@@ -61,7 +50,7 @@ def open_shape_pie(
source_name = source_object.name
selection_path_json = selection_path.to_json()
settings = context.scene.anyimage_settings
point_spacing = cutout_mesh_detail_spacing(settings.cutout_mesh_detail)
edge_length = settings.cutout_edge_length
ready = ai_ready()
generate_normal = ready and bool(
getattr(settings, "cutout_generate_normal", False)
@@ -81,7 +70,7 @@ def open_shape_pie(
source_name,
selection_path_json,
generate_normal,
point_spacing,
edge_length,
alpha_threshold,
fine_outline,
gesture,