diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2020-07-24 09:13:13 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2020-07-24 09:13:13 +0300 |
commit | c0d9f77449abcaf947c76a0d19081c076aae3bc9 (patch) | |
tree | 29beedc165c7ae2a2bb6138c1172b89659bede62 /io_scene_gltf2/blender | |
parent | d1a009898e47c9b5761d99c511fa08e8aec71988 (diff) |
Merge branch 'blender-v2.90-release'
Diffstat (limited to 'io_scene_gltf2/blender')
-rwxr-xr-x | io_scene_gltf2/blender/imp/gltf2_blender_mesh.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py index 175bc920..e393eb86 100755 --- a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py +++ b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py @@ -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 |