[Bf-extensions-cvs] [8ac09109] blender2.8: glTF importer: fix bug in animation import

Julien Duroure noreply at git.blender.org
Sun Nov 25 16:09:41 CET 2018


Commit: 8ac09109617d8acd81747bd3dffed915aa99c8cc
Author: Julien Duroure
Date:   Sun Nov 25 16:08:23 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBA8ac09109617d8acd81747bd3dffed915aa99c8cc

glTF importer: fix bug in animation import

Problem occured when importing a gltf, delete objects, and importing a
new gltf, with same object / armature

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

M	io_scene_gltf2/blender/imp/gltf2_blender_animation_bone.py
M	io_scene_gltf2/blender/imp/gltf2_blender_animation_node.py

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

diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_animation_bone.py b/io_scene_gltf2/blender/imp/gltf2_blender_animation_bone.py
index 6b670aea..ec95692b 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_animation_bone.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_animation_bone.py
@@ -170,6 +170,12 @@ class BlenderBoneAnim():
             action = bpy.data.actions.new(name)
         else:
             action = bpy.data.actions[name]
+            # Check if this action has some users.
+            # If no user (only 1 indeed), that means that this action must be deleted
+            # (is an action from a deleted action)
+            if action.users == 1:
+                bpy.data.actions.remove(action)
+                action = bpy.data.actions.new(name)
         if not obj.animation_data:
             obj.animation_data_create()
         obj.animation_data.action = bpy.data.actions[action.name]
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_animation_node.py b/io_scene_gltf2/blender/imp/gltf2_blender_animation_node.py
index a5d4b40f..2a04f469 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_animation_node.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_animation_node.py
@@ -53,6 +53,12 @@ class BlenderNodeAnim():
         else:
             name = "Animation_" + str(anim_idx) + "_" + obj.name
         action = bpy.data.actions.new(name)
+        # Check if this action has some users.
+        # If no user (only 1 indeed), that means that this action must be deleted
+        # (is an action from a deleted action)
+        if action.users == 1:
+            bpy.data.actions.remove(action)
+            action = bpy.data.actions.new(name)
         if not obj.animation_data:
             obj.animation_data_create()
         obj.animation_data.action = bpy.data.actions[action.name]



More information about the Bf-extensions-cvs mailing list