Refactor depth surface and image cutout nodes for improved functionality and clarity
- Removed deprecated tests and code related to shell wall connections and coincident sheets. - Updated attribute handling in depth surface and image cutout groups, including new vector attribute functions. - Enhanced the inflation logic in the image depth cutout group to better manage shell and balloon behaviors. - Improved parameter naming and descriptions for clarity in the user interface. - Streamlined the geometry processing logic to ensure better performance and maintainability.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"""Behavior checks for face separation and connected Depth Surface shells."""
|
||||
|
||||
from collections import Counter
|
||||
import bpy
|
||||
import bmesh
|
||||
import numpy as np
|
||||
@@ -10,41 +9,6 @@ import pytest
|
||||
from tests.support.depth_surface import assert_closed, component_count, evaluated, surface
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mode", [0, 1])
|
||||
def test_shell_walls_directly_connect_caps(mode):
|
||||
from anyimage.common.object import modifier_input_identifier, set_modifier_input
|
||||
|
||||
obj, set_value = surface(resolution=4)
|
||||
obj.data.attributes.new("o_balloon", "FLOAT", "POINT").data.foreach_set(
|
||||
"value", np.full(len(obj.data.vertices), 0.3)
|
||||
)
|
||||
set_value("Depth Split", 0.5)
|
||||
front, faces = evaluated(obj)
|
||||
edges = Counter(tuple(sorted((a, b))) for face in faces for a, b in zip(face, (*face[1:], face[0])))
|
||||
boundary_count = sum(count == 1 for count in edges.values())
|
||||
result = obj.evaluated_get(bpy.context.evaluated_depsgraph_get())
|
||||
mesh = result.to_mesh()
|
||||
try:
|
||||
welded = {i for i, value in enumerate(mesh.attributes["o_balloon"].data)
|
||||
if mode == 0 and value.value == 0}
|
||||
finally:
|
||||
result.to_mesh_clear()
|
||||
collapsed_walls = sum(count == 1 and a in welded and b in welded for (a, b), count in edges.items())
|
||||
set_value("Mode", mode)
|
||||
modifier = obj.modifiers[0]
|
||||
thickness = modifier_input_identifier(modifier.node_group, "Thickness", subtype="NONE" if mode == 0 else "DISTANCE")
|
||||
for amount in (0.01, 2.0):
|
||||
set_modifier_input(modifier, thickness, amount)
|
||||
obj.update_tag(refresh={"DATA"})
|
||||
bpy.context.view_layer.update()
|
||||
points, shell_faces = evaluated(obj)
|
||||
assert len(points) == 2 * len(front) - len(welded)
|
||||
assert len(shell_faces) == 2 * len(faces) + boundary_count - collapsed_walls
|
||||
assert all(len(face) in (3, 4) for face in shell_faces)
|
||||
assert np.isfinite(points).all()
|
||||
assert_closed(shell_faces)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("thickness", [0.1, 1.4])
|
||||
def test_surface_caps_and_segmented_walls_are_connected(thickness):
|
||||
obj, set_value = surface()
|
||||
@@ -123,29 +87,6 @@ def test_full_wrapper_keeps_closed_shell():
|
||||
assert_closed(faces)
|
||||
|
||||
|
||||
def test_coincident_independent_sheets_do_not_weld_together():
|
||||
obj, set_value = surface(step=0.0)
|
||||
mesh = obj.data
|
||||
vertices = [tuple(v.co) for v in mesh.vertices]
|
||||
faces = [tuple(f.vertices) for f in mesh.polygons]
|
||||
n = len(vertices)
|
||||
duplicate = bpy.data.meshes.new("Close sheets")
|
||||
duplicate.from_pydata(
|
||||
vertices + [(x, y + 1e-8, z) for x, y, z in vertices],
|
||||
[],
|
||||
faces + [tuple(v + n for v in face) for face in faces],
|
||||
)
|
||||
uv = duplicate.uv_layers.new(name="UVMap")
|
||||
for loop in duplicate.loops:
|
||||
x, _y, z = duplicate.vertices[loop.vertex_index].co
|
||||
uv.data[loop.index].uv = (x / 2, z)
|
||||
obj.data = duplicate
|
||||
set_value("Thickness", 0.1)
|
||||
coords, faces = evaluated(obj)
|
||||
assert_closed(faces)
|
||||
assert component_count(faces) == 2
|
||||
|
||||
|
||||
@pytest.mark.parametrize("resolution", [1, 4])
|
||||
def test_planar_depth_preserves_blocks_and_cleans_single_face_width(resolution):
|
||||
obj, set_value = surface(step=0.0, resolution=resolution)
|
||||
|
||||
Reference in New Issue
Block a user