extends Skeleton3D # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # TODO: this doesn't work well because animation pose positions are offset! # The actual solution is to make blender spit out a proper skeleton hierarchy func _reparent_rigify_floating_bones() -> void: var head_bone_idx: int = find_bone("DEF-spine.006") var head_bone_rest: Transform3D = get_bone_global_rest(head_bone_idx) var to_head_arr := ["ORG-face", "DEF-hair-root", "DEF-hair-root.001", "DEF-hair-root.002", "DEF-hair-root.003", "DEF-hair-root.004", "DEF-hair-root.005" ] # parent the face, hair, and horns to the head bone for n in to_head_arr: var idx: int = find_bone(n) var rest: Transform3D = get_bone_global_rest(idx) # set bone position relative to its new parent set_bone_rest(idx, rest * head_bone_rest) #set_bone_pose_position(idx, head_bone_rest.basis.x - rest.basis.x) set_bone_parent(idx, head_bone_idx)