Datasets:
File size: 4,036 Bytes
3e8a75e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | # Loads each GLB listed in a text file the way a Godot game does after the editor imported it (res:// paths in a project
# that ran `--headless --import`; lib/godot.mjs builds that project) and prints one JSON line per file: {"file", "ok",
# "meshes", "bones", "animations", "seconds", "moved_metres", "error"}. An animated file must also play: its first
# animation is sought to nine points and some bone or node must move more than a centimetre from the first frame.
# The runtime importer (GLTFDocument.append_from_file) crashed Godot 4.7.2 with signal 11 on the skinned clips, 2026-11-05.
# Usage: Godot_v4.7.2-stable_win64_console.exe --headless --path <project> --script godot_check.gd -- <res_paths.txt>
extends SceneTree
func count_nodes(root: Node, type_name: String) -> Array:
var found := []
if root.is_class(type_name):
found.append(root)
for child in root.get_children():
found.append_array(count_nodes(child, type_name))
return found
# Bones and every Node3D: a clip on plain nodes (Perseverance's wheels and arm) moves the parts below the node it turns.
func moving_positions(skeletons: Array, nodes: Array) -> Array:
var positions := []
for skeleton in skeletons:
skeleton.force_update_all_bone_transforms()
for bone in skeleton.get_bone_count():
positions.append(skeleton.get_bone_global_pose(bone).origin)
for node in nodes:
positions.append(node.global_position)
return positions
func check_file(file_path: String) -> Dictionary:
var record := {"file": file_path, "ok": false}
var packed: PackedScene = load(file_path)
if packed == null:
record["error"] = "the editor import gave no scene"
return record
var scene: Node = packed.instantiate()
root.add_child(scene)
var meshes := count_nodes(scene, "MeshInstance3D")
var skeletons := count_nodes(scene, "Skeleton3D")
var players := count_nodes(scene, "AnimationPlayer")
var spatial_nodes := count_nodes(scene, "Node3D")
var bones := 0
for skeleton in skeletons:
bones += skeleton.get_bone_count()
record["meshes"] = meshes.size()
record["bones"] = bones
record["animations"] = 0
var played := true
if players.size() > 0:
var player: AnimationPlayer = players[0]
var names := player.get_animation_list()
record["animations"] = names.size()
if names.size() > 0:
var length := player.get_animation(names[0]).length
record["seconds"] = length
# Manual processing: the script runs before the tree's first frame, so the player is stepped by hand.
player.callback_mode_process = AnimationMixer.ANIMATION_CALLBACK_MODE_PROCESS_MANUAL
player.play(names[0])
player.seek(0.0, true)
player.advance(0.0)
var first_frame := moving_positions(skeletons, spatial_nodes)
# Nine points through the clip: an idle clip barely moves at any single one (Rushed_ID, 9 mm at 37 %).
var moved := 0.0
for step in range(1, 10):
player.seek(length * step / 10.0, true)
player.advance(0.0)
var posed := moving_positions(skeletons, spatial_nodes)
for index in posed.size():
moved = max(moved, posed[index].distance_to(first_frame[index]))
record["moved_metres"] = moved
played = moved > 0.01
record["ok"] = (meshes.size() > 0 or bones > 0) and played
if not record["ok"]:
record["error"] = "no mesh or skeleton" if played else "the first animation does not move anything"
scene.queue_free()
return record
var pending_files := []
func _initialize() -> void:
var list_file := FileAccess.open(OS.get_cmdline_user_args()[0], FileAccess.READ)
while not list_file.eof_reached():
var line := list_file.get_line().strip_edges()
if not line.is_empty():
pending_files.append(line)
# One file per frame: an AnimationPlayer only updates its skeleton inside the running tree, which _initialize is not.
func _process(_delta: float) -> bool:
if pending_files.is_empty():
return true
print(JSON.stringify(check_file(pending_files.pop_front())))
return pending_files.is_empty()
|