Blender V5.3
node_composite_scene_time.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{
13 b.add_output<decl::Float>("Seconds"_ustr);
14 b.add_output<decl::Float>("Frame"_ustr);
15}
16
17using namespace blender::compositor;
18
20 public:
22
23 void execute() override
24 {
27 }
28
30 {
31 Result &result = get_result("Seconds");
32 if (!result.should_compute()) {
33 return;
34 }
35
36 result.allocate_single_value();
37 result.set_single_value(context().get_time());
38 }
39
41 {
42 Result &result = get_result("Frame");
43 if (!result.should_compute()) {
44 return;
45 }
46
47 result.allocate_single_value();
48 result.set_single_value(float(context().get_frame_number()));
49 }
50};
51
53{
54 return new SceneTimeOperation(context, node);
55}
56
57static void node_register()
58{
59 static bke::bNodeType ntype;
60
61 cmp_node_type_base(&ntype, "CompositorNodeSceneTime"_ustr, CMP_NODE_SCENE_TIME);
62 ntype.ui_name = "Scene Time";
63 ntype.ui_description = "Input the current scene time in seconds or frames";
64 ntype.enum_name_legacy = "SCENE_TIME";
66 ntype.declare = node_declare;
68
70}
72
73} // namespace blender::nodes::node_composite_scene_time_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define CMP_NODE_SCENE_TIME
#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
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)
void 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
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393