From 6454d95e19d4d99c680448f3bf124a8f7fb0842e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 12 Dec 2014 11:02:03 +0100 Subject: Fix T42683: do not crash on importing trashy FBX files. Looks like FBX allows corruption in its 'database', like UIDs only existing in Connection table, and just ignores it. When in Rome... --- io_scene_fbx/import_fbx.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'io_scene_fbx/import_fbx.py') diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py index d821672d..d25684c9 100644 --- a/io_scene_fbx/import_fbx.py +++ b/io_scene_fbx/import_fbx.py @@ -2134,8 +2134,8 @@ def load(operator, context, filepath="", return [(c_found[0], c_found[1], c_type) for (c_uuid, c_type) in dct.get(fbx_uuid, ()) # 0 is used for the root node, which isnt in fbx_table_nodes - for c_found in (() if c_uuid is 0 else (fbx_table_nodes[c_uuid],)) - if (fbx_id is None) or (c_found[0].id == fbx_id)] + for c_found in (() if c_uuid is 0 else (fbx_table_nodes.get(c_uuid, (None, None)),)) + if (fbx_id is None) or (c_found[0] and c_found[0].id == fbx_id)] def connection_filter_forward(fbx_uuid, fbx_id): return connection_filter_ex(fbx_uuid, fbx_id, fbx_connection_map) @@ -2454,7 +2454,7 @@ def load(operator, context, filepath="", if fbx_obj.id != b'Geometry': continue - mesh = fbx_table_nodes[fbx_uuid][1] + mesh = fbx_table_nodes.get(fbx_uuid, (None, None))[1] # can happen in rare cases if mesh is None: @@ -2537,7 +2537,7 @@ def load(operator, context, filepath="", if fbx_obj.id != b'Material': continue - material = fbx_table_nodes[fbx_uuid][1] + material = fbx_table_nodes.get(fbx_uuid, (None, None))[1] for (fbx_lnk, image, fbx_lnk_type) in connection_filter_reverse(fbx_uuid, b'Texture'): @@ -2655,7 +2655,7 @@ def load(operator, context, filepath="", fbx_obj, blen_data = fbx_item if fbx_obj.id != b'Material': continue - material = fbx_table_nodes[fbx_uuid][1] + material = fbx_table_nodes.get(fbx_uuid, (None, None))[1] image, tex_map = material_images.get(material, {}).get(b'DiffuseColor', (None, None)) # do we have alpha? if image and image.depth == 32: -- cgit v1.2.3