Blender V5.3
node_geo_is_viewport.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
8
10
12
14{
15 b.add_output<decl::Bool>("Is Viewport"_ustr);
16}
17
19{
20 const Depsgraph *depsgraph = params.depsgraph();
21 const eEvaluationMode mode = DEG_get_mode(depsgraph);
22 const bool is_viewport = mode == DAG_EVAL_VIEWPORT;
23
24 params.set_output("Is Viewport"_ustr, is_viewport);
25}
26
27using namespace blender::compositor;
28
30 public:
32
33 void execute() override
34 {
35 const bool is_viewport = this->context().is_viewport();
36
37 Result &result = this->get_result("Is Viewport");
38 result.allocate_single_value();
39 result.set_single_value(is_viewport);
40 }
41};
42
44{
45 return new IsViewportOperation(context, node);
46}
47
48static void node_register()
49{
50 static bke::bNodeType ntype;
51
52 geo_cmp_node_type_base(&ntype, "GeometryNodeIsViewport"_ustr, GEO_NODE_IS_VIEWPORT);
53 ntype.ui_name = "Is Viewport";
54 ntype.ui_description =
55 "Retrieve whether the nodes are being evaluated for the viewport rather than the final "
56 "render";
57 ntype.enum_name_legacy = "IS_VIEWPORT";
60 ntype.declare = node_declare;
63}
65
66} // namespace blender::nodes::node_geo_is_viewport_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define GEO_NODE_IS_VIEWPORT
#define NOD_REGISTER_NODE(REGISTER_FUNC)
NodeOperation(Context &context, const bNode &node)
Result & get_result(StringRef identifier)
Definition operation.cc:40
Context & context() const
Definition operation.cc:57
const Depsgraph * depsgraph() const
void set_output(const UString identifier, T &&value)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static NodeOperation * get_compositor_operation(Context &context, const bNode &node)
static void node_declare(NodeDeclarationBuilder &b)
static void node_geo_exec(GeoNodeExecParams params)
@ DAG_EVAL_VIEWPORT
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
void geo_cmp_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:265
std::string ui_description
Definition BKE_node.hh:271
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:379
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:385
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393