From 5d9c8f2b871f3a02b0348c564039772d9938137a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 10 Sep 2018 15:24:29 +0200 Subject: Fix T56732: FBX camera import fails with assert(fbx_props[0] is not None). Those asserts were already commented out in quiet a few places, now it's obvious that having that set of properties defined in actual data nodes is totally optional, so remove them alltogether. Also fixed a bug in property fetching, with newer (>= 7.4) FBX files we would never get templates... Stupid mistake. :/ --- io_scene_fbx/__init__.py | 2 +- io_scene_fbx/import_fbx.py | 15 +-------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py index 920ddc4c..11668fee 100644 --- a/io_scene_fbx/__init__.py +++ b/io_scene_fbx/__init__.py @@ -21,7 +21,7 @@ bl_info = { "name": "FBX format", "author": "Campbell Barton, Bastien Montagne, Jens Restemeier", - "version": (3, 9, 2), + "version": (3, 9, 3), "blender": (2, 79, 1), "location": "File > Import-Export", "description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions", diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py index 446be0ff..dbc07970 100644 --- a/io_scene_fbx/import_fbx.py +++ b/io_scene_fbx/import_fbx.py @@ -1328,7 +1328,6 @@ def blen_read_material(fbx_tmpl, fbx_obj, settings): fbx_props = (elem_find_first(fbx_obj, b'Properties70'), elem_find_first(fbx_tmpl, b'Properties70', fbx_elem_nil)) - #~ assert(fbx_props[0] is not None) # Some Material may be missing that one, it seems... see T50566. ma_diff = elem_props_get_color_rgb(fbx_props, b'DiffuseColor', const_color_white) ma_spec = elem_props_get_color_rgb(fbx_props, b'SpecularColor', const_color_white) @@ -1446,7 +1445,6 @@ def blen_read_camera(fbx_tmpl, fbx_obj, global_scale): fbx_props = (elem_find_first(fbx_obj, b'Properties70'), elem_find_first(fbx_tmpl, b'Properties70', fbx_elem_nil)) - assert(fbx_props[0] is not None) camera = bpy.data.cameras.new(name=elem_name_utf8) @@ -1475,10 +1473,6 @@ def blen_read_light(fbx_tmpl, fbx_obj, global_scale): fbx_props = (elem_find_first(fbx_obj, b'Properties70'), elem_find_first(fbx_tmpl, b'Properties70', fbx_elem_nil)) - # rare - if fbx_props[0] is None: - lamp = bpy.data.lamps.new(name=elem_name_utf8, type='POINT') - return lamp light_type = { 0: 'POINT', @@ -1959,7 +1953,6 @@ class FbxImportHelperNode: fbx_props = (elem_find_first(self.fbx_elem, b'Properties70'), elem_find_first(fbx_tmpl, b'Properties70', fbx_elem_nil)) - assert(fbx_props[0] is not None) # ---- # Misc Attributes @@ -2116,7 +2109,6 @@ class FbxImportHelperNode: if self.fbx_elem: fbx_props = (elem_find_first(self.fbx_elem, b'Properties70'), elem_find_first(fbx_tmpl, b'Properties70', fbx_elem_nil)) - assert(fbx_props[0] is not None) if settings.use_custom_props: blen_read_custom_properties(self.fbx_elem, arm, settings) @@ -2436,7 +2428,7 @@ def load(operator, context, filepath="", def fbx_template_get(key): ret = fbx_templates.get(key, fbx_elem_nil) - if ret is None: + if ret is fbx_elem_nil: # Newest FBX (7.4 and above) use no more 'K' in their type names... key = (key[0], key[1][1:]) return fbx_templates.get(key, fbx_elem_nil) @@ -2596,7 +2588,6 @@ def load(operator, context, filepath="", fbx_props = (elem_find_first(fbx_obj, b'Properties70'), elem_find_first(fbx_tmpl, b'Properties70', fbx_elem_nil)) - assert(fbx_props[0] is not None) transform_data = blen_read_object_transform_preprocess(fbx_props, fbx_obj, Matrix(), use_prepost_rot) # Note: 'Root' "bones" are handled as (armature) objects. @@ -2957,8 +2948,6 @@ def load(operator, context, filepath="", assert(fbx_obj.id == b'Material') fbx_props = (elem_find_first(fbx_obj, b'Properties70'), elem_find_first(fbx_tmpl, b'Properties70', fbx_elem_nil)) - # Do not assert, it can be None actually, sigh... - #~ assert(fbx_props[0] is not None) # (x / 7.142) is only a guess, cycles usable range is (0.0 -> 0.5) return elem_props_get_number(fbx_props, b'BumpFactor', 2.5) / 7.142 @@ -2967,8 +2956,6 @@ def load(operator, context, filepath="", fbx_props = (elem_find_first(fbx_obj, b'Properties70'), elem_find_first(fbx_tmpl, b'Properties70', fbx_elem_nil)) - # Do not assert, it can be None actually, sigh... - #~ assert(fbx_props[0] is not None) return (elem_props_get_vector_3d(fbx_props, b'Translation', (0.0, 0.0, 0.0)), elem_props_get_vector_3d(fbx_props, b'Rotation', (0.0, 0.0, 0.0)), elem_props_get_vector_3d(fbx_props, b'Scaling', (1.0, 1.0, 1.0)), -- cgit v1.2.3