diff options
author | Jacques Lucke <jacques@blender.org> | 2021-10-18 12:40:00 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-10-18 12:46:21 +0300 |
commit | eb0d216dc1caab515eb7cf1ef6bb1632e5ca8fae (patch) | |
tree | 59e9f61142052255df5680d34d93fe8271251ec3 /source/blender/functions | |
parent | 746ee29d3638402e2435f47787087b6458f026c7 (diff) |
Geometry Nodes: decouple multi-function lifetimes from modifier
Previously, some multi-functions were allocated in a resource scope.
This was fine as long as the multi-functions were only needed during
the current evaluation of the node tree. However, now cases arise
that require the multi-functions to be alive after the modifier is finished.
For example, we want to evaluate fields created with geometry nodes
outside of geometry nodes.
To make this work, `std::shared_ptr` has to be used in a few more places.
Realistically, this shouldn't have a noticable impact on performance.
If this does become a bottleneck in the future, we can think about ways
to make this work without using `shared_ptr` for multi-functions that
are only used once.
Diffstat (limited to 'source/blender/functions')
-rw-r--r-- | source/blender/functions/FN_field.hh | 4 | ||||
-rw-r--r-- | source/blender/functions/intern/field.cc | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/source/blender/functions/FN_field.hh b/source/blender/functions/FN_field.hh index f65c4e443f2..2fca78fa6e7 100644 --- a/source/blender/functions/FN_field.hh +++ b/source/blender/functions/FN_field.hh @@ -204,14 +204,14 @@ class FieldOperation : public FieldNode { * The multi-function used by this node. It is optionally owned. * Multi-functions with mutable or vector parameters are not supported currently. */ - std::unique_ptr<const MultiFunction> owned_function_; + std::shared_ptr<const MultiFunction> owned_function_; const MultiFunction *function_; /** Inputs to the operation. */ blender::Vector<GField> inputs_; public: - FieldOperation(std::unique_ptr<const MultiFunction> function, Vector<GField> inputs = {}); + FieldOperation(std::shared_ptr<const MultiFunction> function, Vector<GField> inputs = {}); FieldOperation(const MultiFunction &function, Vector<GField> inputs = {}); Span<GField> inputs() const; diff --git a/source/blender/functions/intern/field.cc b/source/blender/functions/intern/field.cc index 39688ef3daf..03af3f53065 100644 --- a/source/blender/functions/intern/field.cc +++ b/source/blender/functions/intern/field.cc @@ -534,7 +534,7 @@ const GVArray *IndexFieldInput::get_varray_for_context(const fn::FieldContext &U * FieldOperation. */ -FieldOperation::FieldOperation(std::unique_ptr<const MultiFunction> function, +FieldOperation::FieldOperation(std::shared_ptr<const MultiFunction> function, Vector<GField> inputs) : FieldOperation(*function, std::move(inputs)) { |