Rebuild local Blender WASM environment and recovery evidence
This commit is contained in:
67
tools/web/check-wbv2-p2-003-desktop.py
Normal file
67
tools/web/check-wbv2-p2-003-desktop.py
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python3
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
OPERATIONS = ("Translate", "Merge", "Dissolve", "Extrude", "Inset", "Bevel", "LoopCut")
|
||||
|
||||
|
||||
def mesh_report(label):
|
||||
obj = bpy.data.objects.get("WBV2P2003%sObject" % label)
|
||||
if obj is None or obj.type != "MESH":
|
||||
raise RuntimeError("MESH_EDIT_INVALID: operation fixture object is missing")
|
||||
mesh = obj.data
|
||||
return {
|
||||
"objectId": "object:" + obj.name,
|
||||
"meshId": "mesh:" + mesh.name,
|
||||
"vertexCount": len(mesh.vertices),
|
||||
"edgeCount": len(mesh.edges),
|
||||
"faceCount": len(mesh.polygons),
|
||||
"triangleCount": sum(max(0, len(poly.vertices) - 2) for poly in mesh.polygons),
|
||||
"positionHash": hashlib.sha256(json.dumps([tuple(round(float(value), 6) for value in vertex.co) for vertex in mesh.vertices], separators=(",", ":")).encode()).hexdigest(),
|
||||
}
|
||||
|
||||
|
||||
def report():
|
||||
return {label: mesh_report(label) for label in OPERATIONS}
|
||||
|
||||
|
||||
def main():
|
||||
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
||||
if len(arguments) != 2:
|
||||
raise SystemExit("usage: blender -b --python check-wbv2-p2-003-desktop.py -- FIXTURE REPORT")
|
||||
fixture, output = (pathlib.Path(value).resolve() for value in arguments)
|
||||
bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=True)
|
||||
before = report()
|
||||
descriptor, temporary = tempfile.mkstemp(prefix="wbv2-p2-003-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=True)
|
||||
after = report()
|
||||
finally:
|
||||
pathlib.Path(temporary).unlink(missing_ok=True)
|
||||
if before != after:
|
||||
raise RuntimeError(f"MESH_EDIT_INVALID: desktop save/reopen drift: {before} != {after}")
|
||||
value = {
|
||||
"schemaVersion": 1,
|
||||
"task": "WBV2-P2-003",
|
||||
"operation": "MESH_EDIT_CORE_DESKTOP",
|
||||
"fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(),
|
||||
"meshes": 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("wbv2-p2-003-desktop-ok meshes=%d topology=quad saveReopen=exact" % len(after))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user