[Bf-extensions-cvs] [0b0052bd] master: Fix T102836: FBX export including tangents of empty meshes fails.

Bastien Montagne noreply at git.blender.org
Wed Nov 30 16:29:07 CET 2022


Commit: 0b0052bd53ad8249ed07dfb87705c338af698bde
Author: Bastien Montagne
Date:   Wed Nov 30 16:25:43 2022 +0100
Branches: master
https://developer.blender.org/rBA0b0052bd53ad8249ed07dfb87705c338af698bde

Fix T102836: FBX export including tangents of empty meshes fails.

Not ideal that tangent space calc errors on empty mesh when other
similar processes (like lnors computation) perform as usual... But for
now just fix FBX code for this specific behavior.

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

M	io_scene_fbx/__init__.py
M	io_scene_fbx/export_fbx_bin.py

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

diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index 28c85030..d12e6991 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, 37, 1),
+    "version": (4, 37, 2),
     "blender": (3, 4, 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/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index eb503a97..3ee9c75e 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -1072,11 +1072,14 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
                              "cannot compute/export tangent space for it") % me.name)
                 else:
                     del t_lt
-                    t_ln = array.array(data_types.ARRAY_FLOAT64, (0.0,)) * len(me.loops) * 3
+                    num_loops = len(me.loops)
+                    t_ln = array.array(data_types.ARRAY_FLOAT64, (0.0,)) * num_loops * 3
                     # t_lnw = array.array(data_types.ARRAY_FLOAT64, (0.0,)) * len(me.loops)
                     uv_names = [uvlayer.name for uvlayer in me.uv_layers]
-                    for name in uv_names:
-                        me.calc_tangents(uvmap=name)
+                    # Annoying, `me.calc_tangent` errors in case there is no geometry...
+                    if num_loops > 0:
+                        for name in uv_names:
+                            me.calc_tangents(uvmap=name)
                     for idx, uvlayer in enumerate(me.uv_layers):
                         name = uvlayer.name
                         # Loop bitangents (aka binormals).



More information about the Bf-extensions-cvs mailing list