chore: bump version to 1.0.1 and update related files

This commit is contained in:
2026-09-18 08:36:51 +08:00
parent 0e0287d340
commit 531f7a4dfb
10 changed files with 7 additions and 554 deletions

View File

@@ -6,68 +6,6 @@ import pytest
from tests.support.depth_surface import evaluated
from tests.tools.nodes.test_boundary_smoothing import boundary_neighbors, edge_band
from tools.nodes.common.boundary_smoothing import smooth_boundary_camera
def test_camera_blur_preserves_rays_interior_protection_and_disconnected_surfaces():
bpy.ops.wm.read_factory_settings(use_empty=True)
points, faces, cameras, protected = [], [], [], []
for offset, depth in ((0, 2), (81, 50)):
for y in range(9):
for x in range(9):
value = 20 if offset == 0 and (x, y) == (4, 0) else depth
if offset == 0 and (x, y) == (8, 8):
value = 0
points.append((x, y, 0))
cameras.append((x * value / 10, y * value / 10, value))
protected.append(x == 0)
faces.extend((offset + y * 9 + x, offset + y * 9 + x + 1,
offset + (y + 1) * 9 + x + 1, offset + (y + 1) * 9 + x)
for y in range(8) for x in range(8))
mesh = bpy.data.meshes.new("Disconnected camera samples")
mesh.from_pydata(points, [], faces)
camera = np.asarray(cameras, np.float32)
mesh.attributes.new("test_camera", "FLOAT_VECTOR", "POINT").data.foreach_set("vector", camera.ravel())
mesh.attributes.new("test_protected", "BOOLEAN", "POINT").data.foreach_set("value", protected)
obj = bpy.data.objects.new("Depth samples", mesh)
bpy.context.collection.objects.link(obj)
group = bpy.data.node_groups.new("Boundary depth test", "GeometryNodeTree")
for direction in ("INPUT", "OUTPUT"):
group.interface.new_socket(name="Geometry", in_out=direction, socket_type="NodeSocketGeometry")
control = group.interface.new_socket(name="Boundary Smooth", in_out="INPUT", socket_type="NodeSocketInt")
source = group.nodes.new("NodeGroupInput")
attributes = []
for name, kind in (("test_camera", "FLOAT_VECTOR"), ("test_protected", "BOOLEAN")):
node = group.nodes.new("GeometryNodeInputNamedAttribute")
node.data_type = kind
node.inputs["Name"].default_value = name
attributes.append(node.outputs["Attribute"])
position = group.nodes.new("GeometryNodeSetPosition")
group.links.new(source.outputs["Geometry"], position.inputs["Geometry"])
group.links.new(smooth_boundary_camera(group, *attributes), position.inputs["Position"])
output = group.nodes.new("NodeGroupOutput")
group.links.new(position.outputs[0], output.inputs["Geometry"])
modifier = obj.modifiers.new("Depth", "NODES")
modifier.node_group = group
modifier[control.identifier] = 0
np.testing.assert_array_equal(evaluated(obj)[0], camera)
modifier[control.identifier] = 12
obj.update_tag(refresh={"DATA"})
bpy.context.view_layer.update()
result, result_faces = evaluated(obj)
assert result_faces == faces
assert 2 < result[4, 2] < 10
assert np.isfinite(result).all()
np.testing.assert_array_equal(result[protected], camera[protected])
np.testing.assert_array_equal(result[81:], camera[81:])
np.testing.assert_array_equal(result[80], camera[80])
band = edge_band(faces, set(boundary_neighbors(faces)) - set(np.flatnonzero(protected)))
interior = [i for i in range(len(camera)) if i not in band]
assert interior
np.testing.assert_array_equal(result[interior], camera[interior])
valid = camera[:, 2] > 0
np.testing.assert_allclose(result[valid, :2] / result[valid, 2:3],
camera[valid, :2] / camera[valid, 2:3], atol=1e-6)