Files
workinf_Blender_Wasm/tools/web/check-wbv2-p4-004-desktop.py
mes123456 c2c65d3a09
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Rebuild local Blender WASM environment and recovery evidence
2026-08-27 20:22:15 +08:00

46 lines
2.3 KiB
Python

#!/usr/bin/env python3
import hashlib
import json
import pathlib
import sys
import bpy
def state():
body = bpy.data.objects.get("WBV2P4004RigidBody")
floor = bpy.data.objects.get("WBV2P4004Collision")
if body is None or floor is None or body.rigid_body is None or floor.rigid_body is None:
raise RuntimeError("simulation fixture rigid-body data is missing")
return {
"body": {"name": body.name, "type": body.rigid_body.type, "shape": body.rigid_body.collision_shape, "mass": body.rigid_body.mass, "friction": body.rigid_body.friction, "restitution": body.rigid_body.restitution, "linearDamping": body.rigid_body.linear_damping, "angularDamping": body.rigid_body.angular_damping},
"collision": {"name": floor.name, "type": floor.rigid_body.type, "shape": floor.rigid_body.collision_shape},
"frame": [bpy.context.scene.frame_start, bpy.context.scene.frame_end, bpy.context.scene.frame_current],
}
def main():
arguments = sys.argv[sys.argv.index("--") + 1:]
if len(arguments) != 2:
raise SystemExit("usage: blender -b --factory-startup --python check-wbv2-p4-004-desktop.py -- FIXTURE REPORT")
fixture, report_path = (pathlib.Path(value).resolve() for value in arguments)
bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=False)
before = state()
temporary = fixture.with_name(f"{fixture.stem}-reopen.blend")
try:
bpy.ops.wm.save_as_mainfile(filepath=str(temporary), check_existing=False, compress=True)
bpy.ops.wm.open_mainfile(filepath=str(temporary), load_ui=False)
after = state()
finally:
temporary.unlink(missing_ok=True)
if before != after:
raise RuntimeError(f"simulation save/reopen drift: {before} != {after}")
report = {"schemaVersion": 1, "task": "WBV2-P4-004", "operation": "SIMULATION_CACHE_DESKTOP", "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "state": after, "saveReopen": "EXACT", "blenderVersion": bpy.app.version_string}
report_path.parent.mkdir(parents=True, exist_ok=True)
report_path.write_text(json.dumps(report, indent=2, sort_keys=True) + "\n", encoding="utf-8")
print("wbv2-p4-004-desktop-ok body=ACTIVE mass=2.5 collision=PASSIVE frames=1..4 saveReopen=exact")
if __name__ == "__main__":
main()