glTF importer: fix regression for skinned mesh normals not being renormalized
This commit is contained in:
parent
2c9bc1e642
commit
03e3ef7f71
|
@ -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, 3, 42),
|
||||
"version": (1, 3, 43),
|
||||
'blender': (2, 90, 0),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Import-Export as glTF 2.0',
|
||||
|
|
|
@ -540,6 +540,7 @@ def skin_into_bind_pose(gltf, skin_idx, vert_joints, vert_weights, locs, vert_no
|
|||
if len(vert_normals) != 0:
|
||||
vert_normals[:] = mul_mats_vecs(skinning_mats_3x3, vert_normals)
|
||||
# Don't translate normals!
|
||||
normalize_vecs(vert_normals)
|
||||
|
||||
|
||||
def mul_mats_vecs(mats, vecs):
|
||||
|
@ -547,6 +548,11 @@ def mul_mats_vecs(mats, vecs):
|
|||
return np.matmul(mats, vecs.reshape(len(vecs), 3, 1)).reshape(len(vecs), 3)
|
||||
|
||||
|
||||
def normalize_vecs(vectors):
|
||||
norms = np.linalg.norm(vectors, axis=1, keepdims=True)
|
||||
np.divide(vectors, norms, out=vectors, where=norms != 0)
|
||||
|
||||
|
||||
def merge_duplicate_verts(vert_locs, vert_normals, vert_joints, vert_weights, sk_vert_locs, loop_vidxs, edge_vidxs):
|
||||
# This function attempts to invert the splitting done when exporting to
|
||||
# glTF. Welds together verts with the same per-vert data (but possibly
|
||||
|
|
Loading…
Reference in New Issue