diff options
author | Jacques Lucke <jacques@blender.org> | 2022-01-02 16:27:16 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-01-02 16:27:16 +0300 |
commit | 8be217ada5754b065723dc85c250cf2b60f14e2e (patch) | |
tree | 02e1c18407d37f05b11181c99df5a3830503ffad /source/blender/functions/FN_multi_function_procedure.hh | |
parent | 4c46203cb52ed37694709cc42aa6ca76ed24fe7a (diff) |
Geometry Nodes: add field node type for constants
It is common to have fields that contain a constant value. Before this
commit, such constants were represented by operation nodes which
don't have inputs. Having a special node type for constants makes
working with them a bit cheaper.
It also allows skipping some unnecessary processing when evaluating
fields, because constant fields can be detected more easily.
This commit also generalizes the concept of field node types a bit.
Diffstat (limited to 'source/blender/functions/FN_multi_function_procedure.hh')
-rw-r--r-- | source/blender/functions/FN_multi_function_procedure.hh | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/functions/FN_multi_function_procedure.hh b/source/blender/functions/FN_multi_function_procedure.hh index a26eb1045a7..d73bc089278 100644 --- a/source/blender/functions/FN_multi_function_procedure.hh +++ b/source/blender/functions/FN_multi_function_procedure.hh @@ -268,6 +268,7 @@ class MFProcedure : NonCopyable, NonMovable { Vector<MFReturnInstruction *> return_instructions_; Vector<MFVariable *> variables_; Vector<MFParameter> params_; + Vector<destruct_ptr<MultiFunction>> owned_functions_; MFInstruction *entry_ = nullptr; friend class MFProcedureDotExport; @@ -284,9 +285,10 @@ class MFProcedure : NonCopyable, NonMovable { MFReturnInstruction &new_return_instruction(); void add_parameter(MFParamType::InterfaceType interface_type, MFVariable &variable); - Span<ConstMFParameter> params() const; + template<typename T, typename... Args> const MultiFunction &construct_function(Args &&...args); + MFInstruction *entry(); const MFInstruction *entry() const; void set_entry(MFInstruction &entry); @@ -550,6 +552,15 @@ inline Span<const MFVariable *> MFProcedure::variables() const return variables_; } +template<typename T, typename... Args> +inline const MultiFunction &MFProcedure::construct_function(Args &&...args) +{ + destruct_ptr<T> fn = allocator_.construct<T>(std::forward<Args>(args)...); + const MultiFunction &fn_ref = *fn; + owned_functions_.append(std::move(fn)); + return fn_ref; +} + /** \} */ } // namespace blender::fn |