blob: 1f5317378bbe2a162af32bde65ac0f9944018fd9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup cmpnodes
*/
#include "COM_node_operation.hh"
#include "node_composite_util.hh"
namespace blender::nodes {
static void cmp_node_scene_time_declare(NodeDeclarationBuilder &b)
{
b.add_output<decl::Float>(N_("Seconds"));
b.add_output<decl::Float>(N_("Frame"));
}
using namespace blender::realtime_compositor;
class SceneTimeOperation : public NodeOperation {
public:
using NodeOperation::NodeOperation;
void execute() override
{
execute_seconds();
execute_frame();
}
void execute_seconds()
{
Result &result = get_result("Seconds");
result.allocate_single_value();
result.set_float_value(context().get_time());
}
void execute_frame()
{
Result &result = get_result("Frame");
result.allocate_single_value();
result.set_float_value(static_cast<float>(context().get_frame_number()));
}
};
static NodeOperation *get_compositor_operation(Context &context, DNode node)
{
return new SceneTimeOperation(context, node);
}
} // namespace blender::nodes
void register_node_type_cmp_scene_time()
{
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_SCENE_TIME, "Scene Time", NODE_CLASS_INPUT);
ntype.declare = blender::nodes::cmp_node_scene_time_declare;
ntype.get_compositor_operation = blender::nodes::get_compositor_operation;
nodeRegisterType(&ntype);
}
|