feat: Refactor head transformation logic and update driver paths for pivot integration
This commit is contained in:
+10
-6
@@ -271,13 +271,17 @@ func _apply_profile() -> void:
|
||||
facing_profile_changed.emit(int(facing_profile))
|
||||
|
||||
func _apply_head_flip() -> void:
|
||||
if _body_container == null:
|
||||
return
|
||||
var head := _body_container.get_node_or_null("Head") as Node2D
|
||||
if head != null:
|
||||
var head := get_node_or_null("Skeleton2D/Torso/Head") as Node2D
|
||||
var pivot := get_node_or_null("Skeleton2D/Torso/Head/Pivot") as Node2D
|
||||
if pivot != null:
|
||||
var is_left := (facing_profile == FacingProfile.LEFT)
|
||||
# Keep local X positive (neck upright), invert local Y (mirror brim & face)
|
||||
head.scale = Vector2(1.0, -1.0) if is_left else Vector2(1.0, 1.0)
|
||||
if is_left:
|
||||
# Mirror local X and invert double the bone's rotation to mirror in world space
|
||||
pivot.scale = Vector2(-1.0, 1.0)
|
||||
pivot.rotation = -1.0 * head.rotation
|
||||
else:
|
||||
pivot.scale = Vector2(1.0, 1.0)
|
||||
pivot.rotation = 0.0
|
||||
|
||||
## Per-joint setter notify: updates the resolved TwoBoneIK mod's
|
||||
## flip_bend_direction and emits bend_flag_changed. No-op before _ready (the
|
||||
|
||||
@@ -71,7 +71,7 @@ const BODY_PATHS: Dictionary = {
|
||||
## its bone; its `global_rotation` is the bone frame used (Phase 9 Round 5) to
|
||||
## convert the master-space guide_offset into a bone-relative placement.
|
||||
const DRIVER_PATHS: Dictionary = {
|
||||
"head": "Skeleton2D/Torso/Head/RemoteTransform2D",
|
||||
"head": "Skeleton2D/Torso/Head/Pivot/RemoteTransform2D",
|
||||
"torso": "Skeleton2D/Torso/RemoteTransform2D",
|
||||
"left_upper_arm": "Skeleton2D/Torso/LeftUpperArm/RemoteTransform2D",
|
||||
"left_lower_arm": "Skeleton2D/Torso/LeftUpperArm/LeftLowerArm/RemoteTransform2D",
|
||||
@@ -89,7 +89,7 @@ const IK_LEFT_LEG := "IK_Targets/Left_Leg"
|
||||
const IK_RIGHT_LEG := "IK_Targets/Right_Leg"
|
||||
|
||||
const HEAD_BONE_PATH := "Skeleton2D/Torso/Head"
|
||||
const HEAD_DRIVER_PATH := "Skeleton2D/Torso/Head/RemoteTransform2D"
|
||||
const HEAD_DRIVER_PATH := "Skeleton2D/Torso/Head/Pivot/RemoteTransform2D"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Public API
|
||||
|
||||
Reference in New Issue
Block a user