Skip to content

Commit

Permalink
Merge pull request KhronosGroup#1459 from KhronosGroup/inverted_safe
Browse files Browse the repository at this point in the history
inverted_safe matrix
  • Loading branch information
julienduroure authored Sep 15, 2021
2 parents 8975396 + 4c4d01d commit 95cc38c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions addons/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __collect_matrices(bone):
blender_object.matrix_world @
bone.bone.matrix_local
)
).inverted()
).inverted_safe()
matrices.append(inverse_bind_matrix)

if export_settings['gltf_def_bones'] is False:
Expand Down

0 comments on commit 95cc38c

Please sign in to comment.