Rebuild local Blender WASM environment and recovery evidence
This commit is contained in:
74
tools/web/check-wbv2-p4-003-desktop.py
Normal file
74
tools/web/check-wbv2-p4-003-desktop.py
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python3
|
||||
import hashlib
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def mesh_record(obj):
|
||||
mesh = obj.data
|
||||
mask = mesh.attributes.get(".sculpt_mask")
|
||||
face_sets = mesh.attributes.get(".sculpt_face_set")
|
||||
if mask is None or face_sets is None:
|
||||
raise RuntimeError("sculpt attributes are missing")
|
||||
return {
|
||||
"name": obj.name,
|
||||
"vertexCount": len(mesh.vertices),
|
||||
"faceCount": len(mesh.polygons),
|
||||
"mask": [round(item.value, 6) for item in mask.data],
|
||||
"faceSets": [item.value for item in face_sets.data],
|
||||
}
|
||||
|
||||
|
||||
def nonmesh_record():
|
||||
curve = bpy.data.curves.get("WBV2P4003Curve")
|
||||
point_cloud = bpy.data.pointclouds.get("WBV2P4003PointCloud")
|
||||
if curve is None or point_cloud is None:
|
||||
raise RuntimeError("non-mesh fixture data is missing")
|
||||
return {
|
||||
"curve": {"name": curve.name, "splineCount": len(curve.splines), "pointCount": sum(len(item.bezier_points) + len(item.points) for item in curve.splines)},
|
||||
"pointCloud": {"name": point_cloud.name, "pointCount": len(point_cloud.points)},
|
||||
}
|
||||
|
||||
|
||||
def state():
|
||||
obj = bpy.data.objects.get("WBV2P4003SculptObject")
|
||||
if obj is None or obj.type != "MESH":
|
||||
raise RuntimeError("sculpt object is missing")
|
||||
return {"mesh": mesh_record(obj), "nonMesh": nonmesh_record()}
|
||||
|
||||
|
||||
def main():
|
||||
arguments = sys.argv[sys.argv.index("--") + 1:]
|
||||
if len(arguments) != 2:
|
||||
raise SystemExit("usage: blender -b --factory-startup --python check-wbv2-p4-003-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"sculpt/non-mesh save/reopen drift: {before} != {after}")
|
||||
report = {
|
||||
"schemaVersion": 1,
|
||||
"task": "WBV2-P4-003",
|
||||
"operation": "SCULPT_NONMESH_PAINT_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-003-desktop-ok vertices=5 faces=5 curvePoints=3 pointCloudPoints=3 saveReopen=exact")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user