glTF importer: Keep user render engine (cycles or Eevee) when importing

Note that node tree can't be created when render engine is Workbench, so
switching to Eevee.
This commit is contained in:
Julien Duroure 2019-04-15 16:40:56 +02:00
parent b1cc242cfd
commit fefd011035
2 changed files with 6 additions and 3 deletions

View File

@ -25,7 +25,8 @@ class BlenderGlTF():
@staticmethod
def create(gltf):
"""Create glTF main method."""
bpy.context.scene.render.engine = 'BLENDER_EEVEE'
if bpy.context.scene.render.engine not in ['CYCLES', 'BLENDER_EEVEE']:
bpy.context.scene.render.engine = 'BLENDER_EEVEE'
BlenderGlTF.pre_compute(gltf)
if gltf.data.scenes is not None:

View File

@ -41,7 +41,8 @@ class BlenderScene():
scene = bpy.context.scene
if bpy.context.collection.name in bpy.data.collections: # avoid master collection
gltf.blender_active_collection = bpy.context.collection.name
scene.render.engine = "BLENDER_EEVEE"
if scene.render.engine not in ['CYCLES', 'BLENDER_EEVEE']:
scene.render.engine = "BLENDER_EEVEE"
gltf.blender_scene = scene.name
else:
@ -55,7 +56,8 @@ class BlenderScene():
else:
# No scene in glTF file, create all objects in current scene
scene = bpy.context.scene
scene.render.engine = "BLENDER_EEVEE"
if scene.render.engine not in ['CYCLES', 'BLENDER_EEVEE']:
scene.render.engine = "BLENDER_EEVEE"
if bpy.context.collection.name in bpy.data.collections: # avoid master collection
gltf.blender_active_collection = bpy.context.collection.name
gltf.blender_scene = scene.name