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-01-23 00:39:36 +0300
committerJulien Duroure <julien.duroure@gmail.com>2019-01-23 00:39:36 +0300
commitfb88c7f8a2697ff8e4a02b1169212da332dc1ddc (patch)
treedc347f736474b88aa9bec273993b8a92385c8bfd
parent862b0bbd7d319104e7e5f8ab9576daa97be3298d (diff)
glTF importer: fix bug when joint/bone is a root node of the scene
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_scene.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_scene.py b/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
index 902cc290..2d986b0d 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
@@ -87,17 +87,41 @@ class BlenderScene():
# Parent root node to rotation object
if list_nodes is not None:
+ exclude_nodes = []
for node_idx in list_nodes:
- bpy.data.objects[gltf.data.nodes[node_idx].blender_object].parent = obj_rotation
+ if gltf.data.nodes[node_idx].is_joint:
+ # Do not change parent if root node is already parented (can be the case for skinned mesh)
+ if not bpy.data.objects[gltf.data.nodes[node_idx].blender_armature_name].parent:
+ bpy.data.objects[gltf.data.nodes[node_idx].blender_armature_name].parent = obj_rotation
+ else:
+ exclude_nodes.append(node_idx)
+ else:
+ # Do not change parent if root node is already parented (can be the case for skinned mesh)
+ if not bpy.data.objects[gltf.data.nodes[node_idx].blender_object].parent:
+ bpy.data.objects[gltf.data.nodes[node_idx].blender_object].parent = obj_rotation
+ else:
+ exclude_nodes.append(node_idx)
if gltf.animation_object is False:
+
+
for node_idx in list_nodes:
+
+ if node_idx in exclude_nodes:
+ continue # for root node that are parented by the process
+ # for example skinned meshes
+
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]
+ if gltf.data.nodes[node_idx].is_joint:
+ bpy.data.objects[gltf.data.nodes[node_idx].blender_armature_name].select_set(True)
+ bpy.context.view_layer.objects.active = bpy.data.objects[gltf.data.nodes[node_idx].blender_armature_name]
+
+ else:
+ 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')