Repository: khronosgroup/gltf-blender-io
Issue: Driver issue

* Test case 1, animation not detected
* Test case 2 seems to be OK the first time, but not the second one --> Cache issue
* Test case 3, animation seems to be OK, but SK is wrong (basic mesh has already shapekey baked)
[drivers.zip](https://github.com/KhronosGroup/glTF-Blender-IO/files/4179292/drivers.zip)


Changed files:
addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py, addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py

diff --git a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
index 8f515bcb..99a0ef91 100644
--- a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
+++ b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
@@ -21,6 +21,7 @@ from io_scene_gltf2.io.com import gltf2_io_debug
 from io_scene_gltf2.blender.exp.gltf2_blender_gather_cache import cached
 from io_scene_gltf2.blender.exp import gltf2_blender_gather_animation_samplers
 from io_scene_gltf2.blender.exp import gltf2_blender_gather_animation_channel_target
+from io_scene_gltf2.blender.exp import gltf2_blender_gather_animation_sampler_keyframes
 from io_scene_gltf2.blender.exp import gltf2_blender_get
 from io_scene_gltf2.blender.exp import gltf2_blender_gather_skins
 from io_scene_gltf2.blender.exp import gltf2_blender_gather_drivers
@@ -124,6 +125,8 @@ def gather_animation_channels(blender_action: bpy.types.Action,
     # resetting driver caches
     gltf2_blender_gather_drivers.get_sk_driver_values.reset_cache()
     gltf2_blender_gather_drivers.get_sk_drivers.reset_cache()
+    # resetting bone caches
+    gltf2_blender_gather_animation_sampler_keyframes.get_bone_matrix.reset_cache()
 
     return channels
 
diff --git a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py
index b41e400f..e82d5929 100644
--- a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py
+++ b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py
@@ -69,6 +69,13 @@ def cached(func):
 
 def bonecache(func):
 
+    def reset_cache_bonecache():
+        func.__current_action_name = None
+        func.__current_armature_name = None
+        func.__bonecache = {}
+
+    func.reset_cache = reset_cache_bonecache
+
     @functools.wraps(func)
     def wrapper_bonecache(*args, **kwargs):
         if args[2] is None:
@@ -78,9 +85,7 @@ def bonecache(func):
             pose_bone_if_armature = args[0].pose.bones[args[2]]
 
         if not hasattr(func, "__current_action_name"):
-            func.__current_action_name = None
-            func.__current_armature_name = None
-            func.__bonecache = {}
+            func.reset_cache()
         if args[6] != func.__current_action_name or args[0] != func.__current_armature_name:
             result = func(*args)
             func.__bonecache = result
@@ -106,7 +111,6 @@ def skdriverdiscovercache(func):
     @functools.wraps(func)
     def wrapper_skdriverdiscover(*args, **kwargs):
         if not hasattr(func, "__current_armature_name") or func.__current_armature_name is None:
-            func.__current_armature_name = None
             func.reset_cache()
 
         if args[0] != func.__current_armature_name: