From a927d3e1bca8a9d2c5e16932e32866954435cc7b Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Wed, 28 Oct 2020 18:28:36 +0100 Subject: glTF importer: Fix T82189 avoid traceback on non valid file with empty primitive tab --- io_scene_gltf2/__init__.py | 2 +- io_scene_gltf2/blender/imp/gltf2_blender_mesh.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'io_scene_gltf2') diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index 03180b3f..75b5a497 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -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, 4, 38), + "version": (1, 4, 39), 'blender': (2, 91, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py index 34e979b9..09ec325b 100755 --- a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py +++ b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py @@ -91,9 +91,10 @@ def do_primitives(gltf, mesh_idx, skin_idx, mesh, ob): num_cols = max(i, num_cols) num_shapekeys = 0 - for morph_i, _ in enumerate(pymesh.primitives[0].targets or []): - if pymesh.shapekey_names[morph_i] is not None: - num_shapekeys += 1 + 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 # ------------- # We'll process all the primitives gathering arrays to feed into the -- cgit v1.2.3