From 56129b43d5074ab820e8d1f338ba92a910f5c174 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 12 Oct 2026 04:03:12 +0200 Subject: [PATCH] Package derives no mounts for a ship with no Ship Root, and refuses a framed one whose layout is not loaded smoke_package's hand-tagged ship has a weapon-mount object, no Ship Root and no loaded buffer; the first mounts commit refused it. A ship with no frame has no grid to derive from, so Package leaves its rows alone as before. A framed ship with a mount and an unloaded buffer is refused with 'Load Layout first'. All commits build. Co-Authored-By: Claude Opus 5.5 --- tools/blender/aetheria_ships/__init__.py | 6 +++--- tools/blender/tests/smoke_mounts.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/blender/aetheria_ships/__init__.py b/tools/blender/aetheria_ships/__init__.py index 154912ec6..913b1da57 100644 --- a/tools/blender/aetheria_ships/__init__.py +++ b/tools/blender/aetheria_ships/__init__.py @@ -399,7 +399,7 @@ def _plan_mounts(collection, state, root, path): """(row, weapon-mount object, Position, yaw) for every buffer row whose Transform names a weapon-mount object: the Position from the object's placement, the yaw from the row's Rotation. Refuses before anything changes.""" mounts = _mount_objects(collection) - if not mounts: + if not mounts or root is None: # a ship with no Ship Root has no grid to derive from: its rows are the author's return [] if state.ship_id != collection["aetheria.id"] or state.ship_cc != path: raise ValueError("Load Layout first: the weapon mounts need this ship's layout") @@ -407,8 +407,8 @@ def _plan_mounts(collection, state, root, path): if not paired: return [] origin = collection.get("aetheria.grid_origin") - if root is None or origin is None: - raise ValueError("Rasterise first: a mount needs the ship's Ship Root and grid") + if origin is None: + raise ValueError("Rasterise first: a mount needs the ship's grid") plan = [] for hp, obj in paired: if obj.parent != root: diff --git a/tools/blender/tests/smoke_mounts.py b/tools/blender/tests/smoke_mounts.py index 495a0ecc9..879781f3f 100644 --- a/tools/blender/tests/smoke_mounts.py +++ b/tools/blender/tests/smoke_mounts.py @@ -286,6 +286,16 @@ def main(): by_mount = {fields["Transform"]: fields for fields in map(aetheria_ships.ship_cc.decode_hardpoint, saved)} require(tuple(by_mount["weapon.1"]["Position"]) == (4, 3) and by_mount["weapon.2"]["Rotation"] == REVERSED and tuple(by_mount["reactor.a"]["Position"]) == (2, 2), "The .cc does not hold what Package derived") + # A framed ship whose layout buffer is not loaded cannot be derived from: Package refuses and changes nothing. + state = scene.aetheria_layout + ship_id, glb_before = state.ship_id, glb.read_bytes() + state.ship_id = "" + result, message = run(bpy.ops.aetheria.package_ship) + require(result == {"CANCELLED"} and "Load Layout first" in scene.aetheria_package_report + and all(name not in scene.aetheria_package_report for name in NAMES_NOT_ECHOED), + f"Package took an unloaded layout: {scene.aetheria_package_report}") + require(glb.read_bytes() == glb_before, "A refused Package wrote the GLB") + state.ship_id = ship_id print("PASS 3 package derives ok")