Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2014-11-13 16:51:21 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2014-11-13 16:51:21 +0300
commit765c84e507cc3c5ca7d788bf4de819ad8b1206a7 (patch)
tree0a8bf9bfa91bf6114107f59058190420fe051eac
parent9d276937de26f82a4bbaded388ed474b951f338a (diff)
Fix T42586: Error when attempting to export FBX (non-invertible matrix).
Just use 'new' inverted_safe() everywhere we are not 100% sure the matrix is invertible...
-rw-r--r--io_scene_fbx/export_fbx_bin.py2
-rw-r--r--io_scene_fbx/fbx_utils.py8
-rw-r--r--io_scene_fbx/import_fbx.py16
3 files changed, 13 insertions, 13 deletions
diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index 5d18ffa4..c3183c1c 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -1452,7 +1452,7 @@ def fbx_data_armature_elements(root, arm_obj, scene_data):
# http://area.autodesk.com/forum/autodesk-fbx/fbx-sdk/why-the-values-return-
# by-fbxcluster-gettransformmatrix-x-not-same-with-the-value-in-ascii-fbx-file/
elem_data_single_float64_array(fbx_clstr, b"Transform",
- matrix4_to_array(mat_world_bones[bo_obj].inverted() * mat_world_obj))
+ matrix4_to_array(mat_world_bones[bo_obj].inverted_safe() * mat_world_obj))
elem_data_single_float64_array(fbx_clstr, b"TransformLink", matrix4_to_array(mat_world_bones[bo_obj]))
elem_data_single_float64_array(fbx_clstr, b"TransformAssociateModel", matrix4_to_array(mat_world_arm))
diff --git a/io_scene_fbx/fbx_utils.py b/io_scene_fbx/fbx_utils.py
index e8837fc9..be365791 100644
--- a/io_scene_fbx/fbx_utils.py
+++ b/io_scene_fbx/fbx_utils.py
@@ -902,11 +902,11 @@ class ObjectWrapper(metaclass=MetaObjectWrapper):
if self._tag == 'OB':
return self.bdata.matrix_local.copy()
elif self._tag == 'DP':
- return self._ref.matrix_world.inverted() * self._dupli_matrix
+ return self._ref.matrix_world.inverted_safe() * self._dupli_matrix
else: # 'BO', current pose
# PoseBone.matrix is in armature space, bring in back in real local one!
par = self.bdata.parent
- par_mat_inv = self._ref.pose.bones[par.name].matrix.inverted() if par else Matrix()
+ par_mat_inv = self._ref.pose.bones[par.name].matrix.inverted_safe() if par else Matrix()
return par_mat_inv * self._ref.pose.bones[self.bdata.name].matrix
matrix_local = property(get_matrix_local)
@@ -923,7 +923,7 @@ class ObjectWrapper(metaclass=MetaObjectWrapper):
if self._tag == 'BO':
# Bone.matrix_local is in armature space, bring in back in real local one!
par = self.bdata.parent
- par_mat_inv = par.matrix_local.inverted() if par else Matrix()
+ par_mat_inv = par.matrix_local.inverted_safe() if par else Matrix()
return par_mat_inv * self.bdata.matrix_local
else:
return self.matrix_local
@@ -1012,7 +1012,7 @@ class ObjectWrapper(metaclass=MetaObjectWrapper):
matrix = (parent.matrix_rest_local if rest else parent.matrix_local) * matrix
# ...and move it back into parent's *FBX* local space.
par_mat = parent.fbx_object_matrix(scene_data, rest=rest, local_space=True)
- matrix = par_mat.inverted() * matrix
+ matrix = par_mat.inverted_safe() * matrix
if self.use_bake_space_transform(scene_data):
# If we bake the transforms we need to post-multiply inverse global transform.
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index e3ccd9a9..03be451c 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -360,11 +360,11 @@ def blen_read_object_transform_do(transform_data):
pre_rot *
lcl_rot *
pst_rot *
- rot_piv.inverted() *
+ rot_piv.inverted_safe() *
sca_ofs *
sca_piv *
lcl_scale *
- sca_piv.inverted()
+ sca_piv.inverted_safe()
)
@@ -537,7 +537,7 @@ def blen_read_animations_action_item(action, item, cnodes, fps):
rot_prev = bl_obj.rotation_euler.copy()
# Pre-compute inverted local rest matrix of the bone, if relevant.
- restmat_inv = item.get_bind_matrix().inverted() if item.is_bone else None
+ restmat_inv = item.get_bind_matrix().inverted_safe() if item.is_bone else None
# We assume for now blen init point is frame 1.0, while FBX ktime init point is 0.
for frame, values in blen_read_animations_curves_iter(fbx_curves, 1.0, 0, fps):
@@ -1424,7 +1424,7 @@ class FbxImportHelperNode:
self.post_matrix = settings.global_matrix_inv * (self.post_matrix if self.post_matrix else Matrix())
# process children
- correction_matrix_inv = correction_matrix.inverted() if correction_matrix else None
+ correction_matrix_inv = correction_matrix.inverted_safe() if correction_matrix else None
for child in self.children:
child.find_correction_matrix(settings, correction_matrix_inv)
@@ -1522,7 +1522,7 @@ class FbxImportHelperNode:
parent_matrix = Matrix()
if self.bind_matrix:
- bind_matrix = parent_matrix.inverted() * self.bind_matrix
+ bind_matrix = parent_matrix.inverted_safe() * self.bind_matrix
else:
bind_matrix = self.matrix.copy() if self.matrix else None
@@ -1541,7 +1541,7 @@ class FbxImportHelperNode:
def collect_armature_meshes(self):
if self.is_armature:
- armature_matrix_inv = self.get_world_matrix().inverted()
+ armature_matrix_inv = self.get_world_matrix().inverted_safe()
meshes = set()
for child in self.children:
@@ -1549,7 +1549,7 @@ class FbxImportHelperNode:
for m in meshes:
old_matrix = m.matrix
m.matrix = armature_matrix_inv * m.get_world_matrix()
- m.anim_compensation_matrix = old_matrix.inverted() * m.matrix
+ m.anim_compensation_matrix = old_matrix.inverted_safe() * m.matrix
m.parent = self
self.meshes = meshes
else:
@@ -1666,7 +1666,7 @@ class FbxImportHelperNode:
def set_pose_matrix(self, arm):
pose_bone = arm.bl_obj.pose.bones[self.bl_bone]
- pose_bone.matrix_basis = self.get_bind_matrix().inverted() * self.get_matrix()
+ pose_bone.matrix_basis = self.get_bind_matrix().inverted_safe() * self.get_matrix()
for child in self.children:
if child.ignore: