Blender V5.0
viewport.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2019-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#include "blender/viewport.h"
6#include "blender/util.h"
7
8#include "scene/pass.h"
9
11
22
23BlenderViewportParameters::BlenderViewportParameters(BL::SpaceView3D &b_v3d, bool use_developer_ui)
25{
26 if (!b_v3d) {
27 return;
28 }
29
30 BL::View3DShading shading = b_v3d.shading();
31 PointerRNA cshading = RNA_pointer_get(&shading.ptr, "cycles");
32
33 /* We only copy the shading parameters if we are in look-dev mode.
34 * Otherwise defaults are being used. These defaults mimic normal render settings. */
35 if (shading.type() == BL::View3DShading::type_RENDERED) {
36 use_scene_world = shading.use_scene_world_render();
37 use_scene_lights = shading.use_scene_lights_render();
38
39 if (!use_scene_world) {
40 studiolight_rotate_z = shading.studiolight_rotate_z();
41 studiolight_intensity = shading.studiolight_intensity();
42 studiolight_background_alpha = shading.studiolight_background_alpha();
43 studiolight_path = shading.selected_studio_light().path();
44 }
45 }
46
47 /* Film. */
48
49 /* Lookup display pass based on the enum identifier.
50 * This is because integer values of python enum are not aligned with the passes definition in
51 * the kernel. */
52
54
55 const string display_pass_identifier = get_enum_identifier(cshading, "render_pass");
56 if (!display_pass_identifier.empty()) {
57 const ustring pass_type_identifier(string_to_lower(display_pass_identifier));
58 const NodeEnum *pass_type_enum = Pass::get_type_enum();
59 if (pass_type_enum->exists(pass_type_identifier)) {
60 display_pass = static_cast<PassType>((*pass_type_enum)[pass_type_identifier]);
61 }
62 }
63
64 if (use_developer_ui) {
65 show_active_pixels = get_boolean(cshading, "show_active_pixels");
66 }
67}
68
77
82
84{
85 return shader_modified(other) || film_modified(other);
86}
87
92
return true
bool shader_modified(const BlenderViewportParameters &other) const
Definition viewport.cpp:69
bool film_modified(const BlenderViewportParameters &other) const
Definition viewport.cpp:78
bool use_custom_shader() const
Definition viewport.cpp:88
bool modified(const BlenderViewportParameters &other) const
Definition viewport.cpp:83
static const NodeEnum * get_type_enum()
Definition pass.cpp:45
static bool get_boolean(PointerRNA &ptr, const char *name)
static string get_enum_identifier(PointerRNA &ptr, const char *name)
#define CCL_NAMESPACE_END
PassType
@ PASS_COMBINED
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
string string_to_lower(const string &s)
Definition string.cpp:210
bool exists(ustring x) const
Definition node_enum.h:29