Add-on: an unparented Source mesh is loose; Package reports no library text
One frame predicate: _loose_meshes no longer exempts Source, so a mesh Rasterise reads is a mesh Flip Nose turns (it turns Ship Root's descendants) or the operator refuses and selects it. Package: the glTF exporter's RuntimeError is printed to the console and reported as fixed text; the validator's verdict goes to the console and the panel reports accepted or refused with the anchor count only (no ship ID, no anchor ID). smoke_frame and smoke_package pin each, five hand mutants caught. Every commit builds (Python only). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0906eb53e7
commit
47cc0c28db
3 changed files with 65 additions and 8 deletions
|
|
@ -455,6 +455,9 @@ def _export_glb(context, collection, filepath):
|
|||
bpy.ops.export_scene.gltf(
|
||||
filepath=filepath, export_format="GLB", use_active_collection=True, use_selection=True,
|
||||
export_extras=True, export_yup=True, export_apply=True)
|
||||
except RuntimeError: # the exporter's text holds paths and a traceback
|
||||
traceback.print_exc()
|
||||
raise RuntimeError("The GLB export failed; its message is in the system console") from None
|
||||
finally:
|
||||
for obj in view_layer.objects:
|
||||
obj.select_set(obj in previous_selection)
|
||||
|
|
@ -502,11 +505,13 @@ def _frame_meshes(collection):
|
|||
|
||||
|
||||
def _loose_meshes(collection):
|
||||
"""Meshes of a collection that has a Ship Root which sit outside Source and Generated and are not under the root."""
|
||||
"""Meshes of a collection that has a Ship Root which are not under the root, Generated's apart. Source meshes count:
|
||||
Rasterise reads them and Flip Nose turns only what hangs from Ship Root."""
|
||||
root = _ship_root(collection)
|
||||
if root is None:
|
||||
return []
|
||||
derived = _derived_names(collection)
|
||||
generated = _child(collection, GENERATED)
|
||||
derived = {obj.name for obj in generated.all_objects} if generated else set()
|
||||
framed = {obj.name for obj in root.children_recursive}
|
||||
return [obj for obj in _meshes(collection.all_objects) if obj.name not in derived and obj.name not in framed]
|
||||
|
||||
|
|
@ -792,10 +797,14 @@ class AETHERIA_OT_package_ship(bpy.types.Operator):
|
|||
scene.aetheria_package_report = f"Package failed: {_failure_text(exc)}"
|
||||
self.report({"ERROR"}, scene.aetheria_package_report)
|
||||
return {"CANCELLED"}
|
||||
scene.aetheria_package_report = message or f"validate exited {code}"
|
||||
if message:
|
||||
print(message)
|
||||
if code != 0:
|
||||
self.report({"ERROR"}, f"Packaged {len(anchors)} anchors; the validator refused it: {scene.aetheria_package_report}")
|
||||
scene.aetheria_package_report = (f"Packaged {len(anchors)} anchors; the validator refused the ship; "
|
||||
"its message is in the system console")
|
||||
self.report({"ERROR"}, scene.aetheria_package_report)
|
||||
return {"CANCELLED"}
|
||||
scene.aetheria_package_report = f"Packaged {len(anchors)} anchors; the validator accepted the ship"
|
||||
self.report({"INFO"}, scene.aetheria_package_report)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
|
|
|||
|
|
@ -358,6 +358,15 @@ def main():
|
|||
require(row_count(after, height - 1) == aft and row_count(after, 0) == forward,
|
||||
"Flip Nose did not move the nub's cells from the aft rows to the forward rows")
|
||||
require({(width - 1 - x, height - 1 - y) for x, y in before} == after, "The flipped grid is not the turned grid")
|
||||
# A Source mesh that is not parented to Ship Root is loose too: Rasterise would read it and Flip Nose would not turn it.
|
||||
sphere = bpy.data.objects["Source Sphere"]
|
||||
sphere.parent = None
|
||||
for operator, what in ((bpy.ops.aetheria.flip_nose, "Flip Nose"), (bpy.ops.aetheria.rasterise_hull, "Rasterise")):
|
||||
select(render)
|
||||
refused(operator, "1 meshes in the ship collection are not under Ship Root", f"{what} with an unparented Source mesh")
|
||||
require(sphere.select_get(), f"{what} did not select the unparented Source mesh")
|
||||
sphere.parent = root
|
||||
select(render)
|
||||
print("PASS 5 loose meshes, rasterise and flip nose ok")
|
||||
|
||||
# Pass 6: Package refuses an unsaved buffer, then the saved one validates; the GLB leaves Source and Grid out.
|
||||
|
|
@ -387,6 +396,35 @@ def main():
|
|||
print(f"GLB nodes: {sorted(n for n in names if n)}")
|
||||
require("Hull" in names and "Loose Nub" in names, "The GLB lacks the render meshes")
|
||||
require("Source Sphere" not in names and "Grid" not in names, "The GLB holds the Source or the Grid")
|
||||
require("the validator accepted the ship" in report and not any(name in report for name in NAMES_NOT_ECHOED),
|
||||
f"Package's report is not the fixed text: {report}")
|
||||
# A library error is the console's, not the panel's: a directory where ship.glb goes fails the exporter.
|
||||
glb = Path(path).with_name("ship.glb")
|
||||
glb.unlink()
|
||||
glb.mkdir()
|
||||
try:
|
||||
result, message = run(bpy.ops.aetheria.package_ship)
|
||||
report = scene.aetheria_package_report
|
||||
finally:
|
||||
glb.rmdir()
|
||||
require(result == {"CANCELLED"} and "The GLB export failed" in report, f"A failed GLB export was not refused: {report}")
|
||||
require("Traceback" not in report and not any(name in report for name in NAMES_NOT_ECHOED),
|
||||
f"A library error reached the report: {report}")
|
||||
real_visual = aetheria_ships.replace_visual
|
||||
|
||||
def unwritable(*args, **kwargs):
|
||||
raise OSError(f"probe: cannot write {path}")
|
||||
|
||||
aetheria_ships.replace_visual = unwritable
|
||||
try:
|
||||
result, message = run(bpy.ops.aetheria.package_ship)
|
||||
report = scene.aetheria_package_report
|
||||
finally:
|
||||
aetheria_ships.replace_visual = real_visual
|
||||
require(result == {"CANCELLED"} and report == "Package failed: Stopped by OSError; see the system console",
|
||||
f"A library error of another type is not reported by its type alone: {report}")
|
||||
result, message = run(bpy.ops.aetheria.package_ship)
|
||||
require(result == {"FINISHED"}, f"Package after the failed export was refused: {scene.aetheria_package_report}")
|
||||
print("PASS 6 package ok")
|
||||
guards_pass(aetheria_ships)
|
||||
print("PASS 7 guards ok")
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ unsaved .blend stores the absolute path, which still resolves after Save As to t
|
|||
the .blend is saved there before the final bind, so the bind crosses drives and the package passes prove it resolves.
|
||||
"""
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
|
@ -117,14 +119,20 @@ def bind_cases(ship, path, mods):
|
|||
raise SystemExit("Bind case cross-drive: the stored path is not the absolute .cc path")
|
||||
|
||||
|
||||
CONSOLE = [] # what the last package() sent to the system console
|
||||
|
||||
|
||||
def package(addon):
|
||||
# An operator that reports an error raises it out of bpy.ops; the panel's report is the verdict either way.
|
||||
console = io.StringIO()
|
||||
try:
|
||||
result = bpy.ops.aetheria.package_ship()
|
||||
with contextlib.redirect_stdout(console):
|
||||
result = bpy.ops.aetheria.package_ship()
|
||||
except RuntimeError:
|
||||
result = {"CANCELLED"}
|
||||
CONSOLE[:] = [console.getvalue()]
|
||||
report = bpy.context.scene.aetheria_package_report
|
||||
print(f"PACKAGE {sorted(result)}: {report}")
|
||||
print(f"PACKAGE {sorted(result)}: {report}{CONSOLE[0]}")
|
||||
return result, report
|
||||
|
||||
|
||||
|
|
@ -180,8 +188,10 @@ def main():
|
|||
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")
|
||||
if result != {"CANCELLED"} or "the validator refused the ship" not in report or "thruster" in report or SHIP_ID in report:
|
||||
raise SystemExit("Pass 2: an empty thruster node was not refused with the fixed text")
|
||||
if "thruster-emitter anchor thruster needs a mesh" not in CONSOLE[0]:
|
||||
raise SystemExit("Pass 2: the validator's message naming the anchor did not reach the system console")
|
||||
|
||||
ship.objects.unlink(hollow)
|
||||
ship.objects.link(disc)
|
||||
|
|
|
|||
Loading…
Reference in a new issue