diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-12-09 13:16:25 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-12-09 13:17:16 +0300 |
commit | 7f4878ac7f5612082a1235cf6083dc490cbfc212 (patch) | |
tree | 2fb612ec9cfa6a0f5cc4466860575aa536137b6b /source/blender/functions/FN_field.hh | |
parent | b8bad3549dcef0b761708ef9cc1f814ebedb3106 (diff) |
Cleanup: move public doc-strings into headers for 'functions'
Ref T92709
Diffstat (limited to 'source/blender/functions/FN_field.hh')
-rw-r--r-- | source/blender/functions/FN_field.hh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/functions/FN_field.hh b/source/blender/functions/FN_field.hh index da8e820c42a..d82f685e7ea 100644 --- a/source/blender/functions/FN_field.hh +++ b/source/blender/functions/FN_field.hh @@ -405,6 +405,24 @@ class FieldEvaluator : NonMovable, NonCopyable { IndexMask get_evaluated_as_mask(const int field_index); }; +/** + * Evaluate fields in the given context. If possible, multiple fields should be evaluated together, + * because that can be more efficient when they share common sub-fields. + * + * \param scope: The resource scope that owns data that makes up the output virtual arrays. Make + * sure the scope is not destructed when the output virtual arrays are still used. + * \param fields_to_evaluate: The fields that should be evaluated together. + * \param mask: Determines which indices are computed. The mask may be referenced by the returned + * virtual arrays. So the underlying indices (if applicable) should live longer then #scope. + * \param context: The context that the field is evaluated in. Used to retrieve data from each + * #FieldInput in the field network. + * \param dst_varrays: If provided, the computed data will be written into those virtual arrays + * instead of into newly created ones. That allows making the computed data live longer than + * #scope and is more efficient when the data will be written into those virtual arrays + * later anyway. + * \return The computed virtual arrays for each provided field. If #dst_varrays is passed, the + * provided virtual arrays are returned. + */ Vector<GVArray> evaluate_fields(ResourceScope &scope, Span<GFieldRef> fields_to_evaluate, IndexMask mask, @@ -434,6 +452,15 @@ template<typename T> Field<T> make_constant_field(T value) GField make_constant_field(const CPPType &type, const void *value); +/** + * If the field depends on some input, the same field is returned. + * Otherwise the field is evaluated and a new field is created that just computes this constant. + * + * Making the field constant has two benefits: + * - The field-tree becomes a single node, which is more efficient when the field is evaluated many + * times. + * - Memory of the input fields may be freed. + */ GField make_field_constant_if_possible(GField field); class IndexFieldInput final : public FieldInput { |