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:
Diffstat (limited to 'io_scene_gltf2/blender/imp/gltf2_blender_mesh.py')
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_mesh.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
index b886dd25..c29f5a27 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
@@ -98,11 +98,7 @@ def do_primitives(gltf, mesh_idx, skin_idx, mesh, ob):
while i < COLOR_MAX and ('COLOR_%d' % i) in prim.attributes: i += 1
num_cols = max(i, num_cols)
- num_shapekeys = 0
- if len(pymesh.primitives) > 0: # Empty primitive tab is not allowed, but some invalid files...
- for morph_i, _ in enumerate(pymesh.primitives[0].targets or []):
- if pymesh.shapekey_names[morph_i] is not None:
- num_shapekeys += 1
+ num_shapekeys = sum(sk_name is not None for sk_name in pymesh.shapekey_names)
# -------------
# We'll process all the primitives gathering arrays to feed into the
@@ -190,12 +186,17 @@ def do_primitives(gltf, mesh_idx, skin_idx, mesh, ob):
vert_joints[i] = np.concatenate((vert_joints[i], js))
vert_weights[i] = np.concatenate((vert_weights[i], ws))
- for morph_i, target in enumerate(prim.targets or []):
- if pymesh.shapekey_names[morph_i] is None:
+ sk_i = 0
+ for sk, sk_name in enumerate(pymesh.shapekey_names):
+ if sk_name is None:
continue
- morph_vs = BinaryData.decode_accessor(gltf, target['POSITION'], cache=True)
- morph_vs = morph_vs[unique_indices]
- sk_vert_locs[morph_i] = np.concatenate((sk_vert_locs[morph_i], morph_vs))
+ if prim.targets and 'POSITION' in prim.targets[sk]:
+ morph_vs = BinaryData.decode_accessor(gltf, prim.targets[sk]['POSITION'], cache=True)
+ morph_vs = morph_vs[unique_indices]
+ else:
+ morph_vs = np.zeros((len(unique_indices), 3), dtype=np.float32)
+ sk_vert_locs[sk_i] = np.concatenate((sk_vert_locs[sk_i], morph_vs))
+ sk_i += 1
# inv_indices are the indices into the verts just for this prim;
# calculate indices into the overall verts array