Fbx IO: improve export speed of 'rested' armatures

As part of Fbx Export, while handling Armature modifiers for Meshes, each
armature's position is backed up, then put into REST position for exporting,
and then restored back to original position. A dependency graph update is
triggered at the end of this.

This commit avoids the whole backing position setting + depsgraph update in
case the armature is already in rest position.

As an example, a model which I am developing for a game used to take
20 minutes for the Fbx Export. After this change, it only takes 20 seconds.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D13712
This commit is contained in:
Saravanan 2022-01-10 11:32:45 +01:00 committed by Bastien Montagne
parent f26299bacc
commit 1b0254b531
2 changed files with 7 additions and 3 deletions

View File

@ -21,7 +21,7 @@
bl_info = {
"name": "FBX format",
"author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
"version": (4, 27, 0),
"version": (4, 28, 0),
"blender": (2, 90, 0),
"location": "File > Import-Export",
"description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",

View File

@ -2287,8 +2287,12 @@ def fbx_data_from_scene(scene, depsgraph, settings):
object = mod.object
if object and object.type == 'ARMATURE':
armature = object.data
backup_pose_positions.append((armature, armature.pose_position))
armature.pose_position = 'REST'
# If armature is already in REST position, there's nothing to back-up
# This cuts down on export time dramatically, if all armatures are already in REST position
# by not triggering dependency graph update
if armature.pose_position != 'REST':
backup_pose_positions.append((armature, armature.pose_position))
armature.pose_position = 'REST'
elif mod.show_render or mod.show_viewport:
# If exporting with subsurf collect the last Catmull-Clark subsurf modifier
# and disable it. We can use the original data as long as this is the first