diff --git a/io_scene_psk_psa/psa/builder.py b/io_scene_psk_psa/psa/builder.py index 57005fe..2f33675 100644 --- a/io_scene_psk_psa/psa/builder.py +++ b/io_scene_psk_psa/psa/builder.py @@ -23,12 +23,12 @@ class PsaBuildOptions: def __init__(self): self.animation_data: Optional[AnimData] = None self.sequences: List[PsaExportSequence] = [] - self.bone_filter_mode = 'ALL' + self.bone_filter_mode: str = 'ALL' self.bone_group_indices: List[int] = [] - self.should_ignore_bone_name_restrictions = False - self.sequence_name_prefix = '' - self.sequence_name_suffix = '' - self.root_motion = False + self.should_ignore_bone_name_restrictions: bool = False + self.sequence_name_prefix: str = '' + self.sequence_name_suffix: str = '' + self.root_motion: bool = False def build_psa(context: bpy.types.Context, options: PsaBuildOptions) -> Psa: @@ -145,10 +145,11 @@ def build_psa(context: bpy.types.Context, options: PsaBuildOptions) -> Psa: pose_bone_matrix = pose_bone_parent_matrix.inverted() @ pose_bone_matrix else: if options.root_motion: - # Export root motion + # Get the bone's pose matrix, taking the armature object's world matrix into account. pose_bone_matrix = armature_object.matrix_world @ pose_bone.matrix else: - pose_bone_matrix = pose_bone.matrix + # Use the bind pose matrix for the root bone. + pose_bone_matrix = armature_data.bones[pose_bone.name].matrix_local location = pose_bone_matrix.to_translation() rotation = pose_bone_matrix.to_quaternion().normalized() diff --git a/io_scene_psk_psa/psa/exporter.py b/io_scene_psk_psa/psa/exporter.py index 728bb3a..fa867a9 100644 --- a/io_scene_psk_psa/psa/exporter.py +++ b/io_scene_psk_psa/psa/exporter.py @@ -63,7 +63,9 @@ class PsaExportPropertyGroup(PropertyGroup): name='Root Motion', options=empty_set, default=False, - description='The root bone will be transformed as it appears in the scene', + description='When enabled, the root bone will be transformed as it appears in the scene.\n\n' + 'You might want to disable this if you are exporting an animation for an armature that is ' + 'attached to another object, such as a weapon or a shield', ) should_override_animation_data: BoolProperty( name='Override Animation Data',