[Bf-extensions-cvs] [1b0254b5] master: Fbx IO: improve export speed of 'rested' armatures

Saravanan noreply at git.blender.org
Mon Jan 10 11:43:43 CET 2022


Commit: 1b0254b5315b68fa0273ae197e64fe6bea387d3a
Author: Saravanan
Date:   Mon Jan 10 11:32:45 2022 +0100
Branches: master
https://developer.blender.org/rBA1b0254b5315b68fa0273ae197e64fe6bea387d3a

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

===================================================================

M	io_scene_fbx/__init__.py
M	io_scene_fbx/export_fbx_bin.py

===================================================================

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



More information about the Bf-extensions-cvs mailing list