Blender  V3.3
COM_TimeNode.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
4 #include "COM_TimeNode.h"
5 
7 
8 #include "BKE_colortools.h"
9 
10 namespace blender::compositor {
11 
12 TimeNode::TimeNode(bNode *editor_node) : Node(editor_node)
13 {
14  /* pass */
15 }
16 
18  const CompositorContext &context) const
19 {
20  SetValueOperation *operation = new SetValueOperation();
21  bNode *node = this->get_bnode();
22 
23  /* stack order output: fac */
24  float fac = 0.0f;
25  const int framenumber = context.get_framenumber();
26 
27  if (framenumber < node->custom1) {
28  fac = 0.0f;
29  }
30  else if (framenumber > node->custom2) {
31  fac = 1.0f;
32  }
33  else if (node->custom1 < node->custom2) {
34  fac = (context.get_framenumber() - node->custom1) / (float)(node->custom2 - node->custom1);
35  }
36 
38  fac = BKE_curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac);
39  operation->set_value(clamp_f(fac, 0.0f, 1.0f));
40  converter.add_operation(operation);
41 
42  converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
43 }
44 
45 } // namespace blender::compositor
void BKE_curvemapping_init(struct CurveMapping *cumap)
Definition: colortools.c:1235
float BKE_curvemapping_evaluateF(const struct CurveMapping *cumap, int cur, float value)
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:84
bNode * get_bnode() const
get the reference to the SDNA bNode struct
Definition: COM_Node.h:64
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
Definition: COM_TimeNode.cc:17
TimeNode(bNode *editor_node)
Definition: COM_TimeNode.cc:12
OperationNode * node