[Bf-extensions-cvs] [f89d1c95] blender2.8: Fix orientation issue in object animation
Julien Duroure
noreply at git.blender.org
Sun Nov 25 16:26:21 CET 2018
Commit: f89d1c9581c03160485a7b4b09fa5d538331fdeb
Author: Julien Duroure
Date: Sun Nov 25 16:26:12 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBAf89d1c9581c03160485a7b4b09fa5d538331fdeb
Fix orientation issue in object animation
===================================================================
M io_scene_gltf2/blender/imp/gltf2_blender_animation_bone.py
M io_scene_gltf2/blender/imp/gltf2_blender_animation_node.py
M io_scene_gltf2/blender/imp/gltf2_blender_gltf.py
M io_scene_gltf2/blender/imp/gltf2_blender_scene.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 ec95692b..c0884966 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_animation_bone.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_animation_bone.py
@@ -172,7 +172,7 @@ class BlenderBoneAnim():
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)
+ # (is an action from a deleted object)
if action.users == 1:
bpy.data.actions.remove(action)
action = bpy.data.actions.new(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 2a04f469..9302afd5 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_animation_node.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_animation_node.py
@@ -55,7 +55,7 @@ class BlenderNodeAnim():
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)
+ # (is an action from a deleted object)
if action.users == 1:
bpy.data.actions.remove(action)
action = bpy.data.actions.new(name)
@@ -63,6 +63,10 @@ class BlenderNodeAnim():
obj.animation_data_create()
obj.animation_data.action = bpy.data.actions[action.name]
+ # There is an animation on object
+ # We can't remove Yup2Zup oject
+ gltf.animation_object = True
+
for channel_idx in node.animations[anim_idx]:
channel = animation.channels[channel_idx]
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_gltf.py b/io_scene_gltf2/blender/imp/gltf2_blender_gltf.py
index 0c819f9c..9afc12de 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_gltf.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_gltf.py
@@ -77,6 +77,10 @@ class BlenderGlTF():
# default scene used
gltf.blender_scene = None
+ # Check if there is animation on object
+ # Init is to False, and will be set to True during creation
+ gltf.animation_object = False
+
# Blender material
if gltf.data.materials:
for material in gltf.data.materials:
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_scene.py b/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
index 14310fb8..c155b115 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
@@ -80,16 +80,18 @@ class BlenderScene():
for node_idx in pyscene.nodes:
bpy.data.objects[gltf.data.nodes[node_idx].blender_object].parent = obj_rotation
+ if gltf.animation_object is False:
- for node_idx in pyscene.nodes:
- for obj_ in bpy.context.scene.objects:
- obj_.select_set(False)
- bpy.data.objects[gltf.data.nodes[node_idx].blender_object].select_set(True)
- bpy.context.view_layer.objects.active = bpy.data.objects[gltf.data.nodes[node_idx].blender_object]
- bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM')
+ for node_idx in pyscene.nodes:
+ for obj_ in bpy.context.scene.objects:
+ obj_.select_set(False)
+ bpy.data.objects[gltf.data.nodes[node_idx].blender_object].select_set(True)
+ bpy.context.view_layer.objects.active = bpy.data.objects[gltf.data.nodes[node_idx].blender_object]
+
+ bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM')
- # remove object
- bpy.context.scene.collection.objects.unlink(obj_rotation)
- bpy.data.objects.remove(obj_rotation)
+ # remove object
+ bpy.context.scene.collection.objects.unlink(obj_rotation)
+ bpy.data.objects.remove(obj_rotation)
More information about the Bf-extensions-cvs
mailing list