Blender V4.3
COM_TimeNode.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "COM_TimeNode.h"
6
8
9#include "BKE_colortools.hh"
10
11namespace blender::compositor {
12
13TimeNode::TimeNode(bNode *editor_node) : Node(editor_node)
14{
15 /* pass */
16}
17
19 const CompositorContext &context) const
20{
21 SetValueOperation *operation = new SetValueOperation();
22 const bNode *node = this->get_bnode();
23
24 /* stack order output: fac */
25 float fac = 0.0f;
26 const int framenumber = context.get_framenumber();
27
28 if (framenumber < node->custom1) {
29 fac = 0.0f;
30 }
31 else if (framenumber > node->custom2) {
32 fac = 1.0f;
33 }
34 else if (node->custom1 < node->custom2) {
35 fac = (context.get_framenumber() - node->custom1) / float(node->custom2 - node->custom1);
36 }
37
38 BKE_curvemapping_init((CurveMapping *)node->storage);
39 fac = BKE_curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac);
40 operation->set_value(clamp_f(fac, 0.0f, 1.0f));
41 converter.add_operation(operation);
42
43 converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
44}
45
46} // namespace blender::compositor
float BKE_curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value)
void BKE_curvemapping_init(CurveMapping *cumap)
MINLINE float clamp_f(float value, float min, float max)
Overall context of the compositor.
void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
void add_operation(NodeOperation *operation)
NodeOperationOutput * get_output_socket(unsigned int index=0)
NodeOutput * get_output_socket(unsigned int index=0) const
Definition COM_Node.cc:85
const bNode * get_bnode() const
get the reference to the SDNA bNode struct
Definition COM_Node.h:65
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
TimeNode(bNode *editor_node)