#!/usr/bin/env python3 import hashlib import json import os import pathlib import sys import tempfile import bpy def report(): volume = bpy.data.volumes.get("WebGapVolume") if volume is None: raise RuntimeError("WebGapVolume is missing") return {"id": "volume:" + volume.name, "name": volume.name, "sourcePath": volume.filepath, "displayDensity": float(volume.display.density), "interpolation": "NEAREST" if volume.display.interpolation_method == "CLOSEST" else "LINEAR", "stepSize": float(volume.render.step_size), "velocityGrid": volume.velocity_grid, "velocityScale": 1.0} def main(): arguments = sys.argv[sys.argv.index("--") + 1 :] if len(arguments) != 2: raise SystemExit("usage: blender -b --python check-volume-desktop.py -- FIXTURE REPORT") fixture, output = (pathlib.Path(value).resolve() for value in arguments) bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=False) before = report() descriptor, temporary = tempfile.mkstemp(prefix="m16-volume-reopen-", suffix=".blend", dir=fixture.parent) os.close(descriptor) try: bpy.ops.wm.save_as_mainfile(filepath=temporary, check_existing=False, compress=True) bpy.ops.wm.open_mainfile(filepath=temporary, load_ui=False) after = report() finally: pathlib.Path(temporary).unlink(missing_ok=True) if before != after: raise RuntimeError(f"volume save/reopen drift: {before} != {after}") value = {"schemaVersion": 1, "task": "M16-GAP-00026", "operation": "VOLUME_DATABLOCK_DESKTOP", "fixture": str(fixture), "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "volume": after, "saveReopen": "EXACT", "blenderVersion": bpy.app.version_string} output.parent.mkdir(parents=True, exist_ok=True) output.write_text(json.dumps(value, indent=2, sort_keys=True) + "\n", encoding="utf-8") print(f"volume-desktop-ok id={after['id']} density={after['displayDensity']} saveReopen=exact") if __name__ == "__main__": main()