[Bf-extensions-cvs] [57684e2b] master: Fix T64999: FBX export fails with empty material slot.

Bastien Montagne noreply at git.blender.org
Thu May 23 09:36:06 CEST 2019


Commit: 57684e2bbf6073736bbd7708695d1a912b1a2a76
Author: Bastien Montagne
Date:   Thu May 23 09:34:45 2019 +0200
Branches: master
https://developer.blender.org/rBA57684e2bbf6073736bbd7708695d1a912b1a2a76

Fix T64999: FBX export fails with empty material slot.

We cannot reliably use `mesh.materials`, since those might be empty when
materials are only assigned/linked to the object...

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

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 dfe55f17..f7f9c4e3 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, 14, 8),
+    "version": (4, 14, 9),
     "blender": (2, 80, 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 915dda16..6f01ddf8 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -1130,9 +1130,8 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
     # Face's materials.
     me_fbxmaterials_idx = scene_data.mesh_material_indices.get(me)
     if me_fbxmaterials_idx is not None:
-        # Mapping to indices is done using original material pointers, so need to go from evaluated
-        # to original (this is for the case mesh is a result of evaluated modifier stack).
-        me_blmaterials = [material.original for material in  me.materials]
+        # We cannot use me.materials here, as this array is filled with None in case materials are linked to object...
+        me_blmaterials = [mat_slot.material for mat_slot in me_obj.material_slots]
         if me_fbxmaterials_idx and me_blmaterials:
             lay_ma = elem_data_single_int32(geom, b"LayerElementMaterial", 0)
             elem_data_single_int32(lay_ma, b"Version", FBX_GEOMETRY_MATERIAL_VERSION)



More information about the Bf-extensions-cvs mailing list