Blender V5.0
FN_field.hh File Reference

Go to the source code of this file.

Classes

class  blender::fn::FieldNode
class  blender::fn::GFieldBase< NodePtr >
class  blender::fn::GField
class  blender::fn::GFieldRef
struct  blender::fn::detail::TypedFieldBase
class  blender::fn::Field< T >
class  blender::fn::FieldOperation
class  blender::fn::FieldInput
class  blender::fn::FieldConstant
struct  blender::fn::FieldInputs
class  blender::fn::FieldContext
class  blender::fn::FieldEvaluator
class  blender::fn::IndexFieldInput

Namespaces

namespace  blender
namespace  blender::fn
namespace  blender::fn::detail

Enumerations

enum class  blender::fn::FieldNodeType { blender::fn::Input , blender::fn::Operation , blender::fn::Constant }

Functions

Field Evaluation
Vector< GVArrayblender::fn::evaluate_fields (ResourceScope &scope, Span< GFieldRef > fields_to_evaluate, const IndexMask &mask, const FieldContext &context, Span< GVMutableArray > dst_varrays={})
Utility functions for simple field creation and evaluation
void blender::fn::evaluate_constant_field (const GField &field, void *r_value)
template<typename T>
T blender::fn::evaluate_constant_field (const Field< T > &field)
Field< bool > blender::fn::invert_boolean_field (const Field< bool > &field)
GField blender::fn::make_constant_field (const CPPType &type, const void *value)
template<typename T>
Field< Tblender::fn::make_constant_field (T value)
GField blender::fn::make_field_constant_if_possible (GField field)
#FieldNode Inline Methods
bool blender::fn::operator== (const FieldNode &a, const FieldNode &b)
bool blender::fn::operator!= (const FieldNode &a, const FieldNode &b)

Variables

template<typename T>
static constexpr bool blender::fn::is_field_v

Detailed Description

A #Field represents a function that outputs a value based on an arbitrary number of inputs. The inputs for a specific field evaluation are provided by a #FieldContext.

A typical example is a field that computes a displacement vector for every vertex on a mesh based on its position.

Fields can be built, composed and evaluated at run-time. They are stored in a directed tree graph data structure, whereby each node is a #FieldNode and edges are dependencies. A #FieldNode has an arbitrary number of inputs and at least one output and a #Field references a specific output of a #FieldNode. The inputs of a #FieldNode are other fields.

There are two different types of field nodes:

  • #FieldInput: Has no input and exactly one output. It represents an input to the entire field when it is evaluated. During evaluation, the value of this input is based on a #FieldContext.
  • #FieldOperation: Has an arbitrary number of field inputs and at least one output. Its main use is to compose multiple existing fields into new fields.

When fields are evaluated, they are converted into a multi-function procedure which allows efficient computation. In the future, we might support different field evaluation mechanisms for e.g. the following scenarios:

  • Latency of a single evaluation is more important than throughput.
  • Evaluation should happen on other hardware like GPUs.

Whenever possible, multiple fields should be evaluated together to avoid duplicate work when they share common sub-fields and a common context.

Definition in file FN_field.hh.