Blender V4.3
input_single_value_operation.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BLI_assert.h"
7
9#include "COM_operation.hh"
10#include "COM_result.hh"
11#include "COM_utilities.hh"
12
14
15const StringRef InputSingleValueOperation::output_identifier_ = StringRef("Output");
16
18 : Operation(context), input_socket_(input_socket)
19{
20 const ResultType result_type = get_node_socket_result_type(input_socket_.bsocket());
21 Result result = context.create_result(result_type);
22
23 /* The result of an input single value operation is guaranteed to have a single user. */
25
26 populate_result(result);
27}
28
30{
31 /* Allocate a single value for the result. */
32 Result &result = get_result();
33 result.allocate_single_value();
34
35 const bNodeSocket *bsocket = input_socket_.bsocket();
36
37 /* Set the value of the result to the default value of the input socket. */
38 switch (result.type()) {
40 result.set_float_value(bsocket->default_value_typed<bNodeSocketValueFloat>()->value);
41 break;
43 result.set_vector_value(
44 float4(float3(bsocket->default_value_typed<bNodeSocketValueVector>()->value), 0.0f));
45 break;
47 result.set_color_value(float4(bsocket->default_value_typed<bNodeSocketValueRGBA>()->value));
48 break;
49 default:
50 /* Other types are internal and needn't be handled by operations. */
52 break;
53 }
54}
55
57{
58 return Operation::get_result(output_identifier_);
59}
60
61void InputSingleValueOperation::populate_result(Result result)
62{
63 Operation::populate_result(output_identifier_, result);
64}
65
66} // namespace blender::realtime_compositor
#define BLI_assert_unreachable()
Definition BLI_assert.h:97
InputSingleValueOperation(Context &context, DInputSocket input_socket)
Result & get_result(StringRef identifier)
Definition operation.cc:46
void populate_result(StringRef identifier, Result result)
Definition operation.cc:154
void set_initial_reference_count(int count)
Definition result.cc:587
ResultType get_node_socket_result_type(const bNodeSocket *socket)
Definition utilities.cc:63
VecBase< float, 4 > float4
VecBase< float, 3 > float3