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:
40
tests/tools/nodes/test_validity.py
Normal file
40
tests/tools/nodes/test_validity.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""Verify point culling removes its dangling wire geometry."""
|
||||
|
||||
import bpy
|
||||
|
||||
from tools.nodes.common.nodes import interface_socket
|
||||
from tools.nodes.common.validity import delete_invalid_points
|
||||
|
||||
|
||||
def test_point_culling_removes_wire_edges_without_removing_adjacent_surface():
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
mesh = bpy.data.meshes.new("Two Quads")
|
||||
mesh.from_pydata([(0, 0, 0), (1, 0, 0), (2, 0, 0),
|
||||
(0, 1, 0), (1, 1, 0), (2, 1, 0)], [],
|
||||
[(0, 1, 4, 3), (1, 2, 5, 4)])
|
||||
obj = bpy.data.objects.new("Surface", mesh)
|
||||
bpy.context.collection.objects.link(obj)
|
||||
group = bpy.data.node_groups.new("Point Culling", "GeometryNodeTree")
|
||||
interface_socket(group, "Geometry", "INPUT", "NodeSocketGeometry")
|
||||
interface_socket(group, "Geometry", "OUTPUT", "NodeSocketGeometry")
|
||||
inlet = group.nodes.new("NodeGroupInput")
|
||||
outlet = group.nodes.new("NodeGroupOutput")
|
||||
index = group.nodes.new("GeometryNodeInputIndex")
|
||||
invalid = group.nodes.new("ShaderNodeMath")
|
||||
invalid.operation = "LESS_THAN"
|
||||
invalid.inputs[1].default_value = 1
|
||||
group.links.new(index.outputs[0], invalid.inputs[0])
|
||||
geometry = delete_invalid_points(group, inlet.outputs["Geometry"], invalid.outputs[0])
|
||||
group.links.new(geometry, outlet.inputs["Geometry"])
|
||||
modifier = obj.modifiers.new("Cull", "NODES")
|
||||
modifier.node_group = group
|
||||
evaluated = obj.evaluated_get(bpy.context.evaluated_depsgraph_get())
|
||||
result = evaluated.to_mesh()
|
||||
try:
|
||||
assert len(result.polygons) == 1
|
||||
assert len(result.edges) == 4
|
||||
assert {tuple(vertex.co) for vertex in result.vertices} == {
|
||||
(1, 0, 0), (2, 0, 0), (1, 1, 0), (2, 1, 0),
|
||||
}
|
||||
finally:
|
||||
evaluated.to_mesh_clear()
|
||||
Reference in New Issue
Block a user