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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-07-16 14:38:23 +0300
committerJacques Lucke <jacques@blender.org>2020-07-16 14:38:23 +0300
commit2ddb3dc617a5ad3dd5882cde8c088127bd57f916 (patch)
treebd6405fd9184a5f1437dbc9493a28507e6edc9ec /source/blender/functions
parent56aa5b0d8c6b66369f979e8bee4f1bd99454a99f (diff)
Nodes: support default function for partially implemented nodes
Diffstat (limited to 'source/blender/functions')
-rw-r--r--source/blender/functions/FN_multi_function_builder.hh11
-rw-r--r--source/blender/functions/intern/multi_function_builder.cc29
2 files changed, 40 insertions, 0 deletions
diff --git a/source/blender/functions/FN_multi_function_builder.hh b/source/blender/functions/FN_multi_function_builder.hh
index 6e7efb21850..c2c95f7c355 100644
--- a/source/blender/functions/FN_multi_function_builder.hh
+++ b/source/blender/functions/FN_multi_function_builder.hh
@@ -302,6 +302,17 @@ template<typename T> class CustomMF_Constant : public MultiFunction {
}
};
+class CustomMF_DefaultOutput : public MultiFunction {
+ private:
+ uint output_amount_;
+
+ public:
+ CustomMF_DefaultOutput(StringRef name,
+ Span<MFDataType> input_types,
+ Span<MFDataType> output_types);
+ void call(IndexMask mask, MFParams params, MFContext context) const override;
+};
+
} // namespace blender::fn
#endif /* __FN_MULTI_FUNCTION_BUILDER_HH__ */
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