Files

49 lines
2.5 KiB
GDScript
Raw Permalink Normal View History

2026-09-12 11:01:37 +02:00
extends SceneTree
var failures := 0
var count := 0
func _initialize() -> void: call_deferred("run")
func check(ok: bool, title: String) -> void:
count += 1
if not ok: failures += 1
print("PASS " if ok else "FAIL ", title)
func run() -> void:
var stage := Node3D.new()
root.add_child(stage)
QuarryShell.build(stage)
var wall: MeshInstance3D = stage.get_node("ContinuousStrataWall")
var bounds := wall.mesh.get_aabb()
check(bounds.position.y < -4 and bounds.end.y > 24, "backing buried below floor; scan peaks form the higher skyline")
check(stage.find_children("*", "CollisionObject3D", true, false).is_empty(), "landscape adds no gameplay collision")
var arrays := wall.mesh.surface_get_arrays(0)
var verts: PackedVector3Array = arrays[Mesh.ARRAY_VERTEX]
var normals: PackedVector3Array = arrays[Mesh.ARRAY_NORMAL]
check(Vector3(verts[0].x, 0, verts[0].z).dot(normals[0]) < 0, "wall normals face the playable interior")
wall.create_trimesh_collision()
await physics_frame
await physics_frame
# Offset rays from exact triangle seams to avoid physics edge precision misses.
var missed := 0
for height in [0.05, 1.7, 8.0, 16.0]:
for origin in [Vector3.ZERO, Vector3(35,0,50), Vector3(-35,0,-50)]:
origin.y = height
for angle in 360:
var direction := Vector3(cos(deg_to_rad(angle + 0.137)), 0, sin(deg_to_rad(angle + 0.137)))
var ray := PhysicsRayQueryParameters3D.create(origin, origin + direction * 250)
ray.hit_back_faces = true
if stage.get_world_3d().direct_space_state.intersect_ray(ray).is_empty():
missed += 1
check(missed == 0, "4320 perimeter rays find no gaps at floor/player/roof heights: misses=" + str(missed))
check(stage.get_node("BuriedQuarryApron").mesh.size == Vector2(220,250), "ground extends under entire cliff ring")
var rock := QuarryLandscape.sandstone(null)
check(rock is StandardMaterial3D and rock.albedo_texture != null and rock.normal_enabled, "scanned rock PBR preserves albedo and normals")
var floor_mat := UrbanMaterials.get_surface("sand")
check(floor_mat.albedo_texture != null and floor_mat.normal_texture != null and floor_mat.normal_scale >= 0.65, "sand floor uses real color and normal maps")
var seams := true
for j in QuarryShell.LEVELS.size(): seams = seams and QuarryShell.point(0,j).is_equal_approx(QuarryShell.point(QuarryShell.STEPS,j))
check(seams, "perimeter seam closes at every geological layer")
stage.queue_free()
await process_frame
print("QUARRY GRAPHICS RESULT ", count - failures, "/", count)
quit(1 if failures else 0)