fix: force skeleton skin update at runtime for GLTF models

The AnimationPlayer correctly updates bone poses (proven in tests)
but the MeshInstance visual doesn't reflect the changes. Added
throttled _update_skin() that re-applies bone poses every ~33ms
to trigger NOTIFICATION_UPDATE_SKELETON on the Skeleton3D,
which causes the MeshInstance to update its vertex buffers.

Also set AnimationPlayer process_mode to ALWAYS to ensure it
processes regardless of parent node state.
This commit is contained in:
2026-06-25 00:30:28 -04:00
parent 73831cb418
commit c4dc4ca77c
+5 -2
View File
@@ -101,7 +101,7 @@ func load_model(path: String) -> void:
animation_player = _find_animation_player(scene)
if animation_player:
# Ensure AnimationPlayer processes even if parent has process_mode disabled
animation_player.process_mode = Node.PROCESS_MODE_INHERIT
animation_player.process_mode = Node.PROCESS_MODE_ALWAYS
animation_player.active = true
print("SkinnedPlayerModel: AP process_mode=%d active=%s" % [animation_player.process_mode, animation_player.active])
var anim_list = animation_player.get_animation_list()
@@ -303,13 +303,16 @@ func _add_animation_to_player(ap: AnimationPlayer, anim_name: String, anim: Anim
print("SkinnedPlayerModel: added '%s' (%d tracks)" % [anim_name, anim.get_track_count()])
func _update_skin() -> void:
## Force skeleton skin update by notifying the Skeleton3D that bones changed.
## Force skeleton skin update by re-applying current bone poses.
## GLTF runtime loaded models sometimes need this because the AnimationPlayer's
## internal bone pose updates don't always trigger the visual pipeline.
# Re-apply current bone poses to ensure dirty flags are set.
# This triggers NOTIFICATION_UPDATE_SKELETON on the Skeleton3D.
for i in range(skeleton.get_bone_count()):
skeleton.set_bone_pose(i, skeleton.get_bone_pose(i))
# Also notify the MeshInstance that its skeleton changed
if _mesh_instance:
_mesh_instance.skeleton = _mesh_instance.skeleton
func _setup_first_person() -> void:
# In first person, hide the head and upper body so only arms/hands/legs show