[Bf-extensions-cvs] [219e882] master: Fix T47457: FBX export: Force full keying in case Simplify factor is set to 0.0

Bastien Montagne noreply at git.blender.org
Wed Feb 17 13:30:23 CET 2016


Commit: 219e882b3168669bb733dafcce10bb79d90e8002
Author: Bastien Montagne
Date:   Wed Feb 17 13:28:28 2016 +0100
Branches: master
https://developer.blender.org/rBA219e882b3168669bb733dafcce10bb79d90e8002

Fix T47457: FBX export: Force full keying in case Simplify factor is set to 0.0

Note that it will export all sampled values - even for actually non-animated channels,
not really possible to avoid that without a hell lot more of code, and this rea is
convoluted enough right now.

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

M	io_scene_fbx/export_fbx_bin.py
M	io_scene_fbx/fbx_utils.py

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

diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index 871c198..a77b74d 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -1856,6 +1856,7 @@ def fbx_animations_do(scene_data, ref_id, f_start, f_end, start_zero, objects=No
     Generate animation data (a single AnimStack) from objects, for a given frame range.
     """
     bake_step = scene_data.settings.bake_anim_step
+    simplify_fac = scene_data.settings.bake_anim_simplify_factor
     scene = scene_data.scene
     force_keying = scene_data.settings.bake_anim_use_all_bones
     force_sek = scene_data.settings.bake_anim_force_startend_keying
@@ -1883,18 +1884,21 @@ def fbx_animations_do(scene_data, ref_id, f_start, f_end, start_zero, objects=No
         ACNW = AnimationCurveNodeWrapper
         loc, rot, scale, _m, _mr = ob_obj.fbx_object_tx(scene_data)
         rot_deg = tuple(convert_rad_to_deg_iter(rot))
-        animdata_ob[ob_obj] = (ACNW(ob_obj.key, 'LCL_TRANSLATION', ob_obj.is_bone and force_keying, force_sek, loc),
-                               ACNW(ob_obj.key, 'LCL_ROTATION', ob_obj.is_bone and force_keying, force_sek, rot_deg),
-                               ACNW(ob_obj.key, 'LCL_SCALING', ob_obj.is_bone and force_keying, force_sek, scale))
+        force_key = (simplify_fac == 0.0) or (ob_obj.is_bone and force_keying)
+        print(force_key, simplify_fac)
+        animdata_ob[ob_obj] = (ACNW(ob_obj.key, 'LCL_TRANSLATION', force_key, force_sek, loc),
+                               ACNW(ob_obj.key, 'LCL_ROTATION', force_key, force_sek, rot_deg),
+                               ACNW(ob_obj.key, 'LCL_SCALING', force_key, force_sek, scale))
         p_rots[ob_obj] = rot
 
     animdata_shapes = OrderedDict()
+    force_key = (simplify_fac == 0.0)
     for me, (me_key, _shapes_key, shapes) in scene_data.data_deformers_shape.items():
         # Ignore absolute shape keys for now!
         if not me.shape_keys.use_relative:
             continue
         for shape, (channel_key, geom_key, _shape_verts_co, _shape_verts_idx) in shapes.items():
-            acnode = AnimationCurveNodeWrapper(channel_key, 'SHAPE_KEY', False, force_sek, (0.0,))
+            acnode = AnimationCurveNodeWrapper(channel_key, 'SHAPE_KEY', force_key, force_sek, (0.0,))
             # Sooooo happy to have to twist again like a mad snake... Yes, we need to write those curves twice. :/
             acnode.add_group(me_key, shape.name, shape.name, (shape.name,))
             animdata_shapes[channel_key] = (acnode, me, shape)
@@ -1923,7 +1927,6 @@ def fbx_animations_do(scene_data, ref_id, f_start, f_end, start_zero, objects=No
     scene.frame_set(back_currframe, 0.0)
 
     animations = OrderedDict()
-    simplify_fac = scene_data.settings.bake_anim_simplify_factor
 
     # And now, produce final data (usable by FBX export code)
     # Objects-like loc/rot/scale...
diff --git a/io_scene_fbx/fbx_utils.py b/io_scene_fbx/fbx_utils.py
index ee91a1d..53a540e 100644
--- a/io_scene_fbx/fbx_utils.py
+++ b/io_scene_fbx/fbx_utils.py
@@ -775,6 +775,9 @@ class AnimationCurveNodeWrapper:
         if not self._keys:
             return
 
+        if fac == 0.0:
+            return
+
         # So that, with default factor and step values (1), we get:
         min_reldiff_fac = fac * 1.0e-3  # min relative value evolution: 0.1% of current 'order of magnitude'.
         min_absdiff_fac = 0.1  # A tenth of reldiff...



More information about the Bf-extensions-cvs mailing list