Refactor stickman rig and ragdoll mechanics; enhance pose restoration and stability

- Disabled constraints for the stickman rig's head bone to allow for smoother animations.
- Improved mode transitions in the sandbox stage to preserve stickman poses between EDIT and DIRECT modes.
- Added side profile stabilization for knee bends in the ragdoll component to prevent unnatural poses during physics interactions.
- Enhanced the snap-to-standing functionality to restore the stickman's original pose accurately.
- Introduced new tests for validating pose preservation during mode transitions and ragdoll behavior during walking animations.
- Created a new scene for testing stickman bending and ragdoll transitions.
This commit is contained in:
2026-09-18 22:44:48 -04:00
parent db4ff8d939
commit fbce638bc5
12 changed files with 692 additions and 39 deletions
+27
View File
@@ -32,6 +32,33 @@ func _run() -> void:
_check(runner != null, "typed ActionRunner component resolves")
_check(rig.get_locomotion() == locomotion, "root locomotion facade exposes authored component")
var head_look_at := rig._head_look_at as SkeletonModification2DLookAt
var head_bone := rig.get_node("Skeleton2D/Torso/Head") as Bone2D
var head_target := rig.get_node("IK_Targets/Head") as Marker2D
_check(head_look_at != null and head_look_at.enabled,
"FORWARD profile enables head marker tracking")
var head_rotation_before := head_bone.rotation
head_target.position += Vector2(-400.0, 180.0)
for frame in 4:
await process_frame
_check(absf(wrapf(head_bone.rotation - head_rotation_before, -PI, PI)) > 0.1,
"head bone follows a moved Head marker (before %.3f after %.3f target %s)"
% [head_rotation_before, head_bone.rotation, str(head_target.global_position)])
rig.set_facing_profile(StickmanRig.FacingProfile.LEFT)
_check(not head_look_at.enabled, "LEFT mirror disables non-mirror-invariant head LookAt")
rig.set_facing_profile(StickmanRig.FacingProfile.RIGHT)
_check(head_look_at.enabled, "RIGHT profile re-enables head marker tracking")
var left_bands: Dictionary = StickmanRagdoll.JOINT_BAND_LIMITS[StickmanRig.FacingProfile.LEFT]
var right_bands: Dictionary = StickmanRagdoll.JOINT_BAND_LIMITS[StickmanRig.FacingProfile.RIGHT]
for leg_key: String in ["left_lower_leg", "right_lower_leg"]:
var left_band: Dictionary = left_bands[leg_key]
var right_band: Dictionary = right_bands[leg_key]
_check(float(left_band["lower"]) < 0.0 and float(left_band["upper"]) >= 0.0,
"LEFT %s hinge includes straight and bends backward" % leg_key)
_check(float(right_band["lower"]) <= 0.0 and float(right_band["upper"]) > 0.0,
"RIGHT %s hinge includes straight and bends backward" % leg_key)
var assigned: Array[Dictionary] = [{"type": "wait", "duration": 0.25}]
rig.action_queue = assigned
_check(runner.action_queue.size() == 1, "direct root action_queue assignment delegates")