Blender V5.3
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
10#include "DNA_screen_types.h"
11#include "DNA_view3d_types.h"
12
13#include "RNA_prototypes.hh"
14
16
27
29 blender::View3D *b_v3d,
30 bool use_developer_ui)
32{
33 if (!b_v3d) {
34 return;
35 }
36
37 blender::View3DShading shading = b_v3d->shading;
38 blender::PointerRNA v3d_rna_ptr = RNA_pointer_create_discrete(
39 &b_screen->id, blender::RNA_SpaceView3D, b_v3d);
40 blender::PointerRNA shading_rna_ptr = RNA_pointer_get(&v3d_rna_ptr, "shading");
41
42 /* We only copy the shading parameters if we are in look-dev mode.
43 * Otherwise defaults are being used. These defaults mimic normal render settings. */
44 if (shading.type == blender::OB_RENDER) {
47
48 if (!use_scene_world) {
52 blender::PointerRNA selected_studiolight_rna_ptr = RNA_pointer_get(&shading_rna_ptr,
53 "selected_studio_light");
54 studiolight_path = RNA_string_get(&selected_studiolight_rna_ptr, "path");
55 }
56 }
57
58 /* Film. */
59
60 /* Lookup display pass based on the enum identifier.
61 * This is because integer values of python enum are not aligned with the passes definition in
62 * the kernel. */
63
65
66 blender::PointerRNA cycles_shading_ptr = RNA_pointer_get(&shading_rna_ptr, "cycles");
67 const string display_pass_identifier = get_enum_identifier(cycles_shading_ptr, "render_pass");
68 if (!display_pass_identifier.empty()) {
69 const ustring pass_type_identifier(string_to_lower(display_pass_identifier));
70 const NodeEnum *pass_type_enum = Pass::get_type_enum();
71 if (pass_type_enum->exists(pass_type_identifier)) {
72 display_pass = static_cast<PassType>((*pass_type_enum)[pass_type_identifier]);
73 }
74 }
75
76 if (use_developer_ui) {
77 show_active_pixels = get_boolean(cycles_shading_ptr, "show_active_pixels");
78 }
79}
80
89
94
96{
97 return shader_modified(other) || film_modified(other);
98}
99
104
bool shader_modified(const BlenderViewportParameters &other) const
Definition viewport.cpp:81
bool film_modified(const BlenderViewportParameters &other) const
Definition viewport.cpp:90
bool use_custom_shader() const
Definition viewport.cpp:100
bool modified(const BlenderViewportParameters &other) const
Definition viewport.cpp:95
static const NodeEnum * get_type_enum()
Definition pass.cpp:45
#define CCL_NAMESPACE_END
PassType
@ PASS_COMBINED
@ V3D_SHADING_SCENE_LIGHTS_RENDER
@ V3D_SHADING_SCENE_WORLD_RENDER
string string_to_lower(const string &s)
Definition string.cpp:217
bool exists(ustring x) const
Definition node_enum.h:29
eView3DShading_Flag flag
View3DShading shading