feat: add tests for outline points and thickness handling in depth surface

This commit is contained in:
2026-09-16 00:29:30 +08:00
parent 2dfa9b2add
commit 474fc10f0f
4 changed files with 45 additions and 6 deletions

View File

@@ -145,6 +145,34 @@ def test_planar_depth_preserves_blocks_and_cleans_single_face_width(resolution):
np.testing.assert_allclose(coords, original, atol=1e-6)
def test_outline_points_use_adjacent_face_depth_without_split():
obj, set_value = surface(step=0.0, resolution=2)
image = bpy.data.images["Camera"]
pixels = np.array(image.pixels[:], np.float32).reshape(32, 64, 4)
pixels[..., 2] = 1
# Spike both edge rows to cover Blender's image origin without relying on it.
pixels[(0, -1), :, 2] = 10
image.pixels.foreach_set(pixels.ravel())
image.update()
obj.update_tag(refresh={"DATA"})
bpy.context.view_layer.update()
set_value("Depth Split", 0.0)
coords, faces = evaluated(obj)
boundary = np.isclose(coords[:, 2], 0, atol=0.05) | np.isclose(coords[:, 2], 1, atol=0.05)
assert boundary.any()
np.testing.assert_allclose(coords[boundary, 1], 0, atol=1e-5)
def test_thickness_handles_more_than_4096_source_vertices():
obj, set_value = surface(step=0.0, resolution=45)
assert len(obj.data.vertices) > 4096
set_value("Depth Split", 0.0)
set_value("Thickness", 0.02)
coords, faces = evaluated(obj)
assert np.isfinite(coords).all()
assert_closed(faces)
def test_small_positive_split_preserves_unsplit_projection():
obj, set_value = surface(step=2.0)
original, original_faces = evaluated(obj)