Add tests and implement boundary smoothing and cutout functionality

- Introduced tests for boundary smoothing in `test_boundary_smoothing.py`, verifying that smoothing reduces stair-step artifacts while preserving boundary integrity.
- Added tests for cutout boundary behavior in `test_cutout_boundary.py`, ensuring proper handling of boundary triangles and normal blending.
- Created `test_temporary_attributes.py` to check the cleanup of temporary attributes across depth modifier branches, ensuring no warnings are raised.
- Implemented point culling functionality in `test_validity.py`, confirming that invalid points are removed without affecting adjacent geometry.
- Developed boundary smoothing logic in `boundary_smoothing.py`, allowing for depth smoothing while maintaining edge integrity.
- Added cutout boundary management in `cutout_boundary.py`, including functions for removing boundary triangles and tapering thickness profiles.
- Implemented validity checks in `validity.py` to ensure proper deletion of invalid vertices and associated wire edges.
This commit is contained in:
2026-09-11 20:37:20 +08:00
parent e8129fe495
commit 31074bd511
85 changed files with 2501 additions and 1451 deletions

View File

@@ -19,6 +19,16 @@ def check_asset_library(asset_path):
with bpy.data.libraries.load(str(asset_path), link=True) as (source, target):
assert set(source.node_groups) == GEOMETRY_NAMES | SHADER_NAMES
target.node_groups = sorted(GEOMETRY_NAMES | SHADER_NAMES)
pending, checked = list(target.node_groups), set()
while pending:
group = pending.pop()
if group in checked or group.bl_idname != "GeometryNodeTree":
continue
checked.add(group)
for node in group.nodes:
assert node.bl_idname != "GeometryNodeCaptureAttribute", group.name
if node.bl_idname == "GeometryNodeGroup" and node.node_tree:
pending.append(node.node_tree)
depth_image = bpy.data.images.new("Asset Check Depth", width=8, height=8, float_buffer=True)
depth_image.colorspace_settings.name = "Non-Color"
depth_image.pixels.foreach_set([
@@ -31,7 +41,11 @@ def check_asset_library(asset_path):
if expected_type == "ShaderNodeTree":
continue
mesh = bpy.data.meshes.new("Asset Check Plane")
mesh.from_pydata([(-0.5, -0.5, 0), (0.5, -0.5, 0), (0.5, 0.5, 0), (-0.5, 0.5, 0)], [], [(0, 1, 2, 3)])
mesh.from_pydata(
[(x / 3 - 0.5, y / 3 - 0.5, 0) for y in range(4) for x in range(4)], [],
[(y * 4 + x, y * 4 + x + 1, (y + 1) * 4 + x + 1, (y + 1) * 4 + x)
for y in range(3) for x in range(3)],
)
uv = mesh.uv_layers.new(name="UVMap")
for loop in mesh.loops:
position = mesh.vertices[loop.vertex_index].co
@@ -55,6 +69,12 @@ def check_asset_library(asset_path):
try:
assert len(result.vertices) and len(result.polygons), node_group.name
assert all(isfinite(value) for vertex in result.vertices for value in vertex.co), node_group.name
assert not list(modifier.node_warnings), (
node_group.name, [warning.message for warning in modifier.node_warnings],
)
assert not {attribute.name for attribute in result.attributes} & {
".o_anyimage_depth_cut", ".o_anyimage_original_boundary",
}, node_group.name
finally:
evaluated.to_mesh_clear()
bpy.data.objects.remove(obj, do_unlink=True)