Package Ship: headless Blender smoke, and the authoring doc says how Package and create --like are used

smoke_package.py builds a primitive ship from role-tagged objects, creates it --like Djinni, saves a layout with an
internal reactor, packages it and requires validate to pass; then swaps the thruster disc for an empty and requires the
refusal naming the anchor; then restores and packages again so the left-behind package is good. Proof gate 2's
outstanding authoring action is now Package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-03 17:13:44 +02:00
commit 7d649d5c31
2 changed files with 161 additions and 6 deletions

View file

@ -34,7 +34,8 @@ hull shape and hardpoint slots of the `aetheria.hulldata` record beside it. To t
to Blender's add-on search path, enable `brokkr_bridge` then
`aetheria_ships`, and install `msgpack` into Blender's Python environment.
Create a draft with `dotnet run --project tools/AetherDb -- ship-authoring
create <ship.cc> <stable-id> <name>`, choose that `.cc` in the **Aetheria
create <ship.cc> <stable-id> <name> [--like <shipped hull name>]`; `--like Djinni`
copies that shipped ship's stats and leaves the body and layout empty. Choose that `.cc` in the **Aetheria
Ship** panel, select an object in its ship collection, and press **Bind Ship
Collection**. The collection stores `aetheria.asset_kind=ship`, the stable
`aetheria.id`, and a relative `.cc` path. Select a Grease Pencil object in
@ -51,8 +52,20 @@ assets, lines, the record key, and schema. Save rejects a changed ship ID or
layout revision; reload first if another editor changed those fields. A line
capture leaves the loaded layout revision intact. The saved layout is a draft until
its mount IDs resolve to visual anchors and C# validation passes.
**Package Ship** turns the bound collection into the package. Tag each anchor
object with the custom properties `aetheria.role` (`map-icon`, `hull-collider`,
`shield`, `tractor`, `thruster-emitter`, `radiator-mesh`, `weapon-mount`,
`weapon-muzzle`) and `aetheria.id` (the hardpoint's mount ID for a mount),
plus `aetheria.order` if a weapon has several muzzles. Parent a muzzle to its
weapon mount object. Thrusters and radiators are mesh objects; the others may
be empties. Package exports the collection, Grease Pencil excluded, to
`ship.glb` beside the `.cc`, writes the anchors, captures the lines when the
collection holds exactly one Grease Pencil object, and shows AetherDb's
verdict in the panel. It runs `dotnet run --project <repo>/tools/AetherDb`;
the repo is the add-on preference **Aetheria repo**, or by default the nearest
folder above the `.cc` holding `tools/AetherDb`.
`ship-authoring inspect <ship.cc>` reads drafts; `validate` requires complete
hull, model, and anchor authoring.
hull, model, and anchor authoring, and judges `ship.glb` once it exists.
## Objective
@ -186,10 +199,13 @@ catalog. Continue refuses a run naming a design the catalog no longer holds
1. A typed `.cc` record round-trips between C# and Blender's Python runtime,
preserving unknown future fields and record identity.
2. Blender edits schematic cells and hardpoints in that record. Stable visual
node IDs still need a collection-to-package authoring action; the C#
validator checks their association with mount IDs and GLB nodes. The model
supplies geometry, not a second copy of hull semantics.
2. Blender edits schematic cells and hardpoints in that record. **Package
Ship** writes the anchors and `ship.glb` from the bound collection: each
object tagged `aetheria.role` becomes an anchor whose id, and GLB node
`aetheria.id`, is the object's `aetheria.id`. It then runs
`AetherDb ship-authoring validate`, which judges the GLB too: node ids,
and a mesh under every thruster and radiator anchor. The model supplies
geometry, not a second copy of hull semantics.
3. A command-line validator rejects malformed cells, overlapping or dangling
hardpoints, missing model nodes, and unresolved asset references with
precise errors. It changes no live catalog or scene on failure. The

View file

@ -0,0 +1,139 @@
"""Headless Blender smoke for the Package Ship action, end to end.
blender --background --factory-startup --python tools/blender/tests/smoke_package.py
Environment: CULTLIB_PACKAGES (CultLib's packages directory, as test_ship_cc.py), and whatever AetherDb's build needs
(CULTLIB_ROOT and CULTMATH_ROOT at the pinned revisions), since the add-on runs 'dotnet run --project tools/AetherDb'.
SMOKE_MODS names the mods directory to write into (default: a new temp directory); the package is left there so the
Unity play smoke can load it, and its path is printed as SMOKE_PACKAGE=<ship.cc>.
Pass 1 packages a primitive ship built from role-tagged objects and requires the C# validator to accept it. Pass 2 swaps
the thruster disc for an empty of the same id and requires the validator to refuse it, naming the anchor. Pass 3 puts
the disc back and packages again, so the package left behind is the good one.
"""
import os
import sys
import tempfile
import traceback
from pathlib import Path
import addon_utils
import bpy
REPO = Path(__file__).resolve().parents[3]
PACKAGES = os.environ.get("CULTLIB_PACKAGES") or sys.exit("Set CULTLIB_PACKAGES to CultLib's packages directory")
SHIP_ID = "smoke.gale"
def tetrahedron(name):
mesh = bpy.data.meshes.new(name)
mesh.from_pydata([(0, 0, 0), (1, 0, 0), (0, 1, 0), (0, 0, 1)], [], [(0, 2, 1), (0, 1, 3), (0, 3, 2), (1, 2, 3)])
return mesh
def quad(name, size=1.0):
mesh = bpy.data.meshes.new(name)
half = size / 2
mesh.from_pydata([(-half, -half, 0), (half, -half, 0), (half, half, 0), (-half, half, 0)], [], [(0, 1, 2, 3)])
return mesh
def tagged(collection, name, data, role=None, anchor_id=None, location=(0, 0, 0), parent=None):
obj = bpy.data.objects.new(name, data)
obj.location = location
if role:
obj["aetheria.role"] = role
obj["aetheria.id"] = anchor_id
obj.parent = parent
collection.objects.link(obj)
return obj
def package(addon):
# An operator that reports an error raises it out of bpy.ops; the panel's report is the verdict either way.
try:
result = bpy.ops.aetheria.package_ship()
except RuntimeError:
result = {"CANCELLED"}
report = bpy.context.scene.aetheria_package_report
print(f"PACKAGE {sorted(result)}: {report}")
return result, report
def main():
sys.path.insert(0, str(REPO / "tools" / "blender"))
addon_utils.enable("aetheria_ships", default_set=True, handle_error=None)
import aetheria_ships
# Brokkr is the Blender host's CultLib path provider and is not installed in a factory-startup Blender.
aetheria_ships._brokkr_cultlib = lambda context: PACKAGES
bpy.context.preferences.addons["aetheria_ships"].preferences.aetheria_repo = str(REPO)
mods = Path(os.environ.get("SMOKE_MODS") or tempfile.mkdtemp(prefix="aetheria-smoke-mods-"))
path = str(mods / SHIP_ID / "ship.cc")
if Path(path).exists():
raise SystemExit(f"{path} already exists; point SMOKE_MODS at an empty directory")
code, message = aetheria_ships._aetherdb(bpy.context, path, "create", path, SHIP_ID, "Smoke Gale", "--like", "Djinni")
print(f"CREATE {code}: {message}")
if code != 0:
raise SystemExit("create --like Djinni failed")
scene = bpy.context.scene
ship = bpy.data.collections.new("Smoke Gale")
scene.collection.children.link(ship)
hull = tagged(ship, "Hull", tetrahedron("Hull"))
tagged(ship, "Map Icon", quad("Map Icon"), "map-icon", "map", (0, 0, -1))
tagged(ship, "Hull Collider", tetrahedron("Hull Collider"), "hull-collider", "collider")
tagged(ship, "Shield", None, "shield", "shield")
tagged(ship, "Tractor", None, "tractor", "tractor", (0, 2, 0))
disc = tagged(ship, "Thruster", quad("Thruster", 0.4), "thruster-emitter", "thruster", (0, -1, 0))
gun = tagged(ship, "Gun", None, "weapon-mount", "gun", (1, 0, 0))
tagged(ship, "Gun Muzzle", None, "weapon-muzzle", "gun.muzzle", (0, 0.5, 0), parent=gun)
tagged(ship, "Radiator", quad("Radiator", 0.5), "radiator-mesh", "radiator", (-1, 0, 0))
scene.aetheria_ship_cc_path = path
bpy.context.view_layer.objects.active = hull
if bpy.ops.aetheria.bind_ship_collection() != {"FINISHED"}:
raise SystemExit("Bind Ship Collection failed")
ship_cc = aetheria_ships.ship_cc
_, _, revision = ship_cc.read_layout(path, PACKAGES)
def hardpoint(kind, x, mount):
return ship_cc.encode_hardpoint(Type=ship_cc.HARDPOINT_TYPE_NAMES.index(kind), Position=[x, 0],
Shape=[[1, 1, [True]]], Transform=mount, Rotation=0, Armor=0.0, FiringArc=0.0)
ship_cc.replace_layout(path, PACKAGES, SHIP_ID, revision, [4, 1, [True] * 4], [
hardpoint("Thruster", 0, "thruster"), hardpoint("Radiator", 1, "radiator"),
hardpoint("Energy", 2, "gun"), hardpoint("Reactor", 3, "reactor")])
result, report = package(aetheria_ships)
if result != {"FINISHED"}:
raise SystemExit("Pass 1: the validator refused the primitive ship")
ship.objects.unlink(disc)
hollow = tagged(ship, "Thruster Empty", None, "thruster-emitter", "thruster", (0, -1, 0))
result, report = package(aetheria_ships)
if result != {"CANCELLED"} or "thruster-emitter anchor thruster needs a mesh" not in report:
raise SystemExit("Pass 2: an empty thruster node was not refused by name")
ship.objects.unlink(hollow)
ship.objects.link(disc)
result, report = package(aetheria_ships)
if result != {"FINISHED"}:
raise SystemExit("Pass 3: the restored ship was refused")
print(f"SMOKE_PACKAGE={path}")
print("SMOKE_PACKAGE_OK")
try:
main()
except SystemExit as stop:
print(f"SMOKE_PACKAGE_FAILED: {stop}", flush=True)
os._exit(1)
except Exception:
traceback.print_exc()
print("SMOKE_PACKAGE_FAILED", flush=True)
os._exit(1)
sys.stdout.flush()
os._exit(0)