7b6a141767
Move the 40-odd root-level scripts and scenes into a tree that groups by role,
per the approved roadmap (WS2/WS3): actors/{player,matador,bear}, systems/{combat,
fx,input,debug,render,crowd,config}, ui/, props/ (was tscn_s/). Rename the shell
scene.tscn -> levels/game_shell.tscn and every PascalCase scene to snake_case
(Player.tscn -> player.tscn, MainMenu.tscn -> main_menu.tscn, etc.) so the
case-insensitive web/macOS filesystems can't alias two files together.
Done as a scripted move: each file travels with its .uid; every quoted res:// path
across scenes, scripts, .tres, and project.godot's 9 autoloads is rewritten; the
.godot uid/class cache is rebuilt from scratch. Scenes still resolve by uid, so the
rewrite is belt-and-suspenders. Lint globs (run_tests.sh + both CI workflows) now
walk the new dirs; an orphan animation_tree.gd.uid and 7 pre-existing trailing-
whitespace lints (barrel/torch, never covered by the old root-only glob) are cleaned.
Full suite green on both sides. Asset consolidation (Assets/Animations/fonts ->
art/) is deferred — moving imported .glb/.png/.ttf is safer done in the editor.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017KoYBYQgRyY1zDHXMsXY3V
94 lines
3.1 KiB
GDScript
94 lines
3.1 KiB
GDScript
extends SceneTree
|
|
## Guard for the web/mobile rigid-skin conversion (rigid_skin.gd). The bug it protects against:
|
|
## the converter used to key geometry by destination bone only, so every surface funnelled to a
|
|
## bone collapsed onto one material — matadors came out bald with the wrong uniform colour on the
|
|
## web build. It now keys per (bone, surface), so all source materials survive. This asserts the
|
|
## matador keeps every distinct material after conversion, produces bone-attached pieces, and
|
|
## hides the original skinned meshes (so they never hit the invisible-on-Mali skinning path).
|
|
## Run: godot --headless --script res://tests/rigid_skin_test.gd
|
|
|
|
const RigidSkin = preload("res://systems/render/rigid_skin.gd")
|
|
|
|
var _pass := 0
|
|
var _fail := 0
|
|
|
|
|
|
func _init() -> void:
|
|
_run.call_deferred()
|
|
|
|
|
|
func _ok(c: bool, m: String) -> void:
|
|
if c:
|
|
_pass += 1
|
|
print(" PASS: ", m)
|
|
else:
|
|
_fail += 1
|
|
print(" FAIL: ", m)
|
|
|
|
|
|
func _surface_mats(mi: MeshInstance3D) -> Array:
|
|
var out: Array = []
|
|
var mesh := mi.mesh
|
|
if mesh == null:
|
|
return out
|
|
for s: int in mesh.get_surface_count():
|
|
var mat: Material = mi.material_override
|
|
if mat == null:
|
|
mat = mi.get_surface_override_material(s)
|
|
if mat == null:
|
|
mat = mesh.surface_get_material(s)
|
|
if mat != null and not out.has(mat):
|
|
out.append(mat)
|
|
return out
|
|
|
|
|
|
func _run() -> void:
|
|
var inst: Node = (load("res://Assets/Matador.glb") as PackedScene).instantiate()
|
|
root.add_child(inst)
|
|
|
|
# Distinct materials on the skinned source meshes, before conversion.
|
|
var source: Array = []
|
|
var skinned: Array = []
|
|
for mi: MeshInstance3D in inst.find_children("*", "MeshInstance3D", true, false):
|
|
if mi.skin != null:
|
|
skinned.append(mi)
|
|
for mat: Material in _surface_mats(mi):
|
|
if not source.has(mat):
|
|
source.append(mat)
|
|
_ok(source.size() >= 2, "matador source has multiple distinct materials (%d)" % source.size())
|
|
|
|
var converted := RigidSkin.convert_tree(inst)
|
|
_ok(converted > 0, "convert_tree rebuilt %d skinned mesh(es)" % converted)
|
|
|
|
# Distinct materials on the generated bone-attached pieces.
|
|
var pieces := 0
|
|
var piece_mats: Array = []
|
|
for att: BoneAttachment3D in inst.find_children("*", "BoneAttachment3D", true, false):
|
|
for mi: MeshInstance3D in att.find_children("*", "MeshInstance3D", true, false):
|
|
pieces += 1
|
|
var mesh := mi.mesh
|
|
if mesh == null:
|
|
continue
|
|
# Pieces are multi-surface now (a bone's materials each stay their own surface), so
|
|
# scan every surface — not just surface 0 — to confirm none were dropped.
|
|
for s: int in mesh.get_surface_count():
|
|
var mat := mesh.surface_get_material(s)
|
|
if mat != null and not piece_mats.has(mat):
|
|
piece_mats.append(mat)
|
|
_ok(pieces > 0, "conversion produced bone-attached pieces (%d)" % pieces)
|
|
_ok(piece_mats.size() >= source.size(),
|
|
"every source material survives conversion (%d of %d kept)" % [piece_mats.size(), source.size()])
|
|
|
|
var all_hidden := true
|
|
for mi: MeshInstance3D in skinned:
|
|
if mi.visible:
|
|
all_hidden = false
|
|
_ok(all_hidden, "original skinned meshes are hidden (never drawn on the failing path)")
|
|
|
|
_finish()
|
|
|
|
|
|
func _finish() -> void:
|
|
print("Results: %d passed, %d failed" % [_pass, _fail])
|
|
quit(1 if _fail > 0 else 0)
|