diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2019-09-11 09:22:53 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2019-09-12 10:08:22 +0300 |
commit | 861697c9e55bad362fc493e263fe966095744b37 (patch) | |
tree | 3b9a11147422980029dfaf251b5b84c7c6720f59 /intern/cycles/blender | |
parent | 70a934770521b538b98b8a3e27739ae6a643ebfa (diff) |
Cycles: Initial Support For Local View
This diff will add support for local view to Cycles rendered preview mode.
Currently the implementation shows same results as EEVEE does. This entails
a difference with Blender 2.79, where lights were automatically added to the
local view. {T69780} describes this should be solved before the next release.
This patch also solves missing `owner_id` issues when using the RNA CPP Api
from Cycles. Cycles didn't provide the `owner_id` making some functionality
fail, what then was worked around in Blender. It also fixes an issue in
`makesrna` where incorrect CPP code was generated when only `PARM_RNAPTR`
was provided.
An optional `view_layer` parameter is added to the `Object.local_view_get`
method to reduce lookups.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D5753
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/addon/engine.py | 6 | ||||
-rw-r--r-- | intern/cycles/blender/blender_object.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/blender/blender_python.cpp | 13 |
3 files changed, 16 insertions, 7 deletions
diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py index b8bc74f9e35..0e3de6d8066 100644 --- a/intern/cycles/blender/addon/engine.py +++ b/intern/cycles/blender/addon/engine.py @@ -139,15 +139,19 @@ def create(engine, data, region=None, v3d=None, rv3d=None, preview_osl=False): data = data.as_pointer() prefs = bpy.context.preferences.as_pointer() + screen = None if region: + screen = region.id_data.as_pointer() region = region.as_pointer() if v3d: + screen = screen or v3d.id_data.as_pointer() v3d = v3d.as_pointer() if rv3d: + screen = screen or rv3d.id_data.as_pointer() rv3d = rv3d.as_pointer() engine.session = _cycles.create( - engine.as_pointer(), prefs, data, region, v3d, rv3d, preview_osl) + engine.as_pointer(), prefs, data, screen, region, v3d, rv3d, preview_osl) def free(engine): diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index b0599546244..082fff0c528 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -541,6 +541,7 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph, const bool show_lights = BlenderViewportParameters(b_v3d).use_scene_lights; BL::ViewLayer b_view_layer = b_depsgraph.view_layer_eval(); + const bool has_local_view = b_v3d && b_v3d.local_view(); BL::Depsgraph::object_instances_iterator b_instance_iter; for (b_depsgraph.object_instances.begin(b_instance_iter); @@ -554,9 +555,10 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph, /* test if object needs to be hidden */ const bool show_self = b_instance.show_self(); + const bool show_local_view = !has_local_view || b_ob.local_view_get(b_v3d, b_view_layer); const bool show_particles = b_instance.show_particles(); - if (show_self || show_particles) { + if (show_local_view && (show_self || show_particles)) { /* object itself */ sync_object(b_depsgraph, b_view_layer, diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp index 9753da71eb4..2bea6b34772 100644 --- a/intern/cycles/blender/blender_python.cpp +++ b/intern/cycles/blender/blender_python.cpp @@ -194,14 +194,15 @@ static PyObject *exit_func(PyObject * /*self*/, PyObject * /*args*/) static PyObject *create_func(PyObject * /*self*/, PyObject *args) { - PyObject *pyengine, *pypreferences, *pydata, *pyregion, *pyv3d, *pyrv3d; + PyObject *pyengine, *pypreferences, *pydata, *pyscreen, *pyregion, *pyv3d, *pyrv3d; int preview_osl; if (!PyArg_ParseTuple(args, - "OOOOOOi", + "OOOOOOOi", &pyengine, &pypreferences, &pydata, + &pyscreen, &pyregion, &pyv3d, &pyrv3d, @@ -210,6 +211,8 @@ static PyObject *create_func(PyObject * /*self*/, PyObject *args) } /* RNA */ + ID *bScreen = (ID *)PyLong_AsVoidPtr(pyscreen); + PointerRNA engineptr; RNA_pointer_create(NULL, &RNA_RenderEngine, (void *)PyLong_AsVoidPtr(pyengine), &engineptr); BL::RenderEngine engine(engineptr); @@ -224,15 +227,15 @@ static PyObject *create_func(PyObject * /*self*/, PyObject *args) BL::BlendData data(dataptr); PointerRNA regionptr; - RNA_pointer_create(NULL, &RNA_Region, pylong_as_voidptr_typesafe(pyregion), ®ionptr); + RNA_pointer_create(bScreen, &RNA_Region, pylong_as_voidptr_typesafe(pyregion), ®ionptr); BL::Region region(regionptr); PointerRNA v3dptr; - RNA_pointer_create(NULL, &RNA_SpaceView3D, pylong_as_voidptr_typesafe(pyv3d), &v3dptr); + RNA_pointer_create(bScreen, &RNA_SpaceView3D, pylong_as_voidptr_typesafe(pyv3d), &v3dptr); BL::SpaceView3D v3d(v3dptr); PointerRNA rv3dptr; - RNA_pointer_create(NULL, &RNA_RegionView3D, pylong_as_voidptr_typesafe(pyrv3d), &rv3dptr); + RNA_pointer_create(bScreen, &RNA_RegionView3D, pylong_as_voidptr_typesafe(pyrv3d), &rv3dptr); BL::RegionView3D rv3d(rv3dptr); /* create session */ |