Refactor geometry node arrangement system

- Removed obsolete files: sections.py, semantics.json, and sources.py.
- Introduced new modules: branches.py and layout.py for improved calculation block identification and layout planning.
- Implemented a unified layout strategy for geometry nodes, ensuring consistent spacing and organization.
- Added comprehensive documentation for the new layout design and its goals.
- Established a migration plan for transitioning existing assets to the new layout system.
- Updated tests to validate the new arrangement logic and ensure compatibility with existing geometry node structures.
This commit is contained in:
2026-09-13 23:42:12 +08:00
parent 1bf858b17e
commit 09778c4b48
19 changed files with 727 additions and 1637 deletions

View File

@@ -5,18 +5,16 @@ import numpy as np
import pytest
from tools.nodes.groups.image_plane import build_image_plane_group
from tools.nodes.groups.image_depth_plane import build_image_depth_plane_group
from tools.nodes.groups.image_cutout import build_image_cutout_group
from tools.nodes.build import build_node_groups
from tools.nodes.check import GEOMETRY_NAMES
from tools.nodes.arrangement.arrange import arrange_nodes
from tools.nodes.arrangement.dimensions import estimate_node_dimensions
@pytest.fixture(params=("depth_plane", "cutout"))
@pytest.fixture(params=sorted(GEOMETRY_NAMES))
def node_group(request):
bpy.ops.wm.read_factory_settings(use_empty=True)
if request.param == "depth_plane":
return build_image_depth_plane_group(build_image_plane_group())
return build_image_cutout_group()
return next(group for group in build_node_groups() if group.name == request.param)
def _source(socket):
@@ -130,3 +128,17 @@ def test_arrangement_preserves_program_and_geometry(node_group):
for (before_points, before_faces), (after_points, after_faces) in zip(geometry, evaluate()):
np.testing.assert_allclose(after_points, before_points, atol=1e-6)
assert after_faces == before_faces
display_nodes = [node for node in node_group.nodes if node.bl_idname not in {"NodeFrame", "NodeReroute"}]
boxes = []
for node in display_nodes:
size = estimate_node_dimensions(node)
x, y = node.location_absolute
box = (x, y - size.height, x + size.width, y)
assert all(not (box[0] < other[2] and box[2] > other[0]
and box[1] < other[3] and box[3] > other[1]) for other in boxes), node.name
boxes.append(box)
input_count = sum(node.bl_idname == "NodeGroupInput" for node in display_nodes)
arrange_nodes(node_group)
assert _program(node_group) == program
assert sum(node.bl_idname == "NodeGroupInput" for node in node_group.nodes) == input_count