[Bf-extensions-cvs] [5e564f93] master: Fix T78083: FBX import: handle missing LayerElementNormal data more gracefully

Philipp Oeser noreply at git.blender.org
Fri Jun 26 14:09:59 CEST 2020


Commit: 5e564f9304a03380fc97bfad24121289fceb65dc
Author: Philipp Oeser
Date:   Thu Jun 25 16:58:15 2020 +0200
Branches: master
https://developer.blender.org/rBA5e564f9304a03380fc97bfad24121289fceb65dc

Fix T78083: FBX import: handle missing LayerElementNormal data more
gracefully

If the 'Include Custom Normals' import option is used, and the FBX looks
like it has LayerElementNormal (but lacks the actual data), dont throw
an error, just print a warning and continue.

(this has a downside, since such stuff can easily go unnoticed then, but
this seems to be done elsewhere as well...)

Maniphest Tasks: T78083

Differential Revision: https://developer.blender.org/D8122

===================================================================

M	io_scene_fbx/__init__.py
M	io_scene_fbx/import_fbx.py

===================================================================

diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index b412d35f..e5fa3284 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": (4, 21, 2),
+    "version": (4, 21, 3),
     "blender": (2, 90, 0),
     "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 6664be4e..3e0b2bfd 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -1203,6 +1203,10 @@ def blen_read_geom_layer_normal(fbx_obj, mesh, xform=None):
     fbx_layer_data = elem_prop_first(elem_find_first(fbx_layer, layer_id))
     fbx_layer_index = elem_prop_first(elem_find_first(fbx_layer, b'NormalsIndex'))
 
+    if fbx_layer_data is None:
+        print("warning %r %r missing data" % (layer_id, fbx_layer_name))
+        return False
+
     # try loops, then vertices.
     tries = ((mesh.loops, "Loops", False, blen_read_geom_array_mapped_polyloop),
              (mesh.polygons, "Polygons", True, blen_read_geom_array_mapped_polygon),



More information about the Bf-extensions-cvs mailing list