[Bf-extensions-cvs] [514aca8a] master: Fix T98345: Import von FBX didn't work.

Bastien Montagne noreply at git.blender.org
Mon Jun 13 12:58:02 CEST 2022


Commit: 514aca8ac9cf485a27676fca5441a6445aef498b
Author: Bastien Montagne
Date:   Mon Jun 13 12:55:09 2022 +0200
Branches: master
https://developer.blender.org/rBA514aca8ac9cf485a27676fca5441a6445aef498b

Fix T98345: Import von FBX didn't work.

Highly suspect the source FBX file to be broken, but investigating a 20MB
binary FBX file is not really an option right now, so cannot be 100%
sure. This can only be realistically investigated if we get a much
smaller reproducible case.

In the mean while, add similar check about indices validity for source
FBX data as we already have for destination Blender data arrays. This
allows to keep importing instead of 'crshing' the import process at
least.

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

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 f7415a38..1b7e646d 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -3,7 +3,7 @@
 bl_info = {
     "name": "FBX format",
     "author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
-    "version": (4, 36, 1),
+    "version": (4, 36, 2),
     "blender": (3, 2, 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 5fabec24..90f0c016 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -778,16 +778,22 @@ def blen_read_geom_layerinfo(fbx_layer):
 
 def blen_read_geom_array_setattr(generator, blen_data, blen_attr, fbx_data, stride, item_size, descr, xform):
     """Generic fbx_layer to blen_data setter, generator is expected to yield tuples (ble_idx, fbx_idx)."""
-    max_idx = len(blen_data) - 1
+    max_blen_idx = len(blen_data) - 1
+    max_fbx_idx = len(fbx_data) - 1
     print_error = True
 
     def check_skip(blen_idx, fbx_idx):
         nonlocal print_error
         if fbx_idx < 0:  # Negative values mean 'skip'.
             return True
-        if blen_idx > max_idx:
+        if blen_idx > max_blen_idx:
             if print_error:
-                print("ERROR: too much data in this layer, compared to elements in mesh, skipping!")
+                print("ERROR: too much data in this Blender layer, compared to elements in mesh, skipping!")
+                print_error = False
+            return True
+        if fbx_idx + item_size - 1 > max_fbx_idx:
+            if print_error:
+                print("ERROR: not enough data in this FBX layer, skipping!")
                 print_error = False
             return True
         return False



More information about the Bf-extensions-cvs mailing list