Blender V5.0
attribute.cc File Reference
#include <cstring>
#include <optional>
#include "MEM_guardedalloc.h"
#include "DNA_ID.h"
#include "DNA_curves_types.h"
#include "DNA_customdata_types.h"
#include "DNA_mesh_types.h"
#include "DNA_pointcloud_types.h"
#include "BLI_index_range.hh"
#include "BLI_string.h"
#include "BLI_string_utils.hh"
#include "BLT_translation.hh"
#include "BKE_attribute.hh"
#include "BKE_attribute_legacy_convert.hh"
#include "BKE_curves.hh"
#include "BKE_customdata.hh"
#include "BKE_editmesh.hh"
#include "BKE_grease_pencil.hh"
#include "BKE_mesh.hh"
#include "BKE_pointcloud.hh"
#include "BKE_report.hh"
#include <fmt/format.h>

Go to the source code of this file.

Classes

struct  DomainInfo
class  IndexRange
class  StringRef

Enumerations

enum class  AttrDomain

Functions

static std::array< DomainInfo, ATTR_DOMAIN_NUMget_domains (const AttributeOwner &owner)
static bool bke_attribute_rename_if_exists (AttributeOwner &owner, const StringRef old_name, const StringRef new_name, ReportList *reports)
static bool name_valid_for_builtin_domain_and_type (const blender::bke::AttributeAccessor attributes, const StringRef name, const AttrDomain domain, const blender::bke::AttrType data_type, ReportList *reports)
static bool mesh_attribute_valid (const Mesh &mesh, const StringRef name, const AttrDomain domain, const blender::bke::AttrType data_type, ReportList *reports)
bool BKE_attribute_rename (AttributeOwner &owner, const StringRef old_name, const StringRef new_name, ReportList *reports)
static bool attribute_name_exists (const AttributeOwner &owner, const StringRef name)
std::string BKE_attribute_calc_unique_name (const AttributeOwner &owner, const StringRef name)
CustomDataLayerBKE_attribute_new (AttributeOwner &owner, const StringRef name, const eCustomDataType type, const AttrDomain domain, ReportList *reports)
static void bke_attribute_copy_if_exists (AttributeOwner &owner, const StringRef srcname, const StringRef dstname)
CustomDataLayerBKE_attribute_duplicate (AttributeOwner &owner, const StringRef name, ReportList *reports)
static int color_name_to_index (AttributeOwner &owner, const StringRef name)
static int color_clamp_index (AttributeOwner &owner, int index)
static StringRef color_name_from_index (AttributeOwner &owner, int index)
bool BKE_attribute_remove (AttributeOwner &owner, const StringRef name, ReportList *reports)
CustomDataLayerBKE_attribute_find (const AttributeOwner &owner, const StringRef name, const eCustomDataType type, const AttrDomain domain)
const CustomDataLayerBKE_attribute_search (const AttributeOwner &owner, const StringRef name, const eCustomDataMask type_mask, const AttrDomainMask domain_mask)
CustomDataLayerBKE_attribute_search_for_write (AttributeOwner &owner, const StringRef name, const eCustomDataMask type_mask, const AttrDomainMask domain_mask)
int BKE_attributes_length (const AttributeOwner &owner, AttrDomainMask domain_mask, eCustomDataMask mask)
AttrDomain BKE_attribute_domain (const AttributeOwner &owner, const CustomDataLayer *layer)
int BKE_attribute_domain_size (const AttributeOwner &owner, const int domain)
int BKE_attribute_data_length (AttributeOwner &owner, CustomDataLayer *layer)
bool BKE_attribute_required (const AttributeOwner &owner, const StringRef name)
std::optional< blender::StringRefNullBKE_attributes_active_name_get (AttributeOwner &owner)
void BKE_attributes_active_set (AttributeOwner &owner, const StringRef name)
void BKE_attributes_active_clear (AttributeOwner &owner)
int * BKE_attributes_active_index_p (AttributeOwner &owner)
CustomDataBKE_attributes_iterator_next_domain (AttributeOwner &owner, CustomDataLayer *layers)
CustomDataLayerBKE_attribute_from_index (AttributeOwner &owner, int lookup_index, AttrDomainMask domain_mask, eCustomDataMask layer_mask)
int BKE_attribute_to_index (const AttributeOwner &owner, const CustomDataLayer *layer, AttrDomainMask domain_mask, eCustomDataMask layer_mask)
std::optional< StringRefBKE_id_attributes_active_color_name (const ID *id)
std::optional< StringRefBKE_id_attributes_default_color_name (const ID *id)
void BKE_id_attributes_active_color_set (ID *id, const std::optional< StringRef > name)
void BKE_id_attributes_active_color_clear (ID *id)
void BKE_id_attributes_default_color_set (ID *id, const std::optional< StringRef > name)
const CustomDataLayerBKE_id_attributes_color_find (const ID *id, const StringRef name)
bool BKE_color_attribute_supported (const Mesh &mesh, const StringRef name)
StringRef BKE_uv_map_pin_name_get (const StringRef uv_map_name, char *buffer)

Detailed Description

Implementation of generic geometry attributes management. This is built on top of CustomData, which manages individual domains.

Definition in file attribute.cc.

Enumeration Type Documentation

◆ AttrDomain

enum class blender::bke::AttrDomain : int8_t
strong

Definition at line 63 of file BKE_attribute.hh.

Function Documentation

◆ attribute_name_exists()

bool attribute_name_exists ( const AttributeOwner & owner,
const StringRef name )
static

◆ BKE_attribute_calc_unique_name()

◆ bke_attribute_copy_if_exists()

◆ BKE_attribute_data_length()

◆ BKE_attribute_domain()

◆ BKE_attribute_domain_size()

int BKE_attribute_domain_size ( const AttributeOwner & owner,
const int domain )

Definition at line 733 of file attribute.cc.

References get_domains().

◆ BKE_attribute_duplicate()

◆ BKE_attribute_find()

CustomDataLayer * BKE_attribute_find ( const AttributeOwner & owner,
const StringRef name,
const eCustomDataType type,
const AttrDomain domain )

◆ BKE_attribute_from_index()

◆ BKE_attribute_new()

◆ BKE_attribute_remove()

◆ BKE_attribute_rename()

◆ bke_attribute_rename_if_exists()

bool bke_attribute_rename_if_exists ( AttributeOwner & owner,
const StringRef old_name,
const StringRef new_name,
ReportList * reports )
static

◆ BKE_attribute_required()

◆ BKE_attribute_search()

◆ BKE_attribute_search_for_write()

◆ BKE_attribute_to_index()

int BKE_attribute_to_index ( const AttributeOwner & owner,
const CustomDataLayer * layer,
AttrDomainMask domain_mask,
eCustomDataMask layer_mask )

◆ BKE_attributes_active_clear()

void BKE_attributes_active_clear ( AttributeOwner & owner)

Definition at line 847 of file attribute.cc.

References BKE_attributes_active_index_p().

◆ BKE_attributes_active_index_p()

◆ BKE_attributes_active_name_get()

std::optional< blender::StringRefNull > BKE_attributes_active_name_get ( AttributeOwner & owner)

Definition at line 784 of file attribute.cc.

References blender::bke::allow_procedural_attribute_access(), blender::bke::AttributeStorage::at_index(), ATTR_DOMAIN_MASK_ALL, ATTR_DOMAIN_NUM, BKE_attributes_active_index_p(), BKE_attributes_length(), CD_MASK_PROP_ALL, CD_TYPE_AS_MASK(), blender::IndexRange::contains(), blender::bke::AttributeStorage::count(), get_domains(), AttributeOwner::get_storage(), i, CustomData::layers, Mesh, blender::bke::Attribute::name(), CustomDataLayer::name, CustomData::totlayer, AttributeOwner::type(), and CustomDataLayer::type.

Referenced by blender::ed::geometry::attribute_set_poll(), blender::ed::geometry::convert_attribute(), blender::ed::curves::set_selection_domain::curves_set_selection_domain_exec(), edbm_select_by_attribute_exec(), edbm_select_by_attribute_poll(), blender::ed::geometry::geometry_attribute_convert_exec(), blender::ed::geometry::geometry_attribute_convert_invoke(), blender::ed::geometry::geometry_attribute_convert_poll(), blender::ed::geometry::geometry_attribute_remove_exec(), blender::ed::geometry::geometry_attributes_remove_poll(), blender::ed::mesh::set_attribute::mesh_set_attribute_exec(), blender::ed::mesh::set_attribute::mesh_set_attribute_invoke(), blender::ed::mesh::set_attribute::mesh_set_attribute_ui(), blender::ed::curves::set_attribute_exec(), blender::ed::pointcloud::set_attribute_exec(), blender::ed::curves::set_attribute_invoke(), blender::ed::pointcloud::set_attribute_invoke(), blender::ed::curves::set_attribute_ui(), and blender::ed::pointcloud::set_attribute_ui().

◆ BKE_attributes_active_set()

◆ BKE_attributes_iterator_next_domain()

CustomData * BKE_attributes_iterator_next_domain ( AttributeOwner & owner,
CustomDataLayer * layers )

Definition at line 874 of file attribute.cc.

References ATTR_DOMAIN_NUM, get_domains(), CustomData::layers, and CustomData::totlayer.

◆ BKE_attributes_length()

int BKE_attributes_length ( const AttributeOwner & owner,
AttrDomainMask domain_mask,
eCustomDataMask mask )

◆ BKE_color_attribute_supported()

bool BKE_color_attribute_supported ( const Mesh & mesh,
const StringRef name )

◆ BKE_id_attributes_active_color_clear()

void BKE_id_attributes_active_color_clear ( ID * id)

Definition at line 1001 of file attribute.cc.

References GS, ID_ME, and MEM_SAFE_FREE.

◆ BKE_id_attributes_active_color_name()

std::optional< StringRef > BKE_id_attributes_active_color_name ( const ID * id)

Definition at line 969 of file attribute.cc.

References GS, and ID_ME.

Referenced by BKE_attribute_rename().

◆ BKE_id_attributes_active_color_set()

◆ BKE_id_attributes_color_find()

const CustomDataLayer * BKE_id_attributes_color_find ( const ID * id,
const StringRef name )

◆ BKE_id_attributes_default_color_name()

std::optional< StringRef > BKE_id_attributes_default_color_name ( const ID * id)

Definition at line 977 of file attribute.cc.

References GS, and ID_ME.

Referenced by BKE_attribute_rename().

◆ BKE_id_attributes_default_color_set()

◆ BKE_uv_map_pin_name_get()

◆ color_clamp_index()

int color_clamp_index ( AttributeOwner & owner,
int index )
static

◆ color_name_from_index()

StringRef color_name_from_index ( AttributeOwner & owner,
int index )
static

◆ color_name_to_index()

int color_name_to_index ( AttributeOwner & owner,
const StringRef name )
static

◆ get_domains()

◆ mesh_attribute_valid()

bool mesh_attribute_valid ( const Mesh & mesh,
const StringRef name,
const AttrDomain domain,
const blender::bke::AttrType data_type,
ReportList * reports )
static

◆ name_valid_for_builtin_domain_and_type()

bool name_valid_for_builtin_domain_and_type ( const blender::bke::AttributeAccessor attributes,
const StringRef name,
const AttrDomain domain,
const blender::bke::AttrType data_type,
ReportList * reports )
static