Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2014-09-19 16:31:17 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-09-19 16:31:17 +0400
commitf7ef101d09b0bdb34f88629f0feab5af6d274b43 (patch)
treeaa7d2430f39b50aabe6191b92f51300115b577d5
parentaeb4cb010eb497e3c511edcad05e8d8831a1ca12 (diff)
Fix T41766: FBX (binary) exporter does not export actions with one frame animations.
When we are exporting actions or strips from NLA, and an evaluated anim leads to no anim at all (like single-keyed actions or pure static ones), key all start and end frames. Note this might be overkill (due to baked anim, we will key *all* transform channels), but probably better than skipping completely those actions!
-rw-r--r--io_scene_fbx/export_fbx_bin.py17
-rw-r--r--io_scene_fbx/fbx_utils.py8
-rw-r--r--io_scene_fbx_experimental/export_fbx_bin.py17
-rw-r--r--io_scene_fbx_experimental/fbx_utils.py8
4 files changed, 32 insertions, 18 deletions
diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index d8c64387..f7323863 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 b751025c..e3218699 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 224bf8b4..cd85691a 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 369d9ab4..6e9bf874 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: