Skip to content

Commit e92b6d5

Browse files
committed
Fix constrained bones' scale exports
1 parent 49b03f9 commit e92b6d5

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

Blender/FrontiersAnimationTools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
bl_info = {
1515
"name": "Hedgehog Engine PXD Animation Tools",
1616
"author": "AdelQ, WistfulHopes, Turk645",
17-
"version": (2, 1, 3),
17+
"version": (2, 1, 4),
1818
"blender": (4, 1, 0),
1919
"location": "File > Import/Export",
2020
"description": "Animation and skeleton importer/exporter for Hedgehog Engine 2 games with compressed animations",

Blender/FrontiersAnimationTools/animation/anim_export.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ def anim_export(self_pass, filepath, arm_active, action_active, start_frame, end
5151
scale_map_temp = {}
5252
for pbone in arm_active.pose.bones:
5353
tmp_loc, tmp_rot, tmp_scale = pbone.matrix.decompose()
54+
# Matrix scales necessary to obtain local scales resulting from constraints
55+
if pbone.parent:
56+
parent_scale = pbone.parent.matrix.to_scale()
57+
tmp_scale = mathutils.Vector((tmp_scale.x / parent_scale.x, tmp_scale.y / parent_scale.y, tmp_scale.z / parent_scale.z))
58+
5459
tmp_matrix = mathutils.Matrix.LocRotScale(tmp_loc, tmp_rot, mathutils.Vector((1.0, 1.0, 1.0)))
5560
matrix_map_temp.update({pbone.name: tmp_matrix})
56-
scale_map_temp.update({pbone.name: pbone.scale.copy()}) # normal scale is different from matrix scale
61+
scale_map_temp.update({pbone.name: tmp_scale})
5762

5863
# Negate unscaled parent matrices, write to buffer with actual scales
5964
for pbone in arm_active.pose.bones:
@@ -64,7 +69,7 @@ def anim_export(self_pass, filepath, arm_active, action_active, start_frame, end
6469
tmp_parent_matrix = mathutils.Matrix()
6570
tmp_bone_length = 0.0
6671
tmp_matrix = tmp_parent_matrix.inverted() @ matrix_map_temp[pbone.name]
67-
tmp_loc, tmp_rot, tmp_scale = tmp_matrix.decompose()
72+
tmp_loc, tmp_rot, _ = tmp_matrix.decompose()
6873
tmp_scale = scale_map_temp[pbone.name]
6974

7075
if self_pass.bool_yx_skel:

0 commit comments

Comments
 (0)