diff --git a/surfaces/blender/brokkr_bridge/blender_target.py b/surfaces/blender/brokkr_bridge/blender_target.py index 0fe2092..e765923 100644 --- a/surfaces/blender/brokkr_bridge/blender_target.py +++ b/surfaces/blender/brokkr_bridge/blender_target.py @@ -681,8 +681,13 @@ class BrokkrBlenderTarget: render = scene.render path = sa.resolve_inside(self.output_dir, str(command.get("outputPath") or ""), "output") file_format = sa.still_format(path) - engines = tuple(item.identifier for item in render.bl_rna.properties["engine"].enum_items) - engine = sa.choice(command, "engine", engines) + # The engine enum is dynamic (Cycles and add-on engines register at runtime), and RNA's + # enum_items on a dynamic enum lists only its static defaults, so the running Blender is + # asked by assignment below and a TypeError there is the refusal. + engine = command.get("engine") + if engine is not None and (not isinstance(engine, str) or not engine.strip()): + raise sa.ActionRefused("engine must be a render engine identifier.") + engine = engine.strip().upper() if engine else None width = sa.integer(command, "resolutionX", 1, sa.MAX_RESOLUTION) height = sa.integer(command, "resolutionY", 1, sa.MAX_RESOLUTION) camera_name = str(command.get("cameraName") or "") @@ -697,7 +702,10 @@ class BrokkrBlenderTarget: path.parent.mkdir(parents=True, exist_ok=True) try: if engine is not None: - render.engine = engine + try: + render.engine = engine + except TypeError: + raise sa.ActionRefused(f"engine {engine} is not available in this Blender.") from None if width is not None: render.resolution_x = width if height is not None: diff --git a/surfaces/blender/docs/install.md b/surfaces/blender/docs/install.md index c9200cc..0b764c9 100644 --- a/surfaces/blender/docs/install.md +++ b/surfaces/blender/docs/install.md @@ -128,3 +128,8 @@ gets a `failed` receipt whose message names the rule): `resolutionY` (whole numbers, 1 to 16384), `cameraName`. Engine, resolution, camera, file path and format are restored after the render. The render blocks Blender's UI until it finishes. + +The scene actions were run against Blender 5.2.3 LTS headless with +`surfaces/blender/tests/live/headless_smoke.py` (usage in its docstring). One real +failure it found: Blender's `engine` enum is dynamic, so `bl_rna` lists only +`BLENDER_EEVEE`; `renderStill` now asks Blender by assignment instead. diff --git a/surfaces/blender/tests/live/headless_smoke.py b/surfaces/blender/tests/live/headless_smoke.py new file mode 100644 index 0000000..62ea574 --- /dev/null +++ b/surfaces/blender/tests/live/headless_smoke.py @@ -0,0 +1,75 @@ +"""Live Blender smoke for the scene actions. Not part of the unittest run: it needs Blender. + + BROKKR_RUN= BROKKR_ADDON= \ + blender --background --factory-startup --python surfaces/blender/tests/live/headless_smoke.py + +Writes a tiny .glb into /in, runs every scene action against real bpy, and prints +RESULT lines (accepted/failed) plus the state each action should have produced. +Last run: Blender 5.2.3 LTS on Windows, all actions accepted, both escapes refused. +""" +import json, struct, sys, types, os, traceback +from pathlib import Path +import bpy + +ROOT = Path(os.environ["BROKKR_RUN"]).resolve() +ADDON = Path(os.environ["BROKKR_ADDON"]).resolve() +(ROOT / "in").mkdir(parents=True, exist_ok=True) +(ROOT / "out").mkdir(parents=True, exist_ok=True) + +# tiny triangle glb +pos = struct.pack("<9f", 0,0,0, 1,0,0, 0,1,0) +gltf = {"asset": {"version": "2.0"}, "scene": 0, "scenes": [{"nodes": [0]}], "nodes": [{"mesh": 0, "name": "Tri"}], + "meshes": [{"primitives": [{"attributes": {"POSITION": 0}}]}], + "buffers": [{"byteLength": len(pos)}], + "bufferViews": [{"buffer": 0, "byteLength": len(pos), "target": 34962}], + "accessors": [{"bufferView": 0, "componentType": 5126, "count": 3, "type": "VEC3", "min": [0,0,0], "max": [1,1,0]}]} +j = json.dumps(gltf).encode(); j += b" " * (-len(j) % 4) +b = pos + b"\0" * (-len(pos) % 4) +glb = struct.pack("<4sII", b"glTF", 2, 12 + 8 + len(j) + 8 + len(b)) + struct.pack("