Blender  V2.93
COM_CornerPinNode.cc
Go to the documentation of this file.
1 /* This program is free software; you can redistribute it and/or
2  * modify it under the terms of the GNU General Public License
3  * as published by the Free Software Foundation; either version 2
4  * of the License, or (at your option) any later version.
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public License
12  * along with this program; if not, write to the Free Software Foundation,
13  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14  *
15  * Copyright 2014, Blender Foundation.
16  */
17 
18 #include "COM_CornerPinNode.h"
19 #include "COM_ExecutionSystem.h"
20 
22 
23 namespace blender::compositor {
24 
25 CornerPinNode::CornerPinNode(bNode *editorNode) : Node(editorNode)
26 {
27 }
28 
30  const CompositorContext & /*context*/) const
31 {
32  NodeInput *input_image = this->getInputSocket(0);
33  /* note: socket order differs between UI node and operations:
34  * bNode uses intuitive order following top-down layout:
35  * upper-left, upper-right, lower-left, lower-right
36  * Operations use same order as the tracking blenkernel functions expect:
37  * lower-left, lower-right, upper-right, upper-left
38  */
39  const int node_corner_index[4] = {3, 4, 2, 1};
40 
41  NodeOutput *output_warped_image = this->getOutputSocket(0);
42  NodeOutput *output_plane = this->getOutputSocket(1);
43 
45  converter.addOperation(warp_image_operation);
46  PlaneCornerPinMaskOperation *plane_mask_operation = new PlaneCornerPinMaskOperation();
47  converter.addOperation(plane_mask_operation);
48 
49  converter.mapInputSocket(input_image, warp_image_operation->getInputSocket(0));
50  for (int i = 0; i < 4; i++) {
51  NodeInput *corner_input = getInputSocket(node_corner_index[i]);
52  converter.mapInputSocket(corner_input, warp_image_operation->getInputSocket(i + 1));
53  converter.mapInputSocket(corner_input, plane_mask_operation->getInputSocket(i));
54  }
55  converter.mapOutputSocket(output_warped_image, warp_image_operation->getOutputSocket());
56  converter.mapOutputSocket(output_plane, plane_mask_operation->getOutputSocket());
57 }
58 
59 } // namespace blender::compositor
Overall context of the compositor.
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket)
void addOperation(NodeOperation *operation)
void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
NodeInput are sockets that can receive data/input.
Definition: COM_Node.h:210
NodeOperationInput * getInputSocket(unsigned int index)
NodeOperationOutput * getOutputSocket(unsigned int index=0)
NodeOutput are sockets that can send data/input.
Definition: COM_Node.h:258
NodeOutput * getOutputSocket(const unsigned int index=0) const
Definition: COM_Node.cc:108
NodeInput * getInputSocket(const unsigned int index) const
Definition: COM_Node.cc:113