1
0
mirror of https://github.com/DarklightGames/io_scene_psk_psa.git synced 2024-11-15 02:37:39 +01:00

Fixed a bug where the root bone orientation would be exported incorrectly

This commit is contained in:
Colin Basnett 2022-11-22 12:55:56 -08:00
parent 9ae573422b
commit 38ed183897
2 changed files with 12 additions and 7 deletions

View File

@ -159,9 +159,12 @@ def build_psa(context: bpy.types.Context, options: PsaBuildOptions) -> Psa:
parent_tail = inverse_parent_rotation @ bone.parent.tail parent_tail = inverse_parent_rotation @ bone.parent.tail
location = (parent_tail - parent_head) + bone.head location = (parent_tail - parent_head) + bone.head
else: else:
location = armature.matrix_local @ bone.head armature_local_matrix = armature_object.matrix_local
rot_matrix = bone.matrix @ armature.matrix_local.to_3x3() location = armature_local_matrix @ bone.head
rotation = rot_matrix.to_quaternion() bone_rotation = bone.matrix.to_quaternion().conjugated()
local_rotation = armature_local_matrix.to_3x3().to_quaternion().conjugated()
rotation = bone_rotation @ local_rotation
rotation.conjugate()
psa_bone.location.x = location.x psa_bone.location.x = location.x
psa_bone.location.y = location.y psa_bone.location.y = location.y

View File

@ -103,10 +103,12 @@ def build_psk(context, options: PskBuildOptions) -> Psk:
parent_tail = quat_parent @ bone.parent.tail parent_tail = quat_parent @ bone.parent.tail
location = (parent_tail - parent_head) + bone.head location = (parent_tail - parent_head) + bone.head
else: else:
local_matrix = armature_object.matrix_local armature_local_matrix = armature_object.matrix_local
location = local_matrix @ bone.head location = armature_local_matrix @ bone.head
rot_matrix = bone.matrix @ local_matrix.to_3x3() bone_rotation = bone.matrix.to_quaternion().conjugated()
rotation = rot_matrix.to_quaternion() local_rotation = armature_local_matrix.to_3x3().to_quaternion().conjugated()
rotation = bone_rotation @ local_rotation
rotation.conjugate()
psk_bone.location.x = location.x psk_bone.location.x = location.x
psk_bone.location.y = location.y psk_bone.location.y = location.y