glTF importer: fix T91217: avoid traceback when trying to import some invalid glTF 2.0 files

This commit is contained in:
Julien Duroure 2021-09-15 17:29:56 +02:00
parent 45132ba0f4
commit 4d562682c0
Notes: blender-bot 2023-02-14 18:31:28 +01:00
Referenced by issue #91217, Python exception while importing glb
2 changed files with 5 additions and 1 deletions

View File

@ -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, 7, 24),
"version": (1, 7, 25),
'blender': (2, 91, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',

View File

@ -184,6 +184,10 @@ class BlenderNode():
@staticmethod
def create_mesh_object(gltf, vnode):
pynode = gltf.data.nodes[vnode.mesh_node_idx]
if not (0 <= pynode.mesh < len(gltf.data.meshes)):
# Avoid traceback for invalid gltf file: invalid reference to meshes array
# So return an empty blender object)
return bpy.data.objects.new(vnode.name or mesh.name, None)
pymesh = gltf.data.meshes[pynode.mesh]
# Key to cache the Blender mesh by.