Blender V4.3
blender::bke::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 eCustomDataType 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, eCustomDataType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
 
GSpanAttributeWriter lookup_or_add_for_write_span (StringRef attribute_id, AttrDomain domain, eCustomDataType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
 
GSpanAttributeWriter lookup_or_add_for_write_only_span (StringRef attribute_id, AttrDomain domain, eCustomDataType 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
 
GAttributeReader lookup (const StringRef attribute_id) const
 
GAttributeReader lookup (const StringRef attribute_id, const AttrDomain domain) const
 
GAttributeReader lookup (const StringRef attribute_id, const eCustomDataType 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 (const StringRef attribute_id) const
 
std::optional< AttributeMetaDatalookup_meta_data (const StringRef attribute_id) const
 
GAttributeReader lookup (StringRef attribute_id, std::optional< AttrDomain > domain, std::optional< eCustomDataType > data_type) const
 
GAttributeReader lookup_or_default (StringRef attribute_id, AttrDomain domain, eCustomDataType data_type, const void *default_value=nullptr) const
 
Set< StringRefNullall_ids () const
 

Additional Inherited Members

- Static Public Member Functions inherited from blender::bke::AttributeAccessor
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 678 of file BKE_attribute.hh.

Constructor & Destructor Documentation

◆ MutableAttributeAccessor()

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

Definition at line 680 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

◆ add() [2/2]

bool blender::bke::MutableAttributeAccessor::add ( const StringRef attribute_id,
const AttrDomain domain,
const eCustomDataType 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 734 of file BKE_attribute.hh.

References blender::bke::AttributeAccessorFunctions::add, blender::bke::AttributeAccessor::contains(), blender::bke::AttributeAccessor::fn_, and blender::bke::AttributeAccessor::owner_.

Referenced by add(), blender::nodes::node_geo_instance_on_points_cc::add_instances_from_component(), blender::nodes::node_geo_instances_to_points_cc::convert_instances_to_points(), blender::nodes::node_geo_curve_to_points_cc::copy_curve_domain_attributes(), blender::ed::sculpt_paint::face_set::create_face_sets_mesh(), blender::nodes::node_geo_curves_to_grease_pencil_cc::curve_instances_to_grease_pencil_layers(), blender::bke::CurvesGeometry::CurvesGeometry(), blender::ed::sculpt_paint::face_set::ensure_face_sets_mesh(), blender::bke::gather_attributes(), blender::nodes::node_geo_mesh_to_points_cc::geometry_set_mesh_to_points(), blender::nodes::node_geo_points_to_vertices_cc::geometry_set_points_to_vertices(), blender::bke::mesh_calc_edges(), blender::geometry::mesh_copy_selection(), blender::geometry::mesh_copy_selection_keep_edges(), blender::geometry::mesh_copy_selection_keep_verts(), blender::nodes::node_geo_grease_pencil_to_curves_cc::node_geo_exec(), blender::bke::GeometrySet::propagate_attributes_from_layer_to_instances(), and blender::bke::try_sharing_point_data().

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

References lookup_for_write().

◆ lookup_for_write() [2/2]

GAttributeWriter blender::bke::MutableAttributeAccessor::lookup_for_write ( StringRef attribute_id)

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

Definition at line 714 of file attribute_access.cc.

References attribute.

Referenced by lookup_for_write(), and lookup_for_write_span().

◆ lookup_for_write_span() [1/2]

template<typename T >
SpanAttributeWriter< T > blender::bke::MutableAttributeAccessor::lookup_for_write_span ( const StringRef attribute_id)
inline

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

Definition at line 715 of file BKE_attribute.hh.

References lookup_for_write().

◆ lookup_for_write_span() [2/2]

GSpanAttributeWriter blender::bke::MutableAttributeAccessor::lookup_for_write_span ( StringRef attribute_id)

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

References blender::bke::cpp_type_to_custom_data_type(), blender::CPPType::get(), lookup_or_add_for_write(), and blender::bke::GAttributeWriter::typed().

◆ lookup_or_add_for_write() [2/2]

GAttributeWriter blender::bke::MutableAttributeAccessor::lookup_or_add_for_write ( StringRef attribute_id,
AttrDomain domain,
eCustomDataType 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 743 of file attribute_access.cc.

References add().

Referenced by lookup_or_add_for_write(), lookup_or_add_for_write_only_span(), and lookup_or_add_for_write_span().

◆ lookup_or_add_for_write_only_span() [1/2]

template<typename T >
SpanAttributeWriter< T > blender::bke::MutableAttributeAccessor::lookup_or_add_for_write_only_span ( const StringRef attribute_id,
const AttrDomain domain )
inline

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

Definition at line 823 of file BKE_attribute.hh.

References lookup_or_add_for_write().

◆ lookup_or_add_for_write_only_span() [2/2]

GSpanAttributeWriter blender::bke::MutableAttributeAccessor::lookup_or_add_for_write_only_span ( StringRef attribute_id,
AttrDomain domain,
eCustomDataType data_type )

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

Referenced by BM_mesh_bm_to_me_compact(), blender::nodes::node_geo_distribute_points_on_faces_cc::compute_attribute_outputs(), blender::nodes::node_geo_instances_to_points_cc::convert_instances_to_points(), blender::bke::copy_attributes_group_to_group(), blender::bke::copy_main_point_domain_attribute_to_mesh(), blender::nodes::node_geo_duplicate_elements_cc::copy_stable_id_curves(), blender::nodes::node_geo_duplicate_elements_cc::copy_stable_id_edges(), blender::nodes::node_geo_duplicate_elements_cc::copy_stable_id_faces(), blender::nodes::node_geo_duplicate_elements_cc::copy_stable_id_point(), blender::geometry::create_curve_from_vert_indices(), create_mesh(), blender::bke::curve_legacy_to_curves(), blender::bke::curve_to_mesh_sweep(), blender::geometry::execute_realize_curve_tasks(), blender::geometry::execute_realize_grease_pencil_tasks(), blender::geometry::execute_realize_mesh_tasks(), blender::geometry::execute_realize_pointcloud_tasks(), blender::geometry::extract_mesh_edges(), blender::geometry::extract_mesh_faces(), blender::geometry::extract_mesh_vertices(), blender::bke::gather_attributes(), blender::bke::gather_attributes(), blender::bke::gather_attributes(), blender::bke::gather_attributes_group_to_group(), blender::bke::gather_attributes_to_groups(), blender::geometry::gather_point_attributes_to_interpolate(), blender::nodes::node_geo_mesh_to_points_cc::geometry_set_mesh_to_points(), blender::nodes::node_geo_points_to_vertices_cc::geometry_set_points_to_vertices(), blender::nodes::LazyFunctionForReduceForeachGeometryElement::handle_generation_items_group(), blender::nodes::node_geo_interpolate_curves_cc::interpolate_curve_attributes(), blender::geometry::merge_layers(), blender::nodes::node_geo_distribute_points_in_volume_cc::node_geo_exec(), blender::nodes::node_geo_grease_pencil_to_curves_cc::node_geo_exec(), paintface_flush_flags(), paintvert_flush_flags(), blender::nodes::node_geo_distribute_points_on_faces_cc::point_distribution_calculate(), blender::geometry::point_merge_by_distance(), blender::bke::GeometrySet::propagate_attributes_from_layer_to_instances(), blender::nodes::node_geo_distribute_points_on_faces_cc::propagate_existing_attributes(), blender::geometry::reorder_and_flip_attributes_group_to_group(), blender::geometry::reorder_attributes_group_to_group(), blender::ed::curves::resize_curves(), blender::geometry::retrieve_attribute_spans(), blender::geometry::retrieve_attribute_spans(), blender::bke::retrieve_attributes_for_transfer(), blender::nodes::node_geo_interpolate_curves_cc::store_output_attributes(), and blender::nodes::node_geo_dual_mesh_cc::transfer_attributes().

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

References lookup_or_add_for_write().

◆ lookup_or_add_for_write_span() [2/2]

◆ remove()

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

◆ remove_anonymous()

◆ rename()

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

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