Welcome to mirror list, hosted at ThFree Co, Russian Federation.

COM_NodeConverter.cc « intern « compositor « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 054f822cb65371d394bd43fd50d430c8d6303f8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/* SPDX-License-Identifier: GPL-2.0-or-later
 * Copyright 2013 Blender Foundation. */

#include "BLI_utildefines.h"

#include "COM_Node.h"
#include "COM_NodeOperationBuilder.h"
#include "COM_SetColorOperation.h"
#include "COM_SetValueOperation.h"
#include "COM_SetVectorOperation.h"
#include "COM_SocketProxyOperation.h"

#include "COM_NodeConverter.h" /* own include */

namespace blender::compositor {

NodeConverter::NodeConverter(NodeOperationBuilder *builder) : builder_(builder)
{
}

void NodeConverter::add_operation(NodeOperation *operation)
{
  builder_->add_operation(operation);
}

void NodeConverter::map_input_socket(NodeInput *node_socket, NodeOperationInput *operation_socket)
{
  builder_->map_input_socket(node_socket, operation_socket);
}

void NodeConverter::map_output_socket(NodeOutput *node_socket,
                                      NodeOperationOutput *operation_socket)
{
  builder_->map_output_socket(node_socket, operation_socket);
}

void NodeConverter::add_link(NodeOperationOutput *from, NodeOperationInput *to)
{
  builder_->add_link(from, to);
}

void NodeConverter::add_preview(NodeOperationOutput *output)
{
  builder_->add_preview(output);
}

void NodeConverter::add_node_input_preview(NodeInput *input)
{
  builder_->add_node_input_preview(input);
}

NodeOperation *NodeConverter::set_invalid_output(NodeOutput *output)
{
  /* this is a really bad situation - bring on the pink! - so artists know this is bad */
  const float warning_color[4] = {1.0f, 0.0f, 1.0f, 1.0f};

  SetColorOperation *operation = new SetColorOperation();
  operation->set_channels(warning_color);

  builder_->add_operation(operation);
  builder_->map_output_socket(output, operation->get_output_socket());

  return operation;
}

NodeOperationOutput *NodeConverter::add_input_proxy(NodeInput *input, bool use_conversion)
{
  SocketProxyOperation *proxy = new SocketProxyOperation(input->get_data_type(), use_conversion);
  builder_->add_operation(proxy);

  builder_->map_input_socket(input, proxy->get_input_socket(0));

  return proxy->get_output_socket();
}

NodeOperationInput *NodeConverter::add_output_proxy(NodeOutput *output, bool use_conversion)
{
  SocketProxyOperation *proxy = new SocketProxyOperation(output->get_data_type(), use_conversion);
  builder_->add_operation(proxy);

  builder_->map_output_socket(output, proxy->get_output_socket());

  return proxy->get_input_socket(0);
}

void NodeConverter::add_input_value(NodeOperationInput *input, float value)
{
  SetValueOperation *operation = new SetValueOperation();
  operation->set_value(value);

  builder_->add_operation(operation);
  builder_->add_link(operation->get_output_socket(), input);
}

void NodeConverter::add_input_color(NodeOperationInput *input, const float value[4])
{
  SetColorOperation *operation = new SetColorOperation();
  operation->set_channels(value);

  builder_->add_operation(operation);
  builder_->add_link(operation->get_output_socket(), input);
}

void NodeConverter::add_input_vector(NodeOperationInput *input, const float value[3])
{
  SetVectorOperation *operation = new SetVectorOperation();
  operation->set_vector(value);

  builder_->add_operation(operation);
  builder_->add_link(operation->get_output_socket(), input);
}

void NodeConverter::add_output_value(NodeOutput *output, float value)
{
  SetValueOperation *operation = new SetValueOperation();
  operation->set_value(value);

  builder_->add_operation(operation);
  builder_->map_output_socket(output, operation->get_output_socket());
}

void NodeConverter::add_output_color(NodeOutput *output, const float value[4])
{
  SetColorOperation *operation = new SetColorOperation();
  operation->set_channels(value);

  builder_->add_operation(operation);
  builder_->map_output_socket(output, operation->get_output_socket());
}

void NodeConverter::add_output_vector(NodeOutput *output, const float value[3])
{
  SetVectorOperation *operation = new SetVectorOperation();
  operation->set_vector(value);

  builder_->add_operation(operation);
  builder_->map_output_socket(output, operation->get_output_socket());
}

void NodeConverter::register_viewer(ViewerOperation *viewer)
{
  builder_->register_viewer(viewer);
}

ViewerOperation *NodeConverter::active_viewer() const
{
  return builder_->active_viewer();
}

}  // namespace blender::compositor