Skip to content

Commit fb96416

Browse files
authored
Merge pull request #484 from HENDRIX-ZT2/develop
Pull out nifformat_to_mathutils_matrix, improve comment
2 parents d4ffea8 + f30edc4 commit fb96416

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

io_scene_niftools/modules/nif_import/armature/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ def import_armature(self, n_armature):
220220
for b_name, n_block in self.name_to_block.items():
221221
n_pose = self.pose_store[n_block]
222222
b_pose_bone = b_armature_obj.pose.bones[b_name]
223-
n_bind = mathutils.Matrix(n_pose.as_list()).transposed()
223+
n_bind = math.nifformat_to_mathutils_matrix(n_pose)
224224
b_pose_bone.matrix = math.nif_bind_to_blender_bind(n_bind)
225-
# force update is required to ensure the transforms are set properly in blender
225+
# force update is required after each pbone to ensure the transforms are set properly in blender
226226
bpy.context.view_layer.update()
227227

228228
return b_armature_obj
@@ -239,7 +239,7 @@ def import_bone_bind(self, n_block, b_armature_data, n_armature, b_parent_bone=N
239239
# store nif block for access from object mode
240240
self.name_to_block[b_edit_bone.name] = n_block
241241
# get the nif bone's armature space matrix (under the hood all bone space matrixes are multiplied together)
242-
n_bind = mathutils.Matrix(self.bind_store.get(n_block, NifFormat.Matrix44()).as_list()).transposed()
242+
n_bind = math.nifformat_to_mathutils_matrix(self.bind_store.get(n_block, NifFormat.Matrix44()))
243243
# get transformation in blender's coordinate space
244244
b_bind = math.nif_bind_to_blender_bind(n_bind)
245245

io_scene_niftools/utils/math.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def nif_bind_to_blender_bind(nif_armature_space_matrix):
110110

111111
def import_matrix(n_block, relative_to=None):
112112
"""Retrieves a n_block's transform matrix as a Mathutil.Matrix."""
113-
return mathutils.Matrix(n_block.get_transform(relative_to).as_list()).transposed()
113+
return nifformat_to_mathutils_matrix(n_block.get_transform(relative_to))
114114

115115

116116
def decompose_srt(b_matrix):
@@ -242,3 +242,8 @@ def mathutils_to_nifformat_matrix(b_matrix):
242242
n_matrix.set_rows(*b_matrix.transposed())
243243
return n_matrix
244244

245+
246+
def nifformat_to_mathutils_matrix(n_matrix):
247+
"""Convert a NifFormat.Matrix44 to a blender matrix"""
248+
return mathutils.Matrix(n_matrix.as_list()).transposed()
249+

0 commit comments

Comments
 (0)