refactor: update depth cutout and surface handling for improved geometry manipulation and clarity
This commit is contained in:
@@ -7,7 +7,8 @@ from anyimage.common.object import modifier_input_identifier, set_modifier_input
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mode", [0, 1])
|
||||
def test_normal_smooth_changes_thickness_direction_without_moving_zero_thickness(mode):
|
||||
def test_edge_turn_reshapes_thickness_without_moving_zero_thickness(mode):
|
||||
"""Edge Turn swings the wall direction and leaves zero thickness untouched."""
|
||||
from tests.support.depth_surface import surface, evaluated
|
||||
|
||||
obj, set_value = surface(step=1, resolution=10)
|
||||
@@ -19,24 +20,28 @@ def test_normal_smooth_changes_thickness_direction_without_moving_zero_thickness
|
||||
set_value("Front Inflation", .2)
|
||||
modifier = obj.modifiers[0]
|
||||
thickness = modifier_input_identifier(modifier.node_group, "Thickness", subtype="DISTANCE" if mode else "NONE")
|
||||
turn = modifier_input_identifier(modifier.node_group, "Edge Turn")
|
||||
|
||||
def result(amount, smoothing):
|
||||
def result(amount, edge_turn):
|
||||
set_modifier_input(modifier, thickness, amount)
|
||||
set_value("Normal Smooth", smoothing)
|
||||
set_modifier_input(modifier, turn, edge_turn)
|
||||
obj.update_tag(refresh={"DATA"})
|
||||
bpy.context.view_layer.update()
|
||||
return evaluated(obj)
|
||||
|
||||
raw, faces = result(0, 16)
|
||||
smooth, smooth_faces = result(0, 512)
|
||||
np.testing.assert_array_equal(raw, smooth)
|
||||
assert faces == smooth_faces
|
||||
raw, faces = result(1, 16)
|
||||
smooth, smooth_faces = result(1, 512)
|
||||
assert faces == smooth_faces
|
||||
assert np.isfinite(smooth).all()
|
||||
assert np.max(np.abs(raw - smooth)) > 1e-5
|
||||
plain, faces = result(0, 0)
|
||||
turned, turned_faces = result(0, 2)
|
||||
np.testing.assert_array_equal(plain, turned)
|
||||
assert faces == turned_faces
|
||||
plain, faces = result(1, 0)
|
||||
turned, turned_faces = result(1, 2)
|
||||
assert faces == turned_faces
|
||||
assert np.isfinite(turned).all()
|
||||
assert np.max(np.abs(plain - turned)) > 1e-5
|
||||
|
||||
|
||||
def test_thin_shell_normal_smoothing_is_independent_of_thickness_and_reference():
|
||||
def test_shell_offset_scales_with_thickness_and_ignores_reference():
|
||||
"""A thin Shell moves a distance proportional to its thickness."""
|
||||
from tests.support.depth_surface import surface, evaluated
|
||||
|
||||
obj, set_value = surface(step=0, resolution=12)
|
||||
@@ -49,9 +54,8 @@ def test_thin_shell_normal_smoothing_is_independent_of_thickness_and_reference()
|
||||
set_value('Thickness', 0.)
|
||||
front, _ = evaluated(obj)
|
||||
|
||||
def offsets(thickness, smoothing, reference=10.):
|
||||
def offsets(thickness, reference=10.):
|
||||
set_value('Thickness', thickness)
|
||||
set_value('Normal Smooth', smoothing)
|
||||
set_value('Reference Depth', reference)
|
||||
points, faces = evaluated(obj)
|
||||
adjusted_front = front + (0, 10 - reference, 0)
|
||||
@@ -63,11 +67,9 @@ def test_thin_shell_normal_smoothing_is_independent_of_thickness_and_reference()
|
||||
order = np.argsort(indices[rear])
|
||||
return ((points[rear] - adjusted_front[indices[rear]]) / thickness)[order], faces
|
||||
|
||||
raw, _ = offsets(.02, 16)
|
||||
smooth, faces = offsets(.02, 512)
|
||||
assert np.max(np.linalg.norm(raw - smooth, axis=1)) > .05
|
||||
thinner, thinner_faces = offsets(.01, 512)
|
||||
distant, _ = offsets(.02, 512, 20.)
|
||||
smooth, faces = offsets(.02)
|
||||
thinner, thinner_faces = offsets(.01)
|
||||
distant, _ = offsets(.02, 20.)
|
||||
np.testing.assert_allclose(thinner, smooth, atol=2e-4)
|
||||
np.testing.assert_allclose(distant, smooth, atol=2e-4)
|
||||
assert thinner_faces == faces
|
||||
|
||||
Reference in New Issue
Block a user