Files
IntoHole/assets/collections/storybook/source/verify.py
T
Yanchen 39ff1fd7b4 feat: 建立关卡工坊并整理项目目录
- 加入 Godot 基础试玩、画风展示和通孔验证场景
- 支持自由放球、多层叠放、墙壁、锥口球洞及固定 +5 m/s 定向加速方块
- 保存 Blender 源资产、模型导出、资源制作脚本和关卡编辑存档逻辑
- 按七类目录归档工程,集中 zsh 启动入口并补充 AGENTS.md 文件索引
- 同步设计规则、依赖锁定、验证报告和目录迁移记录

验证:目录迁移后的资源导入与四个场景加载通过;本次提交前检查暂存内容,未重复运行整套物理测试。
2026-11-16 11:12:21 +08:00

69 lines
3.5 KiB
Python

"""Reopen every delivered .blend and compare physical meshes with the snapshot."""
import bpy
import bmesh
import hashlib
import json
from pathlib import Path
ROOT=Path(__file__).resolve().parents[4]
SOURCE=Path(__file__).resolve().parent/'snapshot'
catalog=json.loads((ROOT/'assets/collections/storybook/catalog.json').read_text())
bpy.ops.wm.open_mainfile(filepath=str(SOURCE/'source_snapshot.blend'))
def geometry(obj):
return ([list(v.co) for v in obj.data.vertices],
[list(p.vertices) for p in obj.data.polygons])
baseline={kind:geometry(bpy.data.objects[kind]) for kind in catalog['models'] if kind in bpy.data.objects}
checks=[]
for kind,data in catalog['models'].items():
path=ROOT/data['sourceBlend']
bpy.ops.wm.open_mainfile(filepath=str(path))
obj=bpy.data.objects[kind]
physical=[o for o in bpy.context.scene.objects if not o.name.startswith('ink_')]
authored=data.get('geometryOrigin')=='authored'
mesh_match=None if authored else geometry(obj)==baseline[kind]
correct=(len(physical)==1 and physical[0].name==kind and
(authored or mesh_match) and obj.location.length<1e-6 and
all(abs(x-1)<1e-6 for x in obj.scale))
check={'id':kind,'passed':correct,'objects':[o.name for o in bpy.context.scene.objects],
'geometryMatchesSnapshot':mesh_match,
'origin':list(obj.location),'dimensions':list(obj.dimensions),
'materials':[m.name for m in obj.data.materials]}
if kind=='iron_ball':
radius=max(v.co.length for v in obj.data.vertices)
check['measuredRadius']=radius
correct=correct and abs(radius-data['radius'])<1e-6
check['passed']=correct
if authored:
bm=bmesh.new();bm.from_mesh(obj.data)
volume=abs(bm.calc_volume(signed=True));closed=all(e.is_manifold for e in bm.edges);bm.free()
correct=correct and closed and all(abs(d-1)<1e-6 for d in obj.dimensions)
if kind in ('wall','directional_boost'):
correct=correct and abs(volume-1)<1e-6
if kind=='directional_boost':
arrow=bpy.data.objects.get('ink_boost_arrow_fill')
correct=correct and arrow is not None
if arrow is not None:
points=[v.co for v in arrow.data.vertices]
tip=max(points,key=lambda v:v.x)
correct=correct and tip.x>0 and abs(tip.y)<1e-6 and all(1<v.z<1.01 for v in points)
check['arrowTipBlender']=list(tip)
else:
rings={}
for vertex in obj.data.vertices:
z=round(vertex.co.z,5);radius=round((vertex.co.x**2+vertex.co.y**2)**.5,5)
rings.setdefault(str(z),set()).add(radius)
correct=correct and rings=={'0.0':{.46,.5},'-0.35':{.32},'-1.0':{.32,.36}}
check['measuredRings']={k:sorted(v) for k,v in rings.items()}
check.update({'passed':correct,'closedManifold':closed,'solidVolume':volume})
checks.append(check)
manifest=json.loads((SOURCE/'source_manifest.json').read_text())
source_status={p:hashlib.sha256((ROOT/p).read_bytes()).hexdigest()==sha
for p,sha in manifest['files'].items()}
result={'passed':sum(c['passed'] for c in checks),'failed':sum(not c['passed'] for c in checks),
'baselineStillMatchesSnapshot':source_status,'checks':checks}
(ROOT/'playtest/artifacts/styled/reopened_assets.json').write_text(json.dumps(result,indent=2))
if result['failed']:raise RuntimeError('Standalone source asset verification failed')
print('REOPENED_ASSETS_VERIFIED',result['passed'])