diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-16 14:38:23 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-16 14:38:23 +0300 |
commit | 2ddb3dc617a5ad3dd5882cde8c088127bd57f916 (patch) | |
tree | bd6405fd9184a5f1437dbc9493a28507e6edc9ec /source/blender/functions/intern | |
parent | 56aa5b0d8c6b66369f979e8bee4f1bd99454a99f (diff) |
Nodes: support default function for partially implemented nodes
Diffstat (limited to 'source/blender/functions/intern')
-rw-r--r-- | source/blender/functions/intern/multi_function_builder.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/functions/intern/multi_function_builder.cc b/source/blender/functions/intern/multi_function_builder.cc index 889a2595aab..7797c19d563 100644 --- a/source/blender/functions/intern/multi_function_builder.cc +++ b/source/blender/functions/intern/multi_function_builder.cc @@ -87,4 +87,33 @@ void CustomMF_GenericConstantArray::call(IndexMask mask, } } +CustomMF_DefaultOutput::CustomMF_DefaultOutput(StringRef name, + Span<MFDataType> input_types, + Span<MFDataType> output_types) + : output_amount_(output_types.size()) +{ + MFSignatureBuilder signature = this->get_builder(name); + for (MFDataType data_type : input_types) { + signature.input("Input", data_type); + } + for (MFDataType data_type : output_types) { + signature.output("Output", data_type); + } +} +void CustomMF_DefaultOutput::call(IndexMask mask, MFParams params, MFContext UNUSED(context)) const +{ + for (uint param_index : this->param_indices()) { + MFParamType param_type = this->param_type(param_index); + if (!param_type.is_output()) { + continue; + } + + if (param_type.data_type().is_single()) { + GMutableSpan span = params.uninitialized_single_output(param_index); + const CPPType &type = span.type(); + type.fill_uninitialized_indices(type.default_value(), span.buffer(), mask); + } + } +} + } // namespace blender::fn |