Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey@blender.org>2021-05-27 12:31:03 +0300
committerSergey Sharybin <sergey@blender.org>2021-05-27 12:36:30 +0300
commit2414a5787d0c7a03e89d5087b8d4d5ae8e1d27c8 (patch)
treec54edae55c56d1414e0509e98f705a12778700c0 /intern/cycles
parent7b5f4c88370ed2752d398a8d8c5aca4b4435a0c9 (diff)
Refactor: Move display pass to Cycles viewport parameters
Allows to centralize storage and modification checks in a single place, avoiding duplication in the synchronization code. Ideally we would somehow be able to more granularly modify Cycles side objects. Leaving this for a future decision, because it might be better to implement it as a graph on the sync side.
Diffstat (limited to 'intern/cycles')
-rw-r--r--intern/cycles/blender/blender_sync.cpp7
-rw-r--r--intern/cycles/blender/blender_viewport.cpp51
-rw-r--r--intern/cycles/blender/blender_viewport.h13
3 files changed, 37 insertions, 34 deletions
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index 0d2b2641312..82b3abd4432 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -230,12 +230,7 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d
has_updates_ = true;
}
- if (!has_updates_) {
- Film *film = scene->film;
-
- const PassType new_display_pass = new_viewport_parameters.get_render_pass(b_v3d);
- has_updates_ |= film->get_display_pass() != new_display_pass;
- }
+ has_updates_ |= viewport_parameters.modified(new_viewport_parameters);
}
}
diff --git a/intern/cycles/blender/blender_viewport.cpp b/intern/cycles/blender/blender_viewport.cpp
index 60de2015a67..07408fee218 100644
--- a/intern/cycles/blender/blender_viewport.cpp
+++ b/intern/cycles/blender/blender_viewport.cpp
@@ -25,7 +25,8 @@ BlenderViewportParameters::BlenderViewportParameters()
use_scene_lights(true),
studiolight_rotate_z(0.0f),
studiolight_intensity(1.0f),
- studiolight_background_alpha(1.0f)
+ studiolight_background_alpha(1.0f),
+ display_pass(PASS_COMBINED)
{
}
@@ -37,22 +38,24 @@ BlenderViewportParameters::BlenderViewportParameters(BL::SpaceView3D &b_v3d)
}
BL::View3DShading shading = b_v3d.shading();
+ PointerRNA cshading = RNA_pointer_get(&shading.ptr, "cycles");
- /* We only copy the parameters if we are in look dev mode. otherwise
+ /* We only copy the shading parameters if we are in look dev mode. otherwise
* defaults are being used. These defaults mimic normal render settings */
- if (shading.type() != BL::View3DShading::type_RENDERED) {
- return;
+ if (shading.type() == BL::View3DShading::type_RENDERED) {
+ use_scene_world = shading.use_scene_world_render();
+ use_scene_lights = shading.use_scene_lights_render();
+
+ if (!use_scene_world) {
+ studiolight_rotate_z = shading.studiolight_rotate_z();
+ studiolight_intensity = shading.studiolight_intensity();
+ studiolight_background_alpha = shading.studiolight_background_alpha();
+ studiolight_path = shading.selected_studio_light().path();
+ }
}
- use_scene_world = shading.use_scene_world_render();
- use_scene_lights = shading.use_scene_lights_render();
-
- if (!use_scene_world) {
- studiolight_rotate_z = shading.studiolight_rotate_z();
- studiolight_intensity = shading.studiolight_intensity();
- studiolight_background_alpha = shading.studiolight_background_alpha();
- studiolight_path = shading.selected_studio_light().path();
- }
+ /* Film. */
+ display_pass = (PassType)get_enum(cshading, "render_pass", -1, -1);
}
bool BlenderViewportParameters::shader_modified(const BlenderViewportParameters &other) const
@@ -64,26 +67,26 @@ bool BlenderViewportParameters::shader_modified(const BlenderViewportParameters
studiolight_path != other.studiolight_path;
}
-bool BlenderViewportParameters::use_custom_shader() const
+bool BlenderViewportParameters::film_modified(const BlenderViewportParameters &other) const
{
- return !(use_scene_world && use_scene_lights);
+ return display_pass != other.display_pass;
}
-PassType BlenderViewportParameters::get_render_pass(BL::SpaceView3D &b_v3d)
+bool BlenderViewportParameters::modified(const BlenderViewportParameters &other) const
{
- PassType display_pass = PASS_NONE;
- if (b_v3d) {
- BL::View3DShading b_view3dshading = b_v3d.shading();
- PointerRNA cshading = RNA_pointer_get(&b_view3dshading.ptr, "cycles");
- display_pass = (PassType)get_enum(cshading, "render_pass", -1, -1);
- }
- return display_pass;
+ return shader_modified(other) || film_modified(other);
+}
+
+bool BlenderViewportParameters::use_custom_shader() const
+{
+ return !(use_scene_world && use_scene_lights);
}
PassType update_viewport_display_passes(BL::SpaceView3D &b_v3d, vector<Pass> &passes)
{
if (b_v3d) {
- PassType display_pass = BlenderViewportParameters::get_render_pass(b_v3d);
+ const BlenderViewportParameters viewport_parameters(b_v3d);
+ const PassType display_pass = viewport_parameters.display_pass;
passes.clear();
Pass::add(display_pass, passes);
diff --git a/intern/cycles/blender/blender_viewport.h b/intern/cycles/blender/blender_viewport.h
index c588a5b8f87..0dfb3918852 100644
--- a/intern/cycles/blender/blender_viewport.h
+++ b/intern/cycles/blender/blender_viewport.h
@@ -37,19 +37,24 @@ class BlenderViewportParameters {
float studiolight_background_alpha;
ustring studiolight_path;
+ /* Film. */
+ PassType display_pass;
+
BlenderViewportParameters();
explicit BlenderViewportParameters(BL::SpaceView3D &b_v3d);
/* Check whether any of shading related settings are different from the given parameters. */
bool shader_modified(const BlenderViewportParameters &other) const;
+ /* Check whether any of film related settings are different from the given parameters. */
+ bool film_modified(const BlenderViewportParameters &other) const;
+
+ /* Check whether any of settings are different from the given parameters. */
+ bool modified(const BlenderViewportParameters &other) const;
+
/* Returns truth when a custom shader defined by the viewport is to be used instead of the
* regular background shader or scene light. */
bool use_custom_shader() const;
-
- /* Retrieve the render pass type that needs to be displayed on the given `SpaceView3D`
- * When the `b_v3d` parameter is not given `PASS_NONE` will be returned. */
- static PassType get_render_pass(BL::SpaceView3D &b_v3d);
};
PassType update_viewport_display_passes(BL::SpaceView3D &b_v3d, vector<Pass> &passes);