Blender V5.3
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< T > lookup_for_write (const StringRef name)
template<typename T>
SpanAttributeWriter< T > lookup_for_write_span (const StringRef name)
bool add (const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
template<typename T>
bool add (const StringRef name, const AttrDomain domain, const AttributeInit &initializer)
bool add_override (const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
bool assign_data (const StringRef name, const AttributeInit &initializer)
template<typename T>
AttributeWriter< T > lookup_or_add_for_write (const StringRef name, const AttrDomain domain, const AttributeInit &initializer=AttributeInitDefaultValue())
template<typename T>
SpanAttributeWriter< T > lookup_or_add_for_write_span (const StringRef name, const AttrDomain domain, const AttributeInit &initializer=AttributeInitDefaultValue())
template<typename T>
SpanAttributeWriter< T > lookup_or_add_for_write_only_span (const StringRef name, const AttrDomain domain)
template<typename T>
AttributeWriter< T > convert_or_add_for_write (const StringRef name, const AttrDomain domain, const AttributeInit &initializer=AttributeInitDefaultValue())
template<typename T>
SpanAttributeWriter< T > convert_or_add_for_write_span (const StringRef name, const AttrDomain domain, const AttributeInit &initializer=AttributeInitDefaultValue())
template<typename T>
SpanAttributeWriter< T > convert_or_add_for_write_only_span (const StringRef name, const AttrDomain domain)
bool remove (const StringRef name)
Attribute API
GAttributeWriter lookup_for_write (StringRef name)
GSpanAttributeWriter lookup_for_write_span (StringRef name)
bool rename (StringRef old_name, StringRef new_name, bool overwrite=false)
Set< StringRef > rename (const Map< StringRef, StringRef > &map, bool overwrite=false)
GAttributeWriter lookup_or_add_for_write (StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_or_add_for_write_span (StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_or_add_for_write_only_span (StringRef name, AttrDomain domain, AttrType data_type)
GAttributeWriter convert_or_add_for_write (StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GAttributeWriter convert_or_add_for_write_only (StringRef name, AttrDomain domain, AttrType data_type)
GSpanAttributeWriter convert_or_add_for_write_span (StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter convert_or_add_for_write_only_span (StringRef name, AttrDomain domain, AttrType data_type)
void remove_anonymous ()
Public Member Functions inherited from blender::bke::AttributeAccessor
 AttributeAccessor (const void *owner, const AttributeAccessorFunctions &fn)
bool contains (StringRef name) const
std::optional< AttributeMetaData > lookup_meta_data (StringRef name) const
bool domain_supported (const AttrDomain domain) const
int domain_size (const AttrDomain domain) const
bool is_builtin (const StringRef name) const
std::optional< AttributeDomainAndType > get_builtin_domain_and_type (const StringRef name) const
GPointer get_builtin_default (const StringRef name) const
GAttributeReader lookup (const StringRef name) const
GAttributeReader lookup (const StringRef name, const AttrDomain domain) const
GAttributeReader lookup (const StringRef name, const AttrType data_type) const
template<typename T>
AttributeReader< T > lookup (const StringRef name, const std::optional< AttrDomain > domain=std::nullopt) const
template<typename T>
AttributeReader< T > lookup_or_default (const StringRef name, const AttrDomain domain, const T &default_value) const
AttributeValidator lookup_validator (const StringRef name) const
GVArray adapt_domain (const GVArray &varray, const AttrDomain from_domain, const AttrDomain to_domain) const
template<typename T>
VArray< T > adapt_domain (const VArray< T > &varray, const AttrDomain from_domain, const AttrDomain to_domain) const
void foreach_attribute (const FunctionRef< void(const AttributeIter &)> fn) const
GAttributeReader lookup (StringRef name, std::optional< AttrDomain > domain, std::optional< AttrType > data_type) const
GAttributeReader lookup_or_default (StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
Set< StringRefNull > all_names () const
bool has_anonymous () const

Additional Inherited Members

static std::optional< AttributeAccessor > from_id (const ID &id)
Protected Attributes inherited from blender::bke::AttributeAccessor
void * owner_
const AttributeAccessorFunctions * fn_

Detailed Description

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

Definition at line 707 of file BKE_attribute.hh.

Constructor & Destructor Documentation

◆ MutableAttributeAccessor()

Member Function Documentation

◆ add() [1/2]

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

Definition at line 786 of file BKE_attribute.hh.

◆ add() [2/2]

bool blender::bke::MutableAttributeAccessor::add ( const StringRef name,
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 769 of file BKE_attribute.hh.

◆ add_override()

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

Definition at line 793 of file BKE_attribute.hh.

◆ assign_data()

bool blender::bke::MutableAttributeAccessor::assign_data ( const StringRef name,
const AttributeInit & initializer )
inline

Definition at line 816 of file BKE_attribute.hh.

◆ convert_or_add_for_write() [1/2]

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

Same as above, but should be used when the type is known at compile time. Also see the note on built-in attributes above.

Definition at line 945 of file BKE_attribute.hh.

◆ convert_or_add_for_write() [2/2]

Find an attribute with the given id->name, domain and data type. If it does not exist, create a new attribute. If the attribute with the same name but a different type or domain already exists the attribute will be converted to match the type and domain and then returned. This can only fail for certain built-in attributes, so when you are sure you are not handling one of those you don't need to check if the accessor is valid.

Definition at line 557 of file attribute_access.cc.

◆ convert_or_add_for_write_only()

Find an attribute with the given id, domain and data type. If it does not exist, create a new attribute. If the attribute with the same name but a different type or domain already exists the attribute will be converted to match the type and domain and then returned. The existing data will not be converted, as the write_only indicates the attribute will be rewritten. Also see the note on built-in attributes above.

Definition at line 592 of file attribute_access.cc.

◆ convert_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 990 of file BKE_attribute.hh.

◆ convert_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 an attribute with the same name but a differing domain/type already exists the attribute will be converted to the new domain/type.

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. Also see the note on built-in attributes above.

Definition at line 624 of file attribute_access.cc.

◆ convert_or_add_for_write_span() [1/2]

Same as above, but should be used when the type is known at compile time. Also see the note on built-in attributes above.

Definition at line 960 of file BKE_attribute.hh.

◆ convert_or_add_for_write_span() [2/2]

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 convert_or_add_for_write_only_span. Also see the note on built-in attributes above.

Definition at line 612 of file attribute_access.cc.

◆ lookup_for_write() [1/2]

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

Definition at line 729 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 485 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 744 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 505 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 name,
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 848 of file BKE_attribute.hh.

◆ lookup_or_add_for_write() [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 (e.g. because it already exists on a different domain or with a different type), none is returned.

Definition at line 514 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 892 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 546 of file attribute_access.cc.

◆ lookup_or_add_for_write_span() [1/2]

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

Definition at line 862 of file BKE_attribute.hh.

◆ lookup_or_add_for_write_span() [2/2]

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 533 of file attribute_access.cc.

◆ remove()

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 1007 of file BKE_attribute.hh.

◆ remove_anonymous()

Remove all anonymous attributes.

Definition at line 452 of file attribute_access.cc.

◆ rename() [1/2]

Replace the names of attributes, optionally replacing existing use of the new names.

Returns
A set of failed renames.

Definition at line 641 of file attribute_access.cc.

◆ rename() [2/2]

bool blender::bke::MutableAttributeAccessor::rename ( StringRef old_name,
StringRef new_name,
bool overwrite = false )

Replace the name of an attribute, optionally replacing existing use of the new name.

Returns
True if the rename was successful.

Definition at line 632 of file attribute_access.cc.


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