Changeset View
Changeset View
Standalone View
Standalone View
source/blender/functions/FN_field.hh
| Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | friend bool operator==(const GFieldBase &a, const GFieldBase &b) | ||||
| return *a.node_ == *b.node_ && a.node_output_index_ == b.node_output_index_; | return *a.node_ == *b.node_ && a.node_output_index_ == b.node_output_index_; | ||||
| } | } | ||||
| uint64_t hash() const | uint64_t hash() const | ||||
| { | { | ||||
| return get_default_hash_2(*node_, node_output_index_); | return get_default_hash_2(*node_, node_output_index_); | ||||
| } | } | ||||
| const fn::CPPType &cpp_type() const | const CPPType &cpp_type() const | ||||
| { | { | ||||
| return node_->output_cpp_type(node_output_index_); | return node_->output_cpp_type(node_output_index_); | ||||
| } | } | ||||
| const FieldNode &node() const | const FieldNode &node() const | ||||
| { | { | ||||
| return *node_; | return *node_; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 340 Lines • ▼ Show 20 Lines | |||||
| template<typename T> T evaluate_constant_field(const Field<T> &field) | template<typename T> T evaluate_constant_field(const Field<T> &field) | ||||
| { | { | ||||
| T value; | T value; | ||||
| value.~T(); | value.~T(); | ||||
| evaluate_constant_field(field, &value); | evaluate_constant_field(field, &value); | ||||
| return value; | return value; | ||||
| } | } | ||||
| GField make_constant_field(const CPPType &type, const void *value); | |||||
| template<typename T> Field<T> make_constant_field(T value) | template<typename T> Field<T> make_constant_field(T value) | ||||
| { | { | ||||
| return make_constant_field(CPPType::get<T>(), &value); | return make_constant_field(CPPType::get<T>(), &value); | ||||
| } | } | ||||
| GField make_constant_field(const CPPType &type, const void *value); | |||||
| /** | /** | ||||
| * If the field depends on some input, the same field is returned. | * 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. | * Otherwise the field is evaluated and a new field is created that just computes this constant. | ||||
| * | * | ||||
| * Making the field constant has two benefits: | * Making the field constant has two benefits: | ||||
| * - The field-tree becomes a single node, which is more efficient when the field is evaluated many | * - The field-tree becomes a single node, which is more efficient when the field is evaluated many | ||||
| * times. | * times. | ||||
| * - Memory of the input fields may be freed. | * - Memory of the input fields may be freed. | ||||
| ▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines | |||||