From 1b0254b5315b68fa0273ae197e64fe6bea387d3a Mon Sep 17 00:00:00 2001 From: Saravanan Date: Mon, 10 Jan 2022 11:32:45 +0100 Subject: 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 --- io_scene_fbx/__init__.py | 2 +- io_scene_fbx/export_fbx_bin.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py index 5a2b7997..9ae3cee8 100644 --- a/io_scene_fbx/__init__.py +++ b/io_scene_fbx/__init__.py @@ -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", diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py index 28280bc3..af8e77af 100644 --- a/io_scene_fbx/export_fbx_bin.py +++ b/io_scene_fbx/export_fbx_bin.py @@ -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 -- cgit v1.2.3