[Bf-extensions-cvs] [ca0c66f7] master: glTF importer: Use debug value 100 to not convert Yup to Zup

Julien Duroure noreply at git.blender.org
Tue May 7 11:15:53 CEST 2019


Commit: ca0c66f7bb72c665420628fe4951f3f0d7970518
Author: Julien Duroure
Date:   Tue May 7 10:49:53 2019 +0200
Branches: master
https://developer.blender.org/rBAca0c66f7bb72c665420628fe4951f3f0d7970518

glTF importer: Use debug value 100 to not convert Yup to Zup

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

M	io_scene_gltf2/blender/imp/gltf2_blender_scene.py

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

diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_scene.py b/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
index 400e66e4..e87912ff 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
@@ -63,15 +63,16 @@ class BlenderScene():
             gltf.blender_scene = scene.name
             list_nodes = BlenderScene.get_root_nodes(gltf)
 
-        # Create Yup2Zup empty
-        obj_rotation = bpy.data.objects.new("Yup2Zup", None)
-        obj_rotation.rotation_mode = 'QUATERNION'
-        obj_rotation.rotation_quaternion = Quaternion((sqrt(2) / 2, sqrt(2) / 2, 0.0, 0.0))
-
-        if gltf.blender_active_collection is not None:
-            bpy.data.collections[gltf.blender_active_collection].objects.link(obj_rotation)
-        else:
-            bpy.data.scenes[gltf.blender_scene].collection.objects.link(obj_rotation)
+        if bpy.app.debug_value != 100:
+            # Create Yup2Zup empty
+            obj_rotation = bpy.data.objects.new("Yup2Zup", None)
+            obj_rotation.rotation_mode = 'QUATERNION'
+            obj_rotation.rotation_quaternion = Quaternion((sqrt(2) / 2, sqrt(2) / 2, 0.0, 0.0))
+
+            if gltf.blender_active_collection is not None:
+                bpy.data.collections[gltf.blender_active_collection].objects.link(obj_rotation)
+            else:
+                bpy.data.scenes[gltf.blender_scene].collection.objects.link(obj_rotation)
 
         if list_nodes is not None:
             for node_idx in list_nodes:
@@ -101,61 +102,62 @@ class BlenderScene():
                 for an in gltf.current_animation_names.values():
                     gltf.animation_managed.append(an)
 
-        # Parent root node to rotation object
-        if list_nodes is not None:
-            exclude_nodes = []
-            for node_idx in list_nodes:
-                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
+        if bpy.app.debug_value != 100:
+            # Parent root node to rotation object
+            if list_nodes is not None:
+                exclude_nodes = []
+                for node_idx in list_nodes:
+                    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:
-                        exclude_nodes.append(node_idx)
+                        # 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:
+                if gltf.animation_object is False:
 
 
 
 
 
-                # Avoid rotation bug if collection is hidden or disabled
-                if gltf.blender_active_collection is not None:
-                    gltf.collection_hide_viewport = bpy.data.collections[gltf.blender_active_collection].hide_viewport
-                    bpy.data.collections[gltf.blender_active_collection].hide_viewport = False
-                    # TODO for visibility ... but seems not exposed on bpy for now
+                    # Avoid rotation bug if collection is hidden or disabled
+                    if gltf.blender_active_collection is not None:
+                        gltf.collection_hide_viewport = bpy.data.collections[gltf.blender_active_collection].hide_viewport
+                        bpy.data.collections[gltf.blender_active_collection].hide_viewport = False
+                        # TODO for visibility ... but seems not exposed on bpy for now
 
-                for node_idx in list_nodes:
+                    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
+                        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)
-                    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]
+                        for obj_ in bpy.context.scene.objects:
+                            obj_.select_set(False)
+                        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]
+                        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')
+                        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)
 
-                # Restore collection hiden / disabled values
-                if gltf.blender_active_collection is not None:
-                    bpy.data.collections[gltf.blender_active_collection].hide_viewport = gltf.collection_hide_viewport
-                    # TODO restore visibility when expose in bpy
+                    # Restore collection hiden / disabled values
+                    if gltf.blender_active_collection is not None:
+                        bpy.data.collections[gltf.blender_active_collection].hide_viewport = gltf.collection_hide_viewport
+                        # TODO restore visibility when expose in bpy
 
         # Make first root object the new active one
         if list_nodes is not None:



More information about the Bf-extensions-cvs mailing list