- Implemented `build_mesh_plane.py` to create a geometry node group for mesh planes with customizable parameters. - Created `build_shadeless.py` for a shader node group that displays color without scene lighting while preserving shadows and reflections. - Added `validate.py` to validate the integrity of the newly created node groups and their inputs. - Introduced `validate_cutout.py` to ensure the functionality of cutout node groups and their dependencies. - Developed `validate_mesh_plane.py` to test the mesh plane creation and its modifier settings.
80 lines
2.3 KiB
Python
80 lines
2.3 KiB
Python
from pathlib import Path
|
|
import sys
|
|
|
|
import bpy
|
|
|
|
|
|
PROJECT_ROOT = Path(__file__).parents[2]
|
|
sys.path.insert(0, str(PROJECT_ROOT / "src"))
|
|
sys.path.insert(
|
|
0,
|
|
str(next((PROJECT_ROOT / "src" / "anyimage" / "wheels").glob("blendjob-*.whl"))),
|
|
)
|
|
|
|
from anyimage.operators.common.node_asset import (
|
|
load_asset_node_group,
|
|
load_mesh_plane_node_group,
|
|
load_shadeless_node_group,
|
|
)
|
|
from anyimage.operators.cutout_tool.shape_types import (
|
|
CUTOUT_NODE_GROUP_NAME,
|
|
CUTOUT_NODE_GROUP_NAMES,
|
|
)
|
|
|
|
|
|
def input_names(group):
|
|
return [
|
|
item.name
|
|
for item in group.interface.items_tree
|
|
if item.item_type == "SOCKET" and item.in_out == "INPUT"
|
|
]
|
|
|
|
|
|
def main():
|
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
mesh_plane = load_mesh_plane_node_group()
|
|
shadeless = load_shadeless_node_group()
|
|
cutout = load_asset_node_group(CUTOUT_NODE_GROUP_NAME)
|
|
cutout_groups = {
|
|
name: bpy.data.node_groups[name]
|
|
for name in CUTOUT_NODE_GROUP_NAMES.values()
|
|
}
|
|
|
|
assert mesh_plane.name == "O Mesh Plane"
|
|
assert mesh_plane.bl_idname == "GeometryNodeTree"
|
|
assert mesh_plane.is_modifier
|
|
assert input_names(mesh_plane) == [
|
|
"Geometry",
|
|
"Subdivide",
|
|
"Thickness",
|
|
"Material",
|
|
]
|
|
assert shadeless.name == "O Shadeless"
|
|
assert shadeless.bl_idname == "ShaderNodeTree"
|
|
assert input_names(shadeless) == ["Color"]
|
|
|
|
assert cutout.name == CUTOUT_NODE_GROUP_NAME
|
|
assert cutout.bl_idname == "GeometryNodeTree"
|
|
assert cutout.is_modifier
|
|
assert input_names(cutout)[:3] == ["Geometry", "Shape", "Thickness"]
|
|
assert set(cutout_groups) == set(CUTOUT_NODE_GROUP_NAMES.values())
|
|
for group in cutout_groups.values():
|
|
assert group.bl_idname == "GeometryNodeTree"
|
|
assert not group.is_modifier
|
|
assert input_names(group)[0] == "Geometry"
|
|
|
|
public_groups = {mesh_plane, shadeless, cutout}
|
|
loaded = {*public_groups, *cutout_groups.values()}
|
|
assert all(group.use_fake_user for group in public_groups)
|
|
assert all(group.users > 0 for group in cutout_groups.values())
|
|
if bpy.app.version >= (5, 0, 0):
|
|
assert all(group.library is not None for group in loaded)
|
|
print(
|
|
f"Validated Blender {bpy.app.version_string}: "
|
|
+ ", ".join(sorted(group.name for group in loaded))
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|