extends SceneTree
## Gate: dc-terrain's Performance tunables exist, default to the values that were
## hard-coded before, accept a set, and the terrain panel builds a live row for each.
var ok := true
func _p(c: bool, m: String) -> void:
print(("ok " if c else "FAIL: ") + m)
if not c:
ok = false
func _initialize() -> void:
var t: Node = ClassDB.instantiate("DCTerrain")
_p(t != null, "DCTerrain instantiates")
if t == null:
quit(1); return
# max_splits_per_frame: 16, the budget that actually runs after the spawn burst.
# It read 4 (the octree header's default) while the real budget was a literal 16
# re-written every frame — hyper-games #88 Tier 1 #4.
var want := {"terrain_min_lod": 0, "edit_min_lod": -2, "max_splits_per_frame": 16,
"upload_budget_ms": 6.0, "upload_min_per_frame": 4, "collision_budget_ms": 4.0,
"premesh_queue_depth": 32, "premesh_min_per_frame": 4}
for p: String in want:
var v: Variant = t.get(p)
_p(v != null and is_equal_approx(float(v), float(want[p])), "%s defaults to %s (got %s)" % [p, str(want[p]), str(v)])
t.set("terrain_min_lod", 2)
t.set("upload_budget_ms", 12.5)
_p(int(t.get("terrain_min_lod")) == 2 and is_equal_approx(float(t.get("upload_budget_ms")), 12.5), "values set and read back")
var panel := VBoxContainer.new()
panel.set_script(load("res://scenes/game/terrain_panel.gd"))
root.add_child(t)
root.add_child(panel)
panel.call("setup", t)
var n := 0
for c in panel.get_children():
if c is HSlider and String((c as HSlider).tooltip_text) != "":
n += 1
var expected: int = (panel.get("PERF_KNOBS") as Array).size()
_p(n == expected, "panel built %d/%d Performance sliders" % [n, expected])
print("GATE perf_knobs: %s" % ("PASS" if ok else "FAIL"))
quit(0 if ok else 1)