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:
authorJulien Duroure <julien.duroure@gmail.com>2019-09-11 23:17:38 +0300
committerJulien Duroure <julien.duroure@gmail.com>2019-09-11 23:17:38 +0300
commit8d9e3c94aff9e366d9a4804d98b2517bd04244f6 (patch)
tree4db8a5e40fbe884d972a623ae67b8825ee1f9624 /io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py
parent14f1c99e96adad81aea2a5a77eb51d22b96c9618 (diff)
glTF exporter: performance: huge speedup when exporting using sample animations
Diffstat (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py')
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py
index 99286aea..e73e5522 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py
@@ -65,6 +65,27 @@ def cached(func):
return result
return wrapper_cached
+def bonecache(func):
+
+ @functools.wraps(func)
+ def wrapper_bonecache(*args, **kwargs):
+ if args[2] is None:
+ pose_bone_if_armature = gltf2_blender_get.get_object_from_datapath(args[0],
+ args[1][0].data_path)
+ else:
+ pose_bone_if_armature = args[0].pose.bones[args[2]]
+
+ if not hasattr(func, "__current_action_name"):
+ func.__current_action_name = None
+ func.__bonecache = {}
+ if args[6] != func.__current_action_name:
+ result = func(*args)
+ func.__bonecache = result
+ func.__current_action_name = args[6]
+ return result[args[7]][pose_bone_if_armature.name]
+ else:
+ return func.__bonecache[args[7]][pose_bone_if_armature.name]
+ return wrapper_bonecache
# TODO: replace "cached" with "unique" in all cases where the caching is functional and not only for performance reasons
call_or_fetch = cached