Files
IntoHole/playtest/checks/validate_solid_chutes.gd
Yanchen d1141b04c7 feat: 更新 IntoHole 的球体、滑槽和环境资产
- 为铁球、陶瓷球和木球制作风格化材质,归档 CC0 原始参考
- 更新方形球洞和实心滑槽,统一 90° 弯槽并兼容旧存档
- 用顺流泡沫表示水流方向,为冰块制作三种交错的裂纹
- 同步 Blender 源资产、Godot 加载、工坊和试玩预览
2026-11-19 16:18:41 +08:00

112 lines
4.8 KiB
GDScript

# Headless regression checks for the exported meshes; no playable test scene.
extends SceneTree
const Styled = preload("res://runtime/asset_library.gd")
const Baseline = preload("res://playtest/baseline/scripts/asset_library.gd")
const KINDS = ["straight", "turn_90", "gentle", "steep", "y_merge"]
var trials: Array = []
var results: Array = []
func _initialize() -> void:
call_deferred("run")
func check(name: String, passed: bool, detail: Dictionary = {}) -> void:
results.append({"name":name,"passed":passed,"detail":detail})
print(("PASS " if passed else "FAIL ")+name)
func run() -> void:
Engine.physics_ticks_per_second = 120
var arena := Node3D.new()
root.add_child(arena)
for family in ["baseline", "styled"]:
var lib = Baseline.new() if family == "baseline" else Styled.new()
for kind in KINDS:
for q in range(4):
for probe in ["side", "bottom", "top"]:
var origin := Vector3(trials.size()%12*12,0,trials.size()/12*12)
var basis := Basis(Vector3.UP,-q*PI/2)
arena.add_child(lib.create_piece(kind,origin,q))
var sphere = lib.create_ball()
sphere.freeze = true
arena.add_child(sphere)
var half := 1.0 if kind == "y_merge" else .5
var start := Vector3(-.5 if kind == "y_merge" else 0,.34,half+.65)
var velocity := Vector3(0,0,-3)
var target := Vector3.ZERO
var exit_direction := Vector3.ZERO
if probe == "bottom":
start = Vector3(0,-1,0)
velocity = Vector3(0,3,0)
elif probe == "top":
var descending: bool = kind in ["gentle", "steep"]
start = lib.ball_on_surface(kind,.80 if descending else .05)
velocity = Vector3.ZERO if descending else lib.path_tangent(kind,0)*1.2
target = lib.ball_on_surface(kind,0 if descending else 1)
exit_direction = -lib.path_tangent(kind,0) if descending else lib.path_tangent(kind,1)
sphere.gravity_scale = 1 if probe == "top" else 0
sphere.position = origin+basis*start
trials.append({"name":"%s_%s_r%d_%s"%[family,kind,q*90,probe],
"ball":sphere,"origin":origin,"basis":basis,"probe":probe,"half":half,
"velocity":basis*velocity,"target":target,"exitDirection":exit_direction,
"minZ":start.z,"maxY":start.y,"contacts":0,"reached":false})
await physics_frame
await physics_frame
for trial in trials:
trial.ball.freeze = false
trial.ball.linear_velocity = trial.velocity
if trial.probe == "top":
trial.ball.angular_velocity = Vector3.UP.cross(trial.velocity)/trial.ball.radius
for frame in range(720):
await physics_frame
for trial in trials:
if trial.reached: continue
var sphere = trial.ball
var point: Vector3 = trial.basis.inverse()*(sphere.position-trial.origin)
trial.minZ = minf(trial.minZ,point.z)
trial.maxY = maxf(trial.maxY,point.y)
if sphere.contact_count > 0: trial.contacts += 1
if trial.probe == "top":
var delta: Vector3 = point-trial.target
var axial: float = delta.dot(trial.exitDirection)
if axial > .04 and (delta-trial.exitDirection*axial).length() < .22:
trial.reached = true
sphere.freeze = true
for trial in trials:
var passed: bool = trial.contacts > 0
if trial.probe == "side": passed = passed and trial.minZ >= trial.half+.3-.035
elif trial.probe == "bottom": passed = passed and trial.maxY <= -.3+.035
else: passed = passed and trial.reached
check(trial.name,passed,{"contactFrames":trial.contacts,"minLocalZ":trial.minZ,
"maxLocalY":trial.maxY,"reachedTopExit":trial.reached})
root.remove_child(arena)
arena.queue_free()
await process_frame
# The deleted preset must not shift the remaining menu onto a wrong layout.
var baseline = load("res://playtest/baseline/scenes/main.tscn").instantiate()
root.add_child(baseline)
for i in range(baseline.scenarios.size()):
baseline.build_preset(i)
await process_frame
check("preset_"+baseline.scenarios[i].id,not baseline.records.is_empty())
check("four_remaining_presets",baseline.mode_selector.item_count == 4)
check("merge_balls_preserved",baseline.merge_balls.size() == 2)
root.remove_child(baseline)
baseline.queue_free()
await process_frame
var workshop = load("res://designer/scenes/workshop.tscn").instantiate()
root.add_child(workshop)
await process_frame
check("workshop_examples_exist",workshop.EXAMPLE_LEVELS.all(func(path): return FileAccess.file_exists(path)))
root.remove_child(workshop)
workshop.queue_free()
await process_frame
var failed := 0
for result in results:
if not result.passed: failed += 1
var file := FileAccess.open("res://playtest/artifacts/styled/solid_chutes_report.json",FileAccess.WRITE)
file.store_string(JSON.stringify({"engine":Engine.get_version_info().string,
"geometryRevision":"solid_base_v1","passed":results.size()-failed,"failed":failed,"checks":results}," "))
file.close()
print("SOLID_CHUTES_CHECKS ",results.size()-failed," passed, ",failed," failed")
quit(1 if failed else 0)