extends SceneTree
## SEED blender/geiss_terraces.tscn — the bridged scene holding TerraceGraph: Node3D
## "GeissTerraces" / MeshInstance3D "Terraces" (the object Blender sees) /
## ProcGeometryNode "ProcGeoNodes" (TerraceGraph.HOLDER_T), at the TKNOBS defaults.
##
## ⛔ SEED ONLY, as tools/build_undersea_geiss_graph.gd: once the scene exists it is the
## source of truth, so this refuses to overwrite it. TERRACE_SEED_OUT=<path> writes
## there instead (gates).
##
## Run: "$HYPER_TPS_GODOT" --headless --path . --script res://tools/build_terrace_graph.gd
func _init() -> void:
var dest := OS.get_environment("TERRACE_SEED_OUT")
if dest == "":
dest = TerraceGraph.SCENE_T
if FileAccess.file_exists(dest):
print("[seed_terraces] %s exists — it is the source of truth; not overwritten" % dest)
quit(1)
return
var root := Node3D.new()
root.name = "GeissTerraces"
var path := String(TerraceGraph.HOLDER_T).split("/") # ["Terraces", "ProcGeoNodes"]
var obj := MeshInstance3D.new()
obj.name = path[0]
root.add_child(obj)
obj.owner = root
var holder := ProcGeometryNode.new()
holder.name = path[1]
holder.set_graph(TerraceGraph.make_terraces())
obj.add_child(holder)
holder.owner = root
var ps := PackedScene.new()
var err := ps.pack(root)
if err == OK:
err = ResourceSaver.save(ps, dest)
# A --script save writes no uid; give the scene one so the editor and the bridge can
# refer to it stably.
if err == OK:
err = ResourceSaver.set_uid(dest, ResourceUID.create_id())
root.free()
print("[seed_terraces] %s: %s (%d nodes)" % [dest, error_string(err),
TerraceGraph.make_terraces().get_node_count()])
quit(0 if err == OK else 1)