Blender  V3.3
COM_TranslateNode.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_TranslateNode.h"
5 
7 #include "COM_WrapOperation.h"
9 
10 namespace blender::compositor {
11 
12 TranslateNode::TranslateNode(bNode *editor_node) : Node(editor_node)
13 {
14  /* pass */
15 }
16 
18  const CompositorContext &context) const
19 {
20  bNode *bnode = this->get_bnode();
22 
23  NodeInput *input_socket = this->get_input_socket(0);
24  NodeInput *input_xsocket = this->get_input_socket(1);
25  NodeInput *input_ysocket = this->get_input_socket(2);
26  NodeOutput *output_socket = this->get_output_socket(0);
27 
28  TranslateOperation *operation = context.get_execution_model() == eExecutionModel::Tiled ?
29  new TranslateOperation() :
31  operation->set_wrapping(data->wrap_axis);
32  if (data->relative) {
33  const RenderData *rd = context.get_render_data();
34  const float render_size_factor = context.get_render_percentage_as_factor();
35  float fx = rd->xsch * render_size_factor;
36  float fy = rd->ysch * render_size_factor;
37 
38  operation->setFactorXY(fx, fy);
39  }
40 
41  converter.add_operation(operation);
42  converter.map_input_socket(input_xsocket, operation->get_input_socket(1));
43  converter.map_input_socket(input_ysocket, operation->get_input_socket(2));
44  converter.map_output_socket(output_socket, operation->get_output_socket(0));
45  if (data->wrap_axis && context.get_execution_model() != eExecutionModel::FullFrame) {
46  /* TODO: To be removed with tiled implementation. */
48  WrapOperation *wrap_operation = new WrapOperation(DataType::Color);
49  wrap_operation->set_memory_proxy(write_operation->get_memory_proxy());
50  wrap_operation->set_wrapping(data->wrap_axis);
51 
52  converter.add_operation(write_operation);
53  converter.add_operation(wrap_operation);
54  converter.map_input_socket(input_socket, write_operation->get_input_socket(0));
55  converter.add_link(wrap_operation->get_output_socket(), operation->get_input_socket(0));
56  }
57  else {
58  converter.map_input_socket(input_socket, operation->get_input_socket(0));
59  }
60 }
61 
62 } // namespace blender::compositor
Overall context of the compositor.
void add_link(NodeOperationOutput *from, NodeOperationInput *to)
void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
void add_operation(NodeOperation *operation)
void map_input_socket(NodeInput *node_socket, NodeOperationInput *operation_socket)
NodeInput are sockets that can receive data/input.
Definition: COM_Node.h:190
NodeOperationOutput * get_output_socket(unsigned int index=0)
NodeOperationInput * get_input_socket(unsigned int index)
NodeOutput are sockets that can send data/input.
Definition: COM_Node.h:238
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
NodeInput * get_input_socket(unsigned int index) const
Definition: COM_Node.cc:89
void set_memory_proxy(MemoryProxy *memory_proxy)
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
void setFactorXY(float factorX, float factorY)
void set_wrapping(int wrapping_type)
void * storage