Blender V5.0
blender::nodes::MutableAttributeAccessor Class Reference

#include <BKE_attribute.hh>

Inherits blender::bke::AttributeAccessor.

Public Member Functions

 MutableAttributeAccessor (void *owner, const AttributeAccessorFunctions &fn)
template<typename T>
AttributeWriter< Tlookup_for_write (const StringRef attribute_id)
template<typename T>
SpanAttributeWriter< Tlookup_for_write_span (const StringRef attribute_id)
bool add (const StringRef attribute_id, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
template<typename T>
bool add (const StringRef attribute_id, const AttrDomain domain, const AttributeInit &initializer)
template<typename T>
AttributeWriter< Tlookup_or_add_for_write (const StringRef attribute_id, const AttrDomain domain, const AttributeInit &initializer=AttributeInitDefaultValue())
template<typename T>
SpanAttributeWriter< Tlookup_or_add_for_write_span (const StringRef attribute_id, const AttrDomain domain, const AttributeInit &initializer=AttributeInitDefaultValue())
template<typename T>
SpanAttributeWriter< Tlookup_or_add_for_write_only_span (const StringRef attribute_id, const AttrDomain domain)
bool remove (const StringRef attribute_id)
Attribute API
GAttributeWriter lookup_for_write (StringRef attribute_id)
GSpanAttributeWriter lookup_for_write_span (StringRef attribute_id)
bool rename (StringRef old_attribute_id, StringRef new_attribute_id)
GAttributeWriter lookup_or_add_for_write (StringRef attribute_id, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_or_add_for_write_span (StringRef attribute_id, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_or_add_for_write_only_span (StringRef attribute_id, AttrDomain domain, AttrType data_type)
void remove_anonymous ()
Public Member Functions inherited from blender::bke::AttributeAccessor
 AttributeAccessor (const void *owner, const AttributeAccessorFunctions &fn)
bool domain_supported (const AttrDomain domain) const
int domain_size (const AttrDomain domain) const
bool is_builtin (const StringRef attribute_id) const
std::optional< AttributeDomainAndTypeget_builtin_domain_and_type (const StringRef name) const
GPointer get_builtin_default (const StringRef attribute_id) const
GAttributeReader lookup (const StringRef attribute_id) const
GAttributeReader lookup (const StringRef attribute_id, const AttrDomain domain) const
GAttributeReader lookup (const StringRef attribute_id, const AttrType data_type) const
template<typename T>
AttributeReader< Tlookup (const StringRef attribute_id, const std::optional< AttrDomain > domain=std::nullopt) const
template<typename T>
AttributeReader< Tlookup_or_default (const StringRef attribute_id, const AttrDomain domain, const T &default_value) const
AttributeValidator lookup_validator (const StringRef attribute_id) const
GVArray adapt_domain (const GVArray &varray, const AttrDomain from_domain, const AttrDomain to_domain) const
template<typename T>
VArray< Tadapt_domain (const VArray< T > &varray, const AttrDomain from_domain, const AttrDomain to_domain) const
void foreach_attribute (const FunctionRef< void(const AttributeIter &)> fn) const
bool contains (StringRef attribute_id) const
std::optional< AttributeMetaDatalookup_meta_data (StringRef attribute_id) const
GAttributeReader lookup (StringRef attribute_id, std::optional< AttrDomain > domain, std::optional< AttrType > data_type) const
GAttributeReader lookup_or_default (StringRef attribute_id, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
Set< StringRefNullall_ids () const

Additional Inherited Members

static std::optional< AttributeAccessorfrom_id (const ID &id)
Protected Attributes inherited from blender::bke::AttributeAccessor
void * owner_
const AttributeAccessorFunctionsfn_

Detailed Description

Extends AttributeAccessor with methods that allow modifying individual attributes as well as the set of attributes.

Definition at line 729 of file BKE_attribute.hh.

Constructor & Destructor Documentation

◆ MutableAttributeAccessor()

blender::bke::MutableAttributeAccessor::MutableAttributeAccessor ( void * owner,
const AttributeAccessorFunctions & fn )
inline

Definition at line 731 of file BKE_attribute.hh.

Member Function Documentation

◆ add() [1/2]

template<typename T>
bool blender::bke::MutableAttributeAccessor::add ( const StringRef attribute_id,
const AttrDomain domain,
const AttributeInit & initializer )
inline

Definition at line 799 of file BKE_attribute.hh.

◆ add() [2/2]

bool blender::bke::MutableAttributeAccessor::add ( const StringRef attribute_id,
const AttrDomain domain,
const AttrType data_type,
const AttributeInit & initializer )
inline

Create a new attribute.

Returns
True, when a new attribute has been created. False, when it's not possible to create this attribute or there is already an attribute with that id.

Definition at line 785 of file BKE_attribute.hh.

◆ lookup_for_write() [1/2]

template<typename T>
AttributeWriter< T > blender::bke::MutableAttributeAccessor::lookup_for_write ( const StringRef attribute_id)
inline

Get a writable attribute or non if it does not exist. Make sure to call #finish after changes are done.

Definition at line 751 of file BKE_attribute.hh.

◆ lookup_for_write() [2/2]

Get a writable attribute or none if it does not exist. Make sure to call #finish after changes are done.

Definition at line 814 of file attribute_access.cc.

◆ lookup_for_write_span() [1/2]

Same as above, but returns a type that makes it easier to work with the attribute as a span.

Definition at line 766 of file BKE_attribute.hh.

◆ lookup_for_write_span() [2/2]

Same as above, but returns a type that makes it easier to work with the attribute as a span.

Definition at line 834 of file attribute_access.cc.

◆ lookup_or_add_for_write() [1/2]

template<typename T>
AttributeWriter< T > blender::bke::MutableAttributeAccessor::lookup_or_add_for_write ( const StringRef attribute_id,
const AttrDomain domain,
const AttributeInit & initializer = AttributeInitDefaultValue() )
inline

Same as above, but should be used when the type is known at compile time.

Definition at line 832 of file BKE_attribute.hh.

◆ lookup_or_add_for_write() [2/2]

GAttributeWriter blender::bke::MutableAttributeAccessor::lookup_or_add_for_write ( StringRef attribute_id,
AttrDomain domain,
AttrType data_type,
const AttributeInit & initializer = AttributeInitDefaultValue() )

Find an attribute with the given id, domain and data type. If it does not exist, create a new attribute. If the attribute does not exist and can't be created (e.g. because it already exists on a different domain or with a different type), none is returned.

Definition at line 843 of file attribute_access.cc.

◆ lookup_or_add_for_write_only_span() [1/2]

Same as above, but should be used when the type is known at compile time.

Definition at line 877 of file BKE_attribute.hh.

◆ lookup_or_add_for_write_only_span() [2/2]

Find an attribute with the given id, domain and data type. If it does not exist, create a new attribute. If the attribute does not exist and can't be created, none is returned.

The "only" in the name indicates that the caller should not read existing values from the span. If the attribute is not stored as span internally, the existing values won't be copied over to the span.

For trivial types, the values in a newly created attribute will not be initialized.

Definition at line 876 of file attribute_access.cc.

◆ lookup_or_add_for_write_span() [1/2]

template<typename T>
SpanAttributeWriter< T > blender::bke::MutableAttributeAccessor::lookup_or_add_for_write_span ( const StringRef attribute_id,
const AttrDomain domain,
const AttributeInit & initializer = AttributeInitDefaultValue() )
inline

Same as above, but should be used when the type is known at compile time.

Definition at line 846 of file BKE_attribute.hh.

◆ lookup_or_add_for_write_span() [2/2]

GSpanAttributeWriter blender::bke::MutableAttributeAccessor::lookup_or_add_for_write_span ( StringRef attribute_id,
AttrDomain domain,
AttrType data_type,
const AttributeInit & initializer = AttributeInitDefaultValue() )

Same as above, but returns a type that makes it easier to work with the attribute as a span. If the caller newly initializes the attribute, it's better to use lookup_or_add_for_write_only_span.

Definition at line 862 of file attribute_access.cc.

◆ remove()

bool blender::bke::MutableAttributeAccessor::remove ( const StringRef attribute_id)
inline

Remove an attribute.

Returns
True, when the attribute has been deleted. False, when it's not possible to delete this attribute or if there is no attribute with that id.

Definition at line 894 of file BKE_attribute.hh.

◆ remove_anonymous()

Remove all anonymous attributes.

Definition at line 782 of file attribute_access.cc.

◆ rename()

bool blender::bke::MutableAttributeAccessor::rename ( StringRef old_attribute_id,
StringRef new_attribute_id )

Replace the existing attribute with a new one with a different name.

Definition at line 887 of file attribute_access.cc.


The documentation for this class was generated from the following files: