Workspace: Move engines to workspace and Properties Editor cleanup
authorDalai Felinto <dfelinto@gmail.com>
Mon, 16 Oct 2017 19:15:03 +0000 (17:15 -0200)
committerDalai Felinto <dfelinto@gmail.com>
Mon, 16 Oct 2017 19:29:04 +0000 (17:29 -0200)
Engine is not stored in WorkSpaces. That defines the "context" engine, which
is used for the entire UI.

The engine used for the poll of nodes (add node menu, new nodes when "Use Nodes")
is obtained from context.

Introduce a ViewRender struct for viewport settings that are defined for
workspaces and scene. This struct will be populated with the hand-picked
settings that can be defined per workspace as per the 2.8 design.

* use_scene_settings
* properties editor: workshop + organize context path

Use Scene Settings
==================
For viewport drawing, Workspaces have an option to use the Scene render
settings (F12) instead of the viewport settings.

This way users can quickly preview the final render settings, engine and
View Layer. This will affect all the editors in that workspace, and it will be
clearly indicated in the top-bar.

Properties Editor: Add Workspace and organize context path
==========================================================

We now have the properties of:

Scene, Scene > Layer, Scene > World, Workspace

[Scene | Workspace] > Render Layer > Object
[Scene | Workspace] > Render Layer > Object > Data
(...)

Reviewers: Campbell Barton, Julian Eisel
Differential Revision: https://developer.blender.org/D2842

135 files changed:
intern/cycles/app/io_export_cycles_xml.py
intern/cycles/blender/addon/ui.py
release/scripts/startup/bl_ui/__init__.py
release/scripts/startup/bl_ui/properties_collection.py
release/scripts/startup/bl_ui/properties_data_armature.py
release/scripts/startup/bl_ui/properties_data_camera.py
release/scripts/startup/bl_ui/properties_data_lamp.py
release/scripts/startup/bl_ui/properties_data_lightprobe.py
release/scripts/startup/bl_ui/properties_data_mesh.py
release/scripts/startup/bl_ui/properties_data_modifier.py
release/scripts/startup/bl_ui/properties_data_speaker.py
release/scripts/startup/bl_ui/properties_data_workspace.py [new file with mode: 0644]
release/scripts/startup/bl_ui/properties_freestyle.py
release/scripts/startup/bl_ui/properties_game.py
release/scripts/startup/bl_ui/properties_material.py
release/scripts/startup/bl_ui/properties_object.py
release/scripts/startup/bl_ui/properties_particle.py
release/scripts/startup/bl_ui/properties_physics_cloth.py
release/scripts/startup/bl_ui/properties_physics_common.py
release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
release/scripts/startup/bl_ui/properties_physics_field.py
release/scripts/startup/bl_ui/properties_physics_fluid.py
release/scripts/startup/bl_ui/properties_physics_rigidbody.py
release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
release/scripts/startup/bl_ui/properties_physics_smoke.py
release/scripts/startup/bl_ui/properties_physics_softbody.py
release/scripts/startup/bl_ui/properties_render.py
release/scripts/startup/bl_ui/properties_render_layer.py
release/scripts/startup/bl_ui/properties_scene.py
release/scripts/startup/bl_ui/properties_texture.py
release/scripts/startup/bl_ui/properties_world.py
release/scripts/startup/bl_ui/space_image.py
release/scripts/startup/bl_ui/space_info.py
release/scripts/startup/bl_ui/space_node.py
release/scripts/startup/bl_ui/space_view3d.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py
release/scripts/startup/nodeitems_builtins.py
source/blender/blenkernel/BKE_context.h
source/blender/blenkernel/BKE_layer.h
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/BKE_pointcache.h
source/blender/blenkernel/BKE_scene.h
source/blender/blenkernel/BKE_screen.h
source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/BKE_workspace.h
source/blender/blenkernel/intern/collision.c
source/blender/blenkernel/intern/context.c
source/blender/blenkernel/intern/layer.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/sound.c
source/blender/blenkernel/intern/workspace.c
source/blender/blenloader/intern/versioning_280.c
source/blender/blenloader/intern/versioning_defaults.c
source/blender/depsgraph/DEG_depsgraph.h
source/blender/depsgraph/intern/depsgraph_eval.cc
source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
source/blender/draw/DRW_engine.h
source/blender/draw/engines/external/external_engine.c
source/blender/draw/intern/DRW_render.h
source/blender/draw/intern/draw_manager.c
source/blender/editors/armature/editarmature_sketch.c
source/blender/editors/curve/editcurve.c
source/blender/editors/include/ED_screen.h
source/blender/editors/include/ED_transform_snap_object_context.h
source/blender/editors/include/ED_view3d.h
source/blender/editors/interface/interface_templates.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/physics/physics_pointcache.c
source/blender/editors/render/render_internal.c
source/blender/editors/render/render_opengl.c
source/blender/editors/render/render_preview.c
source/blender/editors/render/render_update.c
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_context.c
source/blender/editors/screen/workspace_edit.c
source/blender/editors/sculpt_paint/paint_image_proj.c
source/blender/editors/space_action/space_action.c
source/blender/editors/space_buttons/buttons_context.c
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_clip/space_clip.c
source/blender/editors/space_file/space_file.c
source/blender/editors/space_graph/space_graph.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_nla/space_nla.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_templates.c
source/blender/editors/space_node/space_node.c
source/blender/editors/space_outliner/outliner_tree.c
source/blender/editors/space_sequencer/space_sequencer.c
source/blender/editors/space_text/space_text.c
source/blender/editors/space_time/space_time.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_draw_legacy.c
source/blender/editors/space_view3d/view3d_ruler.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/view3d_walk.c
source/blender/editors/transform/CMakeLists.txt
source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_snap.c
source/blender/editors/transform/transform_snap_object.c
source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
source/blender/gpu/intern/gpu_material.c
source/blender/makesdna/DNA_layer_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_space_types.h
source/blender/makesdna/DNA_workspace_types.h
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/rna_context.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_scene_api.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_workspace.c
source/blender/nodes/composite/nodes/node_composite_image.c
source/blender/nodes/shader/node_shader_tree.c
source/blender/nodes/texture/node_texture_tree.c
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/include/render_types.h
source/blender/render/intern/include/renderpipeline.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/external_engine.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/pointdensity.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_window.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/creator/creator_args.c
source/gameengine/Converter/BL_BlenderDataConversion.cpp

index 7d6d85f88af5efc7b5a50643be3054290f58a36e..d02487aefa45646c365e3b26e05db5bd176aaa43 100644 (file)
@@ -66,8 +66,7 @@ class RenderButtonsPanel():
 
     @classmethod
     def poll(self, context):
-        rd = context.scene.render
-        return rd.engine == 'CYCLES'
+        return context.engine == 'CYCLES'
 
 
 class PHYSICS_PT_fluid_export(RenderButtonsPanel, bpy.types.Panel):
index de0ab989d8eb350c6ef44dd704793af4544bb328..33b80b5695a2a7c1ec7308f354dfb28e0aba9ab1 100644 (file)
@@ -50,8 +50,7 @@ class CyclesButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        rd = context.scene.render
-        return rd.engine in cls.COMPAT_ENGINES
+        return context.engine in cls.COMPAT_ENGINES
 
 
 def get_device_type(context):
@@ -1691,7 +1690,7 @@ def draw_device(self, context):
     scene = context.scene
     layout = self.layout
 
-    if scene.render.engine == 'CYCLES':
+    if context.engine == 'CYCLES':
         from . import engine
         cscene = scene.cycles
 
@@ -1711,7 +1710,7 @@ def draw_pause(self, context):
     layout = self.layout
     scene = context.scene
 
-    if scene.render.engine == "CYCLES":
+    if context.engine == "CYCLES":
         view = context.space_data
 
         cscene = scene.cycles
index cc3d1ffc2291b1c62addbe44d239ac257988d7b2..d7135ca202c4694b3a383629c2d0f050273ce9bb 100644 (file)
@@ -42,6 +42,7 @@ _modules = [
     "properties_data_modifier",
     "properties_data_lightprobe",
     "properties_data_speaker",
+    "properties_data_workspace",
     "properties_game",
     "properties_mask_common",
     "properties_material",
index 9e7d29358a9b2088246628826c440a64a9397471..ae61dc2b74ffd5017ddfbf149457015ccadab4c7 100644 (file)
@@ -50,7 +50,7 @@ class COLLECTION_PT_clay_settings(CollectionButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -76,8 +76,8 @@ class COLLECTION_PT_object_mode_settings(CollectionButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        ob = context.object
-        return ob and (ob.mode == 'OBJECT')
+        workspace = context.workspace
+        return workspace and hasattr(workspace, 'object_mode') and (workspace.object_mode == 'OBJECT')
 
     def draw(self, context):
         layout = self.layout
@@ -95,8 +95,8 @@ class COLLECTION_PT_edit_mode_settings(CollectionButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        ob = context.object
-        return ob and (ob.mode == 'EDIT')
+        workspace = context.workspace
+        return workspace and hasattr(workspace, 'object_mode') and (workspace.object_mode == 'EDIT')
 
     def draw(self, context):
         layout = self.layout
@@ -119,8 +119,8 @@ class COLLECTION_PT_paint_weight_mode_settings(CollectionButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        ob = context.object
-        return ob and (ob.mode == 'WEIGHT_PAINT')
+        workspace = context.workspace
+        return workspace and hasattr(workspace, 'object_mode') and (workspace.object_mode == 'WEIGHT_PAINT')
 
     def draw(self, context):
         layout = self.layout
@@ -138,8 +138,8 @@ class COLLECTION_PT_paint_vertex_mode_settings(CollectionButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        ob = context.object
-        return ob and (ob.mode == 'VERTEX_PAINT')
+        workspace = context.workspace
+        return workspace and hasattr(workspace, 'object_mode') and (workspace.object_mode == 'VERTEX_PAINT')
 
     def draw(self, context):
         layout = self.layout
index bed8baf82107dd81da8b4dd6425ecc8ca97c023f..fbfb611e03c106994c6d78b121de6d7184a5a599 100644 (file)
@@ -65,7 +65,7 @@ class DATA_PT_skeleton(ArmatureButtonsPanel, Panel):
         col.label(text="Protected Layers:")
         col.prop(arm, "layers_protected", text="")
 
-        if context.scene.render.engine == 'BLENDER_GAME':
+        if context.engine == 'BLENDER_GAME':
             col = layout.column()
             col.label(text="Deform:")
             col.prop(arm, "deform_method", expand=True)
index e0b925557359ccc28ebdd528aff7341b07bb48fc..f77c0ff40e895603b7971c42ccf1f8e64b6c4bb5 100644 (file)
@@ -29,7 +29,7 @@ class CameraButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        engine = context.scene.render.engine
+        engine = context.engine
         return context.camera and (engine in cls.COMPAT_ENGINES)
 
 
@@ -96,7 +96,7 @@ class DATA_PT_lens(CameraButtonsPanel, Panel):
             col.prop(cam, "ortho_scale")
 
         elif cam.type == 'PANO':
-            engine = context.scene.render.engine
+            engine = context.engine
             if engine == 'CYCLES':
                 ccam = cam.cycles
                 col.prop(ccam, "panorama_type", text="Type")
@@ -147,11 +147,11 @@ class DATA_PT_camera_stereoscopy(CameraButtonsPanel, Panel):
 
     def draw(self, context):
         layout = self.layout
-        render = context.scene.render
+        view_render = context.scene.view_render
         st = context.camera.stereo
         cam = context.camera
 
-        is_spherical_stereo = cam.type != 'ORTHO' and render.use_spherical_stereo
+        is_spherical_stereo = cam.type != 'ORTHO' and view_render.use_spherical_stereo
         use_spherical_stereo = is_spherical_stereo and st.use_spherical_stereo
 
         col = layout.column()
@@ -234,10 +234,10 @@ class DATA_PT_camera_dof(CameraButtonsPanel, Panel):
         sub.active = (cam.dof_object is None)
         sub.prop(cam, "dof_distance", text="Distance")
 
-        if context.scene.render.engine == 'BLENDER_EEVEE':
+        if context.engine == 'BLENDER_EEVEE':
             col = split.column(align=True)
             col.label("Aperture:")
-            engine = context.scene.render.engine
+            engine = context.engine
             sub = col.column(align=True)
             sub.prop(dof_options, "fstop")
             sub.prop(dof_options, "blades")
index 40ebdbda75d136b3a8ae1b8761c2c72930c598fe..9ee17d808cf996e8dbbfca8643d2d83ae0711972 100644 (file)
@@ -37,7 +37,7 @@ class DataButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        engine = context.scene.render.engine
+        engine = context.engine
         return context.lamp and (engine in cls.COMPAT_ENGINES)
 
 
@@ -172,7 +172,7 @@ class DATA_PT_sunsky(DataButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         lamp = context.lamp
-        engine = context.scene.render.engine
+        engine = context.engine
         return (lamp and lamp.type == 'SUN') and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -244,7 +244,7 @@ class DATA_PT_shadow(DataButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         lamp = context.lamp
-        engine = context.scene.render.engine
+        engine = context.engine
         return (lamp and lamp.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -359,7 +359,7 @@ class DATA_PT_EEVEE_shadow(DataButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         lamp = context.lamp
-        engine = context.scene.render.engine
+        engine = context.engine
         return (lamp and lamp.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and (engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
@@ -422,7 +422,7 @@ class DATA_PT_area(DataButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         lamp = context.lamp
-        engine = context.scene.render.engine
+        engine = context.engine
         return (lamp and lamp.type == 'AREA') and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -448,7 +448,7 @@ class DATA_PT_spot(DataButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         lamp = context.lamp
-        engine = context.scene.render.engine
+        engine = context.engine
         return (lamp and lamp.type == 'SPOT') and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -483,7 +483,7 @@ class DATA_PT_spot(DataButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         lamp = context.lamp
-        engine = context.scene.render.engine
+        engine = context.engine
         return (lamp and lamp.type == 'SPOT') and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -509,7 +509,7 @@ class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         lamp = context.lamp
-        engine = context.scene.render.engine
+        engine = context.engine
 
         return (lamp and lamp.type in {'POINT', 'SPOT'} and lamp.falloff_type == 'CUSTOM_CURVE') and (engine in cls.COMPAT_ENGINES)
 
index 13af51396326d57b6b621c37f242995f41d54bbb..b1deacb30519e9750fd9afcfdbaee1cfe017d48e 100644 (file)
@@ -28,7 +28,7 @@ class DataButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        engine = context.scene.render.engine
+        engine = context.engine
         return context.lightprobe and (engine in cls.COMPAT_ENGINES)
 
 
@@ -107,7 +107,7 @@ class DATA_PT_lightprobe_parallax(DataButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        engine = context.scene.render.engine
+        engine = context.engine
         return context.lightprobe and context.lightprobe.type == 'CUBEMAP' and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
index 4d00b70a0fa381a071f0db73b0ce3436ea5b5e7f..d98e3f00e7d08aac37134700238799d2f438b0c2 100644 (file)
@@ -130,7 +130,7 @@ class MeshButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        engine = context.scene.render.engine
+        engine = context.engine
         return context.mesh and (engine in cls.COMPAT_ENGINES)
 
 
@@ -198,7 +198,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        engine = context.scene.render.engine
+        engine = context.engine
         obj = context.object
         return (obj and obj.type in {'MESH', 'LATTICE'} and (engine in cls.COMPAT_ENGINES))
 
@@ -285,7 +285,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        engine = context.scene.render.engine
+        engine = context.engine
         obj = context.object
         return (obj and obj.type in {'MESH', 'LATTICE', 'CURVE', 'SURFACE'} and (engine in cls.COMPAT_ENGINES))
 
index 32c758e9d028b83bd0416d02141499a284266536..d886b2f20bce04ce484badb63a31e148a1a40ecb 100644 (file)
@@ -929,7 +929,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col = split.column()
 
         scene = bpy.context.scene
-        engine = scene.render.engine
+        engine = scene.view_render.engine
         show_adaptive_options = (
             engine == 'CYCLES' and md == ob.modifiers[-1] and
             scene.cycles.feature_set == 'EXPERIMENTAL'
index 5ed9ce0478c595e092155a479929f373ba79a53a..769efb96b381590cf887b9610f9b9f7ca8db5a73 100644 (file)
@@ -29,7 +29,7 @@ class DataButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        engine = context.scene.render.engine
+        engine = context.engine
         return context.speaker and (engine in cls.COMPAT_ENGINES)
 
 
diff --git a/release/scripts/startup/bl_ui/properties_data_workspace.py b/release/scripts/startup/bl_ui/properties_data_workspace.py
new file mode 100644 (file)
index 0000000..42a5406
--- /dev/null
@@ -0,0 +1,78 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+import bpy
+from bpy.types import (
+        Panel,
+        )
+
+from rna_prop_ui import PropertyPanel
+
+
+class WorkSpaceButtonsPanel:
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "workspace"
+
+
+class WORKSPACE_PT_context(WorkSpaceButtonsPanel, Panel):
+    bl_label = ""
+    bl_options = {'HIDE_HEADER'}
+
+    def draw(self, context):
+        layout = self.layout
+
+        workspace = context.workspace
+        layout.prop(workspace, "use_scene_settings", icon='SCENE')
+
+
+class WORKSPACE_PT_workspace(WorkSpaceButtonsPanel, Panel):
+    bl_label = "Workspace"
+
+    def draw(self, context):
+        layout = self.layout
+
+        workspace = context.workspace
+        scene = context.scene
+        view_render = workspace.view_render
+
+        layout.enabled = not workspace.use_scene_settings
+
+        layout.template_search(workspace, "render_layer", scene, "render_layers")
+
+        if view_render.has_multiple_engines:
+            layout.prop(view_render, "engine", text="")
+
+
+class WORKSPACE_PT_custom_props(WorkSpaceButtonsPanel, PropertyPanel, Panel):
+    _context_path = "workspace"
+    _property_type = bpy.types.WorkSpace
+
+
+classes = (
+    WORKSPACE_PT_context,
+    WORKSPACE_PT_workspace,
+    WORKSPACE_PT_custom_props,
+)
+
+if __name__ == "__main__":  # only for live edit.
+    from bpy.utils import register_class
+    for cls in classes:
+        register_class(cls)
+
index 3d105934bf825c7f2d1ef2d637084170ea26794c..ddc5c1643d00770f16b9ec31597f8d21c6c56e9d 100644 (file)
@@ -33,7 +33,7 @@ class RenderFreestyleButtonsPanel:
     def poll(cls, context):
         scene = context.scene
         with_freestyle = bpy.app.build_options.freestyle
-        return scene and with_freestyle and(scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and with_freestyle and(scene.view_render.engine in cls.COMPAT_ENGINES)
 
 
 class RENDER_PT_freestyle(RenderFreestyleButtonsPanel, Panel):
@@ -75,7 +75,7 @@ class RenderLayerFreestyleButtonsPanel:
         with_freestyle = bpy.app.build_options.freestyle
 
         return (scene and with_freestyle and rd.use_freestyle and
-                rd.layers.active and(scene.render.engine in cls.COMPAT_ENGINES))
+                rd.layers.active and(scene.view_render.engine in cls.COMPAT_ENGINES))
 
 
 class RenderLayerFreestyleEditorButtonsPanel(RenderLayerFreestyleButtonsPanel):
@@ -183,7 +183,10 @@ class RENDERLAYER_PT_freestyle_lineset(RenderLayerFreestyleEditorButtonsPanel, P
     def draw(self, context):
         layout = self.layout
 
-        rd = context.scene.render
+        scene = context.scene
+        rd = scene.render
+        view_render = scene.view_render
+
         rl = rd.layers.active
         freestyle = rl.freestyle_settings
         lineset = freestyle.linesets.active
@@ -779,7 +782,7 @@ class RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel,
             layout.separator()
 
             row = layout.row()
-            if rd.use_shading_nodes:
+            if view_render.use_shading_nodes:
                 row.prop(linestyle, "use_nodes")
             else:
                 row.prop(linestyle, "use_texture")
@@ -810,7 +813,7 @@ class MaterialFreestyleButtonsPanel:
         material = context.material
         with_freestyle = bpy.app.build_options.freestyle
         return with_freestyle and material and scene and scene.render.use_freestyle and \
-            (scene.render.engine in cls.COMPAT_ENGINES)
+            (scene.view_render.engine in cls.COMPAT_ENGINES)
 
 
 class MATERIAL_PT_freestyle_line(MaterialFreestyleButtonsPanel, Panel):
index 8ea64b537273fe572b1681edc2e03d67fb432dc4..eb2d3d49e612961998c5d63bc429a683e5e06f30 100644 (file)
@@ -34,8 +34,8 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         ob = context.active_object
-        rd = context.scene.render
-        return ob and ob.game and (rd.engine in cls.COMPAT_ENGINES)
+        view_render = context.scene.view_render
+        return ob and ob.game and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -205,8 +205,8 @@ class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         game = context.object.game
-        rd = context.scene.render
-        return (rd.engine in cls.COMPAT_ENGINES) \
+        view_render = context.scene.view_render
+        return (view_render.engine in cls.COMPAT_ENGINES) \
                 and (game.physics_type in {'SENSOR', 'STATIC', 'DYNAMIC', 'RIGID_BODY', 'CHARACTER', 'SOFT_BODY'})
 
     def draw_header(self, context):
@@ -246,8 +246,8 @@ class PHYSICS_PT_game_obstacles(PhysicsButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         game = context.object.game
-        rd = context.scene.render
-        return (rd.engine in cls.COMPAT_ENGINES) \
+        view_render = context.scene.view_render
+        return (view_render.engine in cls.COMPAT_ENGINES) \
                 and (game.physics_type in {'SENSOR', 'STATIC', 'DYNAMIC', 'RIGID_BODY', 'SOFT_BODY', 'CHARACTER', 'NO_COLLISION'})
 
     def draw_header(self, context):
@@ -274,8 +274,8 @@ class RenderButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        rd = context.scene.render
-        return (rd.engine in cls.COMPAT_ENGINES)
+        view_render = context.scene.view_render
+        return (view_render.engine in cls.COMPAT_ENGINES)
 
 
 class RENDER_PT_embedded(RenderButtonsPanel, Panel):
@@ -285,7 +285,7 @@ class RENDER_PT_embedded(RenderButtonsPanel, Panel):
     def draw(self, context):
         layout = self.layout
 
-        rd = context.scene.render
+        view_render = context.scene.view_render
 
         row = layout.row()
         row.operator("view3d.game_start", text="Start")
@@ -474,7 +474,7 @@ class SCENE_PT_game_physics(SceneButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return (scene.render.engine in cls.COMPAT_ENGINES)
+        return (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -532,7 +532,7 @@ class SCENE_PT_game_physics_obstacles(SceneButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return (scene.render.engine in cls.COMPAT_ENGINES)
+        return (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -553,7 +553,7 @@ class SCENE_PT_game_navmesh(SceneButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return (scene and scene.render.engine in cls.COMPAT_ENGINES)
+        return (scene and scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -614,7 +614,7 @@ class SCENE_PT_game_hysteresis(SceneButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return (scene and scene.render.engine in cls.COMPAT_ENGINES)
+        return (scene and scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -640,8 +640,8 @@ class WORLD_PT_game_context_world(WorldButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        rd = context.scene.render
-        return (context.scene) and (rd.engine in cls.COMPAT_ENGINES)
+        view_render = context.scene.view_render
+        return (context.scene) and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -664,7 +664,7 @@ class WORLD_PT_game_world(WorldButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return (scene.world and scene.render.engine in cls.COMPAT_ENGINES)
+        return (scene.world and scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -684,7 +684,7 @@ class WORLD_PT_game_environment_lighting(WorldButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return (scene.world and scene.render.engine in cls.COMPAT_ENGINES)
+        return (scene.world and scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         light = context.world.light_settings
@@ -709,7 +709,7 @@ class WORLD_PT_game_mist(WorldButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return (scene.world and scene.render.engine in cls.COMPAT_ENGINES)
+        return (scene.world and scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         world = context.world
@@ -746,7 +746,7 @@ class DATA_PT_shadow_game(DataButtonsPanel, Panel):
     def poll(cls, context):
         COMPAT_LIGHTS = {'SPOT', 'SUN'}
         lamp = context.lamp
-        engine = context.scene.render.engine
+        engine = context.engine
         return (lamp and lamp.type in COMPAT_LIGHTS) and (engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
@@ -815,7 +815,7 @@ class OBJECT_PT_levels_of_detail(ObjectButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        return context.scene.render.engine in cls.COMPAT_ENGINES
+        return context.engine in cls.COMPAT_ENGINES
 
     def draw(self, context):
         layout = self.layout
index 29cb2466ee548f90f4b1a6b69df4ae03b985da18..42a132004d4e1346b919c2a93a85e91b3b11b3c8 100644 (file)
@@ -82,7 +82,7 @@ class MATERIAL_UL_matslots(UIList):
                 layout.prop(ma, "name", text="", emboss=False, icon_value=icon)
             else:
                 layout.label(text="", icon_value=icon)
-            if ma and not context.scene.render.use_shading_nodes:
+            if ma and not context.view_render.use_shading_nodes:
                 manode = ma.active_node_material
                 if manode:
                     layout.label(text=iface_("Node %s") % manode.name, translate=False, icon_value=layout.icon(manode))
@@ -101,7 +101,7 @@ class MaterialButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES)
+        return context.material and (context.engine in cls.COMPAT_ENGINES)
 
 
 class MATERIAL_PT_context_material(MaterialButtonsPanel, Panel):
@@ -114,7 +114,7 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel, Panel):
         # An exception, don't call the parent poll func because
         # this manages materials for all engine types
 
-        engine = context.scene.render.engine
+        engine = context.engine
         return (context.material or context.object) and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -197,7 +197,7 @@ class MATERIAL_PT_pipeline(MaterialButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return mat and (not simple_material(mat)) and (mat.type in {'SURFACE', 'WIRE', 'VOLUME'}) and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -250,7 +250,7 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -307,7 +307,7 @@ class MATERIAL_PT_specular(MaterialButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -360,7 +360,7 @@ class MATERIAL_PT_shading(MaterialButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -394,7 +394,7 @@ class MATERIAL_PT_transp(MaterialButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
@@ -460,7 +460,7 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
@@ -518,7 +518,7 @@ class MATERIAL_PT_sss(MaterialButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
@@ -569,7 +569,7 @@ class MATERIAL_PT_halo(MaterialButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -622,7 +622,7 @@ class MATERIAL_PT_flare(MaterialButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
@@ -656,7 +656,7 @@ class MATERIAL_PT_game_settings(MaterialButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES)
+        return context.material and (context.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -685,7 +685,7 @@ class MATERIAL_PT_physics(MaterialButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES)
+        return context.material and (context.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -718,7 +718,7 @@ class MATERIAL_PT_strand(MaterialButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return mat and (mat.type in {'SURFACE', 'WIRE', 'HALO'}) and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -764,7 +764,7 @@ class MATERIAL_PT_options(MaterialButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -814,7 +814,7 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -864,7 +864,7 @@ class MATERIAL_PT_transp_game(MaterialButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return check_material(mat) and (engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
@@ -897,7 +897,7 @@ class VolumeButtonsPanel:
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return mat and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES)
 
 
@@ -982,7 +982,7 @@ class MATERIAL_PT_volume_transp(VolumeButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return mat and simple_material(mat) and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -1023,7 +1023,7 @@ class MATERIAL_PT_volume_options(VolumeButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        engine = context.scene.render.engine
+        engine = context.engine
         return check_material(mat) and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -1061,7 +1061,7 @@ class EEVEE_MATERIAL_PT_context_material(MaterialButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        engine = context.scene.render.engine
+        engine = context.engine
         return (context.material or context.object) and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -1135,7 +1135,7 @@ class EEVEE_MATERIAL_PT_surface(MaterialButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        engine = context.scene.render.engine
+        engine = context.engine
         return context.material and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -1163,7 +1163,7 @@ class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        engine = context.scene.render.engine
+        engine = context.engine
         return context.material and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
index 0d8309268fb0e36396eca891add769a7bbcfca4e..dc14396a285a5d8560a59748f42b43567c4b9e33 100644 (file)
@@ -163,7 +163,7 @@ class OBJECT_PT_relations_extras(ObjectButtonsPanel, Panel):
 
         split = layout.split()
 
-        if context.scene.render.engine != 'BLENDER_GAME':
+        if context.engine != 'BLENDER_GAME':
             col = split.column()
             col.label(text="Tracking Axes:")
             col.prop(ob, "track_axis", text="Axis")
index 68f040fb8aa433949ef6d5f188a6ee55bbc53489..8d79da4cd8907c333dabaeb88f7c6ce80f3e7ecc 100644 (file)
@@ -42,7 +42,7 @@ def particle_panel_enabled(context, psys):
 
 def particle_panel_poll(cls, context):
     psys = context.particle_system
-    engine = context.scene.render.engine
+    engine = context.engine
     settings = 0
 
     if psys:
@@ -135,13 +135,13 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        engine = context.scene.render.engine
+        engine = context.engine
         return (context.particle_system or context.object or context.space_data.pin_id) and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
 
-        if context.scene.render.engine == 'BLENDER_GAME':
+        if context.engine == 'BLENDER_GAME':
             layout.label("Not available in the Game Engine")
             return
 
@@ -319,7 +319,7 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         psys = context.particle_system
-        engine = context.scene.render.engine
+        engine = context.engine
         if psys is None:
             return False
         if psys.settings is None:
@@ -417,7 +417,7 @@ class PARTICLE_PT_cache(ParticleButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         psys = context.particle_system
-        engine = context.scene.render.engine
+        engine = context.engine
         if psys is None:
             return False
         if psys.settings is None:
@@ -802,7 +802,7 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel):
     def poll(cls, context):
         psys = context.particle_system
         settings = particle_get_settings(context)
-        engine = context.scene.render.engine
+        engine = context.engine
 
         if settings is None:
             return False
@@ -904,7 +904,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         settings = particle_get_settings(context)
-        engine = context.scene.render.engine
+        engine = context.engine
         if settings is None:
             return False
 
@@ -1103,7 +1103,7 @@ class PARTICLE_PT_draw(ParticleButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         settings = particle_get_settings(context)
-        engine = context.scene.render.engine
+        engine = context.engine
         if settings is None:
             return False
         return engine in cls.COMPAT_ENGINES
index 6ada3c59942c0ae1f8b01699ed18258f7c59c076..07f995640c399bc02a8a8b759aa11d8560eaf29d 100644 (file)
@@ -45,8 +45,8 @@ class PhysicButtonsPanel:
     @classmethod
     def poll(cls, context):
         ob = context.object
-        rd = context.scene.render
-        return (ob and ob.type == 'MESH') and (rd.engine in cls.COMPAT_ENGINES) and (context.cloth)
+        view_render = context.scene.view_render
+        return (ob and ob.type == 'MESH') and (view_render.engine in cls.COMPAT_ENGINES) and (context.cloth)
 
 
 class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
index 73d3d5fc755d3048876f0319644051b49f41cde3..c67b2a57b0c3cc3bd6797ba53972d7c6854fe99b 100644 (file)
@@ -30,8 +30,8 @@ class PhysicButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        rd = context.scene.render
-        return (context.object) and rd.engine in cls.COMPAT_ENGINES
+        view_render = context.scene.view_render
+        return (context.object) and view_render.engine in cls.COMPAT_ENGINES
 
 
 def physics_add(self, layout, md, name, type, typeicon, toggles):
index 767eb185d8ea1d44ac5415f56120ece4c600a2b4..c0ecb09d36081c434a7dc0a7f63c60902de609d8 100644 (file)
@@ -55,8 +55,8 @@ class PhysicButtonsPanel:
     @classmethod
     def poll(cls, context):
         ob = context.object
-        rd = context.scene.render
-        return (ob and ob.type == 'MESH') and rd.engine in cls.COMPAT_ENGINES and context.dynamic_paint
+        view_render = context.scene.view_render
+        return (ob and ob.type == 'MESH') and view_render.engine in cls.COMPAT_ENGINES and context.dynamic_paint
 
 
 class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel):
@@ -109,7 +109,7 @@ class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel):
 
         elif md.ui_type == 'BRUSH':
             brush = md.brush_settings
-            use_shading_nodes = context.scene.render.use_shading_nodes
+            use_shading_nodes = context.view_render.use_shading_nodes
 
             if brush is None:
                 layout.operator("dpaint.type_toggle", text="Add Brush").type = 'BRUSH'
@@ -143,8 +143,8 @@ class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.dynamic_paint
-        rd = context.scene.render
-        return md and md.ui_type == 'CANVAS' and md.canvas_settings and md.canvas_settings.canvas_surfaces.active and rd.engine in cls.COMPAT_ENGINES
+        view_render = context.scene.view_render
+        return md and md.ui_type == 'CANVAS' and md.canvas_settings and md.canvas_settings.canvas_surfaces.active and view_render.engine in cls.COMPAT_ENGINES
 
     def draw(self, context):
         layout = self.layout
@@ -220,13 +220,13 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.dynamic_paint
-        rd = context.scene.render
+        view_render = context.scene.view_render
         if not (md and md.ui_type == 'CANVAS' and md.canvas_settings):
             return 0
         surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
         return (surface and
                 (not (surface.surface_format == 'VERTEX' and (surface.surface_type in {'DISPLACE', 'WAVE'}))) and
-                (rd.engine in cls.COMPAT_ENGINES))
+                (view_render.engine in cls.COMPAT_ENGINES))
 
     def draw(self, context):
         layout = self.layout
@@ -314,11 +314,11 @@ class PHYSICS_PT_dp_canvas_initial_color(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.dynamic_paint
-        rd = context.scene.render
+        view_render = context.scene.view_render
         if not (md and md.ui_type == 'CANVAS' and md.canvas_settings):
             return 0
         surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
-        return (surface and surface.surface_type == 'PAINT') and (rd.engine in cls.COMPAT_ENGINES)
+        return (surface and surface.surface_type == 'PAINT') and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -351,11 +351,11 @@ class PHYSICS_PT_dp_effects(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.dynamic_paint
-        rd = context.scene.render
+        view_render = context.scene.view_render
         if not (md and md.ui_type == 'CANVAS' and md.canvas_settings):
             return False
         surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
-        return (surface and surface.surface_type == 'PAINT') and (rd.engine in cls.COMPAT_ENGINES)
+        return (surface and surface.surface_type == 'PAINT') and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -401,13 +401,13 @@ class PHYSICS_PT_dp_cache(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.dynamic_paint
-        rd = context.scene.render
+        view_render = context.scene.view_render
         return (md and
                 md.ui_type == 'CANVAS' and
                 md.canvas_settings and
                 md.canvas_settings.canvas_surfaces.active and
                 md.canvas_settings.canvas_surfaces.active.is_cache_user and
-                (rd.engine in cls.COMPAT_ENGINES))
+                (view_render.engine in cls.COMPAT_ENGINES))
 
     def draw(self, context):
         surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
@@ -423,8 +423,8 @@ class PHYSICS_PT_dp_brush_source(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.dynamic_paint
-        rd = context.scene.render
-        return md and md.ui_type == 'BRUSH' and md.brush_settings and (rd.engine in cls.COMPAT_ENGINES)
+        view_render = context.scene.view_render
+        return md and md.ui_type == 'BRUSH' and md.brush_settings and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -477,8 +477,8 @@ class PHYSICS_PT_dp_brush_velocity(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.dynamic_paint
-        rd = context.scene.render
-        return md and md.ui_type == 'BRUSH' and md.brush_settings and (rd.engine in cls.COMPAT_ENGINES)
+        view_render = context.scene.view_render
+        return md and md.ui_type == 'BRUSH' and md.brush_settings and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -514,8 +514,8 @@ class PHYSICS_PT_dp_brush_wave(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.dynamic_paint
-        rd = context.scene.render
-        return md and md.ui_type == 'BRUSH' and md.brush_settings and (rd.engine in cls.COMPAT_ENGINES)
+        view_render = context.scene.view_render
+        return md and md.ui_type == 'BRUSH' and md.brush_settings and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
index bb15ba5e189870b219e0b64f275cfa0c2d01f68e..fd212beee974e5d68ac6adef47ef0be17b4a8544 100644 (file)
@@ -33,8 +33,8 @@ class PhysicButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        rd = context.scene.render
-        return (context.object) and (rd.engine in cls.COMPAT_ENGINES)
+        view_render = context.scene.view_render
+        return (context.object) and (view_render.engine in cls.COMPAT_ENGINES)
 
 
 class PHYSICS_PT_field(PhysicButtonsPanel, Panel):
@@ -44,8 +44,8 @@ class PHYSICS_PT_field(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         ob = context.object
-        rd = context.scene.render
-        return (rd.engine in cls.COMPAT_ENGINES) and (ob.field) and (ob.field.type != 'NONE')
+        view_render = context.scene.view_render
+        return (view_render.engine in cls.COMPAT_ENGINES) and (ob.field) and (ob.field.type != 'NONE')
 
     def draw(self, context):
         layout = self.layout
@@ -182,8 +182,8 @@ class PHYSICS_PT_collision(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         ob = context.object
-        rd = context.scene.render
-        return (ob and ob.type == 'MESH') and (rd.engine in cls.COMPAT_ENGINES) and (context.collision)
+        view_render = context.scene.view_render
+        return (ob and ob.type == 'MESH') and (view_render.engine in cls.COMPAT_ENGINES) and (context.collision)
 
     def draw(self, context):
         layout = self.layout
index ab92370f9aeb0cc0a1205f77750a4e992b15bf00..61ca23be4bced46fbfd5fd7b7f7114afa04f0f15 100644 (file)
@@ -37,8 +37,8 @@ class PhysicButtonsPanel:
     @classmethod
     def poll(cls, context):
         ob = context.object
-        rd = context.scene.render
-        return (ob and ob.type == 'MESH') and rd.engine in cls.COMPAT_ENGINES and (context.fluid)
+        view_render = context.scene.view_render
+        return (ob and ob.type == 'MESH') and view_render.engine in cls.COMPAT_ENGINES and (context.fluid)
 
 
 class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel):
@@ -211,8 +211,8 @@ class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.fluid
-        rd = context.scene.render
-        return md and md.settings and (md.settings.type == 'DOMAIN') and rd.engine in cls.COMPAT_ENGINES
+        view_render = context.scene.view_render
+        return md and md.settings and (md.settings.type == 'DOMAIN') and view_render.engine in cls.COMPAT_ENGINES
 
     def draw(self, context):
         layout = self.layout
@@ -265,8 +265,8 @@ class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.fluid
-        rd = context.scene.render
-        return md and md.settings and (md.settings.type == 'DOMAIN') and rd.engine in cls.COMPAT_ENGINES
+        view_render = context.scene.view_render
+        return md and md.settings and (md.settings.type == 'DOMAIN') and view_render.engine in cls.COMPAT_ENGINES
 
     def draw(self, context):
         layout = self.layout
@@ -296,8 +296,8 @@ class PHYSICS_PT_domain_particles(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.fluid
-        rd = context.scene.render
-        return md and md.settings and (md.settings.type == 'DOMAIN') and rd.engine in cls.COMPAT_ENGINES
+        view_render = context.scene.view_render
+        return md and md.settings and (md.settings.type == 'DOMAIN') and view_render.engine in cls.COMPAT_ENGINES
 
     def draw(self, context):
         layout = self.layout
index 6afdd800b880e51dbb7a503ab01076a688451b01..21453ff364262c5847d0302cbbca4050bf9a3768 100644 (file)
@@ -35,7 +35,7 @@ class PHYSICS_PT_rigid_body(PHYSICS_PT_rigidbody_panel, Panel):
     def poll(cls, context):
         obj = context.object
         return (obj and obj.rigid_body and
-                (context.scene.render.engine in cls.COMPAT_ENGINES))
+                (context.engine in cls.COMPAT_ENGINES))
 
     def draw(self, context):
         layout = self.layout
@@ -62,7 +62,7 @@ class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
     def poll(cls, context):
         obj = context.object
         return (obj and obj.rigid_body and
-                (context.scene.render.engine in cls.COMPAT_ENGINES))
+                (context.engine in cls.COMPAT_ENGINES))
 
     def draw(self, context):
         layout = self.layout
@@ -108,7 +108,7 @@ class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel):
         obj = context.object
         return (obj and obj.rigid_body and
                 obj.rigid_body.type == 'ACTIVE' and
-                (context.scene.render.engine in cls.COMPAT_ENGINES))
+                (context.engine in cls.COMPAT_ENGINES))
 
     def draw(self, context):
         layout = self.layout
index 84a4cbb4b68b455a1fc19a4b17902c344508e46c..a9b30c3b38814a847b4990926479a93f3149c884 100644 (file)
@@ -34,8 +34,8 @@ class PHYSICS_PT_rigid_body_constraint(PHYSICS_PT_rigidbody_constraint_panel, Pa
     @classmethod
     def poll(cls, context):
         ob = context.object
-        rd = context.scene.render
-        return (ob and ob.rigid_body_constraint and rd.engine in cls.COMPAT_ENGINES)
+        view_render = context.scene.view_render
+        return (ob and ob.rigid_body_constraint and view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
index bf070bf6acb6a7e92589b5459178c21a91b55caf..f9aba70bb7581d20f03c3b691b1c069a2229c461 100644 (file)
@@ -34,8 +34,8 @@ class PhysicButtonsPanel:
     @classmethod
     def poll(cls, context):
         ob = context.object
-        rd = context.scene.render
-        return (ob and ob.type == 'MESH') and (rd.engine in cls.COMPAT_ENGINES) and (context.smoke)
+        view_render = context.scene.view_render
+        return (ob and ob.type == 'MESH') and (view_render.engine in cls.COMPAT_ENGINES) and (context.smoke)
 
 
 class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel):
@@ -240,8 +240,8 @@ class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.smoke
-        rd = context.scene.render
-        return md and (md.smoke_type == 'DOMAIN') and (rd.engine in cls.COMPAT_ENGINES)
+        view_render = context.scene.view_render
+        return md and (md.smoke_type == 'DOMAIN') and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         md = context.smoke.domain_settings
@@ -280,8 +280,8 @@ class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.smoke
-        rd = context.scene.render
-        return md and (md.smoke_type == 'DOMAIN') and (rd.engine in cls.COMPAT_ENGINES)
+        view_render = context.scene.view_render
+        return md and (md.smoke_type == 'DOMAIN') and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -309,8 +309,8 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.smoke
-        rd = context.scene.render
-        return md and (md.smoke_type == 'DOMAIN') and (rd.engine in cls.COMPAT_ENGINES)
+        view_render = context.scene.view_render
+        return md and (md.smoke_type == 'DOMAIN') and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -346,8 +346,8 @@ class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.smoke
-        rd = context.scene.render
-        return md and (md.smoke_type == 'DOMAIN') and (rd.engine in cls.COMPAT_ENGINES)
+        view_render = context.scene.view_render
+        return md and (md.smoke_type == 'DOMAIN') and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         domain = context.smoke.domain_settings
@@ -361,8 +361,8 @@ class PHYSICS_PT_smoke_display_settings(PhysicButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         md = context.smoke
-        rd = context.scene.render
-        return md and (md.smoke_type == 'DOMAIN') and (not rd.use_game_engine)
+        view_render = context.scene.view_render
+        return md and (md.smoke_type == 'DOMAIN') and (not view_render.use_game_engine)
 
     def draw(self, context):
         domain = context.smoke.domain_settings
index 5efe105e7d82cfc886c91770ad6842f7f4f57a65..186ba19f62d3325917c66bf49ba4a6093ecf5cf7 100644 (file)
@@ -41,8 +41,8 @@ class PhysicButtonsPanel:
     @classmethod
     def poll(cls, context):
         ob = context.object
-        rd = context.scene.render
-        return ob and ob.type in COMPAT_OB_TYPES and rd.engine in cls.COMPAT_ENGINES and context.soft_body
+        view_render = context.scene.view_render
+        return ob and ob.type in COMPAT_OB_TYPES and view_render.engine in cls.COMPAT_ENGINES and context.soft_body
 
 
 class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
index 06c562445f9e2ee513945e8a4f17b94107075b49..6ce11bf7c4d0e2262b672bb82c5a11004d64c681 100644 (file)
@@ -52,7 +52,28 @@ class RenderButtonsPanel:
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+
+
+class RENDER_PT_context(Panel):
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "render"
+    bl_options = {'HIDE_HEADER'}
+    bl_label = ""
+
+    @classmethod
+    def poll(cls, context):
+        return context.scene
+
+    def draw(self, context):
+        layout = self.layout
+
+        scene = context.scene
+        view_render = scene.view_render
+
+        if view_render.has_multiple_engines:
+            layout.prop(view_render, "engine", text="")
 
 
 class RENDER_PT_render(RenderButtonsPanel, Panel):
@@ -207,8 +228,10 @@ class RENDER_PT_motion_blur(RenderButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        rd = context.scene.render
-        return not rd.use_full_sample and (rd.engine in cls.COMPAT_ENGINES)
+        scene = context.scene
+        rd = scene.render
+        view_render = scene.view_render
+        return not rd.use_full_sample and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         rd = context.scene.render
@@ -595,7 +618,7 @@ class RENDER_PT_eevee_ambient_occlusion(RenderButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         scene = context.scene
@@ -626,7 +649,7 @@ class RENDER_PT_eevee_motion_blur(RenderButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         scene = context.scene
@@ -652,7 +675,7 @@ class RENDER_PT_eevee_depth_of_field(RenderButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         scene = context.scene
@@ -678,7 +701,7 @@ class RENDER_PT_eevee_bloom(RenderButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         scene = context.scene
@@ -708,7 +731,7 @@ class RENDER_PT_eevee_volumetric(RenderButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         scene = context.scene
@@ -741,7 +764,7 @@ class RENDER_PT_eevee_screen_space_reflections(RenderButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         scene = context.scene
@@ -773,7 +796,7 @@ class RENDER_PT_eevee_shadows(RenderButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -794,7 +817,7 @@ class RENDER_PT_eevee_sampling(RenderButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -813,7 +836,7 @@ class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -829,6 +852,7 @@ classes = (
     RENDER_MT_presets,
     RENDER_MT_ffmpeg_presets,
     RENDER_MT_framerate_presets,
+    RENDER_PT_context,
     RENDER_PT_render,
     RENDER_PT_dimensions,
     RENDER_PT_antialiasing,
index a53de7644050ee1d4c5e6737c6e18d798b49d562..99776723fd96a89c1227be90024531df859ee963 100644 (file)
@@ -30,7 +30,7 @@ class RenderLayerButtonsPanel:
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
 
 class RENDERLAYER_UL_renderlayers(UIList):
@@ -54,9 +54,9 @@ class RENDERLAYER_PT_layers(RenderLayerButtonsPanel, Panel):
         layout = self.layout
 
         scene = context.scene
-        rd = scene.render
+        view_render = scene.view_render
 
-        if rd.engine == 'BLENDER_GAME':
+        if view_render.engine == 'BLENDER_GAME':
             layout.label("Not available in the Game Engine")
             return
 
@@ -137,7 +137,7 @@ class RENDERLAYER_PT_clay_settings(RenderLayerButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -158,7 +158,7 @@ class RENDERLAYER_PT_eevee_ambient_occlusion(RenderLayerButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         scene = context.scene
@@ -193,7 +193,7 @@ class RENDERLAYER_PT_eevee_motion_blur(RenderLayerButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         scene = context.scene
@@ -223,7 +223,7 @@ class RENDERLAYER_PT_eevee_depth_of_field(RenderLayerButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         scene = context.scene
@@ -253,7 +253,7 @@ class RENDERLAYER_PT_eevee_bloom(RenderLayerButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         scene = context.scene
@@ -287,7 +287,7 @@ class RENDERLAYER_PT_eevee_volumetric(RenderLayerButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         scene = context.scene
@@ -324,7 +324,7 @@ class RENDERLAYER_PT_eevee_screen_space_reflections(RenderLayerButtonsPanel, Pan
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         scene = context.scene
@@ -360,7 +360,7 @@ class RENDERLAYER_PT_eevee_shadows(RenderLayerButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -383,7 +383,7 @@ class RENDERLAYER_PT_eevee_sampling(RenderLayerButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
@@ -404,7 +404,7 @@ class RENDERLAYER_PT_eevee_indirect_lighting(RenderLayerButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+        return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
index 8c65ed2b78a8a861899eff70f21066884b37e57d..a143433a28e664f6ef2e9cd0075df103136a979d 100644 (file)
@@ -60,8 +60,8 @@ class SceneButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        rd = context.scene.render
-        return context.scene and (rd.engine in cls.COMPAT_ENGINES)
+        view_render = context.scene.view_render
+        return context.scene and (view_render.engine in cls.COMPAT_ENGINES)
 
 
 class SCENE_PT_scene(SceneButtonsPanel, Panel):
@@ -75,7 +75,7 @@ class SCENE_PT_scene(SceneButtonsPanel, Panel):
 
         layout.prop(scene, "camera")
         layout.prop(scene, "background_set", text="Background")
-        if context.scene.render.engine != 'BLENDER_GAME':
+        if context.engine != 'BLENDER_GAME':
             layout.prop(scene, "active_clip", text="Active Clip")
 
 
@@ -333,7 +333,7 @@ class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel):
     def poll(cls, context):
         scene = context.scene
         rd = scene.render
-        return scene and (rd.engine in cls.COMPAT_ENGINES)
+        return scene and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         scene = context.scene
@@ -378,9 +378,9 @@ class SCENE_PT_rigid_body_cache(SceneButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        rd = context.scene.render
         scene = context.scene
-        return scene and scene.rigidbody_world and (rd.engine in cls.COMPAT_ENGINES)
+        view_render = scene.view_render
+        return scene and scene.rigidbody_world and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         scene = context.scene
@@ -396,9 +396,9 @@ class SCENE_PT_rigid_body_field_weights(SceneButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        rd = context.scene.render
+        view_render = context.scene.view_render
         scene = context.scene
-        return scene and scene.rigidbody_world and (rd.engine in cls.COMPAT_ENGINES)
+        return scene and scene.rigidbody_world and (view_render.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         scene = context.scene
@@ -412,13 +412,13 @@ class SCENE_PT_simplify(SceneButtonsPanel, Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
 
     def draw_header(self, context):
-        rd = context.scene.render
+        view_render = context.scene.view_render
         self.layout.prop(rd, "use_simplify", text="")
 
     def draw(self, context):
         layout = self.layout
 
-        rd = context.scene.render
+        view_render = context.scene.view_render
 
         layout.active = rd.use_simplify
 
index d309b909f92a314d29a4248040d2787c623367c4..86863b93ce3b7a4550733d1fc3fd191253de2e92 100644 (file)
@@ -125,7 +125,7 @@ class TextureButtonsPanel:
     @classmethod
     def poll(cls, context):
         tex = context.texture
-        return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.scene.render.engine in cls.COMPAT_ENGINES)
+        return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.engine in cls.COMPAT_ENGINES)
 
 
 class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel):
@@ -135,7 +135,7 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        engine = context.scene.render.engine
+        engine = context.engine
         # if not (hasattr(context, "texture_slot") or hasattr(context, "texture_node")):
         #     return False
         return ((context.material or
@@ -292,7 +292,7 @@ class TextureSlotPanel(TextureButtonsPanel):
         if not hasattr(context, "texture_slot"):
             return False
 
-        engine = context.scene.render.engine
+        engine = context.engine
         return TextureButtonsPanel.poll(cls, context) and (engine in cls.COMPAT_ENGINES)
 
 
@@ -304,7 +304,7 @@ class TextureTypePanel(TextureButtonsPanel):
     @classmethod
     def poll(cls, context):
         tex = context.texture
-        engine = context.scene.render.engine
+        engine = context.engine
         return tex and ((tex.type == cls.tex_type and not tex.use_nodes) and (engine in cls.COMPAT_ENGINES))
 
 
@@ -474,7 +474,7 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
     def draw(self, context):
-        if context.scene.render.engine == 'BLENDER_GAME':
+        if context.engine == 'BLENDER_GAME':
             self.draw_bge(context)
         else:
             self.draw_bi(context)
@@ -756,7 +756,7 @@ class TEXTURE_PT_voxeldata(TextureButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         tex = context.texture
-        engine = context.scene.render.engine
+        engine = context.engine
         return tex and (tex.type == 'VOXEL_DATA' and (engine in cls.COMPAT_ENGINES))
 
     def draw(self, context):
@@ -799,7 +799,7 @@ class TEXTURE_PT_pointdensity(TextureButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         tex = context.texture
-        engine = context.scene.render.engine
+        engine = context.engine
         return tex and (tex.type == 'POINT_DENSITY' and (engine in cls.COMPAT_ENGINES))
 
     def draw(self, context):
@@ -874,7 +874,7 @@ class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         tex = context.texture
-        engine = context.scene.render.engine
+        engine = context.engine
         return tex and (tex.type == 'POINT_DENSITY' and (engine in cls.COMPAT_ENGINES))
 
     def draw_header(self, context):
@@ -933,7 +933,7 @@ class TEXTURE_PT_mapping(TextureSlotPanel, Panel):
         if not getattr(context, "texture_slot", None):
             return False
 
-        engine = context.scene.render.engine
+        engine = context.engine
         return (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
@@ -1036,7 +1036,7 @@ class TEXTURE_PT_influence(TextureSlotPanel, Panel):
         if not getattr(context, "texture_slot", None):
             return False
 
-        engine = context.scene.render.engine
+        engine = context.engine
         return (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
index 6e06d0593ff9645ad589411911382fa68ade293e..e56a7977791cf4985c497f0c2838574d4e68d7ca 100644 (file)
@@ -31,7 +31,7 @@ class WorldButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        return (context.world and context.scene.render.engine in cls.COMPAT_ENGINES)
+        return (context.world and context.engine in cls.COMPAT_ENGINES)
 
 
 class WORLD_PT_context_world(WorldButtonsPanel, Panel):
@@ -41,8 +41,8 @@ class WORLD_PT_context_world(WorldButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        rd = context.scene.render
-        return rd.engine in cls.COMPAT_ENGINES
+        view_render = context.scene.view_render
+        return view_render.engine in cls.COMPAT_ENGINES
 
     def draw(self, context):
         layout = self.layout
@@ -69,8 +69,7 @@ class WORLD_PT_preview(WorldButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        rd = context.scene.render
-        return (context.world) and (rd.engine in cls.COMPAT_ENGINES)
+        return (context.world) and (context.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         self.layout.template_preview(context.world)
@@ -257,7 +256,7 @@ class EEVEE_WORLD_PT_surface(WorldButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        engine = context.scene.render.engine
+        engine = context.engine
         return context.world and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
index 5d3f4585a8ab5f92ed11a6bae403ba54c0997258..c105e72b1e52cfea477178c220f558a096ace9d0 100644 (file)
@@ -608,7 +608,7 @@ class IMAGE_PT_game_properties(Panel):
     def poll(cls, context):
         sima = context.space_data
         # display even when not in game mode because these settings effect the 3d view
-        return (sima and sima.image and not sima.show_maskedit)  # and (rd.engine == 'BLENDER_GAME')
+        return (sima and sima.image and not sima.show_maskedit)  # and (view_render.engine == 'BLENDER_GAME')
 
     def draw(self, context):
         layout = self.layout
index f05808c7a2c66e5bc0bc7f019e1b092e07bf65a0..aa999e72f7d8dd09cab5f98a5ab390c3d1a2017f 100644 (file)
@@ -32,7 +32,7 @@ class INFO_HT_header(Header):
         screen = context.screen
         scene = context.scene
         layer = context.render_layer
-        rd = scene.render
+        view_render = workspace.view_render
 
         row = layout.row(align=True)
         row.template_header()
@@ -54,15 +54,17 @@ class INFO_HT_header(Header):
             act_mode_item = bpy.types.Object.bl_rna.properties['mode'].enum_items[layer.objects.active.mode]
         layout.operator_menu_enum("object.mode_set", "mode", text=act_mode_item.name, icon=act_mode_item.icon)
 
-        layout.template_search(workspace, "render_layer", scene, "render_layers")
+        row = layout.row()
+        row.active = not workspace.use_scene_settings
+        row.template_search(workspace, "render_layer", scene, "render_layers")
+
+        if view_render.has_multiple_engines:
+            row.prop(view_render, "engine", text="")
 
         layout.separator()
 
         layout.template_ID(window, "scene", new="scene.new", unlink="scene.delete")
 
-        if rd.has_multiple_engines:
-            layout.prop(rd, "engine", text="")
-
         layout.separator()
 
         layout.template_running_jobs()
@@ -96,12 +98,11 @@ class INFO_MT_editor_menus(Menu):
 
     @staticmethod
     def draw_menus(layout, context):
-        scene = context.scene
-        rd = scene.render
+        view_render = context.view_render
 
         layout.menu("INFO_MT_file")
 
-        if rd.use_game_engine:
+        if view_render.use_game_engine:
             layout.menu("INFO_MT_game")
         else:
             layout.menu("INFO_MT_render")
index 3def0ca6328a63fb667e452fbb4bd8f488ba9c08..335ef67c847ee27b385c6fbb0a43427b37cd0327 100644 (file)
@@ -51,13 +51,14 @@ class NODE_HT_header(Header):
         NODE_MT_editor_menus.draw_collapsible(context, layout)
 
         layout.prop(snode, "tree_type", text="", expand=True)
+        use_shading_nodes = scene.view_render.use_shading_nodes or context.view_render.use_shading_nodes
 
         if snode.tree_type == 'ShaderNodeTree':
-            if scene.render.use_shading_nodes:
+            if use_shading_nodes:
                 layout.prop(snode, "shader_type", text="", expand=True)
 
             ob = context.object
-            if (not scene.render.use_shading_nodes or snode.shader_type == 'OBJECT') and ob:
+            if (not use_shading_nodes or snode.shader_type == 'OBJECT') and ob:
                 row = layout.row()
                 # disable material slot buttons when pinned, cannot find correct slot within id_from (#36589)
                 row.enabled = not snode.pin
@@ -69,17 +70,17 @@ class NODE_HT_header(Header):
                     row.template_ID(id_from, "active_material", new="material.new")
 
                 # Don't show "Use Nodes" Button when Engine is BI for Lamps
-                if snode_id and not (scene.render.use_shading_nodes == 0 and ob.type == 'LAMP'):
+                if snode_id and not (use_shading_nodes == 0 and ob.type == 'LAMP'):
                     layout.prop(snode_id, "use_nodes")
 
-            if scene.render.use_shading_nodes and snode.shader_type == 'WORLD':
+            if use_shading_nodes and snode.shader_type == 'WORLD':
                 row = layout.row()
                 row.enabled = not snode.pin
                 row.template_ID(scene, "world", new="world.new")
                 if snode_id:
                     row.prop(snode_id, "use_nodes")
 
-            if scene.render.use_shading_nodes and snode.shader_type == 'LINESTYLE':
+            if use_shading_nodes and snode.shader_type == 'LINESTYLE':
                 rl = context.scene.render.layers.active
                 lineset = rl.freestyle_settings.linesets.active
                 if lineset is not None:
index a31fd81efb5da864758f6ded6e14fd1f19c7dd88..9bdf1c67f2b146463b4fdbebb6a78904d7de8b70 100644 (file)
@@ -1451,8 +1451,9 @@ class VIEW3D_MT_object_specials(Menu):
             lamp = obj.data
 
             layout.operator_context = 'INVOKE_REGION_WIN'
+            use_shading_nodes = context.view_render.use_shading_nodes
 
-            if scene.render.use_shading_nodes:
+            if use_shading_nodes:
                 try:
                     value = lamp.node_tree.nodes["Emission"].inputs["Strength"].default_value
                 except AttributeError:
@@ -1510,7 +1511,7 @@ class VIEW3D_MT_object_specials(Menu):
                 props.input_scale = -0.01
                 props.header_text = "Spot Blend: %.2f"
 
-                if not scene.render.use_shading_nodes:
+                if not use_shading_nodes:
                     props = layout.operator("wm.context_modal_mouse", text="Clip Start")
                     props.data_path_iter = "selected_editable_objects"
                     props.data_path_item = "data.shadow_buffer_clip_start"
index 5430b108642ab75e02dccebc779b77feef3cad12..88e6f5df86b31e7d8faa91e673fe2b8ca10ad45e 100644 (file)
@@ -1199,7 +1199,7 @@ class TEXTURE_UL_texpaintslots(UIList):
 
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
             layout.prop(item, "name", text="", emboss=False, icon_value=icon)
-            if (not mat.use_nodes) and context.scene.render.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}:
+            if (not mat.use_nodes) and context.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}:
                 mtex_index = mat.texture_paint_slots[index].index
                 layout.prop(mat, "use_textures", text="", index=mtex_index)
         elif self.layout_type == 'GRID':
@@ -1262,7 +1262,7 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
                 else:
                     slot = None
 
-                if (not mat.use_nodes) and context.scene.render.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}:
+                if (not mat.use_nodes) and context.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}:
                     row = col.row(align=True)
                     row.operator_menu_enum("paint.add_texture_paint_slot", "type")
                     row.operator("paint.delete_texture_paint_slot", text="", icon='X')
index 341efd78f5e2d6e8a51686ea10d1adc0c3e10f76..a2bceef7dabb296c2d39ec2fcbc8a0630aed099c 100644 (file)
@@ -47,14 +47,14 @@ class ShaderNewNodeCategory(SortedNodeCategory):
     @classmethod
     def poll(cls, context):
         return (context.space_data.tree_type == 'ShaderNodeTree' and
-                context.scene.render.use_shading_nodes)
+                context.view_render.use_shading_nodes)
 
 
 class ShaderOldNodeCategory(SortedNodeCategory):
     @classmethod
     def poll(cls, context):
         return (context.space_data.tree_type == 'ShaderNodeTree' and
-                not context.scene.render.use_shading_nodes)
+                not context.view_render.use_shading_nodes)
 
 
 class TextureNodeCategory(SortedNodeCategory):
@@ -142,11 +142,11 @@ def object_shader_nodes_poll(context):
 
 
 def cycles_shader_nodes_poll(context):
-    return context.scene.render.engine == 'CYCLES'
+    return context.view_render.engine == 'CYCLES'
 
 
 def eevee_shader_nodes_poll(context):
-    return context.scene.render.engine == 'BLENDER_EEVEE'
+    return context.view_render.engine == 'BLENDER_EEVEE'
 
 
 def eevee_cycles_shader_nodes_poll(context):
index 350d7a4087553668119f277a16db60203374213b..7b071dc01a560d056a530f4f8d3ecc92c6909c61 100644 (file)
@@ -54,6 +54,7 @@ struct SceneLayer;
 struct ScrArea;
 struct SpaceLink;
 struct View3D;
+struct ViewRender;
 struct RegionView3D;
 struct StructRNA;
 struct ToolSettings;
@@ -69,6 +70,7 @@ struct bGPDpalettecolor;
 struct bGPDbrush;
 struct wmWindow;
 struct wmWindowManager;
+struct RenderEngineType;
 struct SpaceText;
 struct SpaceImage;
 struct SpaceClip;
@@ -251,6 +253,8 @@ struct Scene *CTX_data_scene(const bContext *C);
 struct LayerCollection *CTX_data_layer_collection(const bContext *C);
 struct SceneCollection *CTX_data_scene_collection(const bContext *C);
 struct SceneLayer *CTX_data_scene_layer(const bContext *C);
+struct ViewRender *CTX_data_view_render(const bContext *C);
+struct RenderEngineType *CTX_data_engine(const bContext *C);
 struct ToolSettings *CTX_data_tool_settings(const bContext *C);
 
 const char *CTX_data_mode_string(const bContext *C);
index 52d5405ec0a5a43316b305fc25ae4cb45e4bc1b2..1585742729c785958e199d609aed735a9e55ed5f 100644 (file)
@@ -57,7 +57,7 @@ struct WorkSpace;
 void BKE_layer_exit(void);
 
 struct SceneLayer *BKE_scene_layer_from_scene_get(const struct Scene *scene);
-struct SceneLayer *BKE_scene_layer_from_workspace_get(const struct WorkSpace *workspace);
+struct SceneLayer *BKE_scene_layer_from_workspace_get(const struct Scene *scene, const struct WorkSpace *workspace);
 struct SceneLayer *BKE_scene_layer_add(struct Scene *scene, const char *name);
 
 /* DEPRECATED */
@@ -65,8 +65,6 @@ struct SceneLayer *BKE_scene_layer_context_active_PLACEHOLDER(const struct Scene
 
 void BKE_scene_layer_free(struct SceneLayer *sl);
 
-void BKE_scene_layer_engine_set(struct SceneLayer *sl, const char *engine);
-
 void BKE_scene_layer_selected_objects_tag(struct SceneLayer *sl, const int tag);
 
 struct SceneLayer *BKE_scene_layer_find_from_collection(const struct Scene *scene, struct LayerCollection *lc);
@@ -167,6 +165,10 @@ void BKE_visible_objects_iterator_begin(BLI_Iterator *iter, void *data_in);
 void BKE_visible_objects_iterator_next(BLI_Iterator *iter);
 void BKE_visible_objects_iterator_end(BLI_Iterator *iter);
 
+void BKE_renderable_objects_iterator_begin(BLI_Iterator *iter, void *data_in);
+void BKE_renderable_objects_iterator_next(BLI_Iterator *iter);
+void BKE_renderable_objects_iterator_end(BLI_Iterator *iter);
+
 void BKE_selected_bases_iterator_begin(BLI_Iterator *iter, void *data_in);
 void BKE_selected_bases_iterator_next(BLI_Iterator *iter);
 void BKE_selected_bases_iterator_end(BLI_Iterator *iter);
@@ -248,6 +250,29 @@ void BKE_visible_bases_iterator_end(BLI_Iterator *iter);
        ITER_END                                                                  \
 }
 
+typedef struct ObjectsRenderableIteratorData {
+       struct Scene *scene;
+
+       struct {
+               struct SceneLayer *scene_layer;
+               struct Base *base;
+               struct Scene *set;
+       } iter;
+} ObjectsRenderableIteratorData;
+
+#define FOREACH_OBJECT_RENDERABLE(scene_, _instance)                          \
+       ObjectsRenderableIteratorData data_ = {                                   \
+           .scene = (scene_),                                                    \
+       };                                                                        \
+       ITER_BEGIN(BKE_renderable_objects_iterator_begin,                         \
+                  BKE_renderable_objects_iterator_next,                          \
+                  BKE_renderable_objects_iterator_end,                           \
+                  &data_, Object *, _instance)
+
+
+#define FOREACH_OBJECT_RENDERABLE_END                                         \
+       ITER_END
+
 #ifdef __cplusplus
 }
 #endif
index 3bb8f6c9ed346344a1dc9ad0a1acb994ddbf96bb..fe9fb2598d0c0adf2610d4c6f38769b098d5b590 100644 (file)
@@ -74,6 +74,7 @@ struct PointerRNA;
 struct RenderData;
 struct Scene;
 struct Tex;
+struct ViewRender;
 struct SpaceNode;
 struct ARegion;
 struct ColorManagedViewSettings;
@@ -282,7 +283,7 @@ typedef struct bNodeTreeType {
        /* callbacks */
        void (*free_cache)(struct bNodeTree *ntree);
        void (*free_node_cache)(struct bNodeTree *ntree, struct bNode *node);
-       void (*foreach_nodeclass)(struct Scene *scene, void *calldata, bNodeClassCallback func);        /* iteration over all node classes */
+       void (*foreach_nodeclass)(struct ViewRender *view_render, void *calldata, bNodeClassCallback func);     /* iteration over all node classes */
        /* Check visibility in the node editor */
        int (*poll)(const struct bContext *C, struct bNodeTreeType *ntreetype);
        /* Select a node tree from the context */
index f0819c8d79d67457fcb1d515be36ec5958634f38..48fe8423233b4999669f770d6eb9284a67773355 100644 (file)
@@ -90,6 +90,7 @@ struct ParticleKey;
 struct ParticleSystem;
 struct PointCache;
 struct Scene;
+struct SceneLayer;
 struct SmokeModifierData;
 struct SoftBody;
 struct RigidBodyWorld;
@@ -186,6 +187,7 @@ typedef struct PTCacheID {
 typedef struct PTCacheBaker {
        struct Main *main;
        struct Scene *scene;
+       struct SceneLayer *scene_layer;
        int bake;
        int render;
        int anim_init;
@@ -319,7 +321,7 @@ struct PointCache *BKE_ptcache_copy_list(struct ListBase *ptcaches_new, const st
 /********************** Baking *********************/
 
 /* Bakes cache with cache_step sized jumps in time, not accurate but very fast. */
-void BKE_ptcache_quick_cache_all(struct Main *bmain, struct Scene *scene);
+void BKE_ptcache_quick_cache_all(struct Main *bmain, struct Scene *scene, struct SceneLayer *scene_layer);
 
 /* Bake cache or simulate to current frame with settings defined in the baker. */
 void BKE_ptcache_bake(struct PTCacheBaker *baker);
index e517b65cf3e1ea514a9418fc9e471ef9dc78443b..b31cd1742a295a6279116d330d1811df98c40c85 100644 (file)
@@ -50,7 +50,8 @@ struct Scene;
 struct SceneCollection;
 struct SceneLayer;
 struct UnitSettings;
-struct Main;
+struct ViewRender;
+struct WorkSpace;
 
 typedef enum eSceneCopyMethod {
        SCE_COPY_NEW       = 0,
@@ -62,11 +63,21 @@ typedef enum eSceneCopyMethod {
 
 /* Use as the contents of a 'for' loop: for (SETLOOPER(...)) { ... */
 #define SETLOOPER(_sce_basis, _sce_iter, _base)                               \
-       _sce_iter = _sce_basis, _base = _setlooper_base_step(&_sce_iter, NULL);   \
+       _sce_iter = _sce_basis, _base = _setlooper_base_step(&_sce_iter, BKE_scene_layer_from_scene_get(_sce_basis), NULL); \
+       _base;                                                                    \
+       _base = _setlooper_base_step(&_sce_iter, NULL, _base)
+
+#define SETLOOPER_SCENE_LAYER(_sce_basis, _scene_layer, _sce_iter, _base)     \
+       _sce_iter = _sce_basis, _base = _setlooper_base_step(&_sce_iter, _scene_layer, NULL);   \
        _base;                                                                    \
-       _base = _setlooper_base_step(&_sce_iter, _base)
+       _base = _setlooper_base_step(&_sce_iter, NULL, _base)
 
-struct Base *_setlooper_base_step(struct Scene **sce_iter, struct Base *base);
+#define SETLOOPER_SET_ONLY(_sce_basis, _sce_iter, _base)     \
+       _sce_iter = _sce_basis, _base = _setlooper_base_step(&_sce_iter, NULL, NULL);   \
+       _base;                                                                    \
+       _base = _setlooper_base_step(&_sce_iter, NULL, _base)
+
+struct Base *_setlooper_base_step(struct Scene **sce_iter, struct SceneLayer *scene_layer, struct Base *base);
 
 void free_avicodecdata(struct AviCodecData *acd);
 
@@ -168,6 +179,22 @@ int BKE_render_num_threads(const struct RenderData *r);
 
 int BKE_render_preview_pixel_size(const struct RenderData *r);
 
+/**********************************/
+
+struct ViewRender *BKE_viewrender_get(struct Scene *scene, struct WorkSpace *workspace);
+void BKE_viewrender_init(struct ViewRender *view_render);
+void BKE_viewrender_free(struct ViewRender *view_render);
+void BKE_viewrender_copy(struct ViewRender *view_render_dst, const struct ViewRender *view_render_src);
+bool BKE_viewrender_use_new_shading_nodes(const struct ViewRender *view_render);
+bool BKE_viewrender_use_shading_nodes_custom(const struct ViewRender *view_render);
+bool BKE_viewrender_use_world_space_shading(const struct ViewRender *view_render);
+bool BKE_viewrender_use_spherical_stereo(const struct ViewRender *view_render);
+bool BKE_viewrender_uses_blender_internal(const struct ViewRender *view_render);
+bool BKE_viewrender_uses_blender_game(const struct ViewRender *view_render);
+bool BKE_viewrender_uses_blender_eevee(const struct ViewRender *view_render);
+
+/**********************************/
+
 double BKE_scene_unit_scale(const struct UnitSettings *unit, const int unit_type, double value);
 
 /* multiview */
index 3cb78a427ab66c5e94b579d630d85275b5fa5488..2bbe5b0587e63ade34049fa0513a6ada9967621d 100644 (file)
@@ -85,7 +85,7 @@ typedef struct SpaceType {
        void (*exit)(struct wmWindowManager *, struct ScrArea *);
        /* Listeners can react to bContext changes */
        void (*listener)(struct bScreen *sc, struct ScrArea *,
-                        struct wmNotifier *, const struct Scene *scene);
+                        struct wmNotifier *, struct Scene *scene, struct WorkSpace *workspace);
        
        /* refresh context, called after filereads, ED_area_tag_refresh() */
        void (*refresh)(const struct bContext *, struct ScrArea *);
index bcc06a4ab2516fcb0077f7bb0a9fcadbe4ce3bf7..dfb6b47a4e497621bff256b217040ba3f5792604 100644 (file)
@@ -422,7 +422,8 @@ struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C, ListBase *seq
 
 /* view3d draw callback, run when not in background view */
 typedef struct ImBuf *(*SequencerDrawView)(
-        const struct EvaluationContext *eval_ctx, struct Scene *, struct SceneLayer *sl, struct Object *, int, int,
+        const struct EvaluationContext *eval_ctx, struct Scene *,
+        struct SceneLayer *sl, struct Object *, int, int,
         unsigned int, int, bool, bool, bool,
         int, int, bool, const char *,
         struct GPUFX *, struct GPUOffScreen *, char[256]);
index 43962c2eb35d36699a794455164b3bab7e71218c..67868ee961ae104f8f4e4d276a7c556804d188ef 100644 (file)
@@ -115,6 +115,12 @@ struct WorkSpaceLayout *BKE_workspace_hook_layout_for_workspace_get(
 void             BKE_workspace_hook_layout_for_workspace_set(
         struct WorkSpaceInstanceHook *hook, struct WorkSpace *workspace, struct WorkSpaceLayout *layout) ATTR_NONNULL();
 
+struct ViewRender *BKE_workspace_view_render_get(struct WorkSpace *workspace) GETTER_ATTRS;
+
+/* flags */
+bool BKE_workspace_use_scene_settings_get(const struct WorkSpace *workspace) GETTER_ATTRS;
+void BKE_workspace_use_scene_settings_set(struct WorkSpace *workspace, bool value) SETTER_ATTRS;
+
 #undef GETTER_ATTRS
 #undef SETTER_ATTRS
 
index acb48a9646fb2e2a74996e558dd0cec6838b7062..bc50fdd5a1145d7dc41259ef497f06303f02bc6d 100644 (file)
@@ -47,6 +47,7 @@
 
 #include "BKE_cloth.h"
 #include "BKE_effect.h"
+#include "BKE_layer.h"
 #include "BKE_modifier.h"
 #include "BKE_scene.h"
 
index 4f1dd18b39c6b702d7af2cbef86ad5bf0d585544..bc75958ba33ebc8c15ea8db9fdfafe66c2fbfc4d 100644 (file)
@@ -57,6 +57,8 @@
 #include "BKE_sound.h"
 #include "BKE_workspace.h"
 
+#include "RE_engine.h"
+
 #include "RNA_access.h"
 
 #ifdef WITH_PYTHON
@@ -927,10 +929,36 @@ SceneLayer *CTX_data_scene_layer(const bContext *C)
                return sl;
        }
        else {
-               return BKE_scene_layer_from_workspace_get(CTX_wm_workspace(C));
+               return BKE_scene_layer_from_workspace_get(CTX_data_scene(C), CTX_wm_workspace(C));
+       }
+}
+
+ViewRender *CTX_data_view_render(const bContext *C)
+{
+       ViewRender *view_render;
+
+       if (ctx_data_pointer_verify(C, "view_render", (void *)&view_render)) {
+               return view_render;
+       }
+       else {
+               Scene *scene = CTX_data_scene(C);
+               WorkSpace *workspace = CTX_wm_workspace(C);
+               return BKE_viewrender_get(scene, workspace);
        }
 }
 
+RenderEngineType *CTX_data_engine(const bContext *C)
+{
+       const char *engine_id;
+
+       if (!ctx_data_pointer_verify(C, "engine", (void *)&engine_id)) {
+               ViewRender *view_render = CTX_data_view_render(C);
+               engine_id = view_render->engine_id;
+       }
+
+       return RE_engines_find(engine_id);
+}
+
 /**
  * This is tricky. Sometimes the user overrides the render_layer
  * but not the scene_collection. In this case what to do?
@@ -1247,7 +1275,8 @@ void CTX_data_eval_ctx(const bContext *C, EvaluationContext *eval_ctx)
 
        Scene *scene = CTX_data_scene(C);
        SceneLayer *scene_layer = CTX_data_scene_layer(C);
+       RenderEngineType *engine = CTX_data_engine(C);
        DEG_evaluation_context_init_from_scene(eval_ctx,
-                                              scene, scene_layer,
+                                              scene, scene_layer, engine,
                                               DAG_EVAL_VIEWPORT);
 }
index f20b96b8bc781c0e7547297423a3116ef930f198..0e0290414a47a686b5837b1b72da835cc8631ac1 100644 (file)
@@ -82,9 +82,14 @@ SceneLayer *BKE_scene_layer_from_scene_get(const Scene *scene)
 /**
  * Returns the SceneLayer to be used for drawing, outliner, and other context related areas.
  */
-SceneLayer *BKE_scene_layer_from_workspace_get(const struct WorkSpace *workspace)
+SceneLayer *BKE_scene_layer_from_workspace_get(const struct Scene *scene, const struct WorkSpace *workspace)
 {
-       return BKE_workspace_render_layer_get(workspace);
+       if (BKE_workspace_use_scene_settings_get(workspace)) {
+               return BKE_scene_layer_from_scene_get(scene);
+       }
+       else {
+               return BKE_workspace_render_layer_get(workspace);
+       }
 }
 
 /**
@@ -170,14 +175,6 @@ void BKE_scene_layer_free(SceneLayer *sl)
        MEM_freeN(sl);
 }
 
-/**
- * Set the render engine of a renderlayer
- */
-void BKE_scene_layer_engine_set(SceneLayer *sl, const char *engine)
-{
-       BLI_strncpy_utf8(sl->engine, engine, sizeof(sl->engine));
-}
-
 /**
  * Tag all the selected objects of a renderlayer
  */
@@ -1781,6 +1778,89 @@ void BKE_visible_bases_iterator_end(BLI_Iterator *UNUSED(iter))
        /* do nothing */
 }
 
+void BKE_renderable_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
+{
+       ObjectsRenderableIteratorData *data = data_in;
+
+       for (Scene *scene = data->scene; scene; scene = scene->set) {
+               for (SceneLayer *sl = scene->render_layers.first; sl; sl = sl->next) {
+                       for (Base *base = sl->object_bases.first; base; base = base->next) {
+                                base->object->id.flag |=  LIB_TAG_DOIT;
+                       }
+               }
+       }
+
+       SceneLayer *scene_layer = data->scene->render_layers.first;
+       data->iter.scene_layer = scene_layer;
+
+       Base base = {(Base *)scene_layer->object_bases.first, NULL};
+       data->iter.base = &base;
+
+       data->iter.set = NULL;
+
+       iter->data = data_in;
+       BKE_renderable_objects_iterator_next(iter);
+}
+
+void BKE_renderable_objects_iterator_next(BLI_Iterator *iter)
+{
+       ObjectsRenderableIteratorData *data = iter->data;
+       Base *base = data->iter.base->next;
+
+       /* There is still a base in the current scene layer. */
+       if (base != NULL) {
+               Object *ob = base->object;
+
+               iter->current = ob;
+               data->iter.base = base;
+
+               if ((base->flag & BASE_VISIBLED) == 0) {
+                       BKE_renderable_objects_iterator_next(iter);
+               }
+               return;
+       }
+
+       /* Time to go to the next scene layer. */
+       if (data->iter.set == NULL) {
+               while ((data->iter.scene_layer = data->iter.scene_layer->next)) {
+                       SceneLayer *scene_layer = data->iter.scene_layer;
+                       if (scene_layer->flag & SCENE_LAYER_RENDER) {
+
+                               Base base_iter = {(Base *)scene_layer->object_bases.first, NULL};
+                               data->iter.base = &base_iter;
+
+                               BKE_renderable_objects_iterator_next(iter);
+                               return;
+                       }
+               }
+
+               /* Setup the "set" for the next iteration. */
+               Scene scene = {.set = data->scene};
+               data->iter.set = &scene;
+               BKE_renderable_objects_iterator_next(iter);
+               return;
+       }
+
+       /* Look for an object in the next set. */
+       while ((data->iter.set = data->iter.set->set)) {
+               SceneLayer *scene_layer = BKE_scene_layer_from_scene_get(data->iter.set);
+
+               Base base_iter = {(Base *)scene_layer->object_bases.first, NULL};
+               data->iter.base = &base_iter;
+
+               BKE_renderable_objects_iterator_next(iter);
+               return;
+       }
+
+       iter->current = NULL;
+       iter->valid = false;
+}
+
+void BKE_renderable_objects_iterator_end(BLI_Iterator *UNUSED(iter))
+{
+       /* Do nothing - iter->data was static allocated, we can't free it. */
+}
+
 /* Evaluation  */
 
 /**
index 5ec3156f4df895682ac253fa7b682912c2cbe88d..35d65551483afaaddd9ea063f5ea533ebd0c7aea 100644 (file)
@@ -3509,13 +3509,14 @@ PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, const ListBase *ptcach
  * every user action changing stuff, and then it runs a complete bake??? (ton) */
 
 /* Baking */
-void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene)
+void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene, SceneLayer *scene_layer)
 {
        PTCacheBaker baker;
 
        memset(&baker, 0, sizeof(baker));
        baker.main = bmain;
        baker.scene = scene;
+       baker.scene_layer = scene_layer;
        baker.bake = 0;
        baker.render = 0;
        baker.anim_init = 0;
@@ -3541,6 +3542,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
 {
        Main *bmain = baker->main;
        Scene *scene = baker->scene;
+       SceneLayer *scene_layer = baker->scene_layer;
        Scene *sce_iter; /* SETLOOPER macro only */
        Base *base;
        ListBase pidlist;
@@ -3603,7 +3605,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
                }
        }
        else {
-               for (SETLOOPER(scene, sce_iter, base)) {
+               for (SETLOOPER_SCENE_LAYER(scene, scene_layer, sce_iter, base)) {
                        /* cache/bake everything in the scene */
                        BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
 
@@ -3714,7 +3716,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
                }
        }
        else {
-               for (SETLOOPER(scene, sce_iter, base)) {
+               for (SETLOOPER_SCENE_LAYER(scene, scene_layer, sce_iter, base)) {
                        BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
 
                        for (pid=pidlist.first; pid; pid=pid->next) {
index 6b2d809c31aad8b060eec14354a5b84ff8a2f09e..f49ba37faaacf367d7535a440970b665313ea9a7 100644 (file)
@@ -49,6 +49,7 @@
 #include "DNA_space_types.h"
 #include "DNA_view3d_types.h"
 #include "DNA_windowmanager_types.h"
+#include "DNA_workspace_types.h"
 #include "DNA_gpencil_types.h"
 
 #include "BLI_math.h"
@@ -905,7 +906,7 @@ void BKE_scene_init(Scene *sce)
        sce->r.ffcodecdata.audio_bitrate = 192;
        sce->r.ffcodecdata.audio_channels = 2;
 
-       BLI_strncpy(sce->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(sce->r.engine));
+       BKE_viewrender_init(&sce->view_render);
 
        sce->audio.distance_model = 2.0f;
        sce->audio.doppler_factor = 1.0f;
@@ -1541,9 +1542,11 @@ static bool check_rendered_viewport_visible(Main *bmain)
        wmWindow *window;
        for (window = wm->windows.first; window != NULL; window = window->next) {
                const bScreen *screen = BKE_workspace_active_screen_get(window->workspace_hook);
+               WorkSpace *workspace = BKE_workspace_active_get(window->workspace_hook);
                Scene *scene = window->scene;
+               ViewRender *view_render = BKE_viewrender_get(scene, workspace);
                ScrArea *area;
-               RenderEngineType *type = RE_engines_find(scene->r.engine);
+               RenderEngineType *type = RE_engines_find(view_render->engine_id);
                if ((type->draw_engine != NULL) || (type->render_to_view == NULL)) {
                        continue;
                }
@@ -1833,38 +1836,32 @@ float get_render_aosss_error(const RenderData *r, float error)
 }
 
 /**
-  * Helper function for the SETLOOPER macro
+  * Helper function for the SETLOOPER and SETLOOPER_SCENE_LAYER macros
   *
   * It iterates over the bases of the active layer and then the bases
   * of the active layer of the background (set) scenes recursively.
   */
-Base *_setlooper_base_step(Scene **sce_iter, Base *base)
+Base *_setlooper_base_step(Scene **sce_iter, SceneLayer *scene_layer, Base *base)
 {
        if (base && base->next) {
-               /* common case, step to the next */
+               /* Common case, step to the next. */
                return base->next;
        }
-       else if (base == NULL) {
-               /* first time looping, return the scenes first base */
-
-               /* for the first loop we should get the layer from context */
-               SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER((*sce_iter));
-               /* TODO For first scene (non-background set), we should pass the render layer as argument.
-                * In some cases we want it to be the workspace one, in other the scene one. */
-               TODO_LAYER;
-
-               if (sl->object_bases.first) {
-                       return (Base *)sl->object_bases.first;
+       else if ((base == NULL) && (scene_layer != NULL)) {
+               /* First time looping, return the scenes first base. */
+               /* For the first loop we should get the layer from workspace when available. */
+               if (scene_layer->object_bases.first) {
+                       return (Base *)scene_layer->object_bases.first;
                }
-               /* no base on this scene layer */
+               /* No base on this scene layer. */
                goto next_set;
        }
        else {
 next_set:
-               /* reached the end, get the next base in the set */
+               /* Reached the end, get the next base in the set. */
                while ((*sce_iter = (*sce_iter)->set)) {
-                       SceneLayer *sl = BKE_scene_layer_from_scene_get((*sce_iter));
-                       base = (Base *)sl->object_bases.first;
+                       SceneLayer *scene_layer_set = BKE_scene_layer_from_scene_get((*sce_iter));
+                       base = (Base *)scene_layer_set->object_bases.first;
 
                        if (base) {
                                return base;
@@ -1877,42 +1874,39 @@ next_set:
 
 bool BKE_scene_use_new_shading_nodes(const Scene *scene)
 {
-       const RenderEngineType *type = RE_engines_find(scene->r.engine);
-       return (type && type->flag & RE_USE_SHADING_NODES);
+       return BKE_viewrender_use_new_shading_nodes(&scene->view_render);
 }
 
 bool BKE_scene_use_shading_nodes_custom(Scene *scene)
 {
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
-       return (type && type->flag & RE_USE_SHADING_NODES_CUSTOM);
+       return BKE_viewrender_use_shading_nodes_custom(&scene->view_render);
 }
 
 bool BKE_scene_use_world_space_shading(Scene *scene)
 {
-       const RenderEngineType *type = RE_engines_find(scene->r.engine);
+       RenderEngineType *type = RE_engines_find(scene->view_render.engine_id);
        return ((scene->r.mode & R_USE_WS_SHADING) ||
                (type && (type->flag & RE_USE_SHADING_NODES)));
 }
 
 bool BKE_scene_use_spherical_stereo(Scene *scene)
 {
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
-       return (type && type->flag & RE_USE_SPHERICAL_STEREO);
+       return BKE_viewrender_use_spherical_stereo(&scene->view_render);
 }
 
-bool BKE_scene_uses_blender_internal(const  Scene *scene)
+bool BKE_scene_uses_blender_internal(const Scene *scene)
 {
-       return STREQ(scene->r.engine, RE_engine_id_BLENDER_RENDER);
+       return BKE_viewrender_uses_blender_internal(&scene->view_render);
 }
 
 bool BKE_scene_uses_blender_game(const Scene *scene)
 {
-       return STREQ(scene->r.engine, RE_engine_id_BLENDER_GAME);
+       return BKE_viewrender_uses_blender_game(&scene->view_render);
 }
 
 bool BKE_scene_uses_blender_eevee(const Scene *scene)
 {
-       return STREQ(scene->r.engine, RE_engine_id_BLENDER_EEVEE);
+       return BKE_viewrender_uses_blender_eevee(&scene->view_render);
 }
 
 void BKE_scene_base_flag_to_objects(SceneLayer *sl)
@@ -2027,6 +2021,81 @@ int BKE_render_preview_pixel_size(const RenderData *r)
        return r->preview_pixel_size;
 }
 
+/* ***************************************************** */
+/* render engine settings */
+
+ViewRender *BKE_viewrender_get(Scene *scene, WorkSpace *workspace)
+{
+       if (workspace == NULL || BKE_workspace_use_scene_settings_get(workspace)) {
+               return &scene->view_render;
+       }
+       return BKE_workspace_view_render_get(workspace);
+}
+
+/**
+ * Initialize a static created struct for WorkSpace and Scene to store the viewport
+ * related drawing data.
+ */
+void BKE_viewrender_init(ViewRender *view_render)
+{
+       BLI_strncpy(view_render->engine_id, RE_engine_id_BLENDER_EEVEE, sizeof(view_render->engine_id));
+}
+
+/**
+ * Do not free ViewRender itself since it's not even allocated.
+ */
+void BKE_viewrender_free(ViewRender *UNUSED(view_render))
+{
+       /* Do nothing. */
+}
+
+/**
+ * Copy used by libblock copying.
+ */
+void BKE_viewrender_copy(ViewRender *to, const ViewRender *from)
+{
+       *to = *from;
+}
+
+bool BKE_viewrender_use_new_shading_nodes(const ViewRender *view_render)
+{
+       RenderEngineType *type = RE_engines_find(view_render->engine_id);
+       return (type && type->flag & RE_USE_SHADING_NODES);
+}
+
+bool BKE_viewrender_use_shading_nodes_custom(const ViewRender *view_render)
+{
+       RenderEngineType *type = RE_engines_find(view_render->engine_id);
+       return (type && type->flag & RE_USE_SHADING_NODES_CUSTOM);
+}
+
+bool BKE_viewrender_use_spherical_stereo(const ViewRender *view_render)
+{
+       const char *engine_id = view_render->engine_id;
+       RenderEngineType *type = RE_engines_find(engine_id);
+       return (type && type->flag & RE_USE_SPHERICAL_STEREO);
+}
+
+bool BKE_viewrender_uses_blender_internal(const ViewRender *view_render)
+{
+       const char *engine_id = view_render->engine_id;
+       return STREQ(engine_id, RE_engine_id_BLENDER_RENDER);
+}
+
+bool BKE_viewrender_uses_blender_game(const ViewRender *view_render)
+{
+       const char *engine_id = view_render->engine_id;
+       return STREQ(engine_id, RE_engine_id_BLENDER_GAME);
+}
+
+bool BKE_viewrender_uses_blender_eevee(const ViewRender *view_render)
+{
+       const char *engine_id = view_render->engine_id;
+       return STREQ(engine_id, RE_engine_id_BLENDER_EEVEE);
+}
+
+/* ***************************************************** */
+
 /* Apply the needed correction factor to value, based on unit_type (only length-related are affected currently)
  * and unit->scale_length.
  */
index a2568707b0a27ac580fad99f934bc12b81327581..6cf310461c1331fea2dd3cbd737910a893c82c46 100644 (file)
@@ -806,13 +806,76 @@ void BKE_sound_read_waveform(bSound *sound, short *stop)
        BLI_spin_unlock(sound->spinlock);
 }
 
-void BKE_sound_update_scene(Main *bmain, struct Scene *scene)
+static void sound_update_base(Scene *scene, Base *base, void *new_set)
 {
-       Object *ob;
-       Base *base;
+       Object *ob = base->object;
        NlaTrack *track;
        NlaStrip *strip;
        Speaker *speaker;
+       float quat[4];
+
+       if ((ob->id.tag & LIB_TAG_DOIT) == 0) {
+               return;
+       }
+
+       ob->id.tag &= ~LIB_TAG_DOIT;
+
+       if ((ob->type != OB_SPEAKER) || !ob->adt) {
+               return;
+       }
+
+       for (track = ob->adt->nla_tracks.first; track; track = track->next) {
+               for (strip = track->strips.first; strip; strip = strip->next) {
+                       if (strip->type != NLASTRIP_TYPE_SOUND) {
+                               continue;
+                       }
+                       speaker = (Speaker *)ob->data;
+
+                       if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) {
+                               if (speaker->sound) {
+                                       AUD_SequenceEntry_move(strip->speaker_handle, (double)strip->start / FPS, FLT_MAX, 0);
+                               }
+                               else {
+                                       AUD_Sequence_remove(scene->sound_scene, strip->speaker_handle);
+                                       strip->speaker_handle = NULL;
+                               }
+                       }
+                       else {
+                               if (speaker->sound) {
+                                       strip->speaker_handle = AUD_Sequence_add(scene->sound_scene,
+                                                                               speaker->sound->playback_handle,
+                                                                               (double)strip->start / FPS, FLT_MAX, 0);
+                                       AUD_SequenceEntry_setRelative(strip->speaker_handle, 0);
+                               }
+                       }
+
+                       if (strip->speaker_handle) {
+                               const bool mute = ((strip->flag & NLASTRIP_FLAG_MUTED) || (speaker->flag & SPK_MUTED));
+                               AUD_addSet(new_set, strip->speaker_handle);
+                               AUD_SequenceEntry_setVolumeMaximum(strip->speaker_handle, speaker->volume_max);
+                               AUD_SequenceEntry_setVolumeMinimum(strip->speaker_handle, speaker->volume_min);
+                               AUD_SequenceEntry_setDistanceMaximum(strip->speaker_handle, speaker->distance_max);
+                               AUD_SequenceEntry_setDistanceReference(strip->speaker_handle, speaker->distance_reference);
+                               AUD_SequenceEntry_setAttenuation(strip->speaker_handle, speaker->attenuation);
+                               AUD_SequenceEntry_setConeAngleOuter(strip->speaker_handle, speaker->cone_angle_outer);
+                               AUD_SequenceEntry_setConeAngleInner(strip->speaker_handle, speaker->cone_angle_inner);
+                               AUD_SequenceEntry_setConeVolumeOuter(strip->speaker_handle, speaker->cone_volume_outer);
+
+                               mat4_to_quat(quat, ob->obmat);
+                               AUD_SequenceEntry_setAnimationData(strip->speaker_handle, AUD_AP_LOCATION, CFRA, ob->obmat[3], 1);
+                               AUD_SequenceEntry_setAnimationData(strip->speaker_handle, AUD_AP_ORIENTATION, CFRA, quat, 1);
+                               AUD_SequenceEntry_setAnimationData(strip->speaker_handle, AUD_AP_VOLUME, CFRA, &speaker->volume, 1);
+                               AUD_SequenceEntry_setAnimationData(strip->speaker_handle, AUD_AP_PITCH, CFRA, &speaker->pitch, 1);
+                               AUD_SequenceEntry_setSound(strip->speaker_handle, speaker->sound->playback_handle);
+                               AUD_SequenceEntry_setMuted(strip->speaker_handle, mute);
+                       }
+               }
+       }
+}
+
+void BKE_sound_update_scene(Main *bmain, Scene *scene)
+{
+       Base *base;
        Scene *sce_it;
 
        void *new_set = AUD_createSet();
@@ -821,59 +884,18 @@ void BKE_sound_update_scene(Main *bmain, struct Scene *scene)
 
        /* cheap test to skip looping over all objects (no speakers is a common case) */
        if (!BLI_listbase_is_empty(&bmain->speaker)) {
-               for (SETLOOPER(scene, sce_it, base)) {
-                       ob = base->object;
-                       if ((ob->type != OB_SPEAKER) || !ob->adt) {
-                               continue;
-                       }
-                       for (track = ob->adt->nla_tracks.first; track; track = track->next) {
-                               for (strip = track->strips.first; strip; strip = strip->next) {
-                                       if (strip->type != NLASTRIP_TYPE_SOUND) {
-                                               continue;
-                                       }
-                                       speaker = (Speaker *)ob->data;
-
-                                       if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) {
-                                               if (speaker->sound) {
-                                                       AUD_SequenceEntry_move(strip->speaker_handle, (double)strip->start / FPS, FLT_MAX, 0);
-                                               }
-                                               else {
-                                                       AUD_Sequence_remove(scene->sound_scene, strip->speaker_handle);
-                                                       strip->speaker_handle = NULL;
-                                               }
-                                       }
-                                       else {
-                                               if (speaker->sound) {
-                                                       strip->speaker_handle = AUD_Sequence_add(scene->sound_scene,
-                                                                                               speaker->sound->playback_handle,
-                                                                                               (double)strip->start / FPS, FLT_MAX, 0);
-                                                       AUD_SequenceEntry_setRelative(strip->speaker_handle, 0);
-                                               }
-                                       }
-
-                                       if (strip->speaker_handle) {
-                                               const bool mute = ((strip->flag & NLASTRIP_FLAG_MUTED) || (speaker->flag & SPK_MUTED));
-                                               AUD_addSet(new_set, strip->speaker_handle);
-                                               AUD_SequenceEntry_setVolumeMaximum(strip->speaker_handle, speaker->volume_max);
-                                               AUD_SequenceEntry_setVolumeMinimum(strip->speaker_handle, speaker->volume_min);
-                                               AUD_SequenceEntry_setDistanceMaximum(strip->speaker_handle, speaker->distance_max);
-                                               AUD_SequenceEntry_setDistanceReference(strip->speaker_handle, speaker->distance_reference);
-                                               AUD_SequenceEntry_setAttenuation(strip->speaker_handle, speaker->attenuation);
-                                               AUD_SequenceEntry_setConeAngleOuter(strip->speaker_handle, speaker->cone_angle_outer);
-                                               AUD_SequenceEntry_setConeAngleInner(strip->speaker_handle, speaker->cone_angle_inner);
-                                               AUD_SequenceEntry_setConeVolumeOuter(strip->speaker_handle, speaker->cone_volume_outer);
-
-                                               mat4_to_quat(quat, ob->obmat);
-                                               AUD_SequenceEntry_setAnimationData(strip->speaker_handle, AUD_AP_LOCATION, CFRA, ob->obmat[3], 1);
-                                               AUD_SequenceEntry_setAnimationData(strip->speaker_handle, AUD_AP_ORIENTATION, CFRA, quat, 1);
-                                               AUD_SequenceEntry_setAnimationData(strip->speaker_handle, AUD_AP_VOLUME, CFRA, &speaker->volume, 1);
-                                               AUD_SequenceEntry_setAnimationData(strip->speaker_handle, AUD_AP_PITCH, CFRA, &speaker->pitch, 1);
-                                               AUD_SequenceEntry_setSound(strip->speaker_handle, speaker->sound->playback_handle);
-                                               AUD_SequenceEntry_setMuted(strip->speaker_handle, mute);
-                                       }
-                               }
+               BKE_main_id_tag_listbase(&bmain->object, LIB_TAG_DOIT, true);
+
+               for (SceneLayer *scene_layer = scene->render_layers.first; scene_layer; scene_layer = scene_layer->next) {
+                       for (base = scene_layer->object_bases.first; base; base = base->next) {
+                               sound_update_base(scene, base, new_set);
                        }
                }
+
+               for (SETLOOPER_SET_ONLY(scene, sce_it, base)) {
+                       sound_update_base(scene, base, new_set);
+               }
+
        }
 
        while ((handle = AUD_getSet(scene->speaker_handles))) {
index 05dab9208e5d9c77093b9b84fd209da296402b83..0747bde16d34138811fbc42f524453e2fdc361e3 100644 (file)
 
 #include "BLI_utildefines.h"
 #include "BLI_string.h"
+#include "BLI_string_utf8.h"
 #include "BLI_string_utils.h"
 #include "BLI_listbase.h"
 
 #include "BKE_global.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
+#include "BKE_scene.h"
 #include "BKE_screen.h"
 #include "BKE_workspace.h"
 
@@ -161,6 +163,7 @@ void BKE_workspace_remove(Main *bmain, WorkSpace *workspace)
                BKE_workspace_layout_remove(bmain, workspace, layout);
        }
 
+       BKE_viewrender_free(&workspace->view_render);
        BKE_libblock_free(bmain, workspace);
 }
 
@@ -430,3 +433,27 @@ void BKE_workspace_hook_layout_for_workspace_set(
        hook->act_layout = layout;
        workspace_relation_ensure_updated(&workspace->hook_layout_relations, hook, layout);
 }
+
+/**
+ * Get the render engine of a workspace, to be used in the viewport.
+ */
+ViewRender *BKE_workspace_view_render_get(WorkSpace *workspace)
+{
+       return &workspace->view_render;
+}
+
+/* Flags */
+bool BKE_workspace_use_scene_settings_get(const WorkSpace *workspace)
+{
+       return (workspace->flags & WORKSPACE_USE_SCENE_SETTINGS) != 0;
+}
+
+void BKE_workspace_use_scene_settings_set(WorkSpace *workspace, bool value)
+{
+       if (value) {
+               workspace->flags |= WORKSPACE_USE_SCENE_SETTINGS;
+       }
+       else {
+               workspace->flags &= ~WORKSPACE_USE_SCENE_SETTINGS;
+       }
+}
index ba46c8f81b80112992783e242a1a86a973817efa..55245cec56c2e43a526dce67b394e6bd6aa659d4 100644 (file)
@@ -192,7 +192,6 @@ void do_versions_after_linking_280(Main *main)
                                        for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) {
 
                                                SceneLayer *sl = BKE_scene_layer_add(scene, srl->name);
-                                               BKE_scene_layer_engine_set(sl, scene->r.engine);
 
                                                if (srl->mat_override) {
                                                        BKE_collection_override_datablock_add((LayerCollection *)sl->layer_collections.first, "material", (ID *)srl->mat_override);
@@ -510,4 +509,17 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
                        printf("You need to combine transparency and emission shaders to the converted Principled shader nodes.\n");
                }
        }
+
+       {
+               if (!DNA_struct_elem_find(fd->filesdna, "Scene", "ViewRender", "view_render")) {
+                       for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+                               BLI_strncpy_utf8(scene->view_render.engine_id, scene->r.engine,
+                                                sizeof(scene->view_render.engine_id));
+                       }
+
+                       for (WorkSpace *workspace = main->workspaces.first; workspace; workspace = workspace->id.next) {
+                               BKE_viewrender_init(&workspace->view_render);
+                       }
+               }
+       }
 }
index 54ed29ab6fa24937dbeca6996e3830cf341d7491..925a87cb653232a7e96460e7fcd7e54d7dabd570 100644 (file)
@@ -45,6 +45,7 @@
 #include "BKE_brush.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
+#include "BKE_scene.h"
 #include "BKE_workspace.h"
 
 #include "BLO_readfile.h"
@@ -103,6 +104,7 @@ static void update_defaults_startup_workspaces(Main *bmain)
                if (STREQ(workspace->id.name + 2, "Default")) {
                        /* don't rename within iterator, renaming causes listbase to be re-sorted */
                        workspace_default = workspace;
+                       BKE_viewrender_init(&workspace->view_render);
                }
                else {
                        BKE_workspace_remove(bmain, workspace);
@@ -120,7 +122,7 @@ static void update_defaults_startup_workspaces(Main *bmain)
 void BLO_update_defaults_startup_blend(Main *bmain)
 {
        for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
-               BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
+               BLI_strncpy(scene->view_render.engine_id, RE_engine_id_BLENDER_EEVEE, sizeof(scene->view_render.engine_id));
 
                scene->r.im_format.planes = R_IMF_PLANES_RGBA;
                scene->r.im_format.compress = 15;
index 932a7c5128630a2e802ef805a621b12f2624608a..e05b417f245ce89090ea03574bfddb4a3aede007 100644 (file)
@@ -65,6 +65,7 @@ struct Main;
 
 struct PointerRNA;
 struct PropertyRNA;
+struct RenderEngineType;
 struct Scene;
 struct SceneLayer;
 
@@ -84,6 +85,7 @@ typedef struct EvaluationContext {
        float ctime;
 
        struct SceneLayer *scene_layer;
+       struct RenderEngineType *engine;
 } EvaluationContext;
 
 /* DagNode->eval_flags */
@@ -213,6 +215,7 @@ void DEG_evaluation_context_init(struct EvaluationContext *eval_ctx,
 void DEG_evaluation_context_init_from_scene(struct EvaluationContext *eval_ctx,
                                             struct Scene *scene,
                                             struct SceneLayer *scene_layer,
+                                            struct RenderEngineType *engine,
                                             eEvaluationMode mode);
 
 /* Free evaluation context. */
index 77a327405246ee52f46fc940a3a308d27f3e3edd..9235069f531f763ea63df2a5c9c6f5d50ebac1f1 100644 (file)
@@ -79,10 +79,12 @@ void DEG_evaluation_context_init(EvaluationContext *eval_ctx,
 void DEG_evaluation_context_init_from_scene(EvaluationContext *eval_ctx,
                                             Scene *scene,
                                             SceneLayer *scene_layer,
+                                            RenderEngineType *engine,
                                             eEvaluationMode mode)
 {
        DEG_evaluation_context_init(eval_ctx, mode);
        eval_ctx->scene_layer = scene_layer;
+       eval_ctx->engine = engine;
        eval_ctx->ctime = BKE_scene_frame_get(scene);
 }
 
index 03be601ce2c1f489dde8dda0139332b5f9000b8b..e4f1e8b9cf64ee1a00c5943d5a63bec280342a28 100644 (file)
@@ -527,9 +527,9 @@ void update_copy_on_write_scene(const Depsgraph *depsgraph,
                scene_cow->obedit = NULL;
        }
        /* Synchronize active render engine. */
-       BLI_strncpy_utf8(scene_cow->r.engine,
-                        scene_orig->r.engine,
-                        sizeof(scene_cow->r.engine));
+       BLI_strncpy_utf8(scene_cow->view_render.engine_id,
+                        scene_orig->view_render.engine_id,
+                        sizeof(scene_cow->view_render.engine_id));
        /* TODO(sergey): What else do we need here? */
 }
 
index 646d87160944bd9e9e367929437c20ce27a34e9d..e96aec0766f094e9bb0747d61d5eb352db68b22a 100644 (file)
@@ -42,6 +42,8 @@ struct ViewportEngineData;
 struct View3D;
 struct rcti;
 struct GPUOffScreen;
+struct RenderEngineType;
+struct WorkSpace;
 
 #include "BLI_sys_types.h"  /* for bool */
 
@@ -72,6 +74,7 @@ void DRW_draw_view(const struct bContext *C);
 
 void DRW_draw_render_loop_ex(
         struct Depsgraph *graph,
+        struct RenderEngineType *engine,
         struct ARegion *ar, struct View3D *v3d,
         const struct bContext *evil_C);
 void DRW_draw_render_loop(
@@ -79,6 +82,7 @@ void DRW_draw_render_loop(
         struct ARegion *ar, struct View3D *v3d);
 void DRW_draw_render_loop_offscreen(
         struct Depsgraph *graph,
+        struct RenderEngineType *engine,
         struct ARegion *ar, struct View3D *v3d,
         struct GPUOffScreen *ofs);
 void DRW_draw_select_loop(
index f4b38b7ebbfa3b3b39ba5edad76d46c0f7f536e0..76f5b4d98403aba46784d05c4beb841a6964fa8a 100644 (file)
@@ -151,17 +151,16 @@ static void external_draw_scene(void *vedata)
 
        /* Create render engine. */
        if (!rv3d->render_engine) {
-               RenderEngine *engine;
-               type = RE_engines_find(scene->r.engine);
+               RenderEngineType *engine_type = draw_ctx->engine;
 
-               if (!(type->view_update && type->render_to_view)) {
+               if (!(engine_type->view_update && engine_type->render_to_view)) {
                        return;
                }
 
-               engine = RE_engine_create_ex(type, true);
+               RenderEngine *engine = RE_engine_create_ex(engine_type, true);
                engine->tile_x = scene->r.tilex;
                engine->tile_y = scene->r.tiley;
-               type->view_update(engine, draw_ctx->evil_C);
+               engine_type->view_update(engine, draw_ctx->evil_C);
                rv3d->render_engine = engine;
        }
 
index 428bea17f7c35056656ce6bfbe842f4647a0baf2..e8eedac7048f2f7432f4a76e53ab8ec3dc6fe804 100644 (file)
@@ -438,6 +438,8 @@ typedef struct DRWContextState {
        /* Use 'scene->obedit' for edit-mode */
        struct Object *obact;   /* 'OBACT_NEW' */
 
+       struct RenderEngineType *engine;
+
        /* Last resort (some functions take this as an arg so we can't easily avoid).
         * May be NULL when used for selection or depth buffer. */
        const struct bContext *evil_C;
index 38a767b7e348239c3641e79fd66e1b3a3414f538..2a3d9fafd2aeb52e39c5620c72f1c53a5a229a9b 100644 (file)
@@ -37,6 +37,7 @@
 #include "BKE_object.h"
 #include "BKE_pbvh.h"
 #include "BKE_paint.h"
+#include "BKE_workspace.h"
 
 #include "BLT_translation.h"
 #include "BLF_api.h"
@@ -2905,15 +2906,14 @@ static void use_drw_engine(DrawEngineType *engine)
 /* TODO revisit this when proper layering is implemented */
 /* Gather all draw engines needed and store them in DST.enabled_engines
  * That also define the rendering order of engines */
-static void DRW_engines_enable_from_engine(const Scene *scene)
+static void DRW_engines_enable_from_engine(RenderEngineType *engine)
 {
        /* TODO layers */
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
-       if (type->draw_engine != NULL) {
-               use_drw_engine(type->draw_engine);
+       if (engine->draw_engine != NULL) {
+               use_drw_engine(engine->draw_engine);
        }
 
-       if ((type->flag & RE_INTERNAL) == 0) {
+       if ((engine->flag & RE_INTERNAL) == 0) {
                DRW_engines_enable_external();
        }
 }
@@ -2990,11 +2990,12 @@ static void DRW_engines_enable_external(void)
        use_drw_engine(DRW_engine_viewport_external_type.draw_engine);
 }
 
-static void DRW_engines_enable(const Scene *scene, SceneLayer *sl)
+static void DRW_engines_enable(const Scene *scene, SceneLayer *sl, RenderEngineType *engine)
 {
        Object *obact = OBACT_NEW(sl);
        const int mode = CTX_data_mode_enum_ex(scene->obedit, obact);
-       DRW_engines_enable_from_engine(scene);
+
+       DRW_engines_enable_from_engine(engine);
 
        if (DRW_state_draw_support()) {
                DRW_engines_enable_from_object_mode();
@@ -3153,7 +3154,8 @@ void DRW_notify_view_update(const bContext *C)
        View3D *v3d = CTX_wm_view3d(C);
        RegionView3D *rv3d = ar->regiondata;
        Scene *scene = DEG_get_evaluated_scene(graph);
-       SceneLayer *sl = DEG_get_evaluated_scene_layer(graph);
+       RenderEngineType *engine = CTX_data_engine(C);
+       SceneLayer *scene_layer = CTX_data_scene_layer(C);
 
        if (rv3d->viewport == NULL) {
                return;
@@ -3165,17 +3167,17 @@ void DRW_notify_view_update(const bContext *C)
 
        DST.viewport = rv3d->viewport;
        DST.draw_ctx = (DRWContextState){
-               ar, rv3d, v3d, scene, sl, OBACT_NEW(sl), C,
+               ar, rv3d, v3d, scene, scene_layer, OBACT_NEW(scene_layer), engine, C,
        };
 
-       DRW_engines_enable(scene, sl);
+       DRW_engines_enable(scene, scene_layer, engine);
 
        for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
-               DrawEngineType *engine = link->data;
-               ViewportEngineData *data = DRW_viewport_engine_data_get(engine);
+               DrawEngineType *draw_engine = link->data;
+               ViewportEngineData *data = DRW_viewport_engine_data_get(draw_engine);
 
-               if (engine->view_update) {
-                       engine->view_update(data);
+               if (draw_engine->view_update) {
+                       draw_engine->view_update(data);
                }
        }
 
@@ -3197,12 +3199,13 @@ void DRW_notify_view_update(const bContext *C)
 void DRW_draw_view(const bContext *C)
 {
        struct Depsgraph *graph = CTX_data_depsgraph(C);
+       RenderEngineType *engine = CTX_data_engine(C);
        ARegion *ar = CTX_wm_region(C);
        View3D *v3d = CTX_wm_view3d(C);
 
        /* Reset before using it. */
        memset(&DST, 0x0, sizeof(DST));
-       DRW_draw_render_loop_ex(graph, ar, v3d, C);
+       DRW_draw_render_loop_ex(graph, engine, ar, v3d, C);
 }
 
 /**
@@ -3211,11 +3214,12 @@ void DRW_draw_view(const bContext *C)
  */
 void DRW_draw_render_loop_ex(
         struct Depsgraph *graph,
+        RenderEngineType *engine,
         ARegion *ar, View3D *v3d,
         const bContext *evil_C)
 {
        Scene *scene = DEG_get_evaluated_scene(graph);
-       SceneLayer *sl = DEG_get_evaluated_scene_layer(graph);
+       SceneLayer *scene_layer = DEG_get_evaluated_scene_layer(graph);
        RegionView3D *rv3d = ar->regiondata;
 
        DST.draw_ctx.evil_C = evil_C;
@@ -3228,15 +3232,16 @@ void DRW_draw_render_loop_ex(
        cache_is_dirty = GPU_viewport_cache_validate(DST.viewport, DRW_engines_get_hash());
 
        DST.draw_ctx = (DRWContextState){
-               ar, rv3d, v3d, scene, sl, OBACT_NEW(sl),
-               /* reuse if caller sets */
-               DST.draw_ctx.evil_C,
+           ar, rv3d, v3d, scene, scene_layer, OBACT_NEW(scene_layer), engine,
+
+           /* reuse if caller sets */
+           DST.draw_ctx.evil_C,
        };
 
        DRW_viewport_var_init();
 
        /* Get list of enabled engines */
-       DRW_engines_enable(scene, sl);
+       DRW_engines_enable(scene, scene_layer, engine);
 
        /* Update ubos */
        DRW_globals_update();
@@ -3316,11 +3321,15 @@ void DRW_draw_render_loop(
 {
        /* Reset before using it. */
        memset(&DST, 0x0, sizeof(DST));
-       DRW_draw_render_loop_ex(graph, ar, v3d, NULL);
+
+       Scene *scene = DEG_get_evaluated_scene(graph);
+       RenderEngineType *engine = RE_engines_find(scene->view_render.engine_id);
+
+       DRW_draw_render_loop_ex(graph, engine, ar, v3d, NULL);
 }
 
 void DRW_draw_render_loop_offscreen(
-        struct Depsgraph *graph,
+        struct Depsgraph *graph, RenderEngineType *engine,
         ARegion *ar, View3D *v3d, GPUOffScreen *ofs)
 {
        RegionView3D *rv3d = ar->regiondata;
@@ -3335,7 +3344,7 @@ void DRW_draw_render_loop_offscreen(
        /* Reset before using it. */
        memset(&DST, 0x0, sizeof(DST));
        DST.options.is_image_render = true;
-       DRW_draw_render_loop_ex(graph, ar, v3d, NULL);
+       DRW_draw_render_loop_ex(graph, engine, ar, v3d, NULL);
 
        /* restore */
        {
@@ -3360,6 +3369,7 @@ void DRW_draw_select_loop(
         bool UNUSED(use_obedit_skip), bool UNUSED(use_nearest), const rcti *rect)
 {
        Scene *scene = DEG_get_evaluated_scene(graph);
+       RenderEngineType *engine = RE_engines_find(scene->view_render.engine_id);
        SceneLayer *sl = DEG_get_evaluated_scene_layer(graph);
 #ifndef USE_GPU_SELECT
        UNUSED_VARS(vc, scene, sl, v3d, ar, rect);
@@ -3412,7 +3422,7 @@ void DRW_draw_select_loop(
 
        /* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
        DST.draw_ctx = (DRWContextState){
-               ar, rv3d, v3d, scene, sl, OBACT_NEW(sl), (bContext *)NULL,
+               ar, rv3d, v3d, scene, sl, OBACT_NEW(sl), engine, (bContext *)NULL,
        };
 
        DRW_viewport_var_init();
@@ -3478,6 +3488,7 @@ void DRW_draw_depth_loop(
         ARegion *ar, View3D *v3d)
 {
        Scene *scene = DEG_get_evaluated_scene(graph);
+       RenderEngineType *engine = RE_engines_find(scene->view_render.engine_id);
        SceneLayer *sl = DEG_get_evaluated_scene_layer(graph);
        RegionView3D *rv3d = ar->regiondata;
 
@@ -3508,7 +3519,7 @@ void DRW_draw_depth_loop(
 
        /* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
        DST.draw_ctx = (DRWContextState){
-               ar, rv3d, v3d, scene, sl, OBACT_NEW(sl), (bContext *)NULL,
+               ar, rv3d, v3d, scene, sl, OBACT_NEW(sl), engine, (bContext *)NULL,
        };
 
        DRW_viewport_var_init();
index 41c1c73e49cf0e32ac8c1a00af5704b459382f8e..1de7b99c6d261e50b08dd67f9678897cddfde5db 100644 (file)
@@ -998,7 +998,7 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
         * the ideal would be to call this function only at the beginning of the snap operation,
         * or at the beginning of the operator itself */
        struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
-               CTX_data_main(C), CTX_data_scene(C), CTX_data_scene_layer(C), 0,
+               CTX_data_main(C), CTX_data_scene(C), CTX_data_scene_layer(C), CTX_data_engine(C), 0,
                CTX_wm_region(C), CTX_wm_view3d(C));
 
        float mvalf[2] = {UNPACK2(dd->mval)};
index bce6afa2434a7f331c76d785ec90d3fb64866197..f8863a3e00f1dec88c9d46243494b1703fd63a16 100644 (file)
@@ -5017,7 +5017,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
                        const float mval[2] = {UNPACK2(event->mval)};
 
                        struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
-                               CTX_data_main(C), vc.scene, vc.scene_layer, 0,
+                               CTX_data_main(C), vc.scene, vc.scene_layer, vc.engine, 0,
                                vc.ar, vc.v3d);
 
                        ED_transform_snap_object_project_view3d_mixed(
index f650ae879a56dbc04e219e821bcfc2cbb46888e7..e7a8583c50a7397e5fe8e8f5249dc7548d087aff 100644 (file)
@@ -35,6 +35,7 @@
 #include "DNA_space_types.h"
 #include "DNA_view2d_types.h"
 #include "DNA_view3d_types.h"
+#include "DNA_workspace_types.h"
 
 #include "BLI_compiler_attrs.h"
 
@@ -92,7 +93,8 @@ int     ED_area_header_switchbutton(const struct bContext *C, struct uiBlock *bl
 void    ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *sa);
 void    ED_area_exit(struct bContext *C, struct ScrArea *sa);
 int     ED_screen_area_active(const struct bContext *C);
-void    ED_area_do_listen(struct bScreen *sc, ScrArea *sa, struct wmNotifier *note, const Scene *scene);
+void    ED_area_do_listen(struct bScreen *sc, ScrArea *sa, struct wmNotifier *note, const Scene *scene,
+                          const struct WorkSpace *workspace);
 void    ED_area_tag_redraw(ScrArea *sa);
 void    ED_area_tag_redraw_regiontype(ScrArea *sa, int type);
 void    ED_area_tag_refresh(ScrArea *sa);
@@ -129,7 +131,8 @@ void    ED_screen_preview_render(const struct bScreen *screen, int size_x, int s
 struct WorkSpace *ED_workspace_add(
         struct Main *bmain,
         const char *name,
-        SceneLayer *act_render_layer) ATTR_NONNULL();
+        SceneLayer *act_render_layer,
+        struct ViewRender *view_render) ATTR_NONNULL();
 bool ED_workspace_change(
         struct WorkSpace *workspace_new,
         struct bContext *C,
index b802694444beb9650fe3e1cfb8623a5eb3481c8b..babed92230c2c012b100e15fd9def95c6856ec6d 100644 (file)
@@ -30,6 +30,7 @@ struct BMEdge;
 struct BMFace;
 
 struct ListBase;
+struct RenderEngineType;
 struct Scene;
 struct SceneLayer;
 struct Main;
@@ -75,9 +76,9 @@ struct SnapObjectParams {
 
 typedef struct SnapObjectContext SnapObjectContext;
 SnapObjectContext *ED_transform_snap_object_context_create(
-        struct Main *bmain, struct Scene *scene, struct SceneLayer *sl, int flag);
+        struct Main *bmain, struct Scene *scene, struct SceneLayer *sl, struct RenderEngineType *engine, int flag);
 SnapObjectContext *ED_transform_snap_object_context_create_view3d(
-        struct Main *bmain, struct Scene *scene, struct SceneLayer *sl, int flag,
+        struct Main *bmain, struct Scene *scene, struct SceneLayer *sl, struct RenderEngineType *engine, int flag,
         /* extra args for view3d */
         const struct ARegion *ar, const struct View3D *v3d);
 void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx);
index 0dcfd68c0f1ecaf9af96e3b8424139464b3165cb..b55703bff0e20e42955301c89f72116295d2c465 100644 (file)
@@ -51,6 +51,7 @@ struct Nurb;
 struct Object;
 struct RV3DMatrixStore;
 struct RegionView3D;
+struct RenderEngineType;
 struct Scene;
 struct SceneLayer;
 struct ScrArea;
@@ -68,6 +69,7 @@ struct wmWindowManager;
 struct GPUFX;
 struct GPUOffScreen;
 struct GPUFXSettings;
+struct WorkSpace;
 enum eGPUFXFlags;
 
 /* for derivedmesh drawing callbacks, for view3d_select, .... */
@@ -75,6 +77,7 @@ typedef struct ViewContext {
        struct Depsgraph *depsgraph;
        struct Scene *scene;
        struct SceneLayer *scene_layer;
+       struct RenderEngineType *engine;
        struct Object *obact;
        struct Object *obedit;
        struct ARegion *ar;
@@ -369,9 +372,11 @@ void  ED_draw_object_facemap(const struct EvaluationContext *eval_ctx, struct Sc
 
 bool ED_view3d_context_activate(struct bContext *C);
 void ED_view3d_draw_offscreen_init(
-        const struct EvaluationContext *eval_ctx, struct Scene *scene, struct SceneLayer *sl, struct View3D *v3d);
+        const struct EvaluationContext *eval_ctx, struct Scene *scene,
+        struct SceneLayer *sl, struct View3D *v3d);
 void ED_view3d_draw_offscreen(
-        const struct EvaluationContext *eval_ctx, struct Scene *scene, struct SceneLayer *sl, struct View3D *v3d, struct ARegion *ar, int winx, int winy, float viewmat[4][4],
+        const struct EvaluationContext *eval_ctx, struct Scene *scene,
+        struct SceneLayer *scene_layer, struct View3D *v3d, struct ARegion *ar, int winx, int winy, float viewmat[4][4],
         float winmat[4][4], bool do_bgpic, bool do_sky, bool is_persp, const char *viewname,
         struct GPUFX *fx, struct GPUFXSettings *fx_settings,
         struct GPUOffScreen *ofs);
@@ -380,12 +385,14 @@ void ED_view3d_draw_setup_view(
         float viewmat[4][4], float winmat[4][4], const struct rcti *rect);
 
 struct ImBuf *ED_view3d_draw_offscreen_imbuf(
-        const struct EvaluationContext *eval_ctx, struct Scene *scene, struct SceneLayer *sl, struct View3D *v3d, struct ARegion *ar,
+        const struct EvaluationContext *eval_ctx, struct Scene *scene,
+        struct SceneLayer *scene_layer, struct View3D *v3d, struct ARegion *ar,
         int sizex, int sizey, unsigned int flag, bool draw_background,
         int alpha_mode, int samples, bool full_samples, const char *viewname,
         struct GPUFX *fx, struct GPUOffScreen *ofs, char err_out[256]);
 struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
-        const struct EvaluationContext *eval_ctx, struct Scene *scene, struct SceneLayer *sl, struct Object *camera, int width, int height,
+        const struct EvaluationContext *eval_ctx, struct Scene *scene,
+        struct SceneLayer *scene_layer, struct Object *camera, int width, int height,
         unsigned int flag, int drawtype, bool use_solid_tex, bool use_gpencil, bool draw_background,
         int alpha_mode, int samples, bool full_samples, const char *viewname,
         struct GPUFX *fx, struct GPUOffScreen *ofs, char err_out[256]);
index ebd4ce36bbe304caf2bb168a775bf2a8aa4baf26..f2ee8a117066f05e3db9d6eab5e64309955da3fd 100644 (file)
@@ -1193,7 +1193,7 @@ static uiLayout *draw_modifier(
                /* When Modifier is a simulation, show button to switch to context rather than the delete button. */
                if (modifier_can_delete(md) &&
                    (!modifier_is_simulation(md) ||
-                    STREQ(scene->r.engine, RE_engine_id_BLENDER_GAME)))
+                    STREQ(scene->view_render.engine_id, RE_engine_id_BLENDER_GAME)))
                {
                        uiItemO(row, "", ICON_X, "OBJECT_OT_modifier_remove");
                }
index 5749bedc46309b34d4f7e31eb5d87861bd9ca08a..b44b78c450b60d0c0142ef7736112a7b5a985121 100644 (file)
@@ -309,7 +309,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
        ED_view3d_init_mats_rv3d(obedit, ar->regiondata);
 
        struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
-               CTX_data_main(C), CTX_data_scene(C), CTX_data_scene_layer(C), 0,
+               CTX_data_main(C), CTX_data_scene(C), CTX_data_scene_layer(C), CTX_data_engine(C), 0,
                ar, CTX_wm_view3d(C));
 
        BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
index d4f949880eecab2f5aa3f73dfd3b3d7803085b73..74946e3f44d39abd8caeca53ada93ad037d9db64 100644 (file)
@@ -166,6 +166,7 @@ static PTCacheBaker *ptcache_baker_create(bContext *C, wmOperator *op, bool all)
 
        baker->main = CTX_data_main(C);
        baker->scene = CTX_data_scene(C);
+       baker->scene_layer = CTX_data_scene_layer(C);
        baker->bake = RNA_boolean_get(op->ptr, "bake");
        baker->render = 0;
        baker->anim_init = 0;
index ababd637e0060270b5d021bc966c5de7a5d3d59a..8a51d42c59833de05945435cbfb61eaf357f869c 100644 (file)
@@ -56,6 +56,7 @@
 #include "BKE_colortools.h"
 #include "BKE_global.h"
 #include "BKE_image.h"
+#include "BKE_layer.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_node.h"
@@ -64,6 +65,7 @@
 #include "BKE_sequencer.h"
 #include "BKE_screen.h"
 #include "BKE_scene.h"
+#include "BKE_workspace.h"
 
 #include "DEG_depsgraph.h"
 
@@ -787,33 +789,46 @@ static void screen_render_cancel(bContext *C, wmOperator *op)
        WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_RENDER);
 }
 
+static void clean_viewport_memory_base(Base *base)
+{
+       if ((base->flag & BASE_VISIBLED) == 0) {
+               return;
+       }
+
+       Object *object = base->object;
+
+       if (object->id.tag & LIB_TAG_DOIT) {
+               return;
+       }
+
+       object->id.tag &= ~LIB_TAG_DOIT;
+       if (RE_allow_render_generic_object(object)) {
+               BKE_object_free_derived_caches(object);
+       }
+}
+
 static void clean_viewport_memory(Main *bmain, Scene *scene)
 {
-       Object *object;
        Scene *sce_iter;
        Base *base;
 
-       for (object = bmain->object.first; object; object = object->id.next) {
-               object->id.tag |= LIB_TAG_DOIT;
-       }
+       /* Tag all the available objects. */
+       BKE_main_id_tag_listbase(&bmain->object, LIB_TAG_DOIT, true);
 
-       for (SETLOOPER(scene, sce_iter, base)) {
-               if ((base->flag & BASE_VISIBLED) == 0) {
-                       continue;
-               }
-               if (RE_allow_render_generic_object(base->object)) {
-                       base->object->id.tag &= ~LIB_TAG_DOIT;
-               }
-       }
+       /* Go over all the visible objects. */
+       for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
+               for (wmWindow *win = wm->windows.first; win; win = win->next) {
+                       WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
+                       SceneLayer *scene_layer = BKE_scene_layer_from_workspace_get(scene, workspace);
 
-       for (SETLOOPER(scene, sce_iter, base)) {
-               object = base->object;
-               if ((object->id.tag & LIB_TAG_DOIT) == 0) {
-                       continue;
+                       for (base = scene_layer->object_bases.first; base; base = base->next) {
+                               clean_viewport_memory_base(base);
+                       }
                }
-               object->id.tag &= ~LIB_TAG_DOIT;
+       }
 
-               BKE_object_free_derived_caches(object);
+    for (SETLOOPER_SET_ONLY(scene, sce_iter, base)) {
+               clean_viewport_memory_base(base);
        }
 }
 
@@ -1256,10 +1271,10 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda
                /* initalize always */
                if (use_border) {
                        rdata.mode |= R_BORDER;
-                       RE_InitState(re, NULL, &rdata, NULL, rp->ar->winx, rp->ar->winy, &cliprct);
+                       RE_InitState(re, NULL, &rdata, &rp->scene->view_render, NULL, rp->ar->winx, rp->ar->winy, &cliprct);
                }
                else
-                       RE_InitState(re, NULL, &rdata, NULL, rp->ar->winx, rp->ar->winy, NULL);
+                       RE_InitState(re, NULL, &rdata, &rp->scene->view_render, NULL, rp->ar->winx, rp->ar->winy, NULL);
        }
 
        if (orth)
index af932c27c5e7e588c0c283cfbf002f82db149087..c17beded91e1a023741c42d0f7aabb5eacf069e9 100644 (file)
@@ -94,6 +94,7 @@ typedef struct OGLRender {
        Main *bmain;
        Render *re;
        Scene *scene;
+       WorkSpace *workspace;
        SceneLayer *scene_layer;
 
        View3D *v3d;
@@ -267,7 +268,7 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
 static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, RenderResult *rr)
 {
        Scene *scene = oglrender->scene;
-       SceneLayer *sl = oglrender->scene_layer;
+       SceneLayer *scene_layer = oglrender->scene_layer;
        ARegion *ar = oglrender->ar;
        View3D *v3d = oglrender->v3d;
        RegionView3D *rv3d = oglrender->rv3d;
@@ -352,7 +353,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
 
                if (view_context) {
                        ibuf_view = ED_view3d_draw_offscreen_imbuf(
-                              &eval_ctx, scene, sl, v3d, ar, sizex, sizey,
+                              &eval_ctx, scene, scene_layer, v3d, ar, sizex, sizey,
                               IB_rect, draw_bgpic,
                               alpha_mode, oglrender->ofs_samples, oglrender->ofs_full_samples, viewname,
                               oglrender->fx, oglrender->ofs, err_out);
@@ -364,7 +365,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
                }
                else {
                        ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(
-                               &eval_ctx, scene, sl, scene->camera, oglrender->sizex, oglrender->sizey,
+                               &eval_ctx, scene, scene_layer, scene->camera, oglrender->sizex, oglrender->sizey,
                                IB_rect, OB_SOLID, false, true, true,
                                alpha_mode, oglrender->ofs_samples, oglrender->ofs_full_samples, viewname,
                                oglrender->fx, oglrender->ofs, err_out);
@@ -591,6 +592,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
        /* new render clears all callbacks */
        wmWindowManager *wm = CTX_wm_manager(C);
        wmWindow *win = CTX_wm_window(C);
+       WorkSpace *workspace = CTX_wm_workspace(C);
 
        Scene *scene = CTX_data_scene(C);
        ScrArea *prevsa = CTX_wm_area(C);
@@ -662,6 +664,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
        oglrender->sizey = sizey;
        oglrender->bmain = CTX_data_main(C);
        oglrender->scene = scene;
+       oglrender->workspace = workspace;
        oglrender->scene_layer = CTX_data_scene_layer(C);
        oglrender->cfrao = scene->r.cfra;
 
@@ -698,6 +701,8 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
 
        /* create render */
        oglrender->re = RE_NewSceneRender(scene);
+       ViewRender *view_render = BKE_viewrender_get(scene, workspace);
+       RE_SetEngineByID(oglrender->re, view_render->engine_id);
 
        /* create image and image user */
        oglrender->ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
@@ -708,7 +713,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
        oglrender->iuser.ok = 1;
 
        /* create render result */
-       RE_InitState(oglrender->re, NULL, &scene->r, NULL, sizex, sizey, NULL);
+       RE_InitState(oglrender->re, NULL, &scene->r, view_render, NULL, sizex, sizey, NULL);
 
        /* create render views */
        screen_opengl_views_setup(oglrender);
index 3f817672c0072a857fd982e9a38595d2d34dd385..958f1585e84bd776e441903789009aa64293b449 100644 (file)
@@ -173,6 +173,7 @@ typedef struct ShaderPreview {
 
        Main *bmain;
        Main *pr_main;
+       ViewRender *view_render;
 } ShaderPreview;
 
 typedef struct IconPreviewSize {
@@ -187,6 +188,7 @@ typedef struct IconPreview {
        void *owner;
        ID *id;
        ListBase sizes;
+       ViewRender *view_render;
 } IconPreview;
 
 /* *************************** Preview for buttons *********************** */
@@ -229,7 +231,7 @@ void ED_preview_ensure_dbase(void)
 
 static bool check_engine_supports_textures(Scene *scene)
 {
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
+       RenderEngineType *type = RE_engines_find(scene->view_render.engine_id);
        return type->flag & RE_USE_TEXTURE_PREVIEW;
 }
 
@@ -383,10 +385,10 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
                         * seems commonly used render engines does not support
                         * such kind of rendering.
                         */
-                       BLI_strncpy(sce->r.engine, RE_engine_id_BLENDER_RENDER, sizeof(sce->r.engine));
+                       BLI_strncpy(sce->view_render.engine_id, RE_engine_id_BLENDER_RENDER, sizeof(sce->view_render.engine_id));
                }
                else {
-                       BLI_strncpy(sce->r.engine, scene->r.engine, sizeof(sce->r.engine));
+                       BLI_strncpy(sce->view_render.engine_id, scene->view_render.engine_id, sizeof(sce->view_render.engine_id));
                }
                
                if (id_type == ID_MA) {
@@ -857,7 +859,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
                ((Camera *)sce->camera->data)->lens *= (float)sp->sizey / (float)sizex;
 
        /* entire cycle for render engine */
-       RE_PreviewRender(re, pr_main, sce);
+       RE_PreviewRender(re, pr_main, sce, sp->view_render);
 
        ((Camera *)sce->camera->data)->lens = oldlens;
 
@@ -1184,6 +1186,7 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short
 
                /* construct shader preview from image size and previewcustomdata */
                sp->scene = ip->scene;
+               sp->view_render = ip->view_render;
                sp->owner = ip->owner;
                sp->sizex = cur_size->sizex;
                sp->sizey = cur_size->sizey;
@@ -1268,6 +1271,7 @@ void ED_preview_icon_render(Main *bmain, Scene *scene, ID *id, unsigned int *rec
 
        ip.bmain = bmain;
        ip.scene = scene;
+       ip.view_render = &scene->view_render;
        ip.owner = BKE_previewimg_id_ensure(id);
        ip.id = id;
 
@@ -1301,6 +1305,7 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r
        /* customdata for preview thread */
        ip->bmain = CTX_data_main(C);
        ip->scene = CTX_data_scene(C);
+       ip->view_render = &ip->scene->view_render;
        ip->owner = owner;
        ip->id = id;
 
@@ -1328,8 +1333,12 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M
        wmJob *wm_job;
        ShaderPreview *sp;
        Scene *scene = CTX_data_scene(C);
+       WorkSpace *workspace = CTX_wm_workspace(C);
        short id_type = GS(id->name);
-       bool use_new_shading = BKE_scene_use_new_shading_nodes(scene);
+
+       /* Use workspace render only for buttons Window, since the other previews are related to the datablock. */
+       ViewRender *view_render = (method == PR_BUTS_RENDER) ? BKE_viewrender_get(scene, workspace) : &scene->view_render;
+       bool use_new_shading = BKE_viewrender_use_new_shading_nodes(view_render);
 
        /* Only texture node preview is supported with Cycles. */
        if (use_new_shading && method == PR_NODE_RENDER && id_type != ID_TE) {
@@ -1352,6 +1361,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M
        sp->parent = parent;
        sp->slot = slot;
        sp->bmain = CTX_data_main(C);
+       sp->view_render = view_render;
 
        /* hardcoded preview .blend for cycles/internal, this should be solved
         * once with custom preview .blend path for external engines */
index ccea1e5930c6d5cb66eb2e87c68486effba2ed5b..f160b71f633f65ba48d6e33614b9a15ffa8d557c 100644 (file)
@@ -141,7 +141,7 @@ void ED_render_scene_update(Main *bmain, Scene *scene, int updated)
                                        engine->type->view_update(engine, C);
 
                                }
-                               else if ((RE_engines_find(scene->r.engine)->flag & RE_USE_LEGACY_PIPELINE) == 0) {
+                               else if ((RE_engines_find(scene->view_render.engine_id)->flag & RE_USE_LEGACY_PIPELINE) == 0) {
                                        if (updated) {
                                                CTX_wm_screen_set(C, sc);
                                                CTX_wm_area_set(C, sa);
index 0c8ca2a5b87778a8e7fbc5bb07ee6767318b8b5b..852632ceddd4c1f680eb869d2b51ff595dad3b87 100644 (file)
@@ -145,11 +145,11 @@ void ED_region_do_listen(bScreen *sc, ScrArea *sa, ARegion *ar, wmNotifier *note
 }
 
 /* only exported for WM */
-void ED_area_do_listen(bScreen *sc, ScrArea *sa, wmNotifier *note, const Scene *scene)
+void ED_area_do_listen(bScreen *sc, ScrArea *sa, wmNotifier *note, const Scene *scene, const WorkSpace *workspace)
 {
        /* no generic notes? */
        if (sa->type && sa->type->listener) {
-               sa->type->listener(sc, sa, note, scene);
+               sa->type->listener(sc, sa, note, scene, workspace);
        }
 }
 
index 5813f3172953511a6c27420bfed0e08bc7c38fd3..b8575b2da2aa1cb8c70bf5154e6effcdb565cccf 100644 (file)
@@ -89,7 +89,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
        ScrArea *sa = CTX_wm_area(C);
        Scene *scene = WM_window_get_active_scene(win);
        WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
-       SceneLayer *sl = BKE_scene_layer_from_workspace_get(workspace);
+       SceneLayer *sl = BKE_scene_layer_from_workspace_get(scene, workspace);
        Object *obedit = scene->obedit;
        Object *obact = sl->basact ? sl->basact->object : NULL;
 
index 00a965beae7353fd786a02f9c9b6c51bb2cbe9bc..1c5b11c71772464e568ad953a358604733c83073 100644 (file)
@@ -38,6 +38,7 @@
 #include "BKE_main.h"
 #include "BKE_library.h"
 #include "BKE_report.h"
+#include "BKE_scene.h"
 #include "BKE_screen.h"
 #include "BKE_workspace.h"
 
@@ -51,6 +52,8 @@
 #include "ED_object.h"
 #include "ED_screen.h"
 
+#include "MEM_guardedalloc.h"
+
 #include "RNA_access.h"
 
 #include "UI_interface.h"
@@ -68,7 +71,7 @@
  * \{ */
 
 WorkSpace *ED_workspace_add(
-        Main *bmain, const char *name, SceneLayer *act_render_layer)
+        Main *bmain, const char *name, SceneLayer *act_render_layer, ViewRender *view_render)
 {
        WorkSpace *workspace = BKE_workspace_add(bmain, name);
 
@@ -77,6 +80,7 @@ WorkSpace *ED_workspace_add(
 #endif
 
        BKE_workspace_render_layer_set(workspace, act_render_layer);
+       BKE_viewrender_copy(&workspace->view_render, view_render);
 
        return workspace;
 }
@@ -215,7 +219,8 @@ WorkSpace *ED_workspace_duplicate(
        ListBase *layouts_old = BKE_workspace_layouts_get(workspace_old);
        WorkSpace *workspace_new = ED_workspace_add(
                bmain, workspace_old->id.name + 2,
-               BKE_workspace_render_layer_get(workspace_old));
+               BKE_workspace_render_layer_get(workspace_old),
+               &workspace_old->view_render);
        ListBase *transform_orientations_old = BKE_workspace_transform_orientations_get(workspace_old);
        ListBase *transform_orientations_new = BKE_workspace_transform_orientations_get(workspace_new);
 
@@ -231,7 +236,6 @@ WorkSpace *ED_workspace_duplicate(
                        win->workspace_hook->temp_layout_store = layout_new;
                }
        }
-
        return workspace_new;
 }
 
index 2ffd9757f924114284ef4b604d6d69b92b51d843..a8271287e10fbbf40d6ab65c1484d998892c8e5b 100644 (file)
@@ -5455,7 +5455,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
        char filename[FILE_MAX];
 
        Scene *scene = CTX_data_scene(C);
-       SceneLayer *sl = CTX_data_scene_layer(C);
+       SceneLayer *scene_layer = CTX_data_scene_layer(C);
        EvaluationContext eval_ctx;
        ToolSettings *settings = scene->toolsettings;
        int w = settings->imapaint.screen_grab_size[0];
@@ -5473,7 +5473,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
        if (h > maxsize) h = maxsize;
 
        ibuf = ED_view3d_draw_offscreen_imbuf(
-               &eval_ctx, scene, sl, CTX_wm_view3d(C), CTX_wm_region(C),
+               &eval_ctx, scene, scene_layer, CTX_wm_view3d(C), CTX_wm_region(C),
                w, h, IB_rect, false, R_ALPHAPREMUL, 0, false, NULL,
                NULL, NULL, err_out);
        if (!ibuf) {
index f4affb90cc39f24d618f91d0f5c487628e533fd6..50882571dad6c7a644cab22f4756e802a34f2421 100644 (file)
@@ -409,7 +409,8 @@ static void action_main_region_listener(
 
 /* editor level listener */
 static void action_listener(
-        bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene))
+        bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
+        WorkSpace *UNUSED(workspace))
 {
        SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
        
index f6c15f4d0306651873aafe54c25cd3a7d2f7b2ac..8aa4e674d11b0db44f25d8132bffa99eadfacb02 100644 (file)
@@ -57,6 +57,7 @@
 #include "BKE_screen.h"
 #include "BKE_texture.h"
 #include "BKE_linestyle.h"
+#include "BKE_workspace.h"
 
 #include "RNA_access.h"
 
@@ -168,29 +169,53 @@ static int buttons_context_path_linestyle(ButsContextPath *path)
        return 0;
 }
 
+static int buttons_context_path_workspace(ButsContextPath *path)
+{
+       PointerRNA *ptr = &path->ptr[path->len - 1];
+
+       /* This one just verifies. */
+       return RNA_struct_is_a(ptr->type, &RNA_WorkSpace);
+}
+
+static int buttons_context_path_collection(ButsContextPath *path)
+{
+       PointerRNA *ptr = &path->ptr[path->len - 1];
+
+       /* if we already have a (pinned) Collection, we're done */
+       if (RNA_struct_is_a(ptr->type, &RNA_LayerCollection)) {
+               return 1;
+       }
+
+       SceneLayer *sl = ptr->data;
+       LayerCollection *sc = BKE_layer_collection_get_active(sl);
+
+       if (sc) {
+               RNA_pointer_create(NULL, &RNA_LayerCollection, sc, &path->ptr[path->len]);
+               path->len++;
+               return 1;
+       }
+
+       /* no path to a collection possible */
+       return 0;
+}
+
 static int buttons_context_path_object(ButsContextPath *path)
 {
-       Scene *scene;
-       Object *ob;
        PointerRNA *ptr = &path->ptr[path->len - 1];
 
        /* if we already have a (pinned) object, we're done */
        if (RNA_struct_is_a(ptr->type, &RNA_Object)) {
                return 1;
        }
-       /* if we have a scene, use the scene's active object */
-       else if (buttons_context_path_scene(path)) {
-               scene = path->ptr[path->len - 1].data;
 
-               SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene);
-               ob = (sl->basact) ? sl->basact->object : NULL;
+       SceneLayer *sl = ptr->data;
+       Object *ob = (sl->basact) ? sl->basact->object : NULL;
 
-               if (ob) {
-                       RNA_id_pointer_create(&ob->id, &path->ptr[path->len]);
-                       path->len++;
+       if (ob) {
+               RNA_id_pointer_create(&ob->id, &path->ptr[path->len]);
+               path->len++;
 
-                       return 1;
-               }
+               return 1;
        }
 
        /* no path to a object possible */
@@ -559,39 +584,11 @@ static bool buttons_context_linestyle_pinnable(const bContext *C)
 }
 #endif
 
-static int buttons_context_path_collection(const bContext *C, ButsContextPath *path)
-{
-       PointerRNA *ptr = &path->ptr[path->len - 1];
-
-       /* if we already have a (pinned) Collection, we're done */
-       if (RNA_struct_is_a(ptr->type, &RNA_LayerCollection)) {
-               return 1;
-       }
-
-       SceneLayer *sl = CTX_data_scene_layer(C);
-       LayerCollection *sc = BKE_layer_collection_get_active(sl);
-
-       if (sc) {
-               RNA_pointer_create(NULL, &RNA_LayerCollection, sc, &path->ptr[path->len]);
-               path->len++;
-
-               /* temporary object in context path to get edit mode */
-               Object *ob = CTX_data_active_object(C);
-               if (ob) {
-                       RNA_id_pointer_create(&ob->id, &path->ptr[path->len]);
-                       path->len++;
-               }
-
-               return 1;
-       }
-
-       /* no path to a collection possible */
-       return 0;
-}
-
 static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag)
 {
        SpaceButs *sbuts = CTX_wm_space_buts(C);
+       Scene *scene = CTX_data_scene(C);
+       WorkSpace *workspace = CTX_wm_workspace(C);
        ID *id;
        int found;
 
@@ -599,18 +596,32 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
        path->flag = flag;
        path->tex_ctx = sbuts->texture_context;
 
-       /* if some ID datablock is pinned, set the root pointer */
+       const bool use_scene_settings = BKE_workspace_use_scene_settings_get(workspace);
+
+       /* If some ID datablock is pinned, set the root pointer. */
        if (sbuts->pinid) {
                id = sbuts->pinid;
 
                RNA_id_pointer_create(id, &path->ptr[0]);
                path->len++;
        }
+       /* No pinned root, use scene or workspace as initial root. */
+       else {
+               if ((mainb != BCONTEXT_WORKSPACE) && (use_scene_settings ||
+                   ELEM(mainb, BCONTEXT_SCENE, BCONTEXT_RENDER, BCONTEXT_RENDER_LAYER, BCONTEXT_WORLD)))
+               {
+                       RNA_id_pointer_create(&scene->id, &path->ptr[0]);
+                       path->len++;
+               }
+               else {
+                       RNA_id_pointer_create(&workspace->id, &path->ptr[0]);
+                       path->len++;
+               }
+       }
 
-       /* no pinned root, use scene as root */
-       if (path->len == 0) {
-               id = (ID *)CTX_data_scene(C);
-               RNA_id_pointer_create(id, &path->ptr[0]);
+       if (!ELEM(mainb, BCONTEXT_WORKSPACE, BCONTEXT_SCENE, BCONTEXT_RENDER, BCONTEXT_RENDER_LAYER, BCONTEXT_WORLD)) {
+               SceneLayer *scene_layer = BKE_scene_layer_from_workspace_get(scene, workspace);
+               RNA_pointer_create(NULL, &RNA_SceneLayer, scene_layer, &path->ptr[path->len]);
                path->len++;
        }
 
@@ -635,6 +646,12 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
                case BCONTEXT_WORLD:
                        found = buttons_context_path_world(path);
                        break;
+               case BCONTEXT_WORKSPACE:
+                       found = buttons_context_path_workspace(path);
+                       break;
+               case BCONTEXT_COLLECTION:
+                       found = buttons_context_path_collection(path);
+                       break;
                case BCONTEXT_OBJECT:
                case BCONTEXT_PHYSICS:
                case BCONTEXT_CONSTRAINT:
@@ -663,9 +680,6 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
                case BCONTEXT_BONE_CONSTRAINT:
                        found = buttons_context_path_pose_bone(path);
                        break;
-               case BCONTEXT_COLLECTION:
-                       found = buttons_context_path_collection(C, path);
-                       break;
                default:
                        found = 0;
                        break;
@@ -783,7 +797,7 @@ const char *buttons_context_dir[] = {
        "texture", "texture_user", "texture_user_property", "bone", "edit_bone",
        "pose_bone", "particle_system", "particle_system_editable", "particle_settings",
        "cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint",
-       "line_style", "collection", NULL
+       "line_style", "collection", "workspace", NULL
 };
 
 int buttons_context(const bContext *C, const char *member, bContextDataResult *result)
@@ -812,6 +826,10 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
                set_pointer_type(path, result, &RNA_World);
                return 1;
        }
+       else if (CTX_data_equals(member, "workspace")) {
+               /* Do not return one here if scene not found in path, in this case we want to get default context scene! */
+               return set_pointer_type(path, result, &RNA_WorkSpace);
+       }
        else if (CTX_data_equals(member, "object")) {
                set_pointer_type(path, result, &RNA_Object);
                return 1;
@@ -1168,10 +1186,14 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
                        name = RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL);
 
                        if (name) {
-                               if (!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_RENDER_LAYER) && ptr->type == &RNA_Scene)
+                               if ((!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_RENDER_LAYER) && ptr->type == &RNA_Scene) ||
+                                   (!ELEM(sbuts->mainb, BCONTEXT_WORKSPACE) && ptr->type == &RNA_WorkSpace))
+                               {
                                        uiItemLDrag(row, ptr, "", icon);  /* save some space */
-                               else
+                               }
+                               else {
                                        uiItemLDrag(row, ptr, name, icon);
+                               }
 
                                if (name != namebuf)
                                        MEM_freeN(name);
index 299ab7171d697204b3b7cdb94314ba1a282ec982..c2b0b3cdcc0e3bf1a8b389461d75710d59b5ecc6 100644 (file)
@@ -151,6 +151,10 @@ static void buttons_main_region_draw(const bContext *C, ARegion *ar)
                ED_region_panels(C, ar, "render_layer", sbuts->mainb, vertical);
        else if (sbuts->mainb == BCONTEXT_WORLD)
                ED_region_panels(C, ar, "world", sbuts->mainb, vertical);
+       else if (sbuts->mainb == BCONTEXT_WORKSPACE)
+               ED_region_panels(C, ar, "workspace", sbuts->mainb, vertical);
+       else if (sbuts->mainb == BCONTEXT_COLLECTION)
+               ED_region_panels(C, ar, "collection", sbuts->mainb, vertical);
        else if (sbuts->mainb == BCONTEXT_OBJECT)
                ED_region_panels(C, ar, "object", sbuts->mainb, vertical);
        else if (sbuts->mainb == BCONTEXT_DATA)
@@ -171,8 +175,6 @@ static void buttons_main_region_draw(const bContext *C, ARegion *ar)
                ED_region_panels(C, ar, "constraint", sbuts->mainb, vertical);
        else if (sbuts->mainb == BCONTEXT_BONE_CONSTRAINT)
                ED_region_panels(C, ar, "bone_constraint", sbuts->mainb, vertical);
-       else if (sbuts->mainb == BCONTEXT_COLLECTION)
-               ED_region_panels(C, ar, "collection", sbuts->mainb, vertical);
 
        sbuts->re_align = 0;
        sbuts->mainbo = sbuts->mainb;
@@ -235,7 +237,8 @@ static void buttons_area_redraw(ScrArea *sa, short buttons)
 
 /* reused! */
 static void buttons_area_listener(
-        bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene))
+        bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene),
+        const WorkSpace *UNUSED(workspace))
 {
        SpaceButs *sbuts = sa->spacedata.first;
 
index f185eea6d32418fcec02e4fb020d98877218ce28..478254fb165a7697ad79ec1823bca2f39a3ef458 100644 (file)
@@ -330,7 +330,8 @@ static SpaceLink *clip_duplicate(SpaceLink *sl)
        return (SpaceLink *)scn;
 }
 
-static void clip_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene))
+static void clip_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
+                          WorkSpace *UNUSED(workspace))
 {
        /* context changes */
        switch (wmn->category) {
index 6e4815af0323daa8813828559fc50312a8207ecc..780c2ec5a476c0cb792f460f1049654e09abf82f 100644 (file)
@@ -292,7 +292,8 @@ static void file_refresh(const bContext *C, ScrArea *sa)
        }
 }
 
-static void file_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene))
+static void file_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
+                          WorkSpace *UNUSED(workspace))
 {
        SpaceFile *sfile = (SpaceFile *)sa->spacedata.first;
 
index d2358a494d5ca88cda03c8ea3b69962e66a90071..4b89c8db9e6e223aa9576e979cebdb16698456e6 100644 (file)
@@ -475,7 +475,8 @@ static void graph_region_listener(
 }
 
 /* editor level listener */
-static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene))
+static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
+                           WorkSpace *UNUSED(workspace))
 {
        SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first;
        
index 514cb1ab97eab09ba17c55802678ca13681f7032..cd4bfb918b32bea257264aaf6faba671895dad79 100644 (file)
@@ -442,7 +442,8 @@ static void image_refresh(const bContext *C, ScrArea *sa)
        }
 }
 
-static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *scene)
+static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *scene,
+                           WorkSpace *workspace)
 {
        SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
        
@@ -536,7 +537,7 @@ static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, co
                                case ND_TRANSFORM:
                                case ND_MODIFIER:
                                {
-                                       SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene);
+                                       SceneLayer *sl = BKE_scene_layer_from_workspace_get(scene, workspace);
                                        Object *ob = OBACT_NEW(sl);
                                        if (ob && (ob == wmn->reference) && (ob->mode & OB_MODE_EDIT)) {
                                                if (sima->lock && (sima->flag & SI_DRAWSHADOW)) {
index ab7a913ce6262a5be0e2da1cee445f3a476ec4f7..f6068087f024232e7f893a81af81f3d9f44354a4 100644 (file)
@@ -477,7 +477,8 @@ static void nla_channel_region_listener(
 }
 
 /* editor level listener */
-static void nla_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene))
+static void nla_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
+                         WorkSpace *UNUSED(workspace))
 {
        /* context changes */
        switch (wmn->category) {
index 75955ea3ab100d9923eb18098859e347f00efbcd..2f269470b82d1e71279a57d619fbfabd065121e0 100644 (file)
@@ -383,7 +383,7 @@ bool ED_node_is_texture(struct SpaceNode *snode)
 /* called from shading buttons or header */
 void ED_node_shader_default(const bContext *C, ID *id)
 {
-       Scene *scene = CTX_data_scene(C);
+       ViewRender *view_render = CTX_data_view_render(C);
        bNode *in, *out;
        bNodeSocket *fromsock, *tosock, *sock;
        bNodeTree *ntree;
@@ -398,11 +398,11 @@ void ED_node_shader_default(const bContext *C, ID *id)
                        Material *ma = (Material *)id;
                        ma->nodetree = ntree;
 
-                       if (BKE_scene_uses_blender_eevee(scene)) {
+                       if (BKE_viewrender_uses_blender_eevee(view_render)) {
                                output_type = SH_NODE_OUTPUT_MATERIAL;
                                shader_type = SH_NODE_BSDF_PRINCIPLED;
                        }
-                       else if (BKE_scene_use_new_shading_nodes(scene)) {
+                       else if (BKE_viewrender_use_new_shading_nodes(view_render)) {
                                output_type = SH_NODE_OUTPUT_MATERIAL;
                                shader_type = SH_NODE_BSDF_DIFFUSE;
                        }
@@ -460,7 +460,7 @@ void ED_node_shader_default(const bContext *C, ID *id)
        nodeAddLink(ntree, in, fromsock, out, tosock);
 
        /* default values */
-       if (BKE_scene_use_new_shading_nodes(scene)) {
+       if (BKE_viewrender_use_new_shading_nodes(view_render)) {
                PointerRNA sockptr;
                sock = in->inputs.first;
                RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr);
@@ -2353,7 +2353,7 @@ void NODE_OT_tree_socket_move(wmOperatorType *ot)
 static int node_shader_script_update_poll(bContext *C)
 {
        Scene *scene = CTX_data_scene(C);
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
+       RenderEngineType *type = RE_engines_find(scene->view_render.engine_id);
        SpaceNode *snode = CTX_wm_space_node(C);
        bNode *node;
        Text *text;
@@ -2423,7 +2423,7 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
        bool found = false;
 
        /* setup render engine */
-       type = RE_engines_find(scene->r.engine);
+       type = RE_engines_find(scene->view_render.engine_id);
        engine = RE_engine_create(type);
        engine->reports = op->reports;
 
index 5d0877a1eff1ed9d6d9845d477449798aca15ab0..c791b9f6eae40d2c69b61b09849bc4db8b35c2de 100644 (file)
@@ -559,6 +559,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
 {
        Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
+       ViewRender *view_render = CTX_data_view_render(C);
        uiBlock *block = uiLayoutGetBlock(layout);
        uiBut *but = (uiBut *)but_p;
        uiLayout *split, *column;
@@ -575,7 +576,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
        arg->layout = split;
 
        if (ntreetype && ntreetype->foreach_nodeclass)
-               ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb);
+               ntreetype->foreach_nodeclass(view_render, arg, node_menu_column_foreach_cb);
 
        column = uiLayoutColumn(split, false);
        UI_block_layout_set_current(block, column);
index 7cb22dcc5708503f495672df3c9e42f5c1c89b59..e1765e39f7acd2095718f6ca7aee516ff1a0a851 100644 (file)
@@ -382,12 +382,14 @@ static void node_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
 
 }
 
-static void node_area_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *scene)
+static void node_area_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *scene,
+                               WorkSpace *workspace)
 {
        /* note, ED_area_tag_refresh will re-execute compositor */
        SpaceNode *snode = sa->spacedata.first;
+       ViewRender *view_render = BKE_viewrender_get(scene, workspace);
        /* shaderfrom is only used for new shading nodes, otherwise all shaders are from objects */
-       short shader_type = BKE_scene_use_new_shading_nodes(scene) ? snode->shaderfrom : SNODE_SHADER_OBJECT;
+       short shader_type = BKE_viewrender_use_new_shading_nodes(view_render) ? snode->shaderfrom : SNODE_SHADER_OBJECT;
 
        /* preview renders */
        switch (wmn->category) {
index f3a5af4b1641007f196fcc02634aa0a9412ae309..5331c76a0dc43ae9b795136d9ec53cb904f1512d 100644 (file)
@@ -386,7 +386,7 @@ static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *s
        outliner_add_element(soops,  lb, sce->world, te, 0, 0);
 
 #ifdef WITH_FREESTYLE
-       if (STREQ(sce->r.engine, RE_engine_id_BLENDER_RENDER) && (sce->r.mode & R_EDGE_FRS))
+       if (STREQ(sce->view_render->engine_id, RE_engine_id_BLENDER_RENDER) && (sce->r.mode & R_EDGE_FRS))
                outliner_add_line_styles(soops, lb, sce, te);
 #endif
 }
index 3b04e6c80cdd73e16ef1bb2982290774f899dfb6..da16ac5acaa93037b91be6bab11c3caecf29de31 100644 (file)
@@ -338,7 +338,8 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl)
 }
 
 static void sequencer_listener(
-        bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene))
+        bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
+        WorkSpace *UNUSED(workspace))
 {
        /* context changes */
        switch (wmn->category) {
index ed1ef080e0c843cc6c690d150a7f092bb969118c..539fe1c53bd1461c4e0b9f7f4b228d553f1780b9 100644 (file)
@@ -125,7 +125,8 @@ static SpaceLink *text_duplicate(SpaceLink *sl)
        return (SpaceLink *)stextn;
 }
 
-static void text_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene))
+static void text_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
+                          WorkSpace *UNUSED(workspace))
 {
        SpaceText *st = sa->spacedata.first;
 
index 7ecb5cb072d75e5c9d3daaf37624527c848c4e57..8a5277d31da9fea93ee7560b998548b8b6774a06 100644 (file)
@@ -468,7 +468,8 @@ static void time_draw_keyframes(const bContext *C, ARegion *ar)
 /* ---------------- */
 
 /* editor level listener */
-static void time_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene))
+static void time_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, const Scene *UNUSED(scene),
+                          const WorkSpace *UNUSED(workspace))
 {
 
        /* mainly for updating cache display */
index 9654ff74f54132a505957594747f3dcd215ed13c..2267c12f1002adc8ee0341a818cec0d20deb4252 100644 (file)
@@ -1301,7 +1301,8 @@ static void view3d_props_region_listener(
 
 /* area (not region) level listener */
 static void space_view3d_listener(
-        bScreen *UNUSED(sc), ScrArea *sa, struct wmNotifier *wmn, const Scene *UNUSED(scene))
+        bScreen *UNUSED(sc), ScrArea *sa, struct wmNotifier *wmn, Scene *UNUSED(scene),
+        WorkSpace *UNUSED(workspace))
 {
        View3D *v3d = sa->spacedata.first;
 
index ed4d7861d6d6dd8a3437ca69eff1a7ce7a9a2028..ec2dcc75bc0535120afdf7e3fad6cbef6d2fa588 100644 (file)
@@ -1880,10 +1880,11 @@ static void view3d_draw_view(const bContext *C, ARegion *ar)
 void view3d_main_region_draw(const bContext *C, ARegion *ar)
 {
        Scene *scene = CTX_data_scene(C);
+       WorkSpace *workspace = CTX_wm_workspace(C);
        View3D *v3d = CTX_wm_view3d(C);
        RegionView3D *rv3d = ar->regiondata;
-       /* XXX: In the future we should get RE from Layers/Depsgraph */
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
+       ViewRender *view_render = BKE_viewrender_get(scene, workspace);
+       RenderEngineType *type = RE_engines_find(view_render->engine_id);
 
        /* Provisory Blender Internal drawing */
        if (type->flag & RE_USE_LEGACY_PIPELINE) {
@@ -1931,7 +1932,7 @@ static void view3d_stereo3d_setup_offscreen(
 
 void ED_view3d_draw_offscreen_init(const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d)
 {
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
+       RenderEngineType *type = eval_ctx->engine;
        if (type->flag & RE_USE_LEGACY_PIPELINE) {
                /* shadow buffers, before we setup matrices */
                if (draw_glsl_material(scene, sl, NULL, v3d, v3d->drawtype)) {
@@ -1959,7 +1960,8 @@ static void view3d_main_region_clear(Scene *scene, View3D *v3d, ARegion *ar)
  * stuff like shadow buffers
  */
 void ED_view3d_draw_offscreen(
-        const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, int winx, int winy,
+        const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *scene_layer,
+        View3D *v3d, ARegion *ar, int winx, int winy,
         float viewmat[4][4], float winmat[4][4],
         bool do_bgpic, bool do_sky, bool is_persp, const char *viewname,
         GPUFX *fx, GPUFXSettings *fx_settings,
@@ -2013,7 +2015,7 @@ void ED_view3d_draw_offscreen(
                view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, winmat, NULL);
 
        /* main drawing call */
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
+       RenderEngineType *type = eval_ctx->engine;
        if (type->flag & RE_USE_LEGACY_PIPELINE) {
 
                /* framebuffer fx needed, we need to draw offscreen first */
@@ -2055,8 +2057,8 @@ void ED_view3d_draw_offscreen(
        }
        else {
                /* XXX, should take depsgraph as arg */
-               Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, sl);
-               DRW_draw_render_loop_offscreen(depsgraph, ar, v3d, ofs);
+               Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, scene_layer);
+               DRW_draw_render_loop_offscreen(depsgraph, eval_ctx->engine, ar, v3d, ofs);
        }
 
        /* restore size */
@@ -2079,7 +2081,8 @@ void ED_view3d_draw_offscreen(
  * (avoids re-creating when doing multiple GL renders).
  */
 ImBuf *ED_view3d_draw_offscreen_imbuf(
-        const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, int sizex, int sizey,
+        const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *scene_layer,
+        View3D *v3d, ARegion *ar, int sizex, int sizey,
         unsigned int flag, bool draw_background,
         int alpha_mode, int samples, bool full_samples, const char *viewname,
         /* output vars */
@@ -2108,7 +2111,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
                }
        }
 
-       ED_view3d_draw_offscreen_init(eval_ctx, scene, sl, v3d);
+       ED_view3d_draw_offscreen_init(eval_ctx, scene, scene_layer, v3d);
 
        GPU_offscreen_bind(ofs, true);
 
@@ -2150,7 +2153,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
        if ((samples && full_samples) == 0) {
                /* Single-pass render, common case */
                ED_view3d_draw_offscreen(
-                       eval_ctx, scene, sl, v3d, ar, sizex, sizey, NULL, winmat,
+                       eval_ctx, scene, scene_layer, v3d, ar, sizex, sizey, NULL, winmat,
                        draw_background, draw_sky, !is_ortho, viewname,
                        fx, &fx_settings, ofs);
 
@@ -2174,7 +2177,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
 
                /* first sample buffer, also initializes 'rv3d->persmat' */
                ED_view3d_draw_offscreen(
-                       eval_ctx, scene, sl, v3d, ar, sizex, sizey, NULL, winmat,
+                       eval_ctx, scene, scene_layer, v3d, ar, sizex, sizey, NULL, winmat,
                        draw_background, draw_sky, !is_ortho, viewname,
                        fx, &fx_settings, ofs);
                GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, rect_temp);
@@ -2193,7 +2196,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
                                (jit_ofs[j][1] * 2.0f) / sizey);
 
                        ED_view3d_draw_offscreen(
-                               eval_ctx, scene, sl, v3d, ar, sizex, sizey, NULL, winmat_jitter,
+                               eval_ctx, scene, scene_layer, v3d, ar, sizex, sizey, NULL, winmat_jitter,
                                draw_background, draw_sky, !is_ortho, viewname,
                                fx, &fx_settings, ofs);
                        GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, rect_temp);
@@ -2244,7 +2247,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
  * \note used by the sequencer
  */
 ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
-        const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, Object *camera, int width, int height,
+        const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *scene_layer,
+        Object *camera, int width, int height,
         unsigned int flag, int drawtype, bool use_solid_tex, bool use_gpencil, bool draw_background,
         int alpha_mode, int samples, bool full_samples, const char *viewname,
         GPUFX *fx, GPUOffScreen *ofs, char err_out[256])
@@ -2298,7 +2302,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
        invert_m4_m4(rv3d.persinv, rv3d.viewinv);
 
        return ED_view3d_draw_offscreen_imbuf(
-               eval_ctx, scene, sl, &v3d, &ar, width, height, flag,
+               eval_ctx, scene, scene_layer, &v3d, &ar, width, height, flag,
                draw_background, alpha_mode, samples, full_samples, viewname,
                fx, ofs, err_out);
 }
index d24c8241855dde9adac384b5298b4c92f7b19cc2..3680470c73474e6faeb51d888b59a70700f96930 100644 (file)
@@ -1786,8 +1786,7 @@ void ED_scene_draw_fps(Scene *scene, const rcti *rect)
 
 static bool view3d_main_region_do_render_draw(const Scene *scene)
 {
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
-
+       RenderEngineType *type = RE_engines_find(scene->view_render.engine_id);
        return (type && type->view_update && type->render_to_view);
 }
 
@@ -1849,8 +1848,7 @@ static bool view3d_main_region_draw_engine(
        /* create render engine */
        if (!rv3d->render_engine) {
                RenderEngine *engine;
-
-               type = RE_engines_find(scene->r.engine);
+               type = RE_engines_find(scene->view_render.engine_id);
 
                if (!(type->view_update && type->render_to_view))
                        return false;
@@ -1979,7 +1977,7 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Sce
 
        rv3d->rflag &= ~RV3D_IS_GAME_ENGINE;
 #ifdef WITH_GAMEENGINE
-       if (STREQ(scene->r.engine, RE_engine_id_BLENDER_GAME)) {
+       if (STREQ(scene->view_render.engine_id, RE_engine_id_BLENDER_GAME)) {
                rv3d->rflag |= RV3D_IS_GAME_ENGINE;
 
                /* Make sure LoDs are up to date */
index 60e90121ad1ab3a4d814dfb6837114d7d636c046..03f4f506c13dcd9721d0048a33bbf8b22e71ab76 100644 (file)
@@ -282,7 +282,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
        }
        else if (state == RULER_STATE_DRAG) {
                ruler_info->snap_context = ED_transform_snap_object_context_create_view3d(
-                       CTX_data_main(C), CTX_data_scene(C), CTX_data_scene_layer(C), 0,
+                       CTX_data_main(C), CTX_data_scene(C), CTX_data_scene_layer(C), CTX_data_engine(C), 0,
                        ruler_info->ar, CTX_wm_view3d(C));
        }
        else {
index f5d5ae3726f1742a79c08f4fb298f407e74063e5..9014a2c74e6f8d1295599d919dd45024f49a224f 100644 (file)
@@ -114,6 +114,7 @@ void view3d_set_viewcontext(bContext *C, ViewContext *vc)
        vc->depsgraph = CTX_data_depsgraph(C);
        vc->scene = CTX_data_scene(C);
        vc->scene_layer = CTX_data_scene_layer(C);
+       vc->engine = CTX_data_engine(C);
        vc->v3d = CTX_wm_view3d(C);
        vc->win = CTX_wm_window(C);
        vc->rv3d = CTX_wm_region_view3d(C);
index 44b7fadd29f25fd7851385b91f469914d8533a42..2f7893b9b83fe2358b24f604e4d52ac538a6e640 100644 (file)
@@ -58,6 +58,8 @@
 
 #include "GPU_immediate.h"
 
+#include "RE_engine.h"
+
 #include "view3d_intern.h"  /* own include */
 
 #ifdef WITH_INPUT_NDOF
@@ -249,6 +251,7 @@ typedef struct WalkInfo {
        ARegion *ar;
        Scene *scene;
        SceneLayer *scene_layer;
+       RenderEngineType *engine;
 
        wmTimer *timer; /* needed for redraws */
 
@@ -512,6 +515,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
        walk->ar = CTX_wm_region(C);
        walk->scene = CTX_data_scene(C);
        walk->scene_layer = CTX_data_scene_layer(C);
+       walk->engine = CTX_data_engine(C);
 
 #ifdef NDOF_WALK_DEBUG
        puts("\n-- walk begin --");
@@ -600,7 +604,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
        walk->rv3d->rflag |= RV3D_NAVIGATING;
 
        walk->snap_context = ED_transform_snap_object_context_create_view3d(
-               CTX_data_main(C), walk->scene, walk->scene_layer, 0,
+               CTX_data_main(C), walk->scene, walk->scene_layer, walk->engine, 0,
                walk->ar, walk->v3d);
 
        walk->v3d_camera_control = ED_view3d_cameracontrol_acquire(
index fda15545eade30e8517853bb28fc0ef25087e7cc..f38f6c064b8665f45de3609c12c74aeba4cc45eb 100644 (file)
@@ -29,6 +29,7 @@ set(INC
        ../../ikplugin
        ../../makesdna
        ../../makesrna
+       ../../render/extern/include
        ../../windowmanager
        ../../depsgraph
        ../../../../intern/guardedalloc
index 92eb31aabe674c7ed0e1c59fc5353f325fcaf7de..60ad61e34755948e46f98a278eddaf92706e74ca 100644 (file)
@@ -37,6 +37,8 @@
 #include "ED_numinput.h"
 #include "ED_view3d.h"
 
+#include "RE_engine.h"
+
 #include "DNA_listBase.h"
 
 /* ************************** Types ***************************** */
@@ -60,6 +62,7 @@ struct wmTimer;
 struct ARegion;
 struct ReportList;
 struct EditBone;
+struct RenderEngineType;
 struct SnapObjectContext;
 
 /* transinfo->redraw */
@@ -467,6 +470,7 @@ typedef struct TransInfo {
        struct ARegion  *ar;
        struct Scene    *scene;
        struct SceneLayer *scene_layer;
+       struct RenderEngineType *engine;
        struct ToolSettings *settings;
        struct wmTimer *animtimer;
        struct wmKeyMap *keymap;  /* so we can do lookups for header text */
index 166a5805fa1c35e92a7cd0fa3d8f54bd1d3783ee..b04767724eaed899a5aa4b17af741eebdf1faa77 100644 (file)
@@ -2485,7 +2485,7 @@ static void createTransEditVerts(TransInfo *t)
        int *island_vert_map = NULL;
 
        DEG_evaluation_context_init_from_scene(&eval_ctx,
-                                              t->scene, t->scene_layer,
+                                              t->scene, t->scene_layer, t->engine,
                                               DAG_EVAL_VIEWPORT);
 
        /* Even for translation this is needed because of island-orientation, see: T51651. */
@@ -5557,7 +5557,7 @@ static void set_trans_object_base_flags(TransInfo *t)
        /* handle pending update events, otherwise they got copied below */
        EvaluationContext eval_ctx;
        DEG_evaluation_context_init_from_scene(&eval_ctx,
-                                              t->scene, t->scene_layer,
+                                              t->scene, t->scene_layer, t->engine,
                                               DAG_EVAL_VIEWPORT);
        for (base = sl->object_bases.first; base; base = base->next) {
                if (base->object->recalc & OB_RECALC_ALL) {
index 2bed1dd28f2e4150b5d5c801a174c86455d4cbe6..5081b65c215db86d72a4489bc2d3c3188ea91d12 100644 (file)
 #include "WM_types.h"
 #include "WM_api.h"
 
+#include "RE_engine.h"
+
 #include "UI_resources.h"
 #include "UI_view2d.h"
 
@@ -1122,10 +1124,12 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
        Object *obedit = CTX_data_edit_object(C);
        Object *ob = CTX_data_active_object(C);
        bGPdata *gpd = CTX_data_gpencil_data(C);
+       RenderEngineType *engine = CTX_data_engine(C);
        PropertyRNA *prop;
        
        t->scene = sce;
        t->scene_layer = sl;
+       t->engine = engine;
        t->sa = sa;
        t->ar = ar;
        t->obedit = obedit;
index e3ea8a51c6d8e235c65b6c1919516ab51b70000d..2654887d45c003567320d8ccf60ee1edd8533ad7 100644 (file)
@@ -585,7 +585,7 @@ static void initSnappingMode(TransInfo *t)
        if (t->spacetype == SPACE_VIEW3D) {
                if (t->tsnap.object_context == NULL) {
                        t->tsnap.object_context = ED_transform_snap_object_context_create_view3d(
-                               G.main, t->scene, t->scene_layer, 0,
+                               G.main, t->scene, t->scene_layer, t->engine, 0,
                                t->ar, t->view);
 
                        ED_transform_snap_object_context_set_editmesh_callbacks(
index e72bfa40480b68a6afacb23be0486683aba356bb..9d60cac48f002dd8332d68b9c620d4f67082fe82 100644 (file)
@@ -2096,7 +2096,7 @@ static bool snapObjectsRay(
  * \{ */
 
 SnapObjectContext *ED_transform_snap_object_context_create(
-        Main *bmain, Scene *scene, SceneLayer *sl, int flag)
+        Main *bmain, Scene *scene, SceneLayer *sl, RenderEngineType *engine, int flag)
 {
        SnapObjectContext *sctx = MEM_callocN(sizeof(*sctx), __func__);
 
@@ -2105,7 +2105,7 @@ SnapObjectContext *ED_transform_snap_object_context_create(
        sctx->bmain = bmain;
        sctx->scene = scene;
 
-       DEG_evaluation_context_init_from_scene(&sctx->eval_ctx, scene, sl, DAG_EVAL_VIEWPORT);
+       DEG_evaluation_context_init_from_scene(&sctx->eval_ctx, scene, sl, engine, DAG_EVAL_VIEWPORT);
 
        sctx->cache.object_map = BLI_ghash_ptr_new(__func__);
        sctx->cache.mem_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
@@ -2114,11 +2114,11 @@ SnapObjectContext *ED_transform_snap_object_context_create(
 }
 
 SnapObjectContext *ED_transform_snap_object_context_create_view3d(
-        Main *bmain, Scene *scene, SceneLayer *sl, int flag,
+        Main *bmain, Scene *scene, SceneLayer *sl, RenderEngineType *engine, int flag,
         /* extra args for view3d */
         const ARegion *ar, const View3D *v3d)
 {
-       SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, sl, flag);
+       SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, sl, engine, flag);
 
        sctx->use_v3d = true;
        sctx->v3d_data.ar = ar;
index 322acd9966cf7d8b7771226f350ed1c8095310f1..6ab855ac6afcc006ed316dfec573bb1acbd1f105 100644 (file)
@@ -115,8 +115,8 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
        freestyle_scene->r.filtertype = old_scene->r.filtertype;
        freestyle_scene->r.gauss = old_scene->r.gauss;
        freestyle_scene->r.dither_intensity = old_scene->r.dither_intensity;
-       BLI_strncpy(freestyle_scene->r.engine, old_scene->r.engine, sizeof(freestyle_scene->r.engine));
-       freestyle_scene->r.im_format.planes = R_IMF_PLANES_RGBA; 
+       BKE_viewrender_copy(&freestyle_scene->view_render, &old_scene->view_render);
+       freestyle_scene->r.im_format.planes = R_IMF_PLANES_RGBA;
        freestyle_scene->r.im_format.imtype = R_IMF_IMTYPE_PNG;
 
        if (G.debug & G_DEBUG_FREESTYLE) {
@@ -463,7 +463,7 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
                        BLI_ghash_insert(_nodetree_hash, nt, ma);
                }
 
-               if (STREQ(freestyle_scene->r.engine, RE_engine_id_CYCLES)) {
+               if (STREQ(freestyle_scene->view_render.engine_id, RE_engine_id_CYCLES)) {
                        PointerRNA scene_ptr, freestyle_scene_ptr;
                        RNA_pointer_create(NULL, &RNA_Scene, old_scene, &scene_ptr);
                        RNA_pointer_create(NULL, &RNA_Scene, freestyle_scene, &freestyle_scene_ptr);
index ef37d6bd02a8d00c137b3f949ba839a1f2720f9e..55157246c1995decbc58096827c7e015a0afeaea 100644 (file)
@@ -50,6 +50,7 @@
 #include "BKE_colortools.h"
 #include "BKE_global.h"
 #include "BKE_image.h"
+#include "BKE_layer.h"
 #include "BKE_main.h"
 #include "BKE_node.h"
 #include "BKE_scene.h"
index 7ef6e8c34dda483ec19a973c9079714ea21f1c1e..86931401aaed87189a131d11e9f6ae4ae20fd5c4 100644 (file)
@@ -74,7 +74,6 @@ typedef struct LayerCollection {
 typedef struct SceneLayer {
        struct SceneLayer *next, *prev;
        char name[64]; /* MAX_NAME */
-       char engine[32]; /* render engine */
        short active_collection;
        short flag;
        short pad[2];
index d81a4625144de8b948b8251180aef52e936dcdbf..35d3f4470dabc8a62b241034fb83d040be91fd1e 100644 (file)
@@ -749,7 +749,7 @@ typedef struct RenderData {
        float unit_line_thickness; /* in pixels */
 
        /* render engine */
-       char engine[32];
+       char engine[32] DNA_DEPRECATED; // XXX deprecated since 2.8
 
        /* Cycles baking */
        struct BakeData bake;
@@ -772,6 +772,12 @@ typedef struct RenderData {
        struct CurveMapping mblur_shutter_curve;
 } RenderData;
 
+/* *************************************************************** */
+/* Settings related to viewport drawing/render, only settings used by WorkSpace and Scene. */
+typedef struct ViewRender {
+       char engine_id[32];
+} ViewRender;
+
 /* *************************************************************** */
 /* Render Conversion/Simplfication Settings */
 
@@ -883,7 +889,6 @@ typedef struct GameData {
        /* Scene LoD */
        short lodflag, pad2;
        int scehysteresis, pad5;
-
 } GameData;
 
 #define STEREO_NOSTEREO                1
@@ -1699,6 +1704,8 @@ typedef struct Scene {
        IDProperty *layer_properties;  /* settings to be override by workspaces */
 
        int pad5[2];
+
+       ViewRender view_render;
 } Scene;
 
 /* **************** RENDERDATA ********************* */
index 68cc5c2d79e7913d644ec4cf97715a0a754a264a..f172737e3bdee974a4ff8725c715b7f0d6db0674 100644 (file)
@@ -182,6 +182,7 @@ typedef enum eSpaceButtons_Context {
        BCONTEXT_BONE_CONSTRAINT = 12,
        BCONTEXT_RENDER_LAYER = 13,
        BCONTEXT_COLLECTION = 14,
+       BCONTEXT_WORKSPACE = 15,
 
        /* always as last... */
        BCONTEXT_TOT
index 3805e1c0a8ae1fd4516eb6f6012c694bf2d6554f..f6d5f8805a891f0b655a0a498067375b13d26200 100644 (file)
@@ -29,6 +29,7 @@
 #ifndef __DNA_WORKSPACE_TYPES_H__
 #define __DNA_WORKSPACE_TYPES_H__
 
+#include "DNA_scene_types.h"
 
 /* Same logic as DNA_DEPRECATED_ALLOW, but throws 'deprecated'
  * warnings if DNA_PRIVATE_WORKSPACE_ALLOW is not defined */
@@ -77,9 +78,12 @@ typedef struct WorkSpace {
        ListBase transform_orientations DNA_PRIVATE_WORKSPACE;
 
        int object_mode DNA_PRIVATE_WORKSPACE; /* enum ObjectMode */
-       int pad;
+       int flags DNA_PRIVATE_WORKSPACE; /* enum eWorkSpaceFlags */
 
        struct SceneLayer *render_layer DNA_PRIVATE_WORKSPACE;
+
+       char engine_id[32]; /* Render Engine. */
+       struct ViewRender view_render;
 } WorkSpace;
 
 /* internal struct, but exported for read/write */
@@ -132,4 +136,8 @@ typedef struct WorkSpaceInstanceHook {
        struct WorkSpaceLayout *temp_layout_store;
 } WorkSpaceInstanceHook;
 
+typedef enum eWorkSpaceFlags {
+       WORKSPACE_USE_SCENE_SETTINGS = (1 << 0),
+} eWorkSpaceFlags;
+
 #endif /* __DNA_WORKSPACE_TYPES_H__ */
index 114b0c32c153d5e8a01590410f1ba7b9533844e8..501a1cccca6448c6709e93a391c7f1ac9db90c40 100644 (file)
@@ -708,6 +708,7 @@ extern StructRNA RNA_WaveModifier;
 extern StructRNA RNA_VertexWeightEditModifier;
 extern StructRNA RNA_VertexWeightMixModifier;
 extern StructRNA RNA_VertexWeightProximityModifier;
+extern StructRNA RNA_ViewRenderSettings;
 extern StructRNA RNA_Window;
 extern StructRNA RNA_WindowManager;
 extern StructRNA RNA_WipeSequence;
index 5701150b1bf04d3eac40d85462bac77976476dc4..7be3dd60d522ba72ad989826057f54c6778913ef 100644 (file)
@@ -39,6 +39,8 @@
 
 #ifdef RNA_RUNTIME
 
+#include "RE_engine.h"
+
 static PointerRNA rna_Context_manager_get(PointerRNA *ptr)
 {
        bContext *C = (bContext *)ptr->data;
@@ -133,6 +135,26 @@ static PointerRNA rna_Context_scene_layer_get(PointerRNA *ptr)
        return rna_pointer_inherit_refine(ptr, &RNA_SceneLayer, CTX_data_scene_layer(C));
 }
 
+static PointerRNA rna_Context_view_render_get(PointerRNA *ptr)
+{
+       bContext *C = (bContext *)ptr->data;
+       return rna_pointer_inherit_refine(ptr, &RNA_ViewRenderSettings, CTX_data_view_render(C));
+}
+
+static void rna_Context_engine_get(PointerRNA *ptr, char *value)
+ {
+       bContext *C = (bContext *)ptr->data;
+       RenderEngineType *engine = CTX_data_engine(C);
+       strcpy(value, engine->idname);
+}
+
+static int rna_Context_engine_length(PointerRNA *ptr)
+{
+       bContext *C = (bContext *)ptr->data;
+       RenderEngineType *engine = CTX_data_engine(C);
+       return strlen(engine->idname);
+}
+
 static PointerRNA rna_Context_scene_collection_get(PointerRNA *ptr)
 {
        bContext *C = (bContext *)ptr->data;
@@ -263,6 +285,15 @@ void RNA_def_context(BlenderRNA *brna)
        RNA_def_property_struct_type(prop, "SceneLayer");
        RNA_def_property_pointer_funcs(prop, "rna_Context_scene_layer_get", NULL, NULL, NULL);
 
+       prop = RNA_def_property(srna, "view_render", PROP_POINTER, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_struct_type(prop, "ViewRenderSettings");
+       RNA_def_property_pointer_funcs(prop, "rna_Context_view_render_get", NULL, NULL, NULL);
+
+       prop = RNA_def_property(srna, "engine", PROP_STRING, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_string_funcs(prop, "rna_Context_engine_get", "rna_Context_engine_length", NULL);
+
        prop = RNA_def_property(srna, "scene_collection", PROP_POINTER, PROP_NONE);
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_struct_type(prop, "SceneCollection");
index 29d68111bac4f136b552a64ffb9d2c47b425dabc..0f59451e17ce5ac988f65719aaa16339cb3846a7 100644 (file)
@@ -3027,7 +3027,7 @@ static void rna_ShaderNodeScript_update(Main *bmain, Scene *scene, PointerRNA *p
 {
        bNodeTree *ntree = (bNodeTree *)ptr->id.data;
        bNode *node = (bNode *)ptr->data;
-       RenderEngineType *engine_type = RE_engines_find(scene->r.engine);
+       RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
 
        if (engine_type && engine_type->update_script_node) {
                /* auto update node */
index 685844149e1f4a9776fe8f75f083ba2fe672a187..3e1f8f06d927bfa91231b52867f2dcce52fe69df 100644 (file)
@@ -454,6 +454,7 @@ EnumPropertyItem rna_enum_layer_collection_mode_settings_type_items[] = {
 #include "DNA_object_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_text_types.h"
+#include "DNA_workspace_types.h"
 
 #include "RNA_access.h"
 
@@ -1007,6 +1008,11 @@ static void rna_RenderSettings_stereoViews_begin(CollectionPropertyIterator *ite
        rna_iterator_listbase_begin(iter, &rd->views, rna_RenderSettings_stereoViews_skip);
 }
 
+static char *rna_ViewRenderSettings_path(PointerRNA *UNUSED(ptr))
+{
+       return BLI_sprintfN("viewport_render");
+}
+
 static char *rna_RenderSettings_path(PointerRNA *UNUSED(ptr))
 {
        return BLI_sprintfN("render");
@@ -1482,19 +1488,32 @@ static void rna_RenderView_remove(
        WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL);
 }
 
-static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value)
+static void rna_RenderSettings_views_format_set(PointerRNA *ptr, int value)
 {
        RenderData *rd = (RenderData *)ptr->data;
-       RenderEngineType *type = BLI_findlink(&R_engines, value);
-       Scene *scene = (Scene *)ptr->id.data;
 
-       if (type)
-               BLI_strncpy_utf8(rd->engine, type->idname, sizeof(rd->engine));
+       if (rd->views_format == SCE_VIEWS_FORMAT_MULTIVIEW &&
+           value == SCE_VIEWS_FORMAT_STEREO_3D)
+       {
+               /* make sure the actview is visible */
+               if (rd->actview > 1) rd->actview = 1;
+       }
+
+       rd->views_format = value;
+}
+
+static void rna_ViewRenderSettings_engine_set(PointerRNA *ptr, int value)
+{
+       ViewRender *view_render = (ViewRender *)ptr->data;
+       RenderEngineType *type = BLI_findlink(&R_engines, value);
 
-       DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+       if (type) {
+               BLI_strncpy_utf8(view_render->engine_id, type->idname, sizeof(view_render->engine_id));
+               DEG_id_tag_update(ptr->id.data, DEG_TAG_COPY_ON_WRITE);
+       }
 }
 
-static EnumPropertyItem *rna_RenderSettings_engine_itemf(
+static EnumPropertyItem *rna_ViewRenderSettings_engine_itemf(
         bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
 {
        RenderEngineType *type;
@@ -1515,20 +1534,20 @@ static EnumPropertyItem *rna_RenderSettings_engine_itemf(
        return item;
 }
 
-static int rna_RenderSettings_engine_get(PointerRNA *ptr)
+static int rna_ViewRenderSettings_engine_get(PointerRNA *ptr)
 {
-       RenderData *rd = (RenderData *)ptr->data;
+       ViewRender *view_render = (ViewRender *)ptr->data;
        RenderEngineType *type;
        int a = 0;
 
        for (type = R_engines.first; type; type = type->next, a++)
-               if (STREQ(type->idname, rd->engine))
+               if (STREQ(type->idname, view_render->engine_id))
                        return a;
        
        return 0;
 }
 
-static void rna_RenderSettings_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr))
+static void rna_ViewRenderSettings_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr))
 {
        ED_render_engine_changed(bmain);
 }
@@ -1624,44 +1643,30 @@ static char *rna_SceneRenderView_path(PointerRNA *ptr)
        return BLI_sprintfN("render.views[\"%s\"]", srv->name);
 }
 
-static void rna_RenderSettings_views_format_set(PointerRNA *ptr, int value)
-{
-       RenderData *rd = (RenderData *)ptr->data;
-
-       if (rd->views_format == SCE_VIEWS_FORMAT_MULTIVIEW &&
-           value == SCE_VIEWS_FORMAT_STEREO_3D)
-       {
-               /* make sure the actview is visible */
-               if (rd->actview > 1) rd->actview = 1;
-       }
-
-       rd->views_format = value;
-}
-
-static int rna_RenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr))
+static int rna_ViewRenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr))
 {
        return (BLI_listbase_count(&R_engines) > 1);
 }
 
-static int rna_RenderSettings_use_shading_nodes_get(PointerRNA *ptr)
+static int rna_ViewRenderSettings_use_shading_nodes_get(PointerRNA *ptr)
 {
-       Scene *scene = (Scene *)ptr->id.data;
-       return BKE_scene_use_new_shading_nodes(scene);
+       ViewRender *view_render = (ViewRender *)ptr->data;
+       return BKE_viewrender_use_new_shading_nodes(view_render);
 }
 
-static int rna_RenderSettings_use_spherical_stereo_get(PointerRNA *ptr)
+static int rna_ViewRenderSettings_use_spherical_stereo_get(PointerRNA *ptr)
 {
-       Scene *scene = (Scene *)ptr->id.data;
-       return BKE_scene_use_spherical_stereo(scene);
+       ViewRender *view_render = (ViewRender *)ptr->data;
+       return BKE_viewrender_use_spherical_stereo(view_render);
 }
 
-static int rna_RenderSettings_use_game_engine_get(PointerRNA *ptr)
+static int rna_ViewRenderSettings_use_game_engine_get(PointerRNA *ptr)
 {
-       RenderData *rd = (RenderData *)ptr->data;
+       ViewRender *view_render = (ViewRender *)ptr->data;
        RenderEngineType *type;
 
        for (type = R_engines.first; type; type = type->next)
-               if (STREQ(type->idname, rd->engine))
+               if (STREQ(type->idname, view_render->engine_id))
                        return (type->flag & RE_GAME) != 0;
        
        return 0;
@@ -1771,26 +1776,32 @@ static void object_simplify_update(Object *ob)
        }
 }
 
-static void rna_Scene_use_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_Scene_use_simplify_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
 {
        Scene *sce = ptr->id.data;
        Scene *sce_iter;
        Base *base;
 
-       BKE_main_id_tag_listbase(&bmain->object, LIB_TAG_DOIT, true);
-       for (SETLOOPER(sce, sce_iter, base))
+       FOREACH_SCENE_OBJECT(sce, ob)
+       {
+               object_simplify_update(ob);
+       }
+       FOREACH_SCENE_OBJECT_END
+
+       for (SETLOOPER_SET_ONLY(sce, sce_iter, base)) {
                object_simplify_update(base->object);
+       }
        
        WM_main_add_notifier(NC_GEOM | ND_DATA, NULL);
-       DEG_id_tag_update(&scene->id, 0);
+       DEG_id_tag_update(&sce->id, 0);
 }
 
-static void rna_Scene_simplify_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_Scene_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
        Scene *sce = ptr->id.data;
 
        if (sce->r.mode & R_SIMPLIFY)
-               rna_Scene_use_simplify_update(bmain, sce, ptr);
+               rna_Scene_use_simplify_update(bmain, scene, ptr);
 }
 
 static void rna_SceneRenderData_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -2977,59 +2988,6 @@ static void rna_LayerObjects_selected_begin(CollectionPropertyIterator *iter, Po
        rna_iterator_listbase_begin(iter, &sl->object_bases, rna_SceneLayer_objects_selected_skip);
 }
 
-static void rna_SceneLayer_engine_set(PointerRNA *ptr, int value)
-{
-       SceneLayer *sl = (SceneLayer *)ptr->data;
-       RenderEngineType *type = BLI_findlink(&R_engines, value);
-
-       if (type)
-               BKE_scene_layer_engine_set(sl, type->idname);
-}
-
-static EnumPropertyItem *rna_SceneLayer_engine_itemf(
-        bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
-{
-       RenderEngineType *type;
-       EnumPropertyItem *item = NULL;
-       EnumPropertyItem tmp = {0, "", 0, "", ""};
-       int a = 0, totitem = 0;
-
-       for (type = R_engines.first; type; type = type->next, a++) {
-               tmp.value = a;
-               tmp.identifier = type->idname;
-               tmp.name = type->name;
-               RNA_enum_item_add(&item, &totitem, &tmp);
-       }
-
-       RNA_enum_item_end(&item, &totitem);
-       *r_free = true;
-
-       return item;
-}
-
-static int rna_SceneLayer_engine_get(PointerRNA *ptr)
-{
-       SceneLayer *sl = (SceneLayer *)ptr->data;
-       RenderEngineType *type;
-       int a = 0;
-
-       for (type = R_engines.first; type; type = type->next, a++)
-               if (STREQ(type->idname, sl->engine))
-                       return a;
-
-       return 0;
-}
-
-static void rna_SceneLayer_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr))
-{
-       ED_render_engine_changed(bmain);
-}
-
-static int rna_SceneLayer_multiple_engines_get(PointerRNA *UNUSED(ptr))
-{
-       return (BLI_listbase_count(&R_engines) > 1);
-}
-
 static void rna_SceneLayer_update_tagged(SceneLayer *UNUSED(sl), bContext *C)
 {
        Depsgraph *graph = CTX_data_depsgraph(C);
@@ -7067,11 +7025,6 @@ static void rna_def_scene_layer(BlenderRNA *brna)
        StructRNA *srna;
        PropertyRNA *prop;
 
-       static EnumPropertyItem engine_items[] = {
-           {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"},
-           {0, NULL, 0, NULL, NULL}
-       };
-
        srna = RNA_def_struct(brna, "SceneLayer", NULL);
        RNA_def_struct_ui_text(srna, "Render Layer", "Render layer");
        RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS);
@@ -7107,20 +7060,6 @@ static void rna_def_scene_layer(BlenderRNA *brna)
        RNA_def_property_struct_type(prop, "SceneLayerSettings");
        RNA_def_property_ui_text(prop, "Layer Settings", "Override of engine specific render settings");
 
-       /* engine */
-       prop = RNA_def_property(srna, "engine", PROP_ENUM, PROP_NONE);
-       RNA_def_property_enum_items(prop, engine_items);
-       RNA_def_property_enum_funcs(prop, "rna_SceneLayer_engine_get", "rna_SceneLayer_engine_set",
-                                   "rna_SceneLayer_engine_itemf");
-       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-       RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering");
-       RNA_def_property_update(prop, NC_WINDOW, "rna_SceneLayer_engine_update");
-
-       prop = RNA_def_property(srna, "has_multiple_engines", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_funcs(prop, "rna_SceneLayer_multiple_engines_get", NULL);
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available");
-
        /* debug update routine */
        func = RNA_def_function(srna, "update", "rna_SceneLayer_update_tagged");
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
@@ -7937,11 +7876,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
                {0, NULL, 0, NULL, NULL}
        };
 
-       static EnumPropertyItem engine_items[] = {
-               {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"},
-               {0, NULL, 0, NULL, NULL}
-       };
-
        static EnumPropertyItem freestyle_thickness_items[] = {
                {R_LINE_THICKNESS_ABSOLUTE, "ABSOLUTE", 0, "Absolute", "Specify unit line thickness in pixels"},
                {R_LINE_THICKNESS_RELATIVE, "RELATIVE", 0, "Relative",
@@ -8678,35 +8612,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        RNA_def_property_enum_funcs(prop, NULL, "rna_RenderSettings_views_format_set", NULL);
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
 
-       /* engine */
-       prop = RNA_def_property(srna, "engine", PROP_ENUM, PROP_NONE);
-       RNA_def_property_enum_items(prop, engine_items);
-       RNA_def_property_enum_funcs(prop, "rna_RenderSettings_engine_get", "rna_RenderSettings_engine_set",
-                                   "rna_RenderSettings_engine_itemf");
-       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-       RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering");
-       RNA_def_property_update(prop, NC_WINDOW, "rna_RenderSettings_engine_update");
-
-       prop = RNA_def_property(srna, "has_multiple_engines", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_multiple_engines_get", NULL);
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available");
-
-       prop = RNA_def_property(srna, "use_shading_nodes", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_use_shading_nodes_get", NULL);
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Use Shading Nodes", "Active render engine uses new shading nodes system");
-
-       prop = RNA_def_property(srna, "use_spherical_stereo", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_use_spherical_stereo_get", NULL);
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Use Spherical Stereo", "Active render engine supports spherical stereo rendering");
-
-       prop = RNA_def_property(srna, "use_game_engine", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_use_game_engine_get", NULL);
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Use Game Engine", "Current rendering engine is a game engine");
-
        /* simplify */
        prop = RNA_def_property(srna, "use_simplify", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SIMPLIFY);
@@ -8788,6 +8693,52 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        RNA_api_scene_render(srna);
 }
 
+static void rna_def_scene_view_render(BlenderRNA *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
+
+       static EnumPropertyItem engine_items[] = {
+               {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"},
+               {0, NULL, 0, NULL, NULL}
+       };
+
+       srna = RNA_def_struct(brna, "ViewRenderSettings", NULL);
+       RNA_def_struct_sdna(srna, "ViewRender");
+       RNA_def_struct_nested(brna, srna, "Scene");
+       RNA_def_struct_path_func(srna, "rna_ViewRenderSettings_path");
+       RNA_def_struct_ui_text(srna, "View Render", "Rendering settings related to viewport drawing/rendering");
+
+       /* engine */
+       prop = RNA_def_property(srna, "engine", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_items(prop, engine_items);
+       RNA_def_property_enum_funcs(prop, "rna_ViewRenderSettings_engine_get", "rna_ViewRenderSettings_engine_set",
+                                   "rna_ViewRenderSettings_engine_itemf");
+       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+       RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering");
+       RNA_def_property_update(prop, NC_WINDOW, "rna_ViewRenderSettings_engine_update");
+
+       prop = RNA_def_property(srna, "has_multiple_engines", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_multiple_engines_get", NULL);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available");
+
+       prop = RNA_def_property(srna, "use_shading_nodes", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_shading_nodes_get", NULL);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Use Shading Nodes", "Active render engine uses new shading nodes system");
+
+       prop = RNA_def_property(srna, "use_spherical_stereo", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_spherical_stereo_get", NULL);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Use Spherical Stereo", "Active render engine supports spherical stereo rendering");
+
+       prop = RNA_def_property(srna, "use_game_engine", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_game_engine_get", NULL);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Use Game Engine", "Current rendering engine is a game engine");
+}
+
 /* scene.objects */
 static void rna_def_scene_objects(BlenderRNA *brna, PropertyRNA *cprop)
 {
@@ -9335,6 +9286,12 @@ void RNA_def_scene(BlenderRNA *brna)
        RNA_def_property_struct_type(prop, "RenderSettings");
        RNA_def_property_ui_text(prop, "Render Data", "");
 
+       /* View Render */
+       prop = RNA_def_property(srna, "view_render", PROP_POINTER, PROP_NONE);
+       RNA_def_property_flag(prop, PROP_NEVER_NULL);
+       RNA_def_property_struct_type(prop, "ViewRenderSettings");
+       RNA_def_property_ui_text(prop, "View Render", "");
+
        /* Render Engine Data */
        prop = RNA_def_property(srna, "layer_properties", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_collection_sdna(prop, NULL, "layer_properties->data.group", NULL);
@@ -9497,6 +9454,7 @@ void RNA_def_scene(BlenderRNA *brna)
        rna_def_scene_layer_settings(brna);
        rna_def_layer_collection_settings(brna);
        rna_def_scene_render_data(brna);
+       rna_def_scene_view_render(brna);
        rna_def_scene_render_layer(brna);
        rna_def_gpu_fx(brna);
        rna_def_scene_render_view(brna);
index a1ef3f17bd6667437a8da19d46c3f37156b42ac6..baa29df3fc3b94a8cb3ca673b3bbfd5b4777581b 100644 (file)
@@ -151,14 +151,24 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, int previe
 }
 
 static void rna_Scene_ray_cast(
-        Scene *scene, SceneLayer *sl, float origin[3], float direction[3], float ray_dist,
+        Scene *scene, SceneLayer *scene_layer, const char *engine_id,
+        float origin[3], float direction[3], float ray_dist,
         int *r_success, float r_location[3], float r_normal[3], int *r_index,
         Object **r_ob, float r_obmat[16])
 {
+       RenderEngineType *engine;
+
+       if (engine_id == NULL || engine_id[0] == '\0') {
+               engine = RE_engines_find(scene->view_render.engine_id);
+       }
+       else {
+               engine = RE_engines_find(engine_id);
+       }
+
        normalize_v3(direction);
 
        SnapObjectContext *sctx = ED_transform_snap_object_context_create(
-               G.main, scene, sl, 0);
+               G.main, scene, scene_layer, engine, 0);
 
        bool ret = ED_transform_snap_object_project_ray_ex(
                sctx,
@@ -354,6 +364,7 @@ void RNA_api_scene(StructRNA *srna)
        RNA_def_function_ui_description(func, "Cast a ray onto in object space");
        parm = RNA_def_pointer(func, "scene_layer", "SceneLayer", "", "Scene Layer");
        RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+       parm = RNA_def_string(func, "engine", NULL, MAX_NAME, "Engine", "Render engine, use scene one by default");
        /* ray start and end */
        parm = RNA_def_float_vector(func, "origin", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
        RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
index bf583654fc67f928ff09c852d0598924e53b0c1b..016392754d11a4d6ddcbda9be01debc5522e9b1c 100644 (file)
@@ -210,6 +210,7 @@ static EnumPropertyItem buttons_context_items[] = {
        {BCONTEXT_PARTICLE, "PARTICLES", ICON_PARTICLES, "Particles", "Particle"},
        {BCONTEXT_PHYSICS, "PHYSICS", ICON_PHYSICS, "Physics", "Physics"},
        {BCONTEXT_COLLECTION, "COLLECTION", ICON_COLLAPSEMENU, "Collection", "Collection"},
+       {BCONTEXT_WORKSPACE, "WORKSPACE", ICON_RENDER_RESULT, "Workspace", "Workspace"},
        {0, NULL, 0, NULL, NULL}
 };
 
@@ -726,8 +727,14 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value
 
 static int rna_SpaceView3D_viewport_shade_get(PointerRNA *ptr)
 {
-       Scene *scene = WM_windows_scene_get_from_screen(G.main->wm.first, ptr->id.data);
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
+       bScreen *screen = ptr->id.data;
+
+       Scene *scene = WM_windows_scene_get_from_screen(G.main->wm.first, screen);
+       WorkSpace *workspace = WM_windows_workspace_get_from_screen(G.main->wm.first, screen);
+
+       ViewRender *view_render = BKE_viewrender_get(scene, workspace);
+       RenderEngineType *type = RE_engines_find(view_render->engine_id);
+
        View3D *v3d = (View3D *)ptr->data;
        int drawtype = v3d->drawtype;
 
@@ -751,7 +758,9 @@ static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *C, Point
 {
        wmWindow *win = CTX_wm_window(C);
        Scene *scene = WM_window_get_active_scene(win);
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
+       WorkSpace *workspace = WM_window_get_active_workspace(win);
+       ViewRender *view_render = BKE_viewrender_get(scene, workspace);
+       RenderEngineType *type = RE_engines_find(view_render->engine_id);
 
        EnumPropertyItem *item = NULL;
        int totitem = 0;
@@ -1117,14 +1126,18 @@ static EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext *UNUSED(C),
                RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_SCENE);
        }
 
-       if (sbuts->pathflag & (1 << BCONTEXT_COLLECTION)) {
-               RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_COLLECTION);
-       }
-
        if (sbuts->pathflag & (1 << BCONTEXT_WORLD)) {
                RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORLD);
        }
 
+       if (sbuts->pathflag & (1 << BCONTEXT_WORKSPACE)) {
+               RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORKSPACE);
+       }
+
+       if (sbuts->pathflag & (1 << BCONTEXT_COLLECTION)) {
+               RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_COLLECTION);
+       }
+
        if (sbuts->pathflag & (1 << BCONTEXT_OBJECT)) {
                RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_OBJECT);
        }
index c09cc204bbc21c21fe2787853d6f10d84393142c..4e04581a0a86d733dc67899a89fb3206a79b76ed 100644 (file)
 
 #include "BKE_workspace.h"
 
+#include "ED_render.h"
+
+#include "RE_engine.h"
+
 #include "WM_api.h"
 #include "WM_types.h"
 
 #include "rna_internal.h"
 
+/* Allow accessing private members of DNA_workspace_types.h */
+#define DNA_PRIVATE_WORKSPACE_ALLOW
+#include "DNA_workspace_types.h"
 
 #ifdef RNA_RUNTIME
 
@@ -42,7 +49,6 @@
 
 #include "DNA_object_types.h"
 #include "DNA_screen_types.h"
-#include "DNA_workspace_types.h"
 
 #include "RNA_access.h"
 
@@ -154,6 +160,20 @@ static void rna_def_workspace(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Active Render Layer", "The active render layer used in this workspace");
        RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
        RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, NULL);
+
+       /* View Render */
+       prop = RNA_def_property(srna, "view_render", PROP_POINTER, PROP_NONE);
+       RNA_def_property_flag(prop, PROP_NEVER_NULL);
+       RNA_def_property_struct_type(prop, "ViewRenderSettings");
+       RNA_def_property_ui_text(prop, "View Render", "");
+
+       /* Flags */
+       prop = RNA_def_property(srna, "use_scene_settings", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flags", WORKSPACE_USE_SCENE_SETTINGS);
+       RNA_def_property_ui_text(prop, "Scene Settings",
+                                "Use scene settings instead of workspace settings");
+       RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, NULL);
 }
 
 static void rna_def_transform_orientation(BlenderRNA *brna)
index a95c3233132bcf1524f1aaee551ea8b5dafb6ed2..0ca36ef548ea3d14057f6ec6004128d7661586e7 100644 (file)
@@ -41,6 +41,7 @@
 #include "BKE_context.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
+#include "BKE_scene.h"
 
 /* **************** IMAGE (and RenderResult, multilayer image) ******************** */
 
@@ -218,7 +219,7 @@ static void cmp_node_rlayer_create_outputs(bNodeTree *ntree, bNode *node, LinkNo
        Scene *scene = (Scene *)node->id;
 
        if (scene) {
-               RenderEngineType *engine_type = RE_engines_find(scene->r.engine);
+               RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
                if (engine_type && engine_type->update_render_passes) {
                        SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, node->custom1);
                        if (srl) {
diff --git