1
0
mirror of https://github.com/DarklightGames/io_scene_psk_psa.git synced 2024-11-24 06:50:13 +01:00

Removed legacy handling of storing original bone poses within the custom properties of edit bones

It doesn't appear that this code was even being exercised. If problems arise, we can restore the functionality.
This commit is contained in:
Colin Basnett 2023-09-18 14:13:49 -07:00
parent 14c2f585dc
commit cf13aade98
2 changed files with 20 additions and 33 deletions

View File

@ -31,9 +31,9 @@ class ImportBone(object):
self.parent: Optional[ImportBone] = None
self.armature_bone = None
self.pose_bone = None
self.orig_loc: Vector = Vector()
self.orig_quat: Quaternion = Quaternion()
self.post_quat: Quaternion = Quaternion()
self.original_location: Vector = Vector()
self.original_rotation: Quaternion = Quaternion()
self.post_rotation: Quaternion = Quaternion()
self.fcurves: List[FCurve] = []
@ -41,17 +41,17 @@ def _calculate_fcurve_data(import_bone: ImportBone, key_data: typing.Iterable[fl
# Convert world-space transforms to local-space transforms.
key_rotation = Quaternion(key_data[0:4])
key_location = Vector(key_data[4:])
q = import_bone.post_quat.copy()
q.rotate(import_bone.orig_quat)
q = import_bone.post_rotation.copy()
q.rotate(import_bone.original_rotation)
quat = q
q = import_bone.post_quat.copy()
q = import_bone.post_rotation.copy()
if import_bone.parent is None:
q.rotate(key_rotation.conjugated())
else:
q.rotate(key_rotation)
quat.rotate(q.conjugated())
loc = key_location - import_bone.orig_loc
loc.rotate(import_bone.post_quat.conjugated())
loc = key_location - import_bone.original_location
loc.rotate(import_bone.post_rotation.conjugated())
return quat.w, quat.x, quat.y, quat.z, loc.x, loc.y, loc.z
@ -142,23 +142,16 @@ def import_psa(context: Context, psa_reader: PsaReader, armature_object: Object,
if armature_bone.parent is not None and armature_bone.parent.name in psa_bone_names:
import_bone.parent = import_bones_dict[armature_bone.parent.name]
# Calculate the original location & rotation of each bone (in world-space maybe?)
if armature_bone.get('orig_quat') is not None:
# TODO: ideally we don't rely on bone auxiliary data like this, the non-aux data path is incorrect
# (animations are flipped 180 around Z)
import_bone.orig_quat = Quaternion(armature_bone['orig_quat'])
import_bone.orig_loc = Vector(armature_bone['orig_loc'])
import_bone.post_quat = Quaternion(armature_bone['post_quat'])
else:
if import_bone.parent is not None:
import_bone.orig_loc = armature_bone.matrix_local.translation - armature_bone.parent.matrix_local.translation
import_bone.orig_loc.rotate(armature_bone.parent.matrix_local.to_quaternion().conjugated())
import_bone.orig_quat = armature_bone.matrix_local.to_quaternion()
import_bone.orig_quat.rotate(armature_bone.parent.matrix_local.to_quaternion().conjugated())
import_bone.orig_quat.conjugate()
import_bone.original_location = armature_bone.matrix_local.translation - armature_bone.parent.matrix_local.translation
import_bone.original_location.rotate(armature_bone.parent.matrix_local.to_quaternion().conjugated())
import_bone.original_rotation = armature_bone.matrix_local.to_quaternion()
import_bone.original_rotation.rotate(armature_bone.parent.matrix_local.to_quaternion().conjugated())
import_bone.original_rotation.conjugate()
else:
import_bone.orig_loc = armature_bone.matrix_local.translation.copy()
import_bone.orig_quat = armature_bone.matrix_local.to_quaternion()
import_bone.post_quat = import_bone.orig_quat.conjugated()
import_bone.original_location = armature_bone.matrix_local.translation.copy()
import_bone.original_rotation = armature_bone.matrix_local.to_quaternion()
import_bone.post_rotation = import_bone.original_rotation.conjugated()
context.window_manager.progress_begin(0, len(sequences))

View File

@ -39,9 +39,9 @@ class ImportBone:
self.world_rotation_matrix: Matrix = Matrix()
self.world_matrix: Matrix = Matrix()
self.vertex_group = None
self.orig_quat: Quaternion = Quaternion()
self.orig_loc: Vector = Vector()
self.post_quat: Quaternion = Quaternion()
self.original_rotation: Quaternion = Quaternion()
self.original_location: Vector = Vector()
self.post_rotation: Quaternion = Quaternion()
class PskImportResult:
@ -111,12 +111,6 @@ def import_psk(psk: Psk, context, options: PskImportOptions) -> PskImportResult:
edit_bone_matrix.translation = import_bone.world_matrix.translation
edit_bone.matrix = edit_bone_matrix
# Store bind pose information in the bone's custom properties.
# This information is used when importing animations from PSA files.
edit_bone['orig_quat'] = import_bone.local_rotation
edit_bone['orig_loc'] = import_bone.local_translation
edit_bone['post_quat'] = import_bone.local_rotation.conjugated()
# MESH
if options.should_import_mesh:
mesh_data = bpy.data.meshes.new(options.name)