Cleanup: Compositor: Deduplicate single value setters
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_math_vector.hh"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "GPU_shader.hh"
|
||||
#include "GPU_texture.hh"
|
||||
@@ -300,15 +301,6 @@ class Result {
|
||||
* for more information. */
|
||||
RealizationOptions &get_realization_options();
|
||||
|
||||
/* Set the single value of the result to the given value, which also involves setting the single
|
||||
* pixel in the texture to that value. See the class description for more information. */
|
||||
void set_float_value(float value);
|
||||
void set_vector_value(const float4 &value);
|
||||
void set_color_value(const float4 &value);
|
||||
void set_float2_value(const float2 &value);
|
||||
void set_float3_value(const float3 &value);
|
||||
void set_int2_value(const int2 &value);
|
||||
|
||||
/* Set the value of initial_reference_count_, see that member for more details. This should be
|
||||
* called after constructing the result to declare the number of operations that needs it. */
|
||||
void set_initial_reference_count(int count);
|
||||
@@ -381,6 +373,11 @@ class Result {
|
||||
* type. */
|
||||
template<typename T> T get_single_value_default(const T &default_value) const;
|
||||
|
||||
/* Sets the single value of the result to the given value, which also involves setting the single
|
||||
* pixel in the texture to that value. See the class description for more information. Assumes
|
||||
* the result stores a value of the given template type. */
|
||||
template<typename T> void set_single_value(const T &value);
|
||||
|
||||
/* Loads the pixel at the given texel coordinates. Assumes the result stores a value of the given
|
||||
* template type. If the CouldBeSingleValue template argument is true and the result is a single
|
||||
* value result, then that single value is returned for all texel coordinates. */
|
||||
@@ -535,18 +532,23 @@ template<typename T> inline T Result::get_single_value() const
|
||||
static_assert(Result::is_supported_type<T>());
|
||||
|
||||
if constexpr (std::is_same_v<T, float>) {
|
||||
BLI_assert(type_ == ResultType::Float);
|
||||
return float_value_;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, float2>) {
|
||||
BLI_assert(type_ == ResultType::Float2);
|
||||
return float2_value_;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, float3>) {
|
||||
BLI_assert(type_ == ResultType::Float3);
|
||||
return float3_value_;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, float4>) {
|
||||
BLI_assert(ELEM(type_, ResultType::Color, ResultType::Vector));
|
||||
return color_value_;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, int2>) {
|
||||
BLI_assert(type_ == ResultType::Int2);
|
||||
return int2_value_;
|
||||
}
|
||||
else {
|
||||
@@ -562,6 +564,75 @@ template<typename T> inline T Result::get_single_value_default(const T &default_
|
||||
return default_value;
|
||||
}
|
||||
|
||||
template<typename T> inline void Result::set_single_value(const T &value)
|
||||
{
|
||||
BLI_assert(this->is_allocated());
|
||||
BLI_assert(this->is_single_value());
|
||||
static_assert(Result::is_supported_type<T>());
|
||||
|
||||
if constexpr (std::is_same_v<T, float>) {
|
||||
BLI_assert(type_ == ResultType::Float);
|
||||
float_value_ = value;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, float2>) {
|
||||
BLI_assert(type_ == ResultType::Float2);
|
||||
float2_value_ = value;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, float3>) {
|
||||
BLI_assert(type_ == ResultType::Float3);
|
||||
float3_value_ = value;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, float4>) {
|
||||
BLI_assert(ELEM(type_, ResultType::Color, ResultType::Vector));
|
||||
color_value_ = value;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, int2>) {
|
||||
BLI_assert(type_ == ResultType::Int2);
|
||||
int2_value_ = value;
|
||||
}
|
||||
|
||||
switch (storage_type_) {
|
||||
case ResultStorageType::GPU:
|
||||
if constexpr (Result::is_int_type<T>()) {
|
||||
if constexpr (std::is_scalar_v<T>) {
|
||||
GPU_texture_update(gpu_texture_, GPU_DATA_INT, &value);
|
||||
}
|
||||
else {
|
||||
GPU_texture_update(gpu_texture_, GPU_DATA_INT, value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if constexpr (std::is_scalar_v<T>) {
|
||||
GPU_texture_update(gpu_texture_, GPU_DATA_FLOAT, &value);
|
||||
}
|
||||
else {
|
||||
GPU_texture_update(gpu_texture_, GPU_DATA_FLOAT, value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ResultStorageType::FloatCPU:
|
||||
case ResultStorageType::IntegerCPU:
|
||||
if constexpr (Result::is_int_type<T>()) {
|
||||
if constexpr (std::is_scalar_v<T>) {
|
||||
Result::copy_pixel(
|
||||
this->integer_texture(), &value, Result::get_type_channels_count<T>());
|
||||
}
|
||||
else {
|
||||
Result::copy_pixel(this->integer_texture(), value, Result::get_type_channels_count<T>());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if constexpr (std::is_scalar_v<T>) {
|
||||
Result::copy_pixel(this->float_texture(), &value, Result::get_type_channels_count<T>());
|
||||
}
|
||||
else {
|
||||
Result::copy_pixel(this->float_texture(), value, Result::get_type_channels_count<T>());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, bool CouldBeSingleValue> inline T Result::load_pixel(const int2 &texel) const
|
||||
{
|
||||
if constexpr (CouldBeSingleValue) {
|
||||
|
||||
@@ -1661,22 +1661,22 @@ static void compute_single_value(Result &input, Result &output)
|
||||
output.allocate_single_value();
|
||||
switch (input.type()) {
|
||||
case ResultType::Color:
|
||||
output.set_color_value(input.get_single_value<float4>());
|
||||
output.set_single_value(input.get_single_value<float4>());
|
||||
break;
|
||||
case ResultType::Vector:
|
||||
output.set_vector_value(input.get_single_value<float4>());
|
||||
output.set_single_value(input.get_single_value<float4>());
|
||||
break;
|
||||
case ResultType::Float2:
|
||||
output.set_float2_value(input.get_single_value<float2>());
|
||||
output.set_single_value(input.get_single_value<float2>());
|
||||
break;
|
||||
case ResultType::Float:
|
||||
output.set_float_value(input.get_single_value<float>());
|
||||
output.set_single_value(input.get_single_value<float>());
|
||||
break;
|
||||
case ResultType::Float3:
|
||||
output.set_float3_value(input.get_single_value<float3>());
|
||||
output.set_single_value(input.get_single_value<float3>());
|
||||
break;
|
||||
case ResultType::Int2:
|
||||
output.set_int2_value(input.get_single_value<int2>());
|
||||
output.set_single_value(input.get_single_value<int2>());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ ConvertFloatToVectorOperation::ConvertFloatToVectorOperation(Context &context)
|
||||
|
||||
void ConvertFloatToVectorOperation::execute_single(const Result &input, Result &output)
|
||||
{
|
||||
output.set_vector_value(float4(float3(input.get_single_value<float>()), 1.0f));
|
||||
output.set_single_value(float4(float3(input.get_single_value<float>()), 1.0f));
|
||||
}
|
||||
|
||||
void ConvertFloatToVectorOperation::execute_cpu(const Result &input, Result &output)
|
||||
@@ -130,7 +130,7 @@ ConvertFloatToColorOperation::ConvertFloatToColorOperation(Context &context)
|
||||
|
||||
void ConvertFloatToColorOperation::execute_single(const Result &input, Result &output)
|
||||
{
|
||||
output.set_color_value(float4(float3(input.get_single_value<float>()), 1.0f));
|
||||
output.set_single_value(float4(float3(input.get_single_value<float>()), 1.0f));
|
||||
}
|
||||
|
||||
void ConvertFloatToColorOperation::execute_cpu(const Result &input, Result &output)
|
||||
@@ -161,7 +161,7 @@ ConvertColorToFloatOperation::ConvertColorToFloatOperation(Context &context)
|
||||
void ConvertColorToFloatOperation::execute_single(const Result &input, Result &output)
|
||||
{
|
||||
float4 color = input.get_single_value<float4>();
|
||||
output.set_float_value((color.x + color.y + color.z) / 3.0f);
|
||||
output.set_single_value((color.x + color.y + color.z) / 3.0f);
|
||||
}
|
||||
|
||||
void ConvertColorToFloatOperation::execute_cpu(const Result &input, Result &output)
|
||||
@@ -193,7 +193,7 @@ ConvertColorToVectorOperation::ConvertColorToVectorOperation(Context &context)
|
||||
void ConvertColorToVectorOperation::execute_single(const Result &input, Result &output)
|
||||
{
|
||||
float4 color = input.get_single_value<float4>();
|
||||
output.set_vector_value(color);
|
||||
output.set_single_value(color);
|
||||
}
|
||||
|
||||
void ConvertColorToVectorOperation::execute_cpu(const Result &input, Result &output)
|
||||
@@ -224,7 +224,7 @@ ConvertVectorToFloatOperation::ConvertVectorToFloatOperation(Context &context)
|
||||
void ConvertVectorToFloatOperation::execute_single(const Result &input, Result &output)
|
||||
{
|
||||
float4 vector = input.get_single_value<float4>();
|
||||
output.set_float_value((vector[0] + vector[1] + vector[2]) / 3.0f);
|
||||
output.set_single_value((vector[0] + vector[1] + vector[2]) / 3.0f);
|
||||
}
|
||||
|
||||
void ConvertVectorToFloatOperation::execute_cpu(const Result &input, Result &output)
|
||||
@@ -255,7 +255,7 @@ ConvertVectorToColorOperation::ConvertVectorToColorOperation(Context &context)
|
||||
|
||||
void ConvertVectorToColorOperation::execute_single(const Result &input, Result &output)
|
||||
{
|
||||
output.set_color_value(float4(float3(input.get_single_value<float4>()), 1.0f));
|
||||
output.set_single_value(float4(float3(input.get_single_value<float4>()), 1.0f));
|
||||
}
|
||||
|
||||
void ConvertVectorToColorOperation::execute_cpu(const Result &input, Result &output)
|
||||
|
||||
@@ -37,14 +37,14 @@ void InputSingleValueOperation::execute()
|
||||
/* Set the value of the result to the default value of the input socket. */
|
||||
switch (result.type()) {
|
||||
case ResultType::Float:
|
||||
result.set_float_value(bsocket->default_value_typed<bNodeSocketValueFloat>()->value);
|
||||
result.set_single_value(bsocket->default_value_typed<bNodeSocketValueFloat>()->value);
|
||||
break;
|
||||
case ResultType::Vector:
|
||||
result.set_vector_value(
|
||||
result.set_single_value(
|
||||
float4(float3(bsocket->default_value_typed<bNodeSocketValueVector>()->value), 0.0f));
|
||||
break;
|
||||
case ResultType::Color:
|
||||
result.set_color_value(float4(bsocket->default_value_typed<bNodeSocketValueRGBA>()->value));
|
||||
result.set_single_value(float4(bsocket->default_value_typed<bNodeSocketValueRGBA>()->value));
|
||||
break;
|
||||
default:
|
||||
/* Other types are internal and needn't be handled by operations. */
|
||||
|
||||
@@ -45,13 +45,13 @@ void ReduceToSingleValueOperation::execute()
|
||||
result.allocate_single_value();
|
||||
switch (result.type()) {
|
||||
case ResultType::Color:
|
||||
result.set_color_value(pixel);
|
||||
result.set_single_value(float4(pixel));
|
||||
break;
|
||||
case ResultType::Vector:
|
||||
result.set_vector_value(pixel);
|
||||
result.set_single_value(float4(pixel));
|
||||
break;
|
||||
case ResultType::Float:
|
||||
result.set_float_value(*pixel);
|
||||
result.set_single_value(*pixel);
|
||||
break;
|
||||
default:
|
||||
/* Other types are internal and needn't be handled by operations. */
|
||||
|
||||
@@ -235,22 +235,22 @@ void Result::allocate_invalid()
|
||||
allocate_single_value();
|
||||
switch (type_) {
|
||||
case ResultType::Float:
|
||||
set_float_value(0.0f);
|
||||
set_single_value(0.0f);
|
||||
break;
|
||||
case ResultType::Vector:
|
||||
set_vector_value(float4(0.0f));
|
||||
set_single_value(float4(0.0f));
|
||||
break;
|
||||
case ResultType::Color:
|
||||
set_color_value(float4(0.0f));
|
||||
set_single_value(float4(0.0f));
|
||||
break;
|
||||
case ResultType::Float2:
|
||||
set_float2_value(float2(0.0f));
|
||||
set_single_value(float2(0.0f));
|
||||
break;
|
||||
case ResultType::Float3:
|
||||
set_float3_value(float3(0.0f));
|
||||
set_single_value(float3(0.0f));
|
||||
break;
|
||||
case ResultType::Int2:
|
||||
set_int2_value(int2(0));
|
||||
set_single_value(int2(0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -387,126 +387,6 @@ RealizationOptions &Result::get_realization_options()
|
||||
return domain_.realization_options;
|
||||
}
|
||||
|
||||
void Result::set_float_value(float value)
|
||||
{
|
||||
BLI_assert(type_ == ResultType::Float);
|
||||
BLI_assert(is_single_value_);
|
||||
BLI_assert(this->is_allocated());
|
||||
|
||||
float_value_ = value;
|
||||
switch (storage_type_) {
|
||||
case ResultStorageType::GPU:
|
||||
GPU_texture_update(gpu_texture_, GPU_DATA_FLOAT, &value);
|
||||
break;
|
||||
case ResultStorageType::FloatCPU:
|
||||
*float_texture_ = value;
|
||||
break;
|
||||
case ResultStorageType::IntegerCPU:
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Result::set_vector_value(const float4 &value)
|
||||
{
|
||||
BLI_assert(type_ == ResultType::Vector);
|
||||
BLI_assert(is_single_value_);
|
||||
BLI_assert(this->is_allocated());
|
||||
|
||||
vector_value_ = value;
|
||||
switch (storage_type_) {
|
||||
case ResultStorageType::GPU:
|
||||
GPU_texture_update(gpu_texture_, GPU_DATA_FLOAT, value);
|
||||
break;
|
||||
case ResultStorageType::FloatCPU:
|
||||
copy_v4_v4(float_texture_, value);
|
||||
break;
|
||||
case ResultStorageType::IntegerCPU:
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Result::set_color_value(const float4 &value)
|
||||
{
|
||||
BLI_assert(type_ == ResultType::Color);
|
||||
BLI_assert(is_single_value_);
|
||||
BLI_assert(this->is_allocated());
|
||||
|
||||
color_value_ = value;
|
||||
switch (storage_type_) {
|
||||
case ResultStorageType::GPU:
|
||||
GPU_texture_update(gpu_texture_, GPU_DATA_FLOAT, value);
|
||||
break;
|
||||
case ResultStorageType::FloatCPU:
|
||||
copy_v4_v4(float_texture_, value);
|
||||
break;
|
||||
case ResultStorageType::IntegerCPU:
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Result::set_float2_value(const float2 &value)
|
||||
{
|
||||
BLI_assert(type_ == ResultType::Float2);
|
||||
BLI_assert(is_single_value_);
|
||||
BLI_assert(this->is_allocated());
|
||||
|
||||
float2_value_ = value;
|
||||
switch (storage_type_) {
|
||||
case ResultStorageType::GPU:
|
||||
GPU_texture_update(gpu_texture_, GPU_DATA_FLOAT, value);
|
||||
break;
|
||||
case ResultStorageType::FloatCPU:
|
||||
copy_v2_v2(float_texture_, value);
|
||||
break;
|
||||
case ResultStorageType::IntegerCPU:
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Result::set_float3_value(const float3 &value)
|
||||
{
|
||||
BLI_assert(type_ == ResultType::Float3);
|
||||
BLI_assert(is_single_value_);
|
||||
BLI_assert(this->is_allocated());
|
||||
|
||||
float3_value_ = value;
|
||||
switch (storage_type_) {
|
||||
case ResultStorageType::GPU:
|
||||
GPU_texture_update(gpu_texture_, GPU_DATA_FLOAT, value);
|
||||
break;
|
||||
case ResultStorageType::FloatCPU:
|
||||
copy_v3_v3(float_texture_, value);
|
||||
break;
|
||||
case ResultStorageType::IntegerCPU:
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Result::set_int2_value(const int2 &value)
|
||||
{
|
||||
BLI_assert(type_ == ResultType::Int2);
|
||||
BLI_assert(is_single_value_);
|
||||
BLI_assert(this->is_allocated());
|
||||
|
||||
int2_value_ = value;
|
||||
switch (storage_type_) {
|
||||
case ResultStorageType::GPU:
|
||||
GPU_texture_update(gpu_texture_, GPU_DATA_INT, value);
|
||||
break;
|
||||
case ResultStorageType::FloatCPU:
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
case ResultStorageType::IntegerCPU:
|
||||
copy_v2_v2_int(integer_texture_, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Result::set_initial_reference_count(int count)
|
||||
{
|
||||
initial_reference_count_ = count;
|
||||
|
||||
@@ -163,7 +163,7 @@ class ConvertColorSpaceOperation : public NodeOperation {
|
||||
|
||||
Result &output_image = get_result("Image");
|
||||
output_image.allocate_single_value();
|
||||
output_image.set_color_value(color);
|
||||
output_image.set_single_value(color);
|
||||
}
|
||||
|
||||
bool is_identity()
|
||||
|
||||
@@ -71,7 +71,7 @@ class CornerPinOperation : public NodeOperation {
|
||||
}
|
||||
if (output_mask.should_compute()) {
|
||||
output_mask.allocate_single_value();
|
||||
output_mask.set_float_value(1.0f);
|
||||
output_mask.set_single_value(1.0f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class TimeCurveOperation : public NodeOperation {
|
||||
CurveMapping *curve_mapping = const_cast<CurveMapping *>(get_curve_mapping());
|
||||
BKE_curvemapping_init(curve_mapping);
|
||||
const float time = BKE_curvemapping_evaluateF(curve_mapping, 0, compute_normalized_time());
|
||||
result.set_float_value(clamp_f(time, 0.0f, 1.0f));
|
||||
result.set_single_value(clamp_f(time, 0.0f, 1.0f));
|
||||
}
|
||||
|
||||
const CurveMapping *get_curve_mapping()
|
||||
|
||||
@@ -311,7 +311,7 @@ class DefocusOperation : public NodeOperation {
|
||||
|
||||
if (input_depth.is_single_value()) {
|
||||
output_radius.allocate_single_value();
|
||||
output_radius.set_float_value(compute_radius(input_depth.get_single_value<float>()));
|
||||
output_radius.set_single_value(compute_radius(input_depth.get_single_value<float>()));
|
||||
return output_radius;
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ class DefocusOperation : public NodeOperation {
|
||||
|
||||
if (input_depth.is_single_value()) {
|
||||
output_radius.allocate_single_value();
|
||||
output_radius.set_float_value(compute_radius(input_depth.get_single_value<float>()));
|
||||
output_radius.set_single_value(compute_radius(input_depth.get_single_value<float>()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ class IDMaskOperation : public NodeOperation {
|
||||
const float input_mask_value = get_input("ID value").get_single_value<float>();
|
||||
const float mask = int(round(input_mask_value)) == get_index() ? 1.0f : 0.0f;
|
||||
get_result("Alpha").allocate_single_value();
|
||||
get_result("Alpha").set_float_value(mask);
|
||||
get_result("Alpha").set_single_value(mask);
|
||||
}
|
||||
|
||||
int get_index()
|
||||
|
||||
@@ -66,14 +66,14 @@ class LevelsOperation : public NodeOperation {
|
||||
Result &mean_result = get_result("Mean");
|
||||
if (mean_result.should_compute()) {
|
||||
mean_result.allocate_single_value();
|
||||
mean_result.set_float_value(mean);
|
||||
mean_result.set_single_value(mean);
|
||||
}
|
||||
|
||||
Result &standard_deviation_result = get_result("Std Dev");
|
||||
if (standard_deviation_result.should_compute()) {
|
||||
const float standard_deviation = compute_standard_deviation(mean);
|
||||
standard_deviation_result.allocate_single_value();
|
||||
standard_deviation_result.set_float_value(standard_deviation);
|
||||
standard_deviation_result.set_single_value(standard_deviation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class LevelsOperation : public NodeOperation {
|
||||
Result &standard_deviation_result = get_result("Std Dev");
|
||||
if (standard_deviation_result.should_compute()) {
|
||||
standard_deviation_result.allocate_single_value();
|
||||
standard_deviation_result.set_float_value(0.0f);
|
||||
standard_deviation_result.set_single_value(0.0f);
|
||||
}
|
||||
|
||||
Result &mean_result = get_result("Mean");
|
||||
@@ -95,21 +95,21 @@ class LevelsOperation : public NodeOperation {
|
||||
|
||||
switch (get_channel()) {
|
||||
case CMP_NODE_LEVLES_RED:
|
||||
mean_result.set_float_value(input.x);
|
||||
mean_result.set_single_value(input.x);
|
||||
break;
|
||||
case CMP_NODE_LEVLES_GREEN:
|
||||
mean_result.set_float_value(input.y);
|
||||
mean_result.set_single_value(input.y);
|
||||
break;
|
||||
case CMP_NODE_LEVLES_BLUE:
|
||||
mean_result.set_float_value(input.z);
|
||||
mean_result.set_single_value(input.z);
|
||||
break;
|
||||
case CMP_NODE_LEVLES_LUMINANCE_BT709:
|
||||
mean_result.set_float_value(math::dot(input, float3(luminance_coefficients_bt709_)));
|
||||
mean_result.set_single_value(math::dot(input, float3(luminance_coefficients_bt709_)));
|
||||
break;
|
||||
case CMP_NODE_LEVLES_LUMINANCE: {
|
||||
float luminance_coefficients[3];
|
||||
IMB_colormanagement_get_luminance_coefficients(luminance_coefficients);
|
||||
mean_result.set_float_value(math::dot(input, float3(luminance_coefficients)));
|
||||
mean_result.set_single_value(math::dot(input, float3(luminance_coefficients)));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -152,7 +152,7 @@ class MapUVOperation : public NodeOperation {
|
||||
|
||||
Result &output = get_result("Image");
|
||||
output.allocate_single_value();
|
||||
output.set_color_value(result);
|
||||
output.set_single_value(result);
|
||||
}
|
||||
|
||||
void execute_cpu_nearest()
|
||||
|
||||
@@ -128,7 +128,7 @@ class MovieClipOperation : public NodeOperation {
|
||||
Result &result = get_result("Alpha");
|
||||
if (!movie_clip_buffer) {
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(1.0f);
|
||||
result.set_single_value(1.0f);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -159,22 +159,22 @@ class MovieClipOperation : public NodeOperation {
|
||||
if (should_compute_output("Offset X")) {
|
||||
Result &result = get_result("Offset X");
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(0.0f);
|
||||
result.set_single_value(0.0f);
|
||||
}
|
||||
if (should_compute_output("Offset Y")) {
|
||||
Result &result = get_result("Offset Y");
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(0.0f);
|
||||
result.set_single_value(0.0f);
|
||||
}
|
||||
if (should_compute_output("Scale")) {
|
||||
Result &result = get_result("Scale");
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(1.0f);
|
||||
result.set_single_value(1.0f);
|
||||
}
|
||||
if (should_compute_output("Angle")) {
|
||||
Result &result = get_result("Angle");
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(0.0f);
|
||||
result.set_single_value(0.0f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -195,22 +195,22 @@ class MovieClipOperation : public NodeOperation {
|
||||
if (should_compute_output("Offset X")) {
|
||||
Result &result = get_result("Offset X");
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(offset.x);
|
||||
result.set_single_value(offset.x);
|
||||
}
|
||||
if (should_compute_output("Offset Y")) {
|
||||
Result &result = get_result("Offset Y");
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(offset.y);
|
||||
result.set_single_value(offset.y);
|
||||
}
|
||||
if (should_compute_output("Scale")) {
|
||||
Result &result = get_result("Scale");
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(scale);
|
||||
result.set_single_value(scale);
|
||||
}
|
||||
if (should_compute_output("Angle")) {
|
||||
Result &result = get_result("Angle");
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(angle);
|
||||
result.set_single_value(angle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ class PlaneTrackDeformOperation : public NodeOperation {
|
||||
}
|
||||
if (output_mask.should_compute()) {
|
||||
output_mask.allocate_single_value();
|
||||
output_mask.set_float_value(1.0f);
|
||||
output_mask.set_single_value(1.0f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class RGBOperation : public NodeOperation {
|
||||
const bNodeSocket *socket = static_cast<const bNodeSocket *>(bnode().outputs.first);
|
||||
float4 color = float4(static_cast<const bNodeSocketValueRGBA *>(socket->default_value)->value);
|
||||
|
||||
result.set_color_value(color);
|
||||
result.set_single_value(color);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -33,14 +33,14 @@ class SceneTimeOperation : public NodeOperation {
|
||||
{
|
||||
Result &result = get_result("Seconds");
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(context().get_time());
|
||||
result.set_single_value(context().get_time());
|
||||
}
|
||||
|
||||
void execute_frame()
|
||||
{
|
||||
Result &result = get_result("Frame");
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(float(context().get_frame_number()));
|
||||
result.set_single_value(float(context().get_frame_number()));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -141,13 +141,13 @@ class TrackPositionOperation : public NodeOperation {
|
||||
if (should_compute_x) {
|
||||
Result &result = get_result("X");
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(position.x);
|
||||
result.set_single_value(position.x);
|
||||
}
|
||||
|
||||
if (should_compute_y) {
|
||||
Result &result = get_result("Y");
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(position.y);
|
||||
result.set_single_value(position.y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ class TrackPositionOperation : public NodeOperation {
|
||||
|
||||
Result &result = get_result("Speed");
|
||||
result.allocate_single_value();
|
||||
result.set_vector_value(speed);
|
||||
result.set_single_value(speed);
|
||||
}
|
||||
|
||||
void execute_invalid()
|
||||
@@ -183,17 +183,17 @@ class TrackPositionOperation : public NodeOperation {
|
||||
if (should_compute_output("X")) {
|
||||
Result &result = get_result("X");
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(0.0f);
|
||||
result.set_single_value(0.0f);
|
||||
}
|
||||
if (should_compute_output("Y")) {
|
||||
Result &result = get_result("Y");
|
||||
result.allocate_single_value();
|
||||
result.set_float_value(0.0f);
|
||||
result.set_single_value(0.0f);
|
||||
}
|
||||
if (should_compute_output("Speed")) {
|
||||
Result &result = get_result("Speed");
|
||||
result.allocate_single_value();
|
||||
result.set_vector_value(float4(0.0f));
|
||||
result.set_single_value(float4(0.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class ValueOperation : public NodeOperation {
|
||||
const bNodeSocket *socket = static_cast<bNodeSocket *>(bnode().outputs.first);
|
||||
float value = static_cast<bNodeSocketValueFloat *>(socket->default_value)->value;
|
||||
|
||||
result.set_float_value(value);
|
||||
result.set_single_value(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ static Result compute_max_tile_velocity_cpu(Context &context, const Result &velo
|
||||
if (velocity_image.is_single_value()) {
|
||||
Result output = context.create_result(ResultType::Vector);
|
||||
output.allocate_single_value();
|
||||
output.set_vector_value(velocity_image.get_single_value<float4>());
|
||||
output.set_single_value(velocity_image.get_single_value<float4>());
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ static Result dilate_max_velocity_cpu(Context &context,
|
||||
if (max_tile_velocity.is_single_value()) {
|
||||
Result output = context.create_result(ResultType::Vector);
|
||||
output.allocate_single_value();
|
||||
output.set_vector_value(max_tile_velocity.get_single_value<float4>());
|
||||
output.set_single_value(max_tile_velocity.get_single_value<float4>());
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,14 +101,14 @@ class ZCombineOperation : public NodeOperation {
|
||||
combined_color.w = use_alpha() ? math::max(second_color.w, first_color.w) : combined_color.w;
|
||||
|
||||
combined.allocate_single_value();
|
||||
combined.set_color_value(combined_color);
|
||||
combined.set_single_value(combined_color);
|
||||
}
|
||||
|
||||
Result &combined_z = get_result("Z");
|
||||
if (combined_z.should_compute()) {
|
||||
const float combined_z_value = math::interpolate(second_z_value, first_z_value, mix_factor);
|
||||
combined_z.allocate_single_value();
|
||||
combined_z.set_float_value(combined_z_value);
|
||||
combined_z.set_single_value(combined_z_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user