Blender V4.3
COM_NormalNode.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_NormalNode.h"
8
9namespace blender::compositor {
10
11NormalNode::NormalNode(bNode *editor_node) : Node(editor_node)
12{
13 /* pass */
14}
15
17 const CompositorContext & /*context*/) const
18{
19 NodeInput *input_socket = this->get_input_socket(0);
20 NodeOutput *output_socket = this->get_output_socket(0);
21 NodeOutput *output_socket_dotproduct = this->get_output_socket(1);
22
23 SetVectorOperation *operation_set = new SetVectorOperation();
24 float normal[3];
25 output_socket->get_editor_value_vector(normal);
26 /* animation can break normalization, this restores it */
27 normalize_v3(normal);
28 operation_set->setX(normal[0]);
29 operation_set->setY(normal[1]);
30 operation_set->setZ(normal[2]);
31 operation_set->setW(0.0f);
32 converter.add_operation(operation_set);
33
34 converter.map_output_socket(output_socket, operation_set->get_output_socket(0));
35
37 converter.add_operation(operation);
38
39 converter.map_input_socket(input_socket, operation->get_input_socket(0));
40 converter.add_link(operation_set->get_output_socket(0), operation->get_input_socket(1));
41 converter.map_output_socket(output_socket_dotproduct, operation->get_output_socket(0));
42}
43
44} // namespace blender::compositor
MINLINE float normalize_v3(float n[3])
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:191
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:239
void get_editor_value_vector(float *value)
Definition COM_Node.cc:180
NodeOutput * get_output_socket(unsigned int index=0) const
Definition COM_Node.cc:85
NodeInput * get_input_socket(unsigned int index) const
Definition COM_Node.cc:90
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation