Fix T44386: FBX export with 'all actions' enabled was a bit too much enthusiast.

It would export animations from all compatible actions - even for objects that were
actually not animated at all! This would lead to undesired behavior esp. for
simple objects scenes with only one or two animated.

Now we only export all compatible actions for a given object if it is actually
animated.
This commit is contained in:
Bastien Montagne 2015-04-26 14:47:40 +02:00
parent bd9fa80543
commit 3b6028fd8b
Notes: blender-bot 2023-02-14 19:57:33 +01:00
Referenced by issue #44386, FBX: issue export/import
2 changed files with 10 additions and 12 deletions

View File

@ -21,7 +21,7 @@
bl_info = {
"name": "FBX format",
"author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
"version": (3, 2, 3),
"version": (3, 2, 4),
"blender": (2, 74, 0),
"location": "File > Import-Export",
"description": "FBX IO meshes, UV's, vertex colors, materials, "
@ -346,7 +346,9 @@ class ExportFBX(bpy.types.Operator, ExportHelper, IOFBXOrientationHelper):
)
bake_anim_use_all_actions = BoolProperty(
name="All Actions",
description="Export each action as a separated FBX's AnimStack, instead of global scene animation",
description="Export each action as a separated FBX's AnimStack, instead of global scene animation "
"(note that animated objects will get all actions compatible with them, "
"others will get no animation at all)",
default=True,
)
bake_anim_step = FloatProperty(

View File

@ -2010,17 +2010,16 @@ def fbx_animations(scene_data):
ob = ob_obj.bdata # Back to real Blender Object.
if not ob.animation_data:
continue # Do not export animations for objects that are absolutely not animated, see T44386.
# We can't play with animdata and actions and get back to org state easily.
# So we have to add a temp copy of the object to the scene, animate it, and remove it... :/
ob_copy = ob.copy()
# Great, have to handle bones as well if needed...
pbones_matrices = [pbo.matrix_basis.copy() for pbo in ob.pose.bones] if ob.type == 'ARMATURE' else ...
if ob.animation_data:
org_act = ob.animation_data.action
else:
org_act = ...
ob.animation_data_create()
org_act = ob.animation_data.action
path_resolve = ob.path_resolve
for act in bpy.data.actions:
@ -2036,16 +2035,13 @@ def fbx_animations(scene_data):
if pbones_matrices is not ...:
for pbo, mat in zip(ob.pose.bones, pbones_matrices):
pbo.matrix_basis = mat.copy()
ob.animation_data.action = None if org_act is ... else org_act
ob.animation_data.action = org_act
restore_object(ob, ob_copy)
if pbones_matrices is not ...:
for pbo, mat in zip(ob.pose.bones, pbones_matrices):
pbo.matrix_basis = mat.copy()
if org_act is ...:
ob.animation_data_clear()
else:
ob.animation_data.action = org_act
ob.animation_data.action = org_act
bpy.data.objects.remove(ob_copy)