[Bf-extensions-cvs] [c840ce4] master: Fix T43929: Exporting a mesh with shape keys as FBX with smoothing, creates invalid file.

Bastien Montagne noreply at git.blender.org
Thu Mar 12 10:29:08 CET 2015


Commit: c840ce418476ace6d86fcf7751f309c026ff49d2
Author: Bastien Montagne
Date:   Thu Mar 12 10:21:45 2015 +0100
Branches: master
https://developer.blender.org/rBAc840ce418476ace6d86fcf7751f309c026ff49d2

Fix T43929: Exporting a mesh with shape keys as FBX with smoothing, creates invalid file.

Stupid libfbx crashes when there is no normals in 'main' mesh data, and some shape keys linked to that mesh.

Now, issue is, I removed always writing normals because iirc this was giving bugs
with some importers... Re-enabled it for now, let's hope everything works OK.

*do not backport this* to 2.74!

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

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 6b6f39e..eb729fe 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -263,12 +263,12 @@ class ExportFBX(bpy.types.Operator, ExportHelper, OrientationHelper):
             )
     mesh_smooth_type = EnumProperty(
             name="Smoothing",
-            items=(('OFF', "Normals", "Export normals instead of writing edge or face smoothing data"),
+            items=(('OFF', "Normals Only", "Export only normals instead of writing edge or face smoothing data"),
                    ('FACE', "Face", "Write face smoothing"),
                    ('EDGE', "Edge", "Write edge smoothing"),
                    ),
             description="Export smoothing information "
-                        "(prefer 'Off' option if your target importer understand split normals)",
+                        "(prefer 'Normals Only' option if your target importer understand split normals)",
             default='OFF',
             )
     use_mesh_edges = BoolProperty(
@@ -425,7 +425,7 @@ class ExportFBX(bpy.types.Operator, ExportHelper, OrientationHelper):
         layout.prop(self, "mesh_smooth_type")
         layout.prop(self, "use_mesh_edges")
         sub = layout.row()
-        sub.enabled = self.mesh_smooth_type in {'OFF'}
+        #~ sub.enabled = self.mesh_smooth_type in {'OFF'}
         sub.prop(self, "use_tspace")
         layout.prop(self, "use_armature_deform_only")
         if is_74bin:
diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index 8686bbc..d17d714 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -738,6 +738,8 @@ def fbx_data_mesh_shapes_elements(root, me_obj, me, scene_data, fbx_me_tmpl, fbx
     if me not in scene_data.data_deformers_shape:
         return
 
+    write_normals = True  # scene_data.settings.mesh_smooth_type in {'OFF'}
+
     # First, write the geometry data itself (i.e. shapes).
     _me_key, shape_key, shapes = scene_data.data_deformers_shape[me]
 
@@ -768,7 +770,8 @@ def fbx_data_mesh_shapes_elements(root, me_obj, me, scene_data, fbx_me_tmpl, fbx
 
         elem_data_single_int32_array(geom, b"Indexes", shape_verts_idx)
         elem_data_single_float64_array(geom, b"Vertices", shape_verts_co)
-        elem_data_single_float64_array(geom, b"Normals", [0.0] * len(shape_verts_co))
+        if write_normals:
+            elem_data_single_float64_array(geom, b"Normals", [0.0] * len(shape_verts_co))
 
     # Yiha! BindPose for shapekeys too! Dodecasigh...
     # XXX Not sure yet whether several bindposes on same mesh are allowed, or not... :/
@@ -813,7 +816,7 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
 
     # No gscale/gmat here, all data are supposed to be in object space.
     smooth_type = scene_data.settings.mesh_smooth_type
-    write_normals = smooth_type in {'OFF'}
+    write_normals = True  # smooth_type in {'OFF'}
 
     do_bake_space_transform = me_obj.use_bake_space_transform(scene_data)



More information about the Bf-extensions-cvs mailing list