Refactor and enhance geometry node groups for depth plane and material layers

- Updated the depth plane node group to load from an asset and simplified the interface.
- Created a new build script for depth plane geometry nodes.
- Introduced material layer groups for image and depth materials with appropriate sockets.
- Added functionality to connect balloon normal scale to the image material.
- Enhanced tests to validate the new node groups and their connections.
- Ensured that production code does not create node groups directly.
This commit is contained in:
2026-08-31 12:25:23 +08:00
parent 87d7721128
commit 377eee43f5
18 changed files with 602 additions and 405 deletions

32
tests/test_node_assets.py Normal file
View File

@@ -0,0 +1,32 @@
import unittest
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parents[1]
SOURCE_ROOT = PROJECT_ROOT / "src" / "anyimage"
class NodeAssetTest(unittest.TestCase):
def test_production_code_does_not_create_node_groups(self):
offenders = []
for path in SOURCE_ROOT.rglob("*.py"):
if "bpy.data.node_groups.new" in path.read_text(encoding="utf-8"):
offenders.append(path.relative_to(PROJECT_ROOT).as_posix())
self.assertEqual(offenders, [])
def test_runtime_node_group_entries_load_assets(self):
material_source = (
SOURCE_ROOT / "operators" / "common" / "mesh_result.py"
).read_text(encoding="utf-8")
plane_source = (
SOURCE_ROOT / "operators" / "convert_to_plane" / "nodes.py"
).read_text(encoding="utf-8")
self.assertIn("return load_asset_node_group(group_name)", material_source)
self.assertIn(
"return load_asset_node_group(DEPTH_PLANE_NODE_GROUP_NAME)",
plane_source,
)
if __name__ == "__main__":
unittest.main()