glTF exporter: cleanup: use inverted_safe on matrices

This commit is contained in:
Julien Duroure 2021-09-15 17:34:32 +02:00
parent 4d562682c0
commit 29c9aa3475
5 changed files with 9 additions and 9 deletions

View File

@ -15,7 +15,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
"version": (1, 7, 25),
"version": (1, 7, 26),
'blender': (2, 91, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',

View File

@ -387,7 +387,7 @@ def __get_positions(blender_mesh, key_blocks, armature, blender_object, export_s
# Transform for skinning
if armature and blender_object:
apply_matrix = armature.matrix_world.inverted() @ blender_object.matrix_world
apply_matrix = armature.matrix_world.inverted_safe() @ blender_object.matrix_world
loc_transform = armature.matrix_world @ apply_matrix
loc_transform = blender_object.matrix_world
@ -427,8 +427,8 @@ def __get_normals(blender_mesh, key_blocks, armature, blender_object, export_set
# Transform for skinning
if armature and blender_object:
apply_matrix = (armature.matrix_world.inverted() @ blender_object.matrix_world)
apply_matrix = apply_matrix.to_3x3().inverted().transposed()
apply_matrix = (armature.matrix_world.inverted_safe() @ blender_object.matrix_world)
apply_matrix = apply_matrix.to_3x3().inverted_safe().transposed()
normal_transform = armature.matrix_world.to_3x3() @ apply_matrix
normals[:] = __apply_mat_to_all(normal_transform, normals)
@ -463,7 +463,7 @@ def __get_tangents(blender_mesh, armature, blender_object, export_settings):
# Transform for skinning
if armature and blender_object:
apply_matrix = armature.matrix_world.inverted() @ blender_object.matrix_world
apply_matrix = armature.matrix_world.inverted_safe() @ blender_object.matrix_world
tangent_transform = apply_matrix.to_quaternion().to_matrix()
tangents = __apply_mat_to_all(tangent_transform, tangents)
__normalize_vecs(tangents)
@ -482,7 +482,7 @@ def __get_bitangent_signs(blender_mesh, armature, blender_object, export_setting
if armature and blender_object:
# Bitangent signs should flip when handedness changes
# TODO: confirm
apply_matrix = armature.matrix_world.inverted() @ blender_object.matrix_world
apply_matrix = armature.matrix_world.inverted_safe() @ blender_object.matrix_world
tangent_transform = apply_matrix.to_quaternion().to_matrix()
flipped = tangent_transform.determinant() < 0
if flipped:

View File

@ -370,7 +370,7 @@ def __gather_output(channels: typing.Tuple[bpy.types.FCurve],
correction_matrix_local = axis_basis_change @ bone.bone.matrix_local
else:
correction_matrix_local = (
bone.parent.bone.matrix_local.inverted() @
bone.parent.bone.matrix_local.inverted_safe() @
bone.bone.matrix_local
)

View File

@ -40,7 +40,7 @@ def gather_joint(blender_object, blender_bone, export_settings):
correction_matrix_local = axis_basis_change @ blender_bone.bone.matrix_local
else:
correction_matrix_local = (
blender_bone.parent.bone.matrix_local.inverted() @
blender_bone.parent.bone.matrix_local.inverted_safe() @
blender_bone.bone.matrix_local
)

View File

@ -90,7 +90,7 @@ def __gather_inverse_bind_matrices(blender_object, export_settings):
blender_object.matrix_world @
bone.bone.matrix_local
)
).inverted()
).inverted_safe()
matrices.append(inverse_bind_matrix)
if export_settings['gltf_def_bones'] is False: