diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py index d8c643872dc087ee0cd3577d70e0863b27b6467b..f732386327af6f34a3e215fc87d37e3de9d4ebc9 100644 --- a/io_scene_fbx/export_fbx_bin.py +++ b/io_scene_fbx/export_fbx_bin.py @@ -1789,18 +1789,19 @@ def fbx_animations_do(scene_data, ref_id, f_start, f_end, start_zero, objects=No # Objects-like loc/rot/scale... for ob_obj, anims in animdata_ob.items(): for anim in anims: - anim.simplfy(simplify_fac, bake_step) - if anim: - for obj_key, group_key, group, fbx_group, fbx_gname in anim.get_final_data(scene, ref_id, force_keep): - anim_data = animations.get(obj_key) - if anim_data is None: - anim_data = animations[obj_key] = ("dummy_unused_key", OrderedDict()) - anim_data[1][fbx_group] = (group_key, group, fbx_gname) + anim.simplfy(simplify_fac, bake_step, force_keep) + if not anim: + continue + for obj_key, group_key, group, fbx_group, fbx_gname in anim.get_final_data(scene, ref_id, force_keep): + anim_data = animations.get(obj_key) + if anim_data is None: + anim_data = animations[obj_key] = ("dummy_unused_key", OrderedDict()) + anim_data[1][fbx_group] = (group_key, group, fbx_gname) # And meshes' shape keys. for channel_key, (anim_shape, me, shape) in animdata_shapes.items(): final_keys = OrderedDict() - anim_shape.simplfy(simplify_fac, bake_step) + anim_shape.simplfy(simplify_fac, bake_step, force_keep) if not anim_shape: continue for elem_key, group_key, group, fbx_group, fbx_gname in anim_shape.get_final_data(scene, ref_id, force_keep): diff --git a/io_scene_fbx/fbx_utils.py b/io_scene_fbx/fbx_utils.py index b751025c0c9a09aff79f40e3aea74ca2d8a0e1ec..e3218699c16efef377974f4863bff7d5ec502fb0 100644 --- a/io_scene_fbx/fbx_utils.py +++ b/io_scene_fbx/fbx_utils.py @@ -679,7 +679,7 @@ class AnimationCurveNodeWrapper: assert(len(values) == len(self.fbx_props[0])) self._keys.append((frame, values, [True] * len(values))) # write everything by default. - def simplfy(self, fac, step): + def simplfy(self, fac, step, force_keep=False): """ Simplifies sampled curves by only enabling samples when: * their values differ significantly from the previous sample ones, or @@ -726,6 +726,12 @@ class AnimationCurveNodeWrapper: p_keyed[idx] = (currframe, val) are_keyed[idx] = True p_currframe, p_key, p_key_write = currframe, key, key_write + + # If we write nothing (action doing nothing) and are in 'force_keep' mode, we key everything! :P + # See T41766. + if (force_keep and not self): + are_keyed[:] = [True] * len(are_keyed) + # If we did key something, ensure first and last sampled values are keyed as well. for idx, is_keyed in enumerate(are_keyed): if is_keyed: diff --git a/io_scene_fbx_experimental/export_fbx_bin.py b/io_scene_fbx_experimental/export_fbx_bin.py index 224bf8b4ac386efe7741c9aa346748e1bc878630..cd85691a1d4b7ff2d5184b0f32c229dbe5fc95ff 100644 --- a/io_scene_fbx_experimental/export_fbx_bin.py +++ b/io_scene_fbx_experimental/export_fbx_bin.py @@ -1880,18 +1880,19 @@ def fbx_animations_do(scene_data, ref_id, f_start, f_end, start_zero, objects=No # Objects-like loc/rot/scale... for ob_obj, anims in animdata_ob.items(): for anim in anims: - anim.simplfy(simplify_fac, bake_step) - if anim: - for obj_key, group_key, group, fbx_group, fbx_gname in anim.get_final_data(scene, ref_id, force_keep): - anim_data = animations.get(obj_key) - if anim_data is None: - anim_data = animations[obj_key] = ("dummy_unused_key", OrderedDict()) - anim_data[1][fbx_group] = (group_key, group, fbx_gname) + anim.simplfy(simplify_fac, bake_step, force_keep) + if not anim: + continue + for obj_key, group_key, group, fbx_group, fbx_gname in anim.get_final_data(scene, ref_id, force_keep): + anim_data = animations.get(obj_key) + if anim_data is None: + anim_data = animations[obj_key] = ("dummy_unused_key", OrderedDict()) + anim_data[1][fbx_group] = (group_key, group, fbx_gname) # And meshes' shape keys. for channel_key, (anim_shape, me, shape) in animdata_shapes.items(): final_keys = OrderedDict() - anim_shape.simplfy(simplify_fac, bake_step) + anim_shape.simplfy(simplify_fac, bake_step, force_keep) if not anim_shape: continue for elem_key, group_key, group, fbx_group, fbx_gname in anim_shape.get_final_data(scene, ref_id, force_keep): diff --git a/io_scene_fbx_experimental/fbx_utils.py b/io_scene_fbx_experimental/fbx_utils.py index 369d9ab46e846322108859e659a4e733109a51ac..6e9bf8740abe609ea4a8efb03d86ba9a47607484 100644 --- a/io_scene_fbx_experimental/fbx_utils.py +++ b/io_scene_fbx_experimental/fbx_utils.py @@ -679,7 +679,7 @@ class AnimationCurveNodeWrapper: assert(len(values) == len(self.fbx_props[0])) self._keys.append((frame, values, [True] * len(values))) # write everything by default. - def simplfy(self, fac, step): + def simplfy(self, fac, step, force_keep=False): """ Simplifies sampled curves by only enabling samples when: * their values differ significantly from the previous sample ones, or @@ -726,6 +726,12 @@ class AnimationCurveNodeWrapper: p_keyed[idx] = (currframe, val) are_keyed[idx] = True p_currframe, p_key, p_key_write = currframe, key, key_write + + # If we write nothing (action doing nothing) and are in 'force_keep' mode, we key everything! :P + # See T41766. + if (force_keep and not self): + are_keyed[:] = [True] * len(are_keyed) + # If we did key something, ensure first and last sampled values are keyed as well. for idx, is_keyed in enumerate(are_keyed): if is_keyed: