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")