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