Blender V5.3
blender::fn Namespace Reference

Namespaces

namespace  lazy_function
namespace  multi_function
namespace  tests

Classes

class  Field
class  FieldContext
class  FieldEvaluator
struct  FieldHashDeep
class  FieldInput
class  FieldInputs
class  FieldOperation
struct  FieldTreeInfo
class  GField
class  GFieldRef
class  IndexFieldInput
class  LocalUserData
class  UserData

Typedefs

using FieldInputPtr = ImplicitSharingPtr<FieldInput>
using FieldOperationPtr = ImplicitSharingPtr<FieldOperation>
using FieldInputsPtr = ImplicitSharingPtr<FieldInputs>

Functions

bool operator== (const GField &a, const GField &b)
bool operator== (const GFieldRef &a, const GFieldRef &b)
Field< bool > invert_boolean_field (const Field< bool > &field)
static FieldInputsPtr combine_field_inputs (const Span< GField > &fields)
Inline Methods
template<typename T>
bool operator== (const Field< T > &a, const Field< T > &b)
bool operator== (const FieldInput &a, const FieldInput &b)
Field Evaluation
Vector< GVArray > evaluate_fields (ResourceScope &scope, Span< GFieldRef > fields_to_evaluate, const IndexMask &mask, const FieldContext &context, Span< GVMutableArray > dst_varrays={})
static FieldTreeInfo preprocess_field_tree (Span< GFieldRef > entry_fields)
static Vector< GVArray > get_field_context_inputs (ResourceScope &scope, const IndexMask &mask, const FieldContext &context, const Span< GFieldRef > field_inputs)
static Set< UniqueHash > find_varying_fields (const FieldTreeInfo &field_tree_info, const Span< GVArray > field_context_inputs)
static void build_multi_function_procedure_for_fields (mf::Procedure &procedure, ResourceScope &scope, const FieldTreeInfo &field_tree_info, Span< GFieldRef > output_fields)
Utility functions for simple field creation and evaluation
void evaluate_constant_field (const GField &field, void *r_value)
template<typename T>
T evaluate_constant_field (const Field< T > &field)
GField make_field_constant_if_possible (GField field)
#FieldEvaluator
static IndexMask index_mask_from_selection (const IndexMask full_mask, const VArray< bool > &selection, ResourceScope &scope)
static IndexMask evaluate_selection (const Field< bool > &selection_field, const FieldContext &context, const IndexMask &full_mask, ResourceScope &scope)

Variables

template<typename T>
constexpr bool is_field_v = false
template<typename T>
constexpr bool is_field_v< Field< T > > = true

Typedef Documentation

◆ FieldInputPtr

◆ FieldInputsPtr

◆ FieldOperationPtr

Function Documentation

◆ build_multi_function_procedure_for_fields()

void blender::fn::build_multi_function_procedure_for_fields ( mf::Procedure & procedure,
ResourceScope & scope,
const FieldTreeInfo & field_tree_info,
Span< GFieldRef > output_fields )
static

Builds the #procedure so that it computes the fields.

Definition at line 155 of file field_evaluation.cc.

References blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add_new(), blender::BLI_assert(), BLI_assert_unreachable, BLI_assert_unreachable_static_t, build_multi_function_procedure_for_fields(), blender::ResourceScope::construct(), blender::fn::FieldHashDeep::contains(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::contains(), blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::contains(), blender::fn::FieldInput::cpp_type(), blender::fn::FieldInput::debug_name(), blender::fn::FieldTreeInfo::deduplicated_inputs, blender::fn::FieldTreeInfo::deep_hashes, blender::Default, blender::fn::FieldOperation::inputs(), blender::Stack< T, InlineBufferCapacity, Allocator >::is_empty(), blender::fn::FieldHashDeep::lookup(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup(), blender::fn::FieldOperation::multi_function(), blender::Stack< T, InlineBufferCapacity, Allocator >::peek(), blender::Stack< T, InlineBufferCapacity, Allocator >::pop(), PRF_scope, blender::Stack< T, InlineBufferCapacity, Allocator >::push(), blender::Span< T >::size(), T, blender::v, and blender::fn::GFieldRef::variant().

Referenced by build_multi_function_procedure_for_fields(), and evaluate_fields().

◆ combine_field_inputs()

FieldInputsPtr blender::fn::combine_field_inputs ( const Span< GField > & fields)
static

Combine the field inputs from multiple fields. If possible, nothing new is allocated.

Definition at line 266 of file field.cc.

References combine_field_inputs(), and blender::fn::FieldInputs::inputs.

Referenced by combine_field_inputs(), and blender::fn::FieldOperation::FieldOperation().

◆ evaluate_constant_field() [1/2]

template<typename T>
T blender::fn::evaluate_constant_field ( const Field< T > & field)

Definition at line 200 of file FN_field_evaluation.hh.

References evaluate_constant_field(), and T.

◆ evaluate_constant_field() [2/2]

◆ evaluate_fields()

Vector< GVArray > blender::fn::evaluate_fields ( ResourceScope & scope,
Span< GFieldRef > fields_to_evaluate,
const IndexMask & mask,
const FieldContext & context,
Span< GVMutableArray > dst_varrays = {} )

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.

Parameters
scopeThe 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.
fields_to_evaluateThe fields that should be evaluated together.
maskDetermines 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.
contextThe context that the field is evaluated in. Used to retrieve data from each FieldInput in the field network.
dst_varraysIf 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.
Returns
The computed virtual arrays for each provided field. If #dst_varrays is passed, the provided virtual arrays are returned.

Definition at line 300 of file field_evaluation.cc.

References blender::ResourceScope::add_destruct_call(), blender::LinearAllocator< Allocator >::allocate_array(), blender::ResourceScope::allocate_owned(), blender::ResourceScope::allocator(), blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::BLI_assert(), BLI_assert_unreachable_static_t, build_multi_function_procedure_for_fields(), blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::contains(), blender::array_utils::copy(), blender::fn::GFieldRef::cpp_type(), blender::GMutableSpan::data(), blender::fn::FieldTreeInfo::deduplicated_input_hashes, blender::fn::FieldTreeInfo::deduplicated_inputs, blender::fn::FieldTreeInfo::deep_hashes, blender::Default, blender::CPPType::default_construct_indices(), blender::CPPType::destruct_indices(), evaluate_fields(), find_varying_fields(), blender::GVArray::from_empty(), blender::GVArray::from_single_ref(), blender::GVArray::from_span(), get_field_context_inputs(), blender::GVMutableArray::get_internal_span(), hash, blender::Span< T >::index_range(), blender::Vector< T, InlineBufferCapacity, Allocator >::index_range(), blender::Span< T >::is_empty(), blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty(), blender::GVArrayCommon::is_span(), blender::CPPType::is_trivially_destructible, blender::fn::FieldHashDeep::lookup(), blender::threading::parallel_for(), preprocess_field_tree(), PRF_scope, blender::GVArrayCommon::size(), blender::Span< T >::size(), T, blender::GMutableSpan::take_front(), blender::GVArrayCommon::type(), blender::v, and blender::fn::GFieldRef::variant().

Referenced by blender::fn::FieldEvaluator::evaluate(), evaluate_constant_field(), evaluate_fields(), evaluate_selection(), and blender::fn::tests::TEST_F().

◆ evaluate_selection()

IndexMask blender::fn::evaluate_selection ( const Field< bool > & selection_field,
const FieldContext & context,
const IndexMask & full_mask,
ResourceScope & scope )
static

◆ find_varying_fields()

◆ get_field_context_inputs()

Vector< GVArray > blender::fn::get_field_context_inputs ( ResourceScope & scope,
const IndexMask & mask,
const FieldContext & context,
const Span< GFieldRef > field_inputs )
static

Retrieves the data from the context that is passed as input into the field.

Definition at line 98 of file field_evaluation.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::fn::FieldInput::cpp_type(), blender::GVArray::from_single_default(), and get_field_context_inputs().

Referenced by evaluate_fields(), and get_field_context_inputs().

◆ index_mask_from_selection()

IndexMask blender::fn::index_mask_from_selection ( const IndexMask full_mask,
const VArray< bool > & selection,
ResourceScope & scope )
static

◆ invert_boolean_field()

◆ make_field_constant_if_possible()

GField blender::fn::make_field_constant_if_possible ( GField field)

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.

Definition at line 522 of file field_evaluation.cc.

References BUFFER_FOR_CPP_TYPE_VALUE, blender::fn::GField::cpp_type(), blender::fn::GField::depends_on_input(), blender::CPPType::destruct(), evaluate_constant_field(), blender::fn::GField::from_constant(), and make_field_constant_if_possible().

Referenced by make_field_constant_if_possible().

◆ operator==() [1/4]

template<typename T>
bool blender::fn::operator== ( const Field< T > & a,
const Field< T > & b )
inline

Definition at line 549 of file FN_field.hh.

References b, and operator==().

◆ operator==() [2/4]

bool blender::fn::operator== ( const FieldInput & a,
const FieldInput & b )
inline

Definition at line 703 of file FN_field.hh.

References b, and operator==().

◆ operator==() [3/4]

bool blender::fn::operator== ( const GField & a,
const GField & b )

This only implements shallow comparison. A more deep comparison could reveal that two fields are semantically the same even if this comparison is false. Deep comparison is much more expensive though.

Definition at line 37 of file field.cc.

Referenced by operator==(), operator==(), and operator==().

◆ operator==() [4/4]

bool blender::fn::operator== ( const GFieldRef & a,
const GFieldRef & b )

◆ preprocess_field_tree()

Variable Documentation

◆ is_field_v

template<typename T>
bool blender::fn::is_field_v = false
constexpr

Type trait to detect field types.

Definition at line 425 of file FN_field.hh.

Referenced by blender::nodes::socket_type_info_by_static_type().

◆ is_field_v< Field< T > >

template<typename T>
bool blender::fn::is_field_v< Field< T > > = true
constexpr

Definition at line 426 of file FN_field.hh.