Blender V5.0
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 */
7
9
11
12namespace blender::nodes {
13
15{
16 b.add_output<decl::Float>("Seconds");
17 b.add_output<decl::Float>("Frame");
18}
19
20using namespace blender::compositor;
21
23 public:
25
26 void execute() override
27 {
30 }
31
33 {
34 Result &result = get_result("Seconds");
35 if (!result.should_compute()) {
36 return;
37 }
38
39 result.allocate_single_value();
40 result.set_single_value(context().get_time());
41 }
42
44 {
45 Result &result = get_result("Frame");
46 if (!result.should_compute()) {
47 return;
48 }
49
50 result.allocate_single_value();
51 result.set_single_value(float(context().get_frame_number()));
52 }
53};
54
56{
57 return new SceneTimeOperation(context, node);
58}
59
60} // namespace blender::nodes
61
63{
64 static blender::bke::bNodeType ntype;
65
66 cmp_node_type_base(&ntype, "CompositorNodeSceneTime", CMP_NODE_SCENE_TIME);
67 ntype.ui_name = "Scene Time";
68 ntype.ui_description = "Input the current scene time in seconds or frames";
69 ntype.enum_name_legacy = "SCENE_TIME";
73
75}
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define CMP_NODE_SCENE_TIME
#define NOD_REGISTER_NODE(REGISTER_FUNC)
NodeOperation(Context &context, DNode node)
Result & get_result(StringRef identifier)
Definition operation.cc:39
NodeOperation(Context &context, DNode node)
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static void cmp_node_scene_time_declare(NodeDeclarationBuilder &b)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
static void register_node_type_cmp_scene_time()
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:348
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362