Debug: log ModelCache HTTP result/headers/bytes; fix weakref captures
- ModelCache._download: log result enum, HTTP code, body size, Content-Type header, and first 16 bytes for every download — enough to diagnose why Godot receives non-GLB data despite CDN serving valid GLB - Moved disk-cache write to AFTER a successful parse so corrupt bytes are never written; disk cache read now deletes + re-downloads on bad parse - game_screen: replace raw `body` lambda captures with weakref to eliminate "Lambda capture freed" noise (behavior unchanged) Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -427,8 +427,10 @@ func _add_tile(x: int, y: int, affinity: String) -> void:
|
||||
if model_url.is_empty():
|
||||
return
|
||||
|
||||
var body_ref := weakref(body)
|
||||
ModelCache.load_model(model_url, func(model_node: Node3D) -> void:
|
||||
if not is_instance_valid(body):
|
||||
var b := body_ref.get_ref() as StaticBody3D
|
||||
if not is_instance_valid(b):
|
||||
if model_node != null:
|
||||
model_node.queue_free()
|
||||
return
|
||||
@@ -436,13 +438,13 @@ func _add_tile(x: int, y: int, affinity: String) -> void:
|
||||
return
|
||||
|
||||
# Remove the placeholder MeshInstance3D.
|
||||
for child in body.get_children():
|
||||
for child in b.get_children():
|
||||
if child is MeshInstance3D:
|
||||
child.queue_free()
|
||||
|
||||
# Tile body sits at wp + (0, 0.25, 0); model should author its
|
||||
# centre at y = 0 so it fills the same space as the box placeholder.
|
||||
body.add_child(model_node)
|
||||
b.add_child(model_node)
|
||||
)
|
||||
|
||||
|
||||
@@ -540,9 +542,11 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color) -> void:
|
||||
if model_url.is_empty():
|
||||
return
|
||||
|
||||
var body_ref := weakref(body)
|
||||
ModelCache.load_model(model_url, func(model_node: Node3D) -> void:
|
||||
# Guard: body may have been freed by a state rebuild before load finished.
|
||||
if not is_instance_valid(body):
|
||||
var b := body_ref.get_ref() as StaticBody3D
|
||||
if not is_instance_valid(b):
|
||||
if model_node != null:
|
||||
model_node.queue_free()
|
||||
return
|
||||
@@ -550,15 +554,15 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color) -> void:
|
||||
return
|
||||
|
||||
# Remove the placeholder MeshInstance3D.
|
||||
for child in body.get_children():
|
||||
for child in b.get_children():
|
||||
if child is MeshInstance3D:
|
||||
child.queue_free()
|
||||
|
||||
# Position model so its local origin sits at the body's position.
|
||||
# Models should be authored with their base (foot) at y = 0.
|
||||
# Adjust the body back down so the model base lands on the tile surface.
|
||||
body.position = wp + Vector3(0, 0.5, 0)
|
||||
body.add_child(model_node)
|
||||
b.position = wp + Vector3(0, 0.5, 0)
|
||||
b.add_child(model_node)
|
||||
_unit_meshes[iid] = model_node
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user