Cleanup: Move attribute domain enum to C++ header, use enum class

Each value is now out of the global namespace, so they can be shorter
and easier to read. Most of this commit just adds the necessary casting
and namespace specification. `enum class` can be forward declared since
it has a specified size. We will make use of that in the next commit.
This commit is contained in:
Hans Goudey 2023-12-20 13:13:16 -05:00
parent 2618c1d71d
commit 19001c9e6c
311 changed files with 2486 additions and 2347 deletions

View File

@ -725,18 +725,20 @@ static void attr_create_generic(Scene *scene,
const blender::bke::AttributeMetaData meta_data) {
const ustring name{std::string_view(id.name())};
const eAttrDomain b_domain = meta_data.domain;
const blender::bke::AttrDomain b_domain = meta_data.domain;
const eCustomDataType b_data_type = meta_data.data_type;
if (need_motion && name == u_velocity) {
const blender::VArraySpan b_attr = *b_attributes.lookup<blender::float3>(id,
ATTR_DOMAIN_POINT);
const blender::VArraySpan b_attr = *b_attributes.lookup<blender::float3>(
id, blender::bke::AttrDomain::Point);
attr_create_motion(hair, b_attr, motion_scale);
return true;
}
/* Weak, use first float2 attribute as standard UV. */
if (need_uv && !have_uv && b_data_type == CD_PROP_FLOAT2 && b_domain == ATTR_DOMAIN_CURVE) {
if (need_uv && !have_uv && b_data_type == CD_PROP_FLOAT2 &&
b_domain == blender::bke::AttrDomain::Curve)
{
Attribute *attr = attributes.add(ATTR_STD_UV, name);
const blender::VArraySpan b_attr = *b_attributes.lookup<blender::float2>(id);
@ -759,10 +761,10 @@ static void attr_create_generic(Scene *scene,
AttributeElement element = ATTR_ELEMENT_NONE;
switch (b_attr.domain) {
case ATTR_DOMAIN_POINT:
case blender::bke::AttrDomain::Point:
element = ATTR_ELEMENT_CURVE_KEY;
break;
case ATTR_DOMAIN_CURVE:
case blender::bke::AttrDomain::Curve:
element = ATTR_ELEMENT_CURVE;
break;
default:
@ -856,8 +858,8 @@ static void export_hair_curves(Scene *scene,
}
}
const blender::VArraySpan b_radius = *b_curves.attributes().lookup<float>("radius",
ATTR_DOMAIN_POINT);
const blender::VArraySpan b_radius = *b_curves.attributes().lookup<float>(
"radius", blender::bke::AttrDomain::Point);
std::copy(points_by_curve.data().data(),
points_by_curve.data().data() + points_by_curve.size(),
@ -933,8 +935,8 @@ static void export_hair_curves_motion(Hair *hair,
const blender::Span<blender::float3> b_positions = b_curves.positions();
const blender::OffsetIndices points_by_curve = b_curves.points_by_curve();
const blender::VArraySpan b_radius = *b_curves.attributes().lookup<float>("radius",
ATTR_DOMAIN_POINT);
const blender::VArraySpan b_radius = *b_curves.attributes().lookup<float>(
"radius", blender::bke::AttrDomain::Point);
for (const int i : points_by_curve.index_range()) {
const blender::IndexRange points = points_by_curve[i];

View File

@ -287,7 +287,7 @@ static void attr_create_generic(Scene *scene,
if (need_motion && name == u_velocity) {
const blender::VArraySpan b_attribute = *b_attributes.lookup<blender::float3>(
id, ATTR_DOMAIN_POINT);
id, blender::bke::AttrDomain::Point);
attr_create_motion(mesh, b_attribute, motion_scale);
}
@ -300,10 +300,10 @@ static void attr_create_generic(Scene *scene,
return true;
}
eAttrDomain b_domain = meta_data.domain;
if (b_domain == ATTR_DOMAIN_EDGE) {
blender::bke::AttrDomain b_domain = meta_data.domain;
if (b_domain == blender::bke::AttrDomain::Edge) {
/* Blender's attribute API handles edge to vertex attribute domain interpolation. */
b_domain = ATTR_DOMAIN_POINT;
b_domain = blender::bke::AttrDomain::Point;
}
const blender::bke::GAttributeReader b_attr = b_attributes.lookup(id, b_domain);
@ -311,7 +311,8 @@ static void attr_create_generic(Scene *scene,
return true;
}
if (b_attr.domain == ATTR_DOMAIN_CORNER && meta_data.data_type == CD_PROP_BYTE_COLOR) {
if (b_attr.domain == blender::bke::AttrDomain::Corner &&
meta_data.data_type == CD_PROP_BYTE_COLOR) {
Attribute *attr = attributes.add(name, TypeRGBA, ATTR_ELEMENT_CORNER_BYTE);
if (is_render_color) {
attr->std = ATTR_STD_VERTEX_COLOR;
@ -340,13 +341,13 @@ static void attr_create_generic(Scene *scene,
AttributeElement element = ATTR_ELEMENT_NONE;
switch (b_domain) {
case ATTR_DOMAIN_CORNER:
case blender::bke::AttrDomain::Corner:
element = ATTR_ELEMENT_CORNER;
break;
case ATTR_DOMAIN_POINT:
case blender::bke::AttrDomain::Point:
element = ATTR_ELEMENT_VERTEX;
break;
case ATTR_DOMAIN_FACE:
case blender::bke::AttrDomain::Face:
element = ATTR_ELEMENT_FACE;
break;
default:
@ -368,7 +369,7 @@ static void attr_create_generic(Scene *scene,
const blender::VArraySpan src = b_attr.varray.typed<BlenderT>();
switch (b_attr.domain) {
case ATTR_DOMAIN_CORNER: {
case blender::bke::AttrDomain::Corner: {
if (subdivision) {
for (const int i : src.index_range()) {
data[i] = Converter::convert(src[i]);
@ -384,13 +385,13 @@ static void attr_create_generic(Scene *scene,
}
break;
}
case ATTR_DOMAIN_POINT: {
case blender::bke::AttrDomain::Point: {
for (const int i : src.index_range()) {
data[i] = Converter::convert(src[i]);
}
break;
}
case ATTR_DOMAIN_FACE: {
case blender::bke::AttrDomain::Face: {
if (subdivision) {
for (const int i : src.index_range()) {
data[i] = Converter::convert(src[i]);
@ -419,7 +420,8 @@ static set<ustring> get_blender_uv_names(const ::Mesh &b_mesh)
set<ustring> uv_names;
b_mesh.attributes().for_all([&](const blender::bke::AttributeIDRef &id,
const blender::bke::AttributeMetaData meta_data) {
if (meta_data.domain == ATTR_DOMAIN_CORNER && meta_data.data_type == CD_PROP_FLOAT2) {
if (meta_data.domain == blender::bke::AttrDomain::Corner &&
meta_data.data_type == CD_PROP_FLOAT2) {
if (!id.is_anonymous()) {
uv_names.emplace(std::string_view(id.name()));
}
@ -466,7 +468,7 @@ static void attr_create_uv_map(Scene *scene,
}
const blender::VArraySpan b_uv_map = *b_attributes.lookup<blender::float2>(
uv_name.c_str(), ATTR_DOMAIN_CORNER);
uv_name.c_str(), blender::bke::AttrDomain::Corner);
float2 *fdata = uv_attr->data_float2();
for (const int i : corner_tris.index_range()) {
const blender::int3 &tri = corner_tris[i];
@ -543,7 +545,7 @@ static void attr_create_subd_uv_map(Scene *scene,
}
const blender::VArraySpan b_uv_map = *b_attributes.lookup<blender::float2>(
uv_name.c_str(), ATTR_DOMAIN_CORNER);
uv_name.c_str(), blender::bke::AttrDomain::Corner);
float2 *fdata = uv_attr->data_float2();
for (const int i : faces.index_range()) {
@ -828,10 +830,10 @@ static void create_mesh(Scene *scene,
return;
}
const blender::VArraySpan material_indices = *b_attributes.lookup<int>("material_index",
ATTR_DOMAIN_FACE);
const blender::VArraySpan sharp_faces = *b_attributes.lookup<bool>("sharp_face",
ATTR_DOMAIN_FACE);
const blender::VArraySpan material_indices = *b_attributes.lookup<int>(
"material_index", blender::bke::AttrDomain::Face);
const blender::VArraySpan sharp_faces = *b_attributes.lookup<bool>(
"sharp_face", blender::bke::AttrDomain::Face);
blender::Span<blender::float3> corner_normals;
if (use_loop_normals) {
corner_normals = b_mesh.corner_normals();
@ -1054,8 +1056,8 @@ static void create_subd_mesh(Scene *scene,
create_mesh(scene, mesh, b_mesh, used_shaders, need_motion, motion_scale, true, subdivide_uvs);
const blender::VArraySpan creases = *b_mesh.attributes().lookup<float>("crease_edge",
ATTR_DOMAIN_EDGE);
const blender::VArraySpan creases = *b_mesh.attributes().lookup<float>(
"crease_edge", blender::bke::AttrDomain::Edge);
if (!creases.is_empty()) {
size_t num_creases = 0;
for (const int i : creases.index_range()) {
@ -1076,8 +1078,8 @@ static void create_subd_mesh(Scene *scene,
}
}
const blender::VArraySpan vert_creases = *b_mesh.attributes().lookup<float>("crease_vert",
ATTR_DOMAIN_POINT);
const blender::VArraySpan vert_creases = *b_mesh.attributes().lookup<float>(
"crease_vert", blender::bke::AttrDomain::Point);
if (!vert_creases.is_empty()) {
for (const int i : vert_creases.index_range()) {
if (vert_creases[i] != 0.0f) {

View File

@ -57,7 +57,7 @@ static void copy_attributes(PointCloud *pointcloud,
const float motion_scale)
{
const blender::bke::AttributeAccessor b_attributes = b_pointcloud.attributes();
if (b_attributes.domain_size(ATTR_DOMAIN_POINT) == 0) {
if (b_attributes.domain_size(blender::bke::AttrDomain::Point) == 0) {
return;
}
@ -103,8 +103,8 @@ static void export_pointcloud(Scene *scene,
const float motion_scale)
{
const blender::Span<blender::float3> b_positions = b_pointcloud.positions();
const blender::VArraySpan b_radius = *b_pointcloud.attributes().lookup<float>("radius",
ATTR_DOMAIN_POINT);
const blender::VArraySpan b_radius = *b_pointcloud.attributes().lookup<float>(
"radius", blender::bke::AttrDomain::Point);
pointcloud->resize(b_positions.size());
@ -158,8 +158,8 @@ static void export_pointcloud_motion(PointCloud *pointcloud,
const array<float3> &pointcloud_points = pointcloud->get_points();
const blender::Span<blender::float3> b_positions = b_pointcloud.positions();
const blender::VArraySpan b_radius = *b_pointcloud.attributes().lookup<float>("radius",
ATTR_DOMAIN_POINT);
const blender::VArraySpan b_radius = *b_pointcloud.attributes().lookup<float>(
"radius", blender::bke::AttrDomain::Point);
for (int i = 0; i < std::min<int>(num_points, b_positions.size()); i++) {
const float3 P = make_float3(b_positions[i][0], b_positions[i][1], b_positions[i][2]);

View File

@ -13,29 +13,15 @@
#include "BKE_customdata.hh"
#ifdef __cplusplus
extern "C" {
#endif
namespace blender::bke {
enum class AttrDomain : int8_t;
}
struct CustomData;
struct CustomDataLayer;
struct ID;
struct ReportList;
/** #Attribute.domain */
typedef enum eAttrDomain {
ATTR_DOMAIN_AUTO = -1, /* Use for nodes to choose automatically based on other data. */
ATTR_DOMAIN_POINT = 0, /* Mesh, Curve or Point Cloud Point */
ATTR_DOMAIN_EDGE = 1, /* Mesh Edge */
ATTR_DOMAIN_FACE = 2, /* Mesh Face */
ATTR_DOMAIN_CORNER = 3, /* Mesh Corner */
ATTR_DOMAIN_CURVE = 4, /* A single curve in a larger curve data-block */
ATTR_DOMAIN_INSTANCE = 5, /* Instance */
ATTR_DOMAIN_LAYER = 6, /* A layer in a grease pencil data-block */
} eAttrDomain;
#define ATTR_DOMAIN_NUM 7
typedef enum eAttrDomainMask {
typedef enum AttrDomainMask {
ATTR_DOMAIN_MASK_POINT = (1 << 0),
ATTR_DOMAIN_MASK_EDGE = (1 << 1),
ATTR_DOMAIN_MASK_FACE = (1 << 2),
@ -43,14 +29,14 @@ typedef enum eAttrDomainMask {
ATTR_DOMAIN_MASK_CURVE = (1 << 4),
ATTR_DOMAIN_MASK_GREASE_PENCIL_LAYER = (1 << 6),
ATTR_DOMAIN_MASK_ALL = (1 << 7) - 1
} eAttrDomainMask;
ENUM_OPERATORS(eAttrDomainMask, ATTR_DOMAIN_MASK_ALL);
} AttrDomainMask;
ENUM_OPERATORS(AttrDomainMask, ATTR_DOMAIN_MASK_ALL);
#define ATTR_DOMAIN_AS_MASK(domain) ((eAttrDomainMask)((1 << (int)(domain))))
#define ATTR_DOMAIN_AS_MASK(domain) ((AttrDomainMask)((1 << (int)(domain))))
/* All domains that support color attributes. */
#define ATTR_DOMAIN_MASK_COLOR \
((eAttrDomainMask)((ATTR_DOMAIN_MASK_POINT | ATTR_DOMAIN_MASK_CORNER)))
((AttrDomainMask)((ATTR_DOMAIN_MASK_POINT | ATTR_DOMAIN_MASK_CORNER)))
/* Attributes. */
@ -63,7 +49,7 @@ bool BKE_attribute_allow_procedural_access(const char *attribute_name);
struct CustomDataLayer *BKE_id_attribute_new(struct ID *id,
const char *name,
eCustomDataType type,
eAttrDomain domain,
blender::bke::AttrDomain domain,
struct ReportList *reports);
bool BKE_id_attribute_remove(struct ID *id, const char *name, struct ReportList *reports);
@ -77,19 +63,20 @@ struct CustomDataLayer *BKE_id_attribute_duplicate(struct ID *id,
struct CustomDataLayer *BKE_id_attribute_find(const struct ID *id,
const char *name,
eCustomDataType type,
eAttrDomain domain);
blender::bke::AttrDomain domain);
const struct CustomDataLayer *BKE_id_attribute_search(const struct ID *id,
const char *name,
eCustomDataMask type,
eAttrDomainMask domain_mask);
AttrDomainMask domain_mask);
struct CustomDataLayer *BKE_id_attribute_search_for_write(struct ID *id,
const char *name,
eCustomDataMask type,
eAttrDomainMask domain_mask);
AttrDomainMask domain_mask);
eAttrDomain BKE_id_attribute_domain(const struct ID *id, const struct CustomDataLayer *layer);
blender::bke::AttrDomain BKE_id_attribute_domain(const struct ID *id,
const struct CustomDataLayer *layer);
int BKE_id_attribute_data_length(struct ID *id, struct CustomDataLayer *layer);
bool BKE_id_attribute_required(const struct ID *id, const char *name);
bool BKE_id_attribute_rename(struct ID *id,
@ -98,7 +85,7 @@ bool BKE_id_attribute_rename(struct ID *id,
struct ReportList *reports);
int BKE_id_attributes_length(const struct ID *id,
eAttrDomainMask domain_mask,
AttrDomainMask domain_mask,
eCustomDataMask mask);
struct CustomDataLayer *BKE_id_attributes_active_get(struct ID *id);
@ -108,13 +95,13 @@ int *BKE_id_attributes_active_index_p(struct ID *id);
CustomData *BKE_id_attributes_iterator_next_domain(struct ID *id, struct CustomDataLayer *layers);
CustomDataLayer *BKE_id_attribute_from_index(struct ID *id,
int lookup_index,
eAttrDomainMask domain_mask,
AttrDomainMask domain_mask,
eCustomDataMask layer_mask);
/** Layer is allowed to be nullptr; if so -1 (layer not found) will be returned. */
int BKE_id_attribute_to_index(const struct ID *id,
const CustomDataLayer *layer,
eAttrDomainMask domain_mask,
AttrDomainMask domain_mask,
eCustomDataMask layer_mask);
const char *BKE_id_attributes_active_color_name(const struct ID *id);
@ -129,7 +116,3 @@ void BKE_id_attribute_calc_unique_name(struct ID *id, const char *name, char *ou
const char *BKE_uv_map_vert_select_name_get(const char *uv_map_name, char *buffer);
const char *BKE_uv_map_edge_select_name_get(const char *uv_map_name, char *buffer);
const char *BKE_uv_map_pin_name_get(const char *uv_map_name, char *buffer);
#ifdef __cplusplus
}
#endif

View File

@ -27,6 +27,26 @@ class GField;
namespace blender::bke {
enum class AttrDomain : int8_t {
/* Use for to choose automatically based on other data. */
Auto = -1,
/* Mesh, Curve or Point Cloud Point. */
Point = 0,
/* Mesh Edge. */
Edge = 1,
/* Mesh Face. */
Face = 2,
/* Mesh Corner. */
Corner = 3,
/* A single curve in a larger curve data-block. */
Curve = 4,
/* Instance. */
Instance = 5,
/* A layer in a grease pencil data-block. */
Layer = 6,
};
#define ATTR_DOMAIN_NUM 7
/**
* Identifies an attribute with optional anonymous attribute information.
* It does not own the identifier, so it is just a reference.
@ -62,14 +82,14 @@ class AttributeIDRef {
* stored (uv map, vertex group, ...).
*/
struct AttributeMetaData {
eAttrDomain domain;
AttrDomain domain;
eCustomDataType data_type;
BLI_STRUCT_EQUALITY_OPERATORS_2(AttributeMetaData, domain, data_type)
};
struct AttributeKind {
eAttrDomain domain;
AttrDomain domain;
eCustomDataType data_type;
};
@ -162,7 +182,7 @@ template<typename T> struct AttributeReader {
/**
* Domain where the attribute is stored. This also determines the size of the virtual array.
*/
eAttrDomain domain;
AttrDomain domain;
/**
* Information about shared ownership of the attribute array. This will only be provided
@ -221,7 +241,7 @@ template<typename T> struct AttributeWriter {
* Domain where the attribute is stored on the geometry. Also determines the size of the virtual
* array.
*/
eAttrDomain domain;
AttrDomain domain;
/**
* A function that has to be called after the attribute has been edited. This may be empty.
*/
@ -256,7 +276,7 @@ template<typename T> struct SpanAttributeWriter {
/**
* Domain of the attribute. Also determines the size of the span.
*/
eAttrDomain domain;
AttrDomain domain;
/**
* Has to be called after writing to the span.
*/
@ -297,7 +317,7 @@ template<typename T> struct SpanAttributeWriter {
*/
struct GAttributeReader {
GVArray varray;
eAttrDomain domain;
AttrDomain domain;
const ImplicitSharingInfo *sharing_info;
operator bool() const
@ -325,7 +345,7 @@ struct GAttributeReader {
*/
struct GAttributeWriter {
GVMutableArray varray;
eAttrDomain domain;
AttrDomain domain;
std::function<void()> tag_modified_fn;
operator bool() const
@ -351,7 +371,7 @@ struct GAttributeWriter {
*/
struct GSpanAttributeWriter {
GMutableVArraySpan span;
eAttrDomain domain;
AttrDomain domain;
std::function<void()> tag_modified_fn;
GSpanAttributeWriter() = default;
@ -391,14 +411,14 @@ struct AttributeAccessorFunctions {
bool (*contains)(const void *owner, const AttributeIDRef &attribute_id);
std::optional<AttributeMetaData> (*lookup_meta_data)(const void *owner,
const AttributeIDRef &attribute_id);
bool (*domain_supported)(const void *owner, eAttrDomain domain);
int (*domain_size)(const void *owner, eAttrDomain domain);
bool (*domain_supported)(const void *owner, AttrDomain domain);
int (*domain_size)(const void *owner, AttrDomain domain);
bool (*is_builtin)(const void *owner, const AttributeIDRef &attribute_id);
GAttributeReader (*lookup)(const void *owner, const AttributeIDRef &attribute_id);
GVArray (*adapt_domain)(const void *owner,
const GVArray &varray,
eAttrDomain from_domain,
eAttrDomain to_domain);
AttrDomain from_domain,
AttrDomain to_domain);
bool (*for_all)(const void *owner,
FunctionRef<bool(const AttributeIDRef &, const AttributeMetaData &)> fn);
AttributeValidator (*lookup_validator)(const void *owner, const AttributeIDRef &attribute_id);
@ -406,7 +426,7 @@ struct AttributeAccessorFunctions {
bool (*remove)(void *owner, const AttributeIDRef &attribute_id);
bool (*add)(void *owner,
const AttributeIDRef &attribute_id,
eAttrDomain domain,
AttrDomain domain,
eCustomDataType data_type,
const AttributeInit &initializer);
};
@ -460,7 +480,7 @@ class AttributeAccessor {
/**
* \return True, when attributes can exist on that domain.
*/
bool domain_supported(const eAttrDomain domain) const
bool domain_supported(const AttrDomain domain) const
{
return fn_->domain_supported(owner_, domain);
}
@ -468,7 +488,7 @@ class AttributeAccessor {
/**
* \return Number of elements in the given domain.
*/
int domain_size(const eAttrDomain domain) const
int domain_size(const AttrDomain domain) const
{
return fn_->domain_size(owner_, domain);
}
@ -496,14 +516,14 @@ class AttributeAccessor {
* given domain, and converted to the given type, in that order. The result may be empty.
*/
GAttributeReader lookup(const AttributeIDRef &attribute_id,
const std::optional<eAttrDomain> domain,
const std::optional<AttrDomain> domain,
const std::optional<eCustomDataType> data_type) const;
/**
* Get read-only access to the attribute whereby the attribute is interpolated to the given
* domain. The result may be empty.
*/
GAttributeReader lookup(const AttributeIDRef &attribute_id, const eAttrDomain domain) const
GAttributeReader lookup(const AttributeIDRef &attribute_id, const AttrDomain domain) const
{
return this->lookup(attribute_id, domain, std::nullopt);
}
@ -524,7 +544,7 @@ class AttributeAccessor {
*/
template<typename T>
AttributeReader<T> lookup(const AttributeIDRef &attribute_id,
const std::optional<eAttrDomain> domain = std::nullopt) const
const std::optional<AttrDomain> domain = std::nullopt) const
{
const CPPType &cpp_type = CPPType::get<T>();
const eCustomDataType data_type = cpp_type_to_custom_data_type(cpp_type);
@ -538,7 +558,7 @@ class AttributeAccessor {
* If the passed in default value is null, the default value of the type is used (generally 0).
*/
GAttributeReader lookup_or_default(const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const eCustomDataType data_type,
const void *default_value = nullptr) const;
@ -547,7 +567,7 @@ class AttributeAccessor {
*/
template<typename T>
AttributeReader<T> lookup_or_default(const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const T &default_value) const
{
if (AttributeReader<T> varray = this->lookup<T>(attribute_id, domain)) {
@ -568,8 +588,8 @@ class AttributeAccessor {
* Interpolate data from one domain to another.
*/
GVArray adapt_domain(const GVArray &varray,
const eAttrDomain from_domain,
const eAttrDomain to_domain) const
const AttrDomain from_domain,
const AttrDomain to_domain) const
{
return fn_->adapt_domain(owner_, varray, from_domain, to_domain);
}
@ -579,8 +599,8 @@ class AttributeAccessor {
*/
template<typename T>
VArray<T> adapt_domain(const VArray<T> &varray,
const eAttrDomain from_domain,
const eAttrDomain to_domain) const
const AttrDomain from_domain,
const AttrDomain to_domain) const
{
return this->adapt_domain(GVArray(varray), from_domain, to_domain).typed<T>();
}
@ -665,7 +685,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
* this attribute or there is already an attribute with that id.
*/
bool add(const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const eCustomDataType data_type,
const AttributeInit &initializer)
{
@ -673,7 +693,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
}
template<typename T>
bool add(const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const AttributeInit &initializer)
{
const CPPType &cpp_type = CPPType::get<T>();
@ -688,7 +708,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
*/
GAttributeWriter lookup_or_add_for_write(
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const eCustomDataType data_type,
const AttributeInit &initializer = AttributeInitDefaultValue());
@ -699,7 +719,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
*/
GSpanAttributeWriter lookup_or_add_for_write_span(
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const eCustomDataType data_type,
const AttributeInit &initializer = AttributeInitDefaultValue());
@ -709,7 +729,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
template<typename T>
AttributeWriter<T> lookup_or_add_for_write(
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const AttributeInit &initializer = AttributeInitDefaultValue())
{
const CPPType &cpp_type = CPPType::get<T>();
@ -723,7 +743,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
template<typename T>
SpanAttributeWriter<T> lookup_or_add_for_write_span(
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const AttributeInit &initializer = AttributeInitDefaultValue())
{
AttributeWriter<T> attribute = this->lookup_or_add_for_write<T>(
@ -745,7 +765,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
* For trivial types, the values in a newly created attribute will not be initialized.
*/
GSpanAttributeWriter lookup_or_add_for_write_only_span(const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const eCustomDataType data_type);
/**
@ -753,7 +773,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
*/
template<typename T>
SpanAttributeWriter<T> lookup_or_add_for_write_only_span(const AttributeIDRef &attribute_id,
const eAttrDomain domain)
const AttrDomain domain)
{
AttributeWriter<T> attribute = this->lookup_or_add_for_write<T>(
attribute_id, domain, AttributeInitConstruct());
@ -793,7 +813,7 @@ struct AttributeTransferData {
Vector<AttributeTransferData> retrieve_attributes_for_transfer(
const AttributeAccessor src_attributes,
MutableAttributeAccessor dst_attributes,
eAttrDomainMask domain_mask,
AttrDomainMask domain_mask,
const AnonymousAttributePropagationInfo &propagation_info,
const Set<std::string> &skip = {});
@ -805,7 +825,7 @@ eCustomDataType attribute_data_type_highest_complexity(Span<eCustomDataType> dat
* Domains with a higher "information density" have a higher priority,
* in order to choose a domain that will not lose data through domain conversion.
*/
eAttrDomain attribute_domain_highest_priority(Span<eAttrDomain> domains);
AttrDomain attribute_domain_highest_priority(Span<AttrDomain> domains);
/* -------------------------------------------------------------------- */
/** \name #AttributeIDRef Inline Methods
@ -861,7 +881,7 @@ inline const AnonymousAttributeID &AttributeIDRef::anonymous_id() const
}
void gather_attributes(AttributeAccessor src_attributes,
eAttrDomain domain,
AttrDomain domain,
const AnonymousAttributePropagationInfo &propagation_info,
const Set<std::string> &skip,
const IndexMask &selection,
@ -871,7 +891,7 @@ void gather_attributes(AttributeAccessor src_attributes,
* Fill the destination attribute by gathering indexed values from src attributes.
*/
void gather_attributes(AttributeAccessor src_attributes,
eAttrDomain domain,
AttrDomain domain,
const AnonymousAttributePropagationInfo &propagation_info,
const Set<std::string> &skip,
Span<int> indices,
@ -883,7 +903,7 @@ void gather_attributes(AttributeAccessor src_attributes,
* source and result group must be the same.
*/
void gather_attributes_group_to_group(AttributeAccessor src_attributes,
eAttrDomain domain,
AttrDomain domain,
const AnonymousAttributePropagationInfo &propagation_info,
const Set<std::string> &skip,
OffsetIndices<int> src_offsets,
@ -892,7 +912,7 @@ void gather_attributes_group_to_group(AttributeAccessor src_attributes,
MutableAttributeAccessor dst_attributes);
void gather_attributes_to_groups(AttributeAccessor src_attributes,
eAttrDomain domain,
AttrDomain domain,
const AnonymousAttributePropagationInfo &propagation_info,
const Set<std::string> &skip,
OffsetIndices<int> dst_offsets,
@ -900,13 +920,13 @@ void gather_attributes_to_groups(AttributeAccessor src_attributes,
MutableAttributeAccessor dst_attributes);
void copy_attributes(const AttributeAccessor src_attributes,
const eAttrDomain domain,
const AttrDomain domain,
const AnonymousAttributePropagationInfo &propagation_info,
const Set<std::string> &skip,
MutableAttributeAccessor dst_attributes);
void copy_attributes_group_to_group(AttributeAccessor src_attributes,
eAttrDomain domain,
AttrDomain domain,
const AnonymousAttributePropagationInfo &propagation_info,
const Set<std::string> &skip,
OffsetIndices<int> src_offsets,
@ -915,7 +935,7 @@ void copy_attributes_group_to_group(AttributeAccessor src_attributes,
MutableAttributeAccessor dst_attributes);
void fill_attribute_range_default(MutableAttributeAccessor dst_attributes,
eAttrDomain domain,
AttrDomain domain,
const Set<std::string> &skip,
IndexRange range);

View File

@ -23,7 +23,7 @@ struct BakeSocketConfig {
* The domain on which an the attribute corresponding to the socket should be stored (only used
* for some socket types).
*/
Vector<eAttrDomain> domains;
Vector<AttrDomain> domains;
/**
* Determines which geometries a field socket should be evaluated on. This can be used to
* implement rules like a field should only be evaluated on the preceding or on all geometries.

View File

@ -394,9 +394,9 @@ class CurvesGeometry : public ::CurvesGeometry {
* Attributes.
*/
GVArray adapt_domain(const GVArray &varray, eAttrDomain from, eAttrDomain to) const;
GVArray adapt_domain(const GVArray &varray, AttrDomain from, AttrDomain to) const;
template<typename T>
VArray<T> adapt_domain(const VArray<T> &varray, eAttrDomain from, eAttrDomain to) const
VArray<T> adapt_domain(const VArray<T> &varray, AttrDomain from, AttrDomain to) const
{
return this->adapt_domain(GVArray(varray), from, to).typed<T>();
}

View File

@ -28,16 +28,16 @@ class Drawing;
class MeshFieldContext : public fn::FieldContext {
private:
const Mesh &mesh_;
eAttrDomain domain_;
AttrDomain domain_;
public:
MeshFieldContext(const Mesh &mesh, eAttrDomain domain);
MeshFieldContext(const Mesh &mesh, AttrDomain domain);
const Mesh &mesh() const
{
return mesh_;
}
eAttrDomain domain() const
AttrDomain domain() const
{
return domain_;
}
@ -46,17 +46,17 @@ class MeshFieldContext : public fn::FieldContext {
class CurvesFieldContext : public fn::FieldContext {
private:
const CurvesGeometry &curves_;
eAttrDomain domain_;
AttrDomain domain_;
public:
CurvesFieldContext(const CurvesGeometry &curves, eAttrDomain domain);
CurvesFieldContext(const CurvesGeometry &curves, AttrDomain domain);
const CurvesGeometry &curves() const
{
return curves_;
}
eAttrDomain domain() const
AttrDomain domain() const
{
return domain_;
}
@ -91,12 +91,12 @@ class GreasePencilFieldContext : public fn::FieldContext {
class GreasePencilLayerFieldContext : public fn::FieldContext {
private:
const GreasePencil &grease_pencil_;
eAttrDomain domain_;
AttrDomain domain_;
int layer_index_;
public:
GreasePencilLayerFieldContext(const GreasePencil &grease_pencil,
eAttrDomain domain,
AttrDomain domain,
int layer_index)
: grease_pencil_(grease_pencil), domain_(domain), layer_index_(layer_index)
{
@ -107,7 +107,7 @@ class GreasePencilLayerFieldContext : public fn::FieldContext {
return grease_pencil_;
}
eAttrDomain domain() const
AttrDomain domain() const
{
return domain_;
}
@ -148,7 +148,7 @@ class GeometryFieldContext : public fn::FieldContext {
*/
const void *geometry_;
const GeometryComponent::Type type_;
eAttrDomain domain_;
AttrDomain domain_;
/**
* Only used when the type is grease pencil and the domain is either points or curves
* (not layers).
@ -158,16 +158,16 @@ class GeometryFieldContext : public fn::FieldContext {
friend GeometryFieldInput;
public:
GeometryFieldContext(const GeometryFieldContext &other, eAttrDomain domain);
GeometryFieldContext(const GeometryComponent &component, eAttrDomain domain);
GeometryFieldContext(const GeometryFieldContext &other, AttrDomain domain);
GeometryFieldContext(const GeometryComponent &component, AttrDomain domain);
GeometryFieldContext(const void *geometry,
GeometryComponent::Type type,
eAttrDomain domain,
AttrDomain domain,
int grease_pencil_layer_index);
GeometryFieldContext(const Mesh &mesh, eAttrDomain domain);
GeometryFieldContext(const CurvesGeometry &curves, eAttrDomain domain);
GeometryFieldContext(const Mesh &mesh, AttrDomain domain);
GeometryFieldContext(const CurvesGeometry &curves, AttrDomain domain);
GeometryFieldContext(const GreasePencil &grease_pencil);
GeometryFieldContext(const GreasePencil &grease_pencil, eAttrDomain domain, int layer_index);
GeometryFieldContext(const GreasePencil &grease_pencil, AttrDomain domain, int layer_index);
GeometryFieldContext(const PointCloud &points);
GeometryFieldContext(const Instances &instances);
@ -181,7 +181,7 @@ class GeometryFieldContext : public fn::FieldContext {
return type_;
}
eAttrDomain domain() const
AttrDomain domain() const
{
return domain_;
}
@ -189,7 +189,7 @@ class GeometryFieldContext : public fn::FieldContext {
int grease_pencil_layer_index() const
{
BLI_assert(this->type_ == GeometryComponent::Type::GreasePencil);
BLI_assert(ELEM(this->domain_, ATTR_DOMAIN_LAYER, ATTR_DOMAIN_CURVE, ATTR_DOMAIN_POINT));
BLI_assert(ELEM(this->domain_, AttrDomain::Layer, AttrDomain::Curve, AttrDomain::Point));
return grease_pencil_layer_index_;
}
@ -211,7 +211,7 @@ class GeometryFieldInput : public fn::FieldInput {
ResourceScope &scope) const override;
virtual GVArray get_varray_for_context(const GeometryFieldContext &context,
const IndexMask &mask) const = 0;
virtual std::optional<eAttrDomain> preferred_domain(const GeometryComponent &component) const;
virtual std::optional<AttrDomain> preferred_domain(const GeometryComponent &component) const;
};
class MeshFieldInput : public fn::FieldInput {
@ -221,9 +221,9 @@ class MeshFieldInput : public fn::FieldInput {
const IndexMask &mask,
ResourceScope &scope) const override;
virtual GVArray get_varray_for_context(const Mesh &mesh,
eAttrDomain domain,
AttrDomain domain,
const IndexMask &mask) const = 0;
virtual std::optional<eAttrDomain> preferred_domain(const Mesh &mesh) const;
virtual std::optional<AttrDomain> preferred_domain(const Mesh &mesh) const;
};
class CurvesFieldInput : public fn::FieldInput {
@ -233,9 +233,9 @@ class CurvesFieldInput : public fn::FieldInput {
const IndexMask &mask,
ResourceScope &scope) const override;
virtual GVArray get_varray_for_context(const CurvesGeometry &curves,
eAttrDomain domain,
AttrDomain domain,
const IndexMask &mask) const = 0;
virtual std::optional<eAttrDomain> preferred_domain(const CurvesGeometry &curves) const;
virtual std::optional<AttrDomain> preferred_domain(const CurvesGeometry &curves) const;
};
class PointCloudFieldInput : public fn::FieldInput {
@ -291,7 +291,7 @@ class AttributeFieldInput : public GeometryFieldInput {
uint64_t hash() const override;
bool is_equal_to(const fn::FieldNode &other) const override;
std::optional<eAttrDomain> preferred_domain(const GeometryComponent &component) const override;
std::optional<AttrDomain> preferred_domain(const GeometryComponent &component) const override;
};
class AttributeExistsFieldInput final : public bke::GeometryFieldInput {
@ -332,7 +332,7 @@ class NamedLayerSelectionFieldInput final : public bke::GeometryFieldInput {
const IndexMask &mask) const final;
uint64_t hash() const override;
bool is_equal_to(const fn::FieldNode &other) const override;
std::optional<eAttrDomain> preferred_domain(const GeometryComponent &component) const override;
std::optional<AttrDomain> preferred_domain(const GeometryComponent &component) const override;
};
class IDAttributeFieldInput : public GeometryFieldInput {
@ -351,9 +351,9 @@ class IDAttributeFieldInput : public GeometryFieldInput {
bool is_equal_to(const fn::FieldNode &other) const override;
};
VArray<float3> curve_normals_varray(const CurvesGeometry &curves, eAttrDomain domain);
VArray<float3> curve_normals_varray(const CurvesGeometry &curves, AttrDomain domain);
VArray<float3> mesh_normals_varray(const Mesh &mesh, const IndexMask &mask, eAttrDomain domain);
VArray<float3> mesh_normals_varray(const Mesh &mesh, const IndexMask &mask, AttrDomain domain);
class NormalFieldInput : public GeometryFieldInput {
public:
@ -408,28 +408,28 @@ class AnonymousAttributeFieldInput : public GeometryFieldInput {
uint64_t hash() const override;
bool is_equal_to(const fn::FieldNode &other) const override;
std::optional<eAttrDomain> preferred_domain(const GeometryComponent &component) const override;
std::optional<AttrDomain> preferred_domain(const GeometryComponent &component) const override;
};
class CurveLengthFieldInput final : public CurvesFieldInput {
public:
CurveLengthFieldInput();
GVArray get_varray_for_context(const CurvesGeometry &curves,
eAttrDomain domain,
AttrDomain domain,
const IndexMask &mask) const final;
uint64_t hash() const override;
bool is_equal_to(const fn::FieldNode &other) const override;
std::optional<eAttrDomain> preferred_domain(const bke::CurvesGeometry &curves) const final;
std::optional<AttrDomain> preferred_domain(const bke::CurvesGeometry &curves) const final;
};
bool try_capture_field_on_geometry(GeometryComponent &component,
const AttributeIDRef &attribute_id,
eAttrDomain domain,
AttrDomain domain,
const fn::GField &field);
bool try_capture_field_on_geometry(GeometryComponent &component,
const AttributeIDRef &attribute_id,
eAttrDomain domain,
AttrDomain domain,
const fn::Field<bool> &selection,
const fn::GField &field);
@ -437,7 +437,7 @@ bool try_capture_field_on_geometry(GeometryComponent &component,
* Try to find the geometry domain that the field should be evaluated on. If it is not obvious
* which domain is correct, none is returned.
*/
std::optional<eAttrDomain> try_detect_field_domain(const GeometryComponent &component,
std::optional<AttrDomain> try_detect_field_domain(const GeometryComponent &component,
const fn::GField &field);
} // namespace blender::bke

View File

@ -78,7 +78,7 @@ class GeometryComponent : public ImplicitSharingMixin {
virtual ~GeometryComponent() = default;
static GeometryComponentPtr create(Type component_type);
int attribute_domain_size(eAttrDomain domain) const;
int attribute_domain_size(AttrDomain domain) const;
/**
* Get access to the attributes in this geometry component. May return none if the geometry does

View File

@ -178,7 +178,7 @@ class BaryWeightSampleFn : public mf::MultiFunction {
std::optional<bke::MeshFieldContext> source_context_;
std::unique_ptr<fn::FieldEvaluator> source_evaluator_;
const GVArray *source_data_;
eAttrDomain domain_;
AttrDomain domain_;
public:
BaryWeightSampleFn(GeometrySet geometry, fn::GField src_field);

View File

@ -493,7 +493,7 @@ struct SculptAttributeParams {
struct SculptAttribute {
/* Domain, data type and name */
eAttrDomain domain;
blender::bke::AttrDomain domain;
eCustomDataType proptype;
char name[MAX_CUSTOMDATA_LAYER_NAME];
@ -580,7 +580,7 @@ struct SculptSession {
MPropCol *vcol;
MLoopCol *mcol;
eAttrDomain vcol_domain;
blender::bke::AttrDomain vcol_domain;
eCustomDataType vcol_type;
/* Mesh connectivity maps. */
@ -762,14 +762,14 @@ int BKE_sculptsession_vertex_count(const SculptSession *ss);
/* Ensure an attribute layer exists. */
SculptAttribute *BKE_sculpt_attribute_ensure(Object *ob,
eAttrDomain domain,
blender::bke::AttrDomain domain,
eCustomDataType proptype,
const char *name,
const SculptAttributeParams *params);
/* Returns nullptr if attribute does not exist. */
SculptAttribute *BKE_sculpt_attribute_get(Object *ob,
eAttrDomain domain,
blender::bke::AttrDomain domain,
eCustomDataType proptype,
const char *name);

View File

@ -528,7 +528,9 @@ blender::Span<blender::float3> BKE_pbvh_get_vert_normals(const PBVH *pbvh);
PBVHColorBufferNode *BKE_pbvh_node_color_buffer_get(PBVHNode *node);
void BKE_pbvh_node_color_buffer_free(PBVH *pbvh);
bool BKE_pbvh_get_color_layer(Mesh *mesh, CustomDataLayer **r_layer, eAttrDomain *r_domain);
bool BKE_pbvh_get_color_layer(Mesh *mesh,
CustomDataLayer **r_layer,
blender::bke::AttrDomain *r_domain);
/* Swaps colors at each element in indices (of domain pbvh->vcol_domain)
* with values in colors. */

View File

@ -537,13 +537,13 @@ static void set_rest_position(Mesh &mesh)
if (positions) {
if (positions.sharing_info && positions.varray.is_span()) {
attributes.add<float3>("rest_position",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
AttributeInitShared(positions.varray.get_internal_span().data(),
*positions.sharing_info));
}
else {
attributes.add<float3>(
"rest_position", ATTR_DOMAIN_POINT, AttributeInitVArray(positions.varray));
"rest_position", AttrDomain::Point, AttributeInitVArray(positions.varray));
}
}
}

View File

@ -39,6 +39,7 @@
#include "RNA_access.hh"
using blender::IndexRange;
using blender::bke::AttrDomain;
struct DomainInfo {
CustomData *customdata;
@ -52,8 +53,8 @@ static void get_domains(const ID *id, DomainInfo info[ATTR_DOMAIN_NUM])
switch (GS(id->name)) {
case ID_PT: {
PointCloud *pointcloud = (PointCloud *)id;
info[ATTR_DOMAIN_POINT].customdata = &pointcloud->pdata;
info[ATTR_DOMAIN_POINT].length = pointcloud->totpoint;
info[int(AttrDomain::Point)].customdata = &pointcloud->pdata;
info[int(AttrDomain::Point)].length = pointcloud->totpoint;
break;
}
case ID_ME: {
@ -61,39 +62,39 @@ static void get_domains(const ID *id, DomainInfo info[ATTR_DOMAIN_NUM])
BMEditMesh *em = mesh->edit_mesh;
if (em != nullptr) {
BMesh *bm = em->bm;
info[ATTR_DOMAIN_POINT].customdata = &bm->vdata;
info[ATTR_DOMAIN_POINT].length = bm->totvert;
info[ATTR_DOMAIN_EDGE].customdata = &bm->edata;
info[ATTR_DOMAIN_EDGE].length = bm->totedge;
info[ATTR_DOMAIN_CORNER].customdata = &bm->ldata;
info[ATTR_DOMAIN_CORNER].length = bm->totloop;
info[ATTR_DOMAIN_FACE].customdata = &bm->pdata;
info[ATTR_DOMAIN_FACE].length = bm->totface;
info[int(AttrDomain::Point)].customdata = &bm->vdata;
info[int(AttrDomain::Point)].length = bm->totvert;
info[int(AttrDomain::Edge)].customdata = &bm->edata;
info[int(AttrDomain::Edge)].length = bm->totedge;
info[int(AttrDomain::Corner)].customdata = &bm->ldata;
info[int(AttrDomain::Corner)].length = bm->totloop;
info[int(AttrDomain::Face)].customdata = &bm->pdata;
info[int(AttrDomain::Face)].length = bm->totface;
}
else {
info[ATTR_DOMAIN_POINT].customdata = &mesh->vert_data;
info[ATTR_DOMAIN_POINT].length = mesh->verts_num;
info[ATTR_DOMAIN_EDGE].customdata = &mesh->edge_data;
info[ATTR_DOMAIN_EDGE].length = mesh->edges_num;
info[ATTR_DOMAIN_CORNER].customdata = &mesh->corner_data;
info[ATTR_DOMAIN_CORNER].length = mesh->corners_num;
info[ATTR_DOMAIN_FACE].customdata = &mesh->face_data;
info[ATTR_DOMAIN_FACE].length = mesh->faces_num;
info[int(AttrDomain::Point)].customdata = &mesh->vert_data;
info[int(AttrDomain::Point)].length = mesh->verts_num;
info[int(AttrDomain::Edge)].customdata = &mesh->edge_data;
info[int(AttrDomain::Edge)].length = mesh->edges_num;
info[int(AttrDomain::Corner)].customdata = &mesh->corner_data;
info[int(AttrDomain::Corner)].length = mesh->corners_num;
info[int(AttrDomain::Face)].customdata = &mesh->face_data;
info[int(AttrDomain::Face)].length = mesh->faces_num;
}
break;
}
case ID_CV: {
Curves *curves = (Curves *)id;
info[ATTR_DOMAIN_POINT].customdata = &curves->geometry.point_data;
info[ATTR_DOMAIN_POINT].length = curves->geometry.point_num;
info[ATTR_DOMAIN_CURVE].customdata = &curves->geometry.curve_data;
info[ATTR_DOMAIN_CURVE].length = curves->geometry.curve_num;
info[int(AttrDomain::Point)].customdata = &curves->geometry.point_data;
info[int(AttrDomain::Point)].length = curves->geometry.point_num;
info[int(AttrDomain::Curve)].customdata = &curves->geometry.curve_data;
info[int(AttrDomain::Curve)].length = curves->geometry.curve_num;
break;
}
case ID_GP: {
GreasePencil *grease_pencil = (GreasePencil *)id;
info[ATTR_DOMAIN_LAYER].customdata = &grease_pencil->layers_data;
info[ATTR_DOMAIN_LAYER].length = grease_pencil->layers().size();
info[int(AttrDomain::Layer)].customdata = &grease_pencil->layers_data;
info[int(AttrDomain::Layer)].length = grease_pencil->layers().size();
break;
}
default:
@ -279,14 +280,14 @@ void BKE_id_attribute_calc_unique_name(ID *id, const char *name, char *outname)
CustomDataLayer *BKE_id_attribute_new(ID *id,
const char *name,
const eCustomDataType type,
const eAttrDomain domain,
const AttrDomain domain,
ReportList *reports)
{
using namespace blender::bke;
DomainInfo info[ATTR_DOMAIN_NUM];
get_domains(id, info);
CustomData *customdata = info[domain].customdata;
CustomData *customdata = info[int(domain)].customdata;
if (customdata == nullptr) {
BKE_report(reports, RPT_ERROR, "Attribute domain not supported by this geometry type");
return nullptr;
@ -453,7 +454,7 @@ bool BKE_id_attribute_remove(ID *id, const char *name, ReportList *reports)
id, color_name_from_index(id, color_clamp_index(id, default_color_index)));
}
if (type == CD_PROP_FLOAT2 && domain == ATTR_DOMAIN_CORNER) {
if (type == CD_PROP_FLOAT2 && domain == int(AttrDomain::Corner)) {
char buffer[MAX_CUSTOMDATA_LAYER_NAME];
BM_data_layer_free_named(
em->bm, data, BKE_uv_map_vert_select_name_get(name_copy.c_str(), buffer));
@ -501,7 +502,7 @@ bool BKE_id_attribute_remove(ID *id, const char *name, ReportList *reports)
id, color_name_from_index(id, color_clamp_index(id, default_color_index)));
}
if (metadata->data_type == CD_PROP_FLOAT2 && metadata->domain == ATTR_DOMAIN_CORNER) {
if (metadata->data_type == CD_PROP_FLOAT2 && metadata->domain == AttrDomain::Corner) {
char buffer[MAX_CUSTOMDATA_LAYER_NAME];
attributes->remove(BKE_uv_map_vert_select_name_get(name_copy.c_str(), buffer));
attributes->remove(BKE_uv_map_edge_select_name_get(name_copy.c_str(), buffer));
@ -516,7 +517,7 @@ bool BKE_id_attribute_remove(ID *id, const char *name, ReportList *reports)
CustomDataLayer *BKE_id_attribute_find(const ID *id,
const char *name,
const eCustomDataType type,
const eAttrDomain domain)
const AttrDomain domain)
{
if (!name) {
return nullptr;
@ -524,7 +525,7 @@ CustomDataLayer *BKE_id_attribute_find(const ID *id,
DomainInfo info[ATTR_DOMAIN_NUM];
get_domains(id, info);
CustomData *customdata = info[domain].customdata;
CustomData *customdata = info[int(domain)].customdata;
if (customdata == nullptr) {
return nullptr;
}
@ -542,7 +543,7 @@ CustomDataLayer *BKE_id_attribute_find(const ID *id,
const CustomDataLayer *BKE_id_attribute_search(const ID *id,
const char *name,
const eCustomDataMask type_mask,
const eAttrDomainMask domain_mask)
const AttrDomainMask domain_mask)
{
if (!name) {
return nullptr;
@ -550,14 +551,14 @@ const CustomDataLayer *BKE_id_attribute_search(const ID *id,
DomainInfo info[ATTR_DOMAIN_NUM];
get_domains(id, info);
for (eAttrDomain domain = ATTR_DOMAIN_POINT; domain < ATTR_DOMAIN_NUM;
domain = static_cast<eAttrDomain>(int(domain) + 1))
for (AttrDomain domain = AttrDomain::Point; int(domain) < ATTR_DOMAIN_NUM;
domain = AttrDomain(int(domain) + 1))
{
if (!(domain_mask & ATTR_DOMAIN_AS_MASK(domain))) {
continue;
}
CustomData *customdata = info[domain].customdata;
CustomData *customdata = info[int(domain)].customdata;
if (customdata == nullptr) {
continue;
}
@ -576,7 +577,7 @@ const CustomDataLayer *BKE_id_attribute_search(const ID *id,
CustomDataLayer *BKE_id_attribute_search_for_write(ID *id,
const char *name,
const eCustomDataMask type_mask,
const eAttrDomainMask domain_mask)
const AttrDomainMask domain_mask)
{
/* Reuse the implementation of the const version.
* Implicit sharing for the layer's data is handled below. */
@ -589,13 +590,13 @@ CustomDataLayer *BKE_id_attribute_search_for_write(ID *id,
DomainInfo info[ATTR_DOMAIN_NUM];
get_domains(id, info);
const eAttrDomain domain = BKE_id_attribute_domain(id, layer);
CustomData_ensure_data_is_mutable(layer, info[domain].length);
const AttrDomain domain = BKE_id_attribute_domain(id, layer);
CustomData_ensure_data_is_mutable(layer, info[int(domain)].length);
return layer;
}
int BKE_id_attributes_length(const ID *id, eAttrDomainMask domain_mask, eCustomDataMask mask)
int BKE_id_attributes_length(const ID *id, AttrDomainMask domain_mask, eCustomDataMask mask)
{
DomainInfo info[ATTR_DOMAIN_NUM];
get_domains(id, info);
@ -616,7 +617,7 @@ int BKE_id_attributes_length(const ID *id, eAttrDomainMask domain_mask, eCustomD
return length;
}
eAttrDomain BKE_id_attribute_domain(const ID *id, const CustomDataLayer *layer)
AttrDomain BKE_id_attribute_domain(const ID *id, const CustomDataLayer *layer)
{
DomainInfo info[ATTR_DOMAIN_NUM];
get_domains(id, info);
@ -627,12 +628,12 @@ eAttrDomain BKE_id_attribute_domain(const ID *id, const CustomDataLayer *layer)
continue;
}
if (ARRAY_HAS_ITEM((CustomDataLayer *)layer, customdata->layers, customdata->totlayer)) {
return static_cast<eAttrDomain>(domain);
return AttrDomain(domain);
}
}
BLI_assert_msg(0, "Custom data layer not found in geometry");
return static_cast<eAttrDomain>(ATTR_DOMAIN_POINT);
return AttrDomain(AttrDomain::Point);
}
int BKE_id_attribute_data_length(ID *id, CustomDataLayer *layer)
@ -774,7 +775,7 @@ CustomData *BKE_id_attributes_iterator_next_domain(ID *id, CustomDataLayer *laye
CustomDataLayer *BKE_id_attribute_from_index(ID *id,
int lookup_index,
eAttrDomainMask domain_mask,
AttrDomainMask domain_mask,
eCustomDataMask layer_mask)
{
DomainInfo info[ATTR_DOMAIN_NUM];
@ -808,7 +809,7 @@ CustomDataLayer *BKE_id_attribute_from_index(ID *id,
int BKE_id_attribute_to_index(const ID *id,
const CustomDataLayer *layer,
eAttrDomainMask domain_mask,
AttrDomainMask domain_mask,
eCustomDataMask layer_mask)
{
if (!layer) {

View File

@ -132,22 +132,22 @@ eCustomDataType attribute_data_type_highest_complexity(Span<eCustomDataType> dat
* \note Generally the order should mirror the order of the domains
* established in each component's ComponentAttributeProviders.
*/
static int attribute_domain_priority(const eAttrDomain domain)
static int attribute_domain_priority(const AttrDomain domain)
{
switch (domain) {
case ATTR_DOMAIN_INSTANCE:
case AttrDomain::Instance:
return 0;
case ATTR_DOMAIN_LAYER:
case AttrDomain::Layer:
return 1;
case ATTR_DOMAIN_CURVE:
case AttrDomain::Curve:
return 2;
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
return 3;
case ATTR_DOMAIN_EDGE:
case AttrDomain::Edge:
return 4;
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
return 5;
case ATTR_DOMAIN_CORNER:
case AttrDomain::Corner:
return 6;
default:
/* Domain not supported in nodes yet. */
@ -156,12 +156,12 @@ static int attribute_domain_priority(const eAttrDomain domain)
}
}
eAttrDomain attribute_domain_highest_priority(Span<eAttrDomain> domains)
AttrDomain attribute_domain_highest_priority(Span<AttrDomain> domains)
{
int highest_priority = INT_MIN;
eAttrDomain highest_priority_domain = ATTR_DOMAIN_CORNER;
AttrDomain highest_priority_domain = AttrDomain::Corner;
for (const eAttrDomain domain : domains) {
for (const AttrDomain domain : domains) {
const int priority = attribute_domain_priority(domain);
if (priority > highest_priority) {
highest_priority = priority;
@ -539,7 +539,7 @@ bool CustomDataAttributeProvider::try_delete(void *owner, const AttributeIDRef &
bool CustomDataAttributeProvider::try_create(void *owner,
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const eCustomDataType data_type,
const AttributeInit &initializer) const
{
@ -595,7 +595,7 @@ static GVArray try_adapt_data_type(GVArray varray, const CPPType &to_type)
}
GAttributeReader AttributeAccessor::lookup(const AttributeIDRef &attribute_id,
const std::optional<eAttrDomain> domain,
const std::optional<AttrDomain> domain,
const std::optional<eCustomDataType> data_type) const
{
GAttributeReader attribute = this->lookup(attribute_id);
@ -626,7 +626,7 @@ GAttributeReader AttributeAccessor::lookup(const AttributeIDRef &attribute_id,
}
GAttributeReader AttributeAccessor::lookup_or_default(const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const eCustomDataType data_type,
const void *default_value) const
{
@ -716,7 +716,7 @@ GSpanAttributeWriter MutableAttributeAccessor::lookup_for_write_span(
GAttributeWriter MutableAttributeAccessor::lookup_or_add_for_write(
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const eCustomDataType data_type,
const AttributeInit &initializer)
{
@ -735,7 +735,7 @@ GAttributeWriter MutableAttributeAccessor::lookup_or_add_for_write(
GSpanAttributeWriter MutableAttributeAccessor::lookup_or_add_for_write_span(
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const eCustomDataType data_type,
const AttributeInit &initializer)
{
@ -748,7 +748,7 @@ GSpanAttributeWriter MutableAttributeAccessor::lookup_or_add_for_write_span(
}
GSpanAttributeWriter MutableAttributeAccessor::lookup_or_add_for_write_only_span(
const AttributeIDRef &attribute_id, const eAttrDomain domain, const eCustomDataType data_type)
const AttributeIDRef &attribute_id, const AttrDomain domain, const eCustomDataType data_type)
{
GAttributeWriter attribute = this->lookup_or_add_for_write(
attribute_id, domain, data_type, AttributeInitConstruct());
@ -807,7 +807,7 @@ fn::GField AttributeValidator::validate_field_if_necessary(const fn::GField &fie
Vector<AttributeTransferData> retrieve_attributes_for_transfer(
const AttributeAccessor src_attributes,
MutableAttributeAccessor dst_attributes,
const eAttrDomainMask domain_mask,
const AttrDomainMask domain_mask,
const AnonymousAttributePropagationInfo &propagation_info,
const Set<std::string> &skip)
{
@ -836,7 +836,7 @@ Vector<AttributeTransferData> retrieve_attributes_for_transfer(
/** \} */
void gather_attributes(const AttributeAccessor src_attributes,
const eAttrDomain domain,
const AttrDomain domain,
const AnonymousAttributePropagationInfo &propagation_info,
const Set<std::string> &skip,
const IndexMask &selection,
@ -895,7 +895,7 @@ static bool indices_are_range(const Span<int> indices, const IndexRange range)
}
void gather_attributes(const AttributeAccessor src_attributes,
const eAttrDomain domain,
const AttrDomain domain,
const AnonymousAttributePropagationInfo &propagation_info,
const Set<std::string> &skip,
const Span<int> indices,
@ -929,7 +929,7 @@ void gather_attributes(const AttributeAccessor src_attributes,
}
void gather_attributes_group_to_group(const AttributeAccessor src_attributes,
const eAttrDomain domain,
const AttrDomain domain,
const AnonymousAttributePropagationInfo &propagation_info,
const Set<std::string> &skip,
const OffsetIndices<int> src_offsets,
@ -960,7 +960,7 @@ void gather_attributes_group_to_group(const AttributeAccessor src_attributes,
}
void gather_attributes_to_groups(const AttributeAccessor src_attributes,
const eAttrDomain domain,
const AttrDomain domain,
const AnonymousAttributePropagationInfo &propagation_info,
const Set<std::string> &skip,
const OffsetIndices<int> dst_offsets,
@ -990,7 +990,7 @@ void gather_attributes_to_groups(const AttributeAccessor src_attributes,
}
void copy_attributes(const AttributeAccessor src_attributes,
const eAttrDomain domain,
const AttrDomain domain,
const AnonymousAttributePropagationInfo &propagation_info,
const Set<std::string> &skip,
MutableAttributeAccessor dst_attributes)
@ -1005,7 +1005,7 @@ void copy_attributes(const AttributeAccessor src_attributes,
}
void copy_attributes_group_to_group(const AttributeAccessor src_attributes,
const eAttrDomain domain,
const AttrDomain domain,
const AnonymousAttributePropagationInfo &propagation_info,
const Set<std::string> &skip,
const OffsetIndices<int> src_offsets,
@ -1039,7 +1039,7 @@ void copy_attributes_group_to_group(const AttributeAccessor src_attributes,
}
void fill_attribute_range_default(MutableAttributeAccessor attributes,
const eAttrDomain domain,
const AttrDomain domain,
const Set<std::string> &skip,
const IndexRange range)
{

View File

@ -46,7 +46,7 @@ class BuiltinAttributeProvider {
protected:
const std::string name_;
const eAttrDomain domain_;
const AttrDomain domain_;
const eCustomDataType data_type_;
const CreatableEnum createable_;
const DeletableEnum deletable_;
@ -54,7 +54,7 @@ class BuiltinAttributeProvider {
public:
BuiltinAttributeProvider(std::string name,
const eAttrDomain domain,
const AttrDomain domain,
const eCustomDataType data_type,
const CreatableEnum createable,
const DeletableEnum deletable,
@ -79,7 +79,7 @@ class BuiltinAttributeProvider {
return name_;
}
eAttrDomain domain() const
AttrDomain domain() const
{
return domain_;
}
@ -108,7 +108,7 @@ class DynamicAttributesProvider {
virtual bool try_delete(void *owner, const AttributeIDRef &attribute_id) const = 0;
virtual bool try_create(void *owner,
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const eCustomDataType data_type,
const AttributeInit &initializer) const
{
@ -119,7 +119,7 @@ class DynamicAttributesProvider {
virtual bool foreach_attribute(const void *owner,
const AttributeForeachCallback callback) const = 0;
virtual void foreach_domain(const FunctionRef<void(eAttrDomain)> callback) const = 0;
virtual void foreach_domain(const FunctionRef<void(AttrDomain)> callback) const = 0;
};
/**
@ -128,11 +128,11 @@ class DynamicAttributesProvider {
class CustomDataAttributeProvider final : public DynamicAttributesProvider {
private:
static constexpr uint64_t supported_types_mask = CD_MASK_PROP_ALL;
eAttrDomain domain_;
AttrDomain domain_;
CustomDataAccessInfo custom_data_access_;
public:
CustomDataAttributeProvider(const eAttrDomain domain,
CustomDataAttributeProvider(const AttrDomain domain,
const CustomDataAccessInfo custom_data_access)
: domain_(domain), custom_data_access_(custom_data_access)
{
@ -147,13 +147,13 @@ class CustomDataAttributeProvider final : public DynamicAttributesProvider {
bool try_create(void *owner,
const AttributeIDRef &attribute_id,
eAttrDomain domain,
AttrDomain domain,
const eCustomDataType data_type,
const AttributeInit &initializer) const final;
bool foreach_attribute(const void *owner, const AttributeForeachCallback callback) const final;
void foreach_domain(const FunctionRef<void(eAttrDomain)> callback) const final
void foreach_domain(const FunctionRef<void(AttrDomain)> callback) const final
{
callback(domain_);
}
@ -181,7 +181,7 @@ class BuiltinCustomDataLayerProvider final : public BuiltinAttributeProvider {
public:
BuiltinCustomDataLayerProvider(std::string attribute_name,
const eAttrDomain domain,
const AttrDomain domain,
const eCustomDataType attribute_type,
const eCustomDataType stored_type,
const CreatableEnum creatable,
@ -229,7 +229,7 @@ class ComponentAttributeProviders {
/**
* All the domains that are supported by at least one of the providers above.
*/
VectorSet<eAttrDomain> supported_domains_;
VectorSet<AttrDomain> supported_domains_;
public:
ComponentAttributeProviders(Span<const BuiltinAttributeProvider *> builtin_attribute_providers,
@ -242,7 +242,7 @@ class ComponentAttributeProviders {
supported_domains_.add(provider->domain());
}
for (const DynamicAttributesProvider *provider : dynamic_attribute_providers) {
provider->foreach_domain([&](eAttrDomain domain) { supported_domains_.add(domain); });
provider->foreach_domain([&](AttrDomain domain) { supported_domains_.add(domain); });
}
}
@ -256,7 +256,7 @@ class ComponentAttributeProviders {
return dynamic_attribute_providers_;
}
Span<eAttrDomain> supported_domains() const
Span<AttrDomain> supported_domains() const
{
return supported_domains_;
}
@ -414,7 +414,7 @@ inline bool remove(void *owner, const AttributeIDRef &attribute_id)
template<const ComponentAttributeProviders &providers>
inline bool add(void *owner,
const AttributeIDRef &attribute_id,
eAttrDomain domain,
AttrDomain domain,
eCustomDataType data_type,
const AttributeInit &initializer)
{

View File

@ -161,10 +161,10 @@ static StringRefNull get_endian_io_name(const int endian)
return "big";
}
static StringRefNull get_domain_io_name(const eAttrDomain domain)
static StringRefNull get_domain_io_name(const AttrDomain domain)
{
const char *io_name = "unknown";
RNA_enum_id_from_value(rna_enum_attribute_domain_items, domain, &io_name);
RNA_enum_id_from_value(rna_enum_attribute_domain_items, int(domain), &io_name);
return io_name;
}
@ -175,13 +175,13 @@ static StringRefNull get_data_type_io_name(const eCustomDataType data_type)
return io_name;
}
static std::optional<eAttrDomain> get_domain_from_io_name(const StringRefNull io_name)
static std::optional<AttrDomain> get_domain_from_io_name(const StringRefNull io_name)
{
int domain;
if (!RNA_enum_value_from_identifier(rna_enum_attribute_domain_items, io_name.c_str(), &domain)) {
return std::nullopt;
}
return eAttrDomain(domain);
return AttrDomain(domain);
}
static std::optional<eCustomDataType> get_data_type_from_io_name(const StringRefNull io_name)
@ -382,7 +382,7 @@ template<typename T>
return false;
}
const std::optional<eAttrDomain> domain = get_domain_from_io_name(*domain_str);
const std::optional<AttrDomain> domain = get_domain_from_io_name(*domain_str);
const std::optional<eCustomDataType> data_type = get_data_type_from_io_name(*type_str);
if (!domain || !data_type) {
return false;

View File

@ -61,7 +61,7 @@ Array<std::unique_ptr<BakeItem>> move_socket_values_to_bake_items(const Span<voi
auto &value_variant = *static_cast<SocketValueVariant *>(socket_value);
if (value_variant.is_context_dependent_field()) {
const fn::GField &field = value_variant.get<fn::GField>();
const eAttrDomain domain = config.domains[i];
const AttrDomain domain = config.domains[i];
const std::string attribute_name = ".bake_" + std::to_string(i);
const Span<int> geometry_indices = config.geometries_by_attribute[i];
for (const int geometry_i : geometry_indices) {

View File

@ -1122,6 +1122,8 @@ BVHTree *BKE_bvhtree_from_mesh_get(BVHTreeFromMesh *data,
const BVHCacheType bvh_cache_type,
const int tree_type)
{
using namespace blender;
using namespace blender::bke;
BVHCache **bvh_cache_p = (BVHCache **)&mesh->runtime->bvh_cache;
Span<int3> corner_tris;
@ -1196,7 +1198,7 @@ BVHTree *BKE_bvhtree_from_mesh_get(BVHTreeFromMesh *data,
int mask_bits_act_len = -1;
const BitVector<> mask = corner_tris_no_hidden_map_get(
mesh->faces(),
*attributes.lookup_or_default(".hide_poly", ATTR_DOMAIN_FACE, false),
*attributes.lookup_or_default(".hide_poly", AttrDomain::Face, false),
corner_tris.size(),
&mask_bits_act_len);
data->tree = bvhtree_from_mesh_corner_tris_create_tree(

View File

@ -116,7 +116,7 @@ Curves *curve_legacy_to_curves(const Curve &curve_legacy, const ListBase &nurbs_
const OffsetIndices points_by_curve = curves.points_by_curve();
MutableSpan<float3> positions = curves.positions_for_write();
SpanAttributeWriter<float> radius_attribute =
curves_attributes.lookup_or_add_for_write_only_span<float>("radius", ATTR_DOMAIN_POINT);
curves_attributes.lookup_or_add_for_write_only_span<float>("radius", AttrDomain::Point);
MutableSpan<float> radii = radius_attribute.span;
MutableSpan<float> tilts = curves.tilt_for_write();

View File

@ -334,17 +334,17 @@ static ResultOffsets calculate_result_offsets(const CurvesInfo &info, const bool
return result;
}
static eAttrDomain get_attribute_domain_for_mesh(const AttributeAccessor &mesh_attributes,
static AttrDomain get_attribute_domain_for_mesh(const AttributeAccessor &mesh_attributes,
const AttributeIDRef &attribute_id)
{
/* Only use a different domain if it is builtin and must only exist on one domain. */
if (!mesh_attributes.is_builtin(attribute_id)) {
return ATTR_DOMAIN_POINT;
return AttrDomain::Point;
}
std::optional<AttributeMetaData> meta_data = mesh_attributes.lookup_meta_data(attribute_id);
if (!meta_data) {
return ATTR_DOMAIN_POINT;
return AttrDomain::Point;
}
return meta_data->domain;
@ -461,14 +461,14 @@ static void build_mesh_positions(const CurvesInfo &curves_info,
const GAttributeReader src = curves_info.main.attributes().lookup("position");
if (src.sharing_info && src.varray.is_span()) {
const AttributeInitShared init(src.varray.get_internal_span().data(), *src.sharing_info);
if (mesh.attributes_for_write().add<float3>("position", ATTR_DOMAIN_POINT, init)) {
if (mesh.attributes_for_write().add<float3>("position", AttrDomain::Point, init)) {
return;
}
}
}
}
const Span<float3> main_positions = curves_info.main.evaluated_positions();
mesh.attributes_for_write().add<float3>("position", ATTR_DOMAIN_POINT, AttributeInitConstruct());
mesh.attributes_for_write().add<float3>("position", AttrDomain::Point, AttributeInitConstruct());
MutableSpan<float3> positions = mesh.vert_positions_for_write();
if (ignore_profile_position) {
array_utils::copy(main_positions, positions);
@ -477,7 +477,7 @@ static void build_mesh_positions(const CurvesInfo &curves_info,
const Span<float3> tangents = curves_info.main.evaluated_tangents();
const Span<float3> normals = curves_info.main.evaluated_normals();
Span<float> radii_eval = {};
if (const GVArray radii = *curves_info.main.attributes().lookup("radius", ATTR_DOMAIN_POINT)) {
if (const GVArray radii = *curves_info.main.attributes().lookup("radius", AttrDomain::Point)) {
radii_eval = evaluate_attribute(radii, curves_info.main, eval_buffer).typed<float>();
}
foreach_curve_combination(curves_info, offsets, [&](const CombinationInfo &info) {
@ -534,7 +534,7 @@ static bool try_sharing_point_data(const CurvesGeometry &main,
const GAttributeReader &src,
MutableAttributeAccessor mesh_attributes)
{
if (mesh_attributes.domain_size(ATTR_DOMAIN_POINT) != main.points_num()) {
if (mesh_attributes.domain_size(AttrDomain::Point) != main.points_num()) {
return false;
}
if (!src.sharing_info || !src.varray.is_span()) {
@ -542,7 +542,7 @@ static bool try_sharing_point_data(const CurvesGeometry &main,
}
return mesh_attributes.add(
id,
ATTR_DOMAIN_POINT,
AttrDomain::Point,
bke::cpp_type_to_custom_data_type(src.varray.type()),
AttributeInitShared(src.varray.get_internal_span().data(), *src.sharing_info));
}
@ -564,12 +564,12 @@ static bool try_direct_evaluate_point_data(const CurvesGeometry &main,
static void copy_main_point_domain_attribute_to_mesh(const CurvesInfo &curves_info,
const AttributeIDRef &id,
const ResultOffsets &offsets,
const eAttrDomain dst_domain,
const AttrDomain dst_domain,
const GAttributeReader &src_attribute,
Vector<std::byte> &eval_buffer,
MutableAttributeAccessor mesh_attributes)
{
if (dst_domain == ATTR_DOMAIN_POINT) {
if (dst_domain == AttrDomain::Point) {
if (try_sharing_point_data(curves_info.main, id, src_attribute, mesh_attributes)) {
return;
}
@ -579,7 +579,7 @@ static void copy_main_point_domain_attribute_to_mesh(const CurvesInfo &curves_in
if (!dst_attribute) {
return;
}
if (dst_domain == ATTR_DOMAIN_POINT) {
if (dst_domain == AttrDomain::Point) {
if (try_direct_evaluate_point_data(curves_info.main, src_attribute, dst_attribute.span)) {
dst_attribute.finish();
return;
@ -591,13 +591,13 @@ static void copy_main_point_domain_attribute_to_mesh(const CurvesInfo &curves_in
const Span<T> src = src_all.typed<T>();
MutableSpan<T> dst = dst_attribute.span.typed<T>();
switch (dst_domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
foreach_curve_combination(curves_info, offsets, [&](const CombinationInfo &info) {
copy_main_point_data_to_mesh_verts(
src.slice(info.main_points), info.profile_points.size(), dst.slice(info.vert_range));
});
break;
case ATTR_DOMAIN_EDGE:
case AttrDomain::Edge:
foreach_curve_combination(curves_info, offsets, [&](const CombinationInfo &info) {
copy_main_point_data_to_mesh_edges(src.slice(info.main_points),
info.profile_points.size(),
@ -606,7 +606,7 @@ static void copy_main_point_domain_attribute_to_mesh(const CurvesInfo &curves_in
dst.slice(info.edge_range));
});
break;
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
foreach_curve_combination(curves_info, offsets, [&](const CombinationInfo &info) {
copy_main_point_data_to_mesh_faces(src.slice(info.main_points),
info.main_segment_num,
@ -614,7 +614,7 @@ static void copy_main_point_domain_attribute_to_mesh(const CurvesInfo &curves_in
dst.slice(info.face_range));
});
break;
case ATTR_DOMAIN_CORNER:
case AttrDomain::Corner:
/* Unsupported for now, since there are no builtin attributes to convert into. */
break;
default:
@ -665,7 +665,7 @@ static void copy_profile_point_data_to_mesh_faces(const Span<T> src,
static void copy_profile_point_domain_attribute_to_mesh(const CurvesInfo &curves_info,
const ResultOffsets &offsets,
const eAttrDomain dst_domain,
const AttrDomain dst_domain,
const GSpan src_all,
GMutableSpan dst_all)
{
@ -674,19 +674,19 @@ static void copy_profile_point_domain_attribute_to_mesh(const CurvesInfo &curves
const Span<T> src = src_all.typed<T>();
MutableSpan<T> dst = dst_all.typed<T>();
switch (dst_domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
foreach_curve_combination(curves_info, offsets, [&](const CombinationInfo &info) {
copy_profile_point_data_to_mesh_verts(
src.slice(info.profile_points), info.main_points.size(), dst.slice(info.vert_range));
});
break;
case ATTR_DOMAIN_EDGE:
case AttrDomain::Edge:
foreach_curve_combination(curves_info, offsets, [&](const CombinationInfo &info) {
copy_profile_point_data_to_mesh_edges(
src.slice(info.profile_points), info.main_segment_num, dst.slice(info.edge_range));
});
break;
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
foreach_curve_combination(curves_info, offsets, [&](const CombinationInfo &info) {
copy_profile_point_data_to_mesh_faces(src.slice(info.profile_points),
info.main_segment_num,
@ -694,7 +694,7 @@ static void copy_profile_point_domain_attribute_to_mesh(const CurvesInfo &curves
dst.slice(info.face_range));
});
break;
case ATTR_DOMAIN_CORNER:
case AttrDomain::Corner:
/* Unsupported for now, since there are no builtin attributes to convert into. */
break;
default:
@ -724,22 +724,22 @@ static void copy_indices_to_offset_ranges(const VArray<T> &src,
static void copy_curve_domain_attribute_to_mesh(const ResultOffsets &mesh_offsets,
const Span<int> curve_indices,
const eAttrDomain dst_domain,
const AttrDomain dst_domain,
const GVArray &src,
GMutableSpan dst)
{
Span<int> offsets;
switch (dst_domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
offsets = mesh_offsets.vert;
break;
case ATTR_DOMAIN_EDGE:
case AttrDomain::Edge:
offsets = mesh_offsets.edge;
break;
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
offsets = mesh_offsets.face;
break;
case ATTR_DOMAIN_CORNER:
case AttrDomain::Corner:
offsets = mesh_offsets.loop;
break;
default:
@ -769,7 +769,7 @@ static void write_sharp_bezier_edges(const CurvesInfo &curves_info,
return;
}
sharp_edges = mesh_attributes.lookup_or_add_for_write_span<bool>("sharp_edge", ATTR_DOMAIN_EDGE);
sharp_edges = mesh_attributes.lookup_or_add_for_write_span<bool>("sharp_edge", AttrDomain::Edge);
const OffsetIndices profile_points_by_curve = profile.points_by_curve();
const VArray<int8_t> types = profile.curve_types();
@ -830,7 +830,7 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main,
/* TODO: This is used to keep the tests passing after refactoring mesh shade smooth flags. It
* can be removed if the tests are updated and the final shading results will be the same. */
SpanAttributeWriter<bool> sharp_faces = mesh_attributes.lookup_or_add_for_write_span<bool>(
"sharp_face", ATTR_DOMAIN_FACE);
"sharp_face", AttrDomain::Face);
foreach_curve_combination(curves_info, offsets, [&](const CombinationInfo &info) {
const bool has_caps = fill_caps && !info.main_cyclic && info.profile_cyclic;
if (has_caps) {
@ -862,7 +862,7 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main,
if (fill_caps) {
if (!sharp_edges) {
sharp_edges = mesh_attributes.lookup_or_add_for_write_span<bool>("sharp_edge",
ATTR_DOMAIN_EDGE);
AttrDomain::Edge);
}
foreach_curve_combination(curves_info, offsets, [&](const CombinationInfo &info) {
if (info.main_cyclic || !info.profile_cyclic) {
@ -889,16 +889,16 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main,
return true;
}
const eAttrDomain src_domain = meta_data.domain;
const AttrDomain src_domain = meta_data.domain;
const eCustomDataType type = meta_data.data_type;
const GAttributeReader src = main_attributes.lookup(id, src_domain, type);
const eAttrDomain dst_domain = get_attribute_domain_for_mesh(mesh_attributes, id);
const AttrDomain dst_domain = get_attribute_domain_for_mesh(mesh_attributes, id);
if (src_domain == ATTR_DOMAIN_POINT) {
if (src_domain == AttrDomain::Point) {
copy_main_point_domain_attribute_to_mesh(
curves_info, id, offsets, dst_domain, src, eval_buffer, mesh_attributes);
}
else if (src_domain == ATTR_DOMAIN_CURVE) {
else if (src_domain == AttrDomain::Curve) {
GSpanAttributeWriter dst = mesh_attributes.lookup_or_add_for_write_only_span(
id, dst_domain, type);
if (dst) {
@ -921,25 +921,25 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main,
{
return true;
}
const eAttrDomain src_domain = meta_data.domain;
const AttrDomain src_domain = meta_data.domain;
const eCustomDataType type = meta_data.data_type;
const GVArray src = *profile_attributes.lookup(id, src_domain, type);
const eAttrDomain dst_domain = get_attribute_domain_for_mesh(mesh_attributes, id);
const AttrDomain dst_domain = get_attribute_domain_for_mesh(mesh_attributes, id);
GSpanAttributeWriter dst = mesh_attributes.lookup_or_add_for_write_only_span(
id, dst_domain, type);
if (!dst) {
return true;
}
if (src_domain == ATTR_DOMAIN_POINT) {
if (src_domain == AttrDomain::Point) {
copy_profile_point_domain_attribute_to_mesh(curves_info,
offsets,
dst_domain,
evaluate_attribute(src, profile, eval_buffer),
dst.span);
}
else if (src_domain == ATTR_DOMAIN_CURVE) {
else if (src_domain == AttrDomain::Curve) {
copy_curve_domain_attribute_to_mesh(
offsets, offsets.profile_indices, dst_domain, src, dst.span);
}

View File

@ -347,7 +347,7 @@ bool CurvesEditHints::is_valid() const
void curves_normals_point_domain_calc(const CurvesGeometry &curves, MutableSpan<float3> normals)
{
const bke::CurvesFieldContext context(curves, ATTR_DOMAIN_POINT);
const bke::CurvesFieldContext context(curves, AttrDomain::Point);
fn::FieldEvaluator evaluator(context, curves.points_num());
fn::Field<float3> field(std::make_shared<bke::NormalFieldInput>());
evaluator.add_with_destination(std::move(field), normals);

View File

@ -63,7 +63,7 @@ CurvesGeometry::CurvesGeometry(const int point_num, const int curve_num)
BLI_listbase_clear(&this->vertex_group_names);
this->attributes_for_write().add<float3>(
"position", ATTR_DOMAIN_POINT, AttributeInitConstruct());
"position", AttrDomain::Point, AttributeInitConstruct());
this->runtime = MEM_new<CurvesGeometryRuntime>(__func__);
@ -185,24 +185,24 @@ CurvesGeometry::~CurvesGeometry()
/** \name Accessors
* \{ */
static int domain_num(const CurvesGeometry &curves, const eAttrDomain domain)
static int domain_num(const CurvesGeometry &curves, const AttrDomain domain)
{
return domain == ATTR_DOMAIN_POINT ? curves.points_num() : curves.curves_num();
return domain == AttrDomain::Point ? curves.points_num() : curves.curves_num();
}
static CustomData &domain_custom_data(CurvesGeometry &curves, const eAttrDomain domain)
static CustomData &domain_custom_data(CurvesGeometry &curves, const AttrDomain domain)
{
return domain == ATTR_DOMAIN_POINT ? curves.point_data : curves.curve_data;
return domain == AttrDomain::Point ? curves.point_data : curves.curve_data;
}
static const CustomData &domain_custom_data(const CurvesGeometry &curves, const eAttrDomain domain)
static const CustomData &domain_custom_data(const CurvesGeometry &curves, const AttrDomain domain)
{
return domain == ATTR_DOMAIN_POINT ? curves.point_data : curves.curve_data;
return domain == AttrDomain::Point ? curves.point_data : curves.curve_data;
}
template<typename T>
static VArray<T> get_varray_attribute(const CurvesGeometry &curves,
const eAttrDomain domain,
const AttrDomain domain,
const StringRefNull name,
const T default_value)
{
@ -219,7 +219,7 @@ static VArray<T> get_varray_attribute(const CurvesGeometry &curves,
template<typename T>
static Span<T> get_span_attribute(const CurvesGeometry &curves,
const eAttrDomain domain,
const AttrDomain domain,
const StringRefNull name)
{
const int num = domain_num(curves, domain);
@ -235,7 +235,7 @@ static Span<T> get_span_attribute(const CurvesGeometry &curves,
template<typename T>
static MutableSpan<T> get_mutable_attribute(CurvesGeometry &curves,
const eAttrDomain domain,
const AttrDomain domain,
const StringRefNull name,
const T default_value = T())
{
@ -258,12 +258,12 @@ static MutableSpan<T> get_mutable_attribute(CurvesGeometry &curves,
VArray<int8_t> CurvesGeometry::curve_types() const
{
return get_varray_attribute<int8_t>(
*this, ATTR_DOMAIN_CURVE, ATTR_CURVE_TYPE, CURVE_TYPE_CATMULL_ROM);
*this, AttrDomain::Curve, ATTR_CURVE_TYPE, CURVE_TYPE_CATMULL_ROM);
}
MutableSpan<int8_t> CurvesGeometry::curve_types_for_write()
{
return get_mutable_attribute<int8_t>(*this, ATTR_DOMAIN_CURVE, ATTR_CURVE_TYPE);
return get_mutable_attribute<int8_t>(*this, AttrDomain::Curve, ATTR_CURVE_TYPE);
}
void CurvesGeometry::fill_curve_types(const CurveType type)
@ -338,11 +338,11 @@ void CurvesGeometry::update_curve_types()
Span<float3> CurvesGeometry::positions() const
{
return get_span_attribute<float3>(*this, ATTR_DOMAIN_POINT, ATTR_POSITION);
return get_span_attribute<float3>(*this, AttrDomain::Point, ATTR_POSITION);
}
MutableSpan<float3> CurvesGeometry::positions_for_write()
{
return get_mutable_attribute<float3>(*this, ATTR_DOMAIN_POINT, ATTR_POSITION);
return get_mutable_attribute<float3>(*this, AttrDomain::Point, ATTR_POSITION);
}
Span<int> CurvesGeometry::offsets() const
@ -361,111 +361,111 @@ MutableSpan<int> CurvesGeometry::offsets_for_write()
VArray<bool> CurvesGeometry::cyclic() const
{
return get_varray_attribute<bool>(*this, ATTR_DOMAIN_CURVE, ATTR_CYCLIC, false);
return get_varray_attribute<bool>(*this, AttrDomain::Curve, ATTR_CYCLIC, false);
}
MutableSpan<bool> CurvesGeometry::cyclic_for_write()
{
return get_mutable_attribute<bool>(*this, ATTR_DOMAIN_CURVE, ATTR_CYCLIC, false);
return get_mutable_attribute<bool>(*this, AttrDomain::Curve, ATTR_CYCLIC, false);
}
VArray<int> CurvesGeometry::resolution() const
{
return get_varray_attribute<int>(*this, ATTR_DOMAIN_CURVE, ATTR_RESOLUTION, 12);
return get_varray_attribute<int>(*this, AttrDomain::Curve, ATTR_RESOLUTION, 12);
}
MutableSpan<int> CurvesGeometry::resolution_for_write()
{
return get_mutable_attribute<int>(*this, ATTR_DOMAIN_CURVE, ATTR_RESOLUTION, 12);
return get_mutable_attribute<int>(*this, AttrDomain::Curve, ATTR_RESOLUTION, 12);
}
VArray<int8_t> CurvesGeometry::normal_mode() const
{
return get_varray_attribute<int8_t>(*this, ATTR_DOMAIN_CURVE, ATTR_NORMAL_MODE, 0);
return get_varray_attribute<int8_t>(*this, AttrDomain::Curve, ATTR_NORMAL_MODE, 0);
}
MutableSpan<int8_t> CurvesGeometry::normal_mode_for_write()
{
return get_mutable_attribute<int8_t>(*this, ATTR_DOMAIN_CURVE, ATTR_NORMAL_MODE);
return get_mutable_attribute<int8_t>(*this, AttrDomain::Curve, ATTR_NORMAL_MODE);
}
VArray<float> CurvesGeometry::tilt() const
{
return get_varray_attribute<float>(*this, ATTR_DOMAIN_POINT, ATTR_TILT, 0.0f);
return get_varray_attribute<float>(*this, AttrDomain::Point, ATTR_TILT, 0.0f);
}
MutableSpan<float> CurvesGeometry::tilt_for_write()
{
return get_mutable_attribute<float>(*this, ATTR_DOMAIN_POINT, ATTR_TILT);
return get_mutable_attribute<float>(*this, AttrDomain::Point, ATTR_TILT);
}
VArray<int8_t> CurvesGeometry::handle_types_left() const
{
return get_varray_attribute<int8_t>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_LEFT, 0);
return get_varray_attribute<int8_t>(*this, AttrDomain::Point, ATTR_HANDLE_TYPE_LEFT, 0);
}
MutableSpan<int8_t> CurvesGeometry::handle_types_left_for_write()
{
return get_mutable_attribute<int8_t>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_LEFT, 0);
return get_mutable_attribute<int8_t>(*this, AttrDomain::Point, ATTR_HANDLE_TYPE_LEFT, 0);
}
VArray<int8_t> CurvesGeometry::handle_types_right() const
{
return get_varray_attribute<int8_t>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_RIGHT, 0);
return get_varray_attribute<int8_t>(*this, AttrDomain::Point, ATTR_HANDLE_TYPE_RIGHT, 0);
}
MutableSpan<int8_t> CurvesGeometry::handle_types_right_for_write()
{
return get_mutable_attribute<int8_t>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_RIGHT, 0);
return get_mutable_attribute<int8_t>(*this, AttrDomain::Point, ATTR_HANDLE_TYPE_RIGHT, 0);
}
Span<float3> CurvesGeometry::handle_positions_left() const
{
return get_span_attribute<float3>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_LEFT);
return get_span_attribute<float3>(*this, AttrDomain::Point, ATTR_HANDLE_POSITION_LEFT);
}
MutableSpan<float3> CurvesGeometry::handle_positions_left_for_write()
{
return get_mutable_attribute<float3>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_LEFT);
return get_mutable_attribute<float3>(*this, AttrDomain::Point, ATTR_HANDLE_POSITION_LEFT);
}
Span<float3> CurvesGeometry::handle_positions_right() const
{
return get_span_attribute<float3>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_RIGHT);
return get_span_attribute<float3>(*this, AttrDomain::Point, ATTR_HANDLE_POSITION_RIGHT);
}
MutableSpan<float3> CurvesGeometry::handle_positions_right_for_write()
{
return get_mutable_attribute<float3>(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_RIGHT);
return get_mutable_attribute<float3>(*this, AttrDomain::Point, ATTR_HANDLE_POSITION_RIGHT);
}
VArray<int8_t> CurvesGeometry::nurbs_orders() const
{
return get_varray_attribute<int8_t>(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_ORDER, 4);
return get_varray_attribute<int8_t>(*this, AttrDomain::Curve, ATTR_NURBS_ORDER, 4);
}
MutableSpan<int8_t> CurvesGeometry::nurbs_orders_for_write()
{
return get_mutable_attribute<int8_t>(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_ORDER, 4);
return get_mutable_attribute<int8_t>(*this, AttrDomain::Curve, ATTR_NURBS_ORDER, 4);
}
Span<float> CurvesGeometry::nurbs_weights() const
{
return get_span_attribute<float>(*this, ATTR_DOMAIN_POINT, ATTR_NURBS_WEIGHT);
return get_span_attribute<float>(*this, AttrDomain::Point, ATTR_NURBS_WEIGHT);
}
MutableSpan<float> CurvesGeometry::nurbs_weights_for_write()
{
return get_mutable_attribute<float>(*this, ATTR_DOMAIN_POINT, ATTR_NURBS_WEIGHT);
return get_mutable_attribute<float>(*this, AttrDomain::Point, ATTR_NURBS_WEIGHT);
}
VArray<int8_t> CurvesGeometry::nurbs_knots_modes() const
{
return get_varray_attribute<int8_t>(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_KNOTS_MODE, 0);
return get_varray_attribute<int8_t>(*this, AttrDomain::Curve, ATTR_NURBS_KNOTS_MODE, 0);
}
MutableSpan<int8_t> CurvesGeometry::nurbs_knots_modes_for_write()
{
return get_mutable_attribute<int8_t>(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_KNOTS_MODE, 0);
return get_mutable_attribute<int8_t>(*this, AttrDomain::Curve, ATTR_NURBS_KNOTS_MODE, 0);
}
Span<float2> CurvesGeometry::surface_uv_coords() const
{
return get_span_attribute<float2>(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_UV_COORDINATE);
return get_span_attribute<float2>(*this, AttrDomain::Curve, ATTR_SURFACE_UV_COORDINATE);
}
MutableSpan<float2> CurvesGeometry::surface_uv_coords_for_write()
{
return get_mutable_attribute<float2>(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_UV_COORDINATE);
return get_mutable_attribute<float2>(*this, AttrDomain::Curve, ATTR_SURFACE_UV_COORDINATE);
}
Span<MDeformVert> CurvesGeometry::deform_verts() const
@ -1166,13 +1166,13 @@ CurvesGeometry curves_copy_point_selection(
},
[&]() {
gather_attributes(curves.attributes(),
ATTR_DOMAIN_POINT,
AttrDomain::Point,
propagation_info,
{},
points_to_copy,
dst_curves.attributes_for_write());
gather_attributes(curves.attributes(),
ATTR_DOMAIN_CURVE,
AttrDomain::Curve,
propagation_info,
{},
curves_to_copy,
@ -1219,7 +1219,7 @@ CurvesGeometry curves_copy_curve_selection(
MutableAttributeAccessor dst_attributes = dst_curves.attributes_for_write();
gather_attributes_group_to_group(src_attributes,
ATTR_DOMAIN_POINT,
AttrDomain::Point,
propagation_info,
{},
points_by_curve,
@ -1228,7 +1228,7 @@ CurvesGeometry curves_copy_curve_selection(
dst_attributes);
gather_attributes(
src_attributes, ATTR_DOMAIN_CURVE, propagation_info, {}, curves_to_copy, dst_attributes);
src_attributes, AttrDomain::Curve, propagation_info, {}, curves_to_copy, dst_attributes);
dst_curves.update_curve_types();
dst_curves.remove_attributes_based_on_types();
@ -1294,7 +1294,7 @@ void CurvesGeometry::reverse_curves(const IndexMask &curves_to_reverse)
MutableAttributeAccessor attributes = this->attributes_for_write();
attributes.for_all([&](const AttributeIDRef &id, AttributeMetaData meta_data) {
if (meta_data.domain != ATTR_DOMAIN_POINT) {
if (meta_data.domain != AttrDomain::Point) {
return true;
}
if (meta_data.data_type == CD_PROP_STRING) {
@ -1457,8 +1457,8 @@ static GVArray adapt_curve_domain_curve_to_point(const CurvesGeometry &curves,
}
GVArray CurvesGeometry::adapt_domain(const GVArray &varray,
const eAttrDomain from,
const eAttrDomain to) const
const AttrDomain from,
const AttrDomain to) const
{
if (!varray) {
return {};
@ -1475,10 +1475,10 @@ GVArray CurvesGeometry::adapt_domain(const GVArray &varray,
return GVArray::ForSingle(varray.type(), this->attributes().domain_size(to), value);
}
if (from == ATTR_DOMAIN_POINT && to == ATTR_DOMAIN_CURVE) {
if (from == AttrDomain::Point && to == AttrDomain::Curve) {
return adapt_curve_domain_point_to_curve(*this, varray);
}
if (from == ATTR_DOMAIN_CURVE && to == ATTR_DOMAIN_POINT) {
if (from == AttrDomain::Curve && to == AttrDomain::Point) {
return adapt_curve_domain_curve_to_point(*this, varray);
}

View File

@ -255,7 +255,7 @@ int BKE_object_data_transfer_dttype_to_srcdst_index(const int dtdata_type)
* is set).
*/
static void data_transfer_mesh_attributes_transfer_active_color_string(
Mesh *mesh_dst, const Mesh *mesh_src, const eAttrDomainMask mask_domain, const int data_type)
Mesh *mesh_dst, const Mesh *mesh_src, const AttrDomainMask mask_domain, const int data_type)
{
if (mesh_dst->active_color_attribute) {
return;
@ -306,7 +306,7 @@ static void data_transfer_mesh_attributes_transfer_active_color_string(
* is set).
*/
static void data_transfer_mesh_attributes_transfer_default_color_string(
Mesh *mesh_dst, const Mesh *mesh_src, const eAttrDomainMask mask_domain, const int data_type)
Mesh *mesh_dst, const Mesh *mesh_src, const AttrDomainMask mask_domain, const int data_type)
{
if (mesh_dst->default_color_attribute) {
return;
@ -377,8 +377,8 @@ static void data_transfer_dtdata_type_postprocess(Mesh *me_dst,
bke::MutableAttributeAccessor attributes = me_dst->attributes_for_write();
bke::SpanAttributeWriter<bool> sharp_edges = attributes.lookup_or_add_for_write_span<bool>(
"sharp_edge", ATTR_DOMAIN_EDGE);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
"sharp_edge", bke::AttrDomain::Edge);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", bke::AttrDomain::Face);
/* Note loop_nors_dst contains our custom normals as transferred from source... */
blender::bke::mesh::normals_loop_custom_set(me_dst->vert_positions(),
me_dst->edges(),

View File

@ -3220,15 +3220,16 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds,
Object *ob)
{
using namespace blender;
using namespace blender::bke;
Mesh *mesh;
float min[3];
float max[3];
float size[3];
float cell_size_scaled[3];
const bke::AttributeAccessor orig_attributes = orgmesh->attributes();
const AttributeAccessor orig_attributes = orgmesh->attributes();
const VArraySpan orig_material_indices = *orig_attributes.lookup<int>("material_index",
ATTR_DOMAIN_FACE);
AttrDomain::Face);
const short mp_mat_nr = orig_material_indices.is_empty() ? 0 : orig_material_indices[0];
int i;
@ -3259,9 +3260,9 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds,
blender::MutableSpan<int> corner_verts = mesh->corner_verts_for_write();
const bool is_sharp = orgmesh->attributes()
.lookup_or_default<bool>("sharp_face", ATTR_DOMAIN_FACE, false)
.lookup_or_default<bool>("sharp_face", AttrDomain::Face, false)
.varray[0];
bke::mesh_smooth_set(*mesh, !is_sharp);
mesh_smooth_set(*mesh, !is_sharp);
/* Get size (dimension) but considering scaling. */
copy_v3_v3(cell_size_scaled, fds->cell_size);
@ -3291,7 +3292,7 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds,
if (use_speedvectors) {
CustomDataLayer *velocity_layer = BKE_id_attribute_new(
&mesh->id, "velocity", CD_PROP_FLOAT3, ATTR_DOMAIN_POINT, nullptr);
&mesh->id, "velocity", CD_PROP_FLOAT3, AttrDomain::Point, nullptr);
velarray = static_cast<float(*)[3]>(velocity_layer->data);
}
@ -3346,7 +3347,7 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds,
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter material_indices = attributes.lookup_or_add_for_write_span<int>(
"material_index", ATTR_DOMAIN_FACE);
"material_index", AttrDomain::Face);
/* Loop for triangles. */
for (const int i : face_offsets.index_range().drop_back(1)) {

View File

@ -211,23 +211,23 @@ static Array<float3> curve_normal_point_domain(const bke::CurvesGeometry &curves
return results;
}
VArray<float3> curve_normals_varray(const CurvesGeometry &curves, const eAttrDomain domain)
VArray<float3> curve_normals_varray(const CurvesGeometry &curves, const AttrDomain domain)
{
const VArray<int8_t> types = curves.curve_types();
if (curves.is_single_type(CURVE_TYPE_POLY)) {
return curves.adapt_domain<float3>(
VArray<float3>::ForSpan(curves.evaluated_normals()), ATTR_DOMAIN_POINT, domain);
VArray<float3>::ForSpan(curves.evaluated_normals()), AttrDomain::Point, domain);
}
Array<float3> normals = curve_normal_point_domain(curves);
if (domain == ATTR_DOMAIN_POINT) {
if (domain == AttrDomain::Point) {
return VArray<float3>::ForContainer(std::move(normals));
}
if (domain == ATTR_DOMAIN_CURVE) {
if (domain == AttrDomain::Curve) {
return curves.adapt_domain<float3>(
VArray<float3>::ForContainer(std::move(normals)), ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE);
VArray<float3>::ForContainer(std::move(normals)), AttrDomain::Point, AttrDomain::Curve);
}
return nullptr;
@ -240,7 +240,7 @@ VArray<float3> curve_normals_varray(const CurvesGeometry &curves, const eAttrDom
* \{ */
static VArray<float> construct_curve_length_gvarray(const CurvesGeometry &curves,
const eAttrDomain domain)
const AttrDomain domain)
{
curves.ensure_evaluated_lengths();
@ -250,12 +250,12 @@ static VArray<float> construct_curve_length_gvarray(const CurvesGeometry &curves
return curves.evaluated_length_total_for_curve(index, cyclic[index]);
});
if (domain == ATTR_DOMAIN_CURVE) {
if (domain == AttrDomain::Curve) {
return lengths;
}
if (domain == ATTR_DOMAIN_POINT) {
return curves.adapt_domain<float>(std::move(lengths), ATTR_DOMAIN_CURVE, ATTR_DOMAIN_POINT);
if (domain == AttrDomain::Point) {
return curves.adapt_domain<float>(std::move(lengths), AttrDomain::Curve, AttrDomain::Point);
}
return {};
@ -268,7 +268,7 @@ CurveLengthFieldInput::CurveLengthFieldInput()
}
GVArray CurveLengthFieldInput::get_varray_for_context(const CurvesGeometry &curves,
const eAttrDomain domain,
const AttrDomain domain,
const IndexMask & /*mask*/) const
{
return construct_curve_length_gvarray(curves, domain);
@ -285,10 +285,10 @@ bool CurveLengthFieldInput::is_equal_to(const fn::FieldNode &other) const
return dynamic_cast<const CurveLengthFieldInput *>(&other) != nullptr;
}
std::optional<eAttrDomain> CurveLengthFieldInput::preferred_domain(
std::optional<AttrDomain> CurveLengthFieldInput::preferred_domain(
const bke::CurvesGeometry & /*curves*/) const
{
return ATTR_DOMAIN_CURVE;
return AttrDomain::Curve;
}
/** \} */
@ -358,9 +358,9 @@ class CurvesVertexGroupsAttributeProvider final : public DynamicAttributesProvid
const Span<MDeformVert> dverts = curves->deform_verts();
if (dverts.is_empty()) {
static const float default_value = 0.0f;
return {VArray<float>::ForSingle(default_value, curves->points_num()), ATTR_DOMAIN_POINT};
return {VArray<float>::ForSingle(default_value, curves->points_num()), AttrDomain::Point};
}
return {bke::varray_for_deform_verts(dverts, vertex_group_index), ATTR_DOMAIN_POINT};
return {bke::varray_for_deform_verts(dverts, vertex_group_index), AttrDomain::Point};
}
GAttributeWriter try_get_for_write(void *owner, const AttributeIDRef &attribute_id) const final
@ -379,7 +379,7 @@ class CurvesVertexGroupsAttributeProvider final : public DynamicAttributesProvid
return {};
}
MutableSpan<MDeformVert> dverts = curves->deform_verts_for_write();
return {bke::varray_for_mutable_deform_verts(dverts, vertex_group_index), ATTR_DOMAIN_POINT};
return {bke::varray_for_mutable_deform_verts(dverts, vertex_group_index), AttrDomain::Point};
}
bool try_delete(void *owner, const AttributeIDRef &attribute_id) const final
@ -417,16 +417,16 @@ class CurvesVertexGroupsAttributeProvider final : public DynamicAttributesProvid
return true;
}
LISTBASE_FOREACH (const bDeformGroup *, group, &curves->vertex_group_names) {
if (!callback(group->name, {ATTR_DOMAIN_POINT, CD_PROP_FLOAT})) {
if (!callback(group->name, {AttrDomain::Point, CD_PROP_FLOAT})) {
return false;
}
}
return true;
}
void foreach_domain(const FunctionRef<void(eAttrDomain)> callback) const final
void foreach_domain(const FunctionRef<void(AttrDomain)> callback) const final
{
callback(ATTR_DOMAIN_POINT);
callback(AttrDomain::Point);
}
};
@ -464,7 +464,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
}};
static BuiltinCustomDataLayerProvider position("position",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_FLOAT3,
CD_PROP_FLOAT3,
BuiltinAttributeProvider::Creatable,
@ -473,7 +473,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
tag_component_positions_changed);
static BuiltinCustomDataLayerProvider radius("radius",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_FLOAT,
CD_PROP_FLOAT,
BuiltinAttributeProvider::Creatable,
@ -482,7 +482,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
tag_component_radii_changed);
static BuiltinCustomDataLayerProvider id("id",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_INT32,
CD_PROP_INT32,
BuiltinAttributeProvider::Creatable,
@ -491,7 +491,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
nullptr);
static BuiltinCustomDataLayerProvider tilt("tilt",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_FLOAT,
CD_PROP_FLOAT,
BuiltinAttributeProvider::Creatable,
@ -500,7 +500,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
tag_component_normals_changed);
static BuiltinCustomDataLayerProvider handle_right("handle_right",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_FLOAT3,
CD_PROP_FLOAT3,
BuiltinAttributeProvider::Creatable,
@ -509,7 +509,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
tag_component_positions_changed);
static BuiltinCustomDataLayerProvider handle_left("handle_left",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_FLOAT3,
CD_PROP_FLOAT3,
BuiltinAttributeProvider::Creatable,
@ -524,7 +524,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
},
mf::build::exec_presets::AllSpanOrSingle());
static BuiltinCustomDataLayerProvider handle_type_right("handle_type_right",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_INT8,
CD_PROP_INT8,
BuiltinAttributeProvider::Creatable,
@ -534,7 +534,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
AttributeValidator{&handle_type_clamp});
static BuiltinCustomDataLayerProvider handle_type_left("handle_type_left",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_INT8,
CD_PROP_INT8,
BuiltinAttributeProvider::Creatable,
@ -544,7 +544,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
AttributeValidator{&handle_type_clamp});
static BuiltinCustomDataLayerProvider nurbs_weight("nurbs_weight",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_FLOAT,
CD_PROP_FLOAT,
BuiltinAttributeProvider::Creatable,
@ -557,7 +557,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
[](int8_t value) { return std::max<int8_t>(value, 0); },
mf::build::exec_presets::AllSpanOrSingle());
static BuiltinCustomDataLayerProvider nurbs_order("nurbs_order",
ATTR_DOMAIN_CURVE,
AttrDomain::Curve,
CD_PROP_INT8,
CD_PROP_INT8,
BuiltinAttributeProvider::Creatable,
@ -573,7 +573,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
},
mf::build::exec_presets::AllSpanOrSingle());
static BuiltinCustomDataLayerProvider normal_mode("normal_mode",
ATTR_DOMAIN_CURVE,
AttrDomain::Curve,
CD_PROP_INT8,
CD_PROP_INT8,
BuiltinAttributeProvider::Creatable,
@ -589,7 +589,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
},
mf::build::exec_presets::AllSpanOrSingle());
static BuiltinCustomDataLayerProvider nurbs_knots_mode("knots_mode",
ATTR_DOMAIN_CURVE,
AttrDomain::Curve,
CD_PROP_INT8,
CD_PROP_INT8,
BuiltinAttributeProvider::Creatable,
@ -605,7 +605,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
},
mf::build::exec_presets::AllSpanOrSingle());
static BuiltinCustomDataLayerProvider curve_type("curve_type",
ATTR_DOMAIN_CURVE,
AttrDomain::Curve,
CD_PROP_INT8,
CD_PROP_INT8,
BuiltinAttributeProvider::Creatable,
@ -619,7 +619,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
[](int value) { return std::max<int>(value, 1); },
mf::build::exec_presets::AllSpanOrSingle());
static BuiltinCustomDataLayerProvider resolution("resolution",
ATTR_DOMAIN_CURVE,
AttrDomain::Curve,
CD_PROP_INT32,
CD_PROP_INT32,
BuiltinAttributeProvider::Creatable,
@ -629,7 +629,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
AttributeValidator{&resolution_clamp});
static BuiltinCustomDataLayerProvider cyclic("cyclic",
ATTR_DOMAIN_CURVE,
AttrDomain::Curve,
CD_PROP_BOOL,
CD_PROP_BOOL,
BuiltinAttributeProvider::Creatable,
@ -638,8 +638,8 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
tag_component_topology_changed);
static CurvesVertexGroupsAttributeProvider vertex_groups;
static CustomDataAttributeProvider curve_custom_data(ATTR_DOMAIN_CURVE, curve_access);
static CustomDataAttributeProvider point_custom_data(ATTR_DOMAIN_POINT, point_access);
static CustomDataAttributeProvider curve_custom_data(AttrDomain::Curve, curve_access);
static CustomDataAttributeProvider point_custom_data(AttrDomain::Point, point_access);
return ComponentAttributeProviders({&position,
&radius,
@ -666,27 +666,27 @@ static AttributeAccessorFunctions get_curves_accessor_functions()
static const ComponentAttributeProviders providers = create_attribute_providers_for_curve();
AttributeAccessorFunctions fn =
attribute_accessor_functions::accessor_functions_for_providers<providers>();
fn.domain_size = [](const void *owner, const eAttrDomain domain) {
fn.domain_size = [](const void *owner, const AttrDomain domain) {
if (owner == nullptr) {
return 0;
}
const CurvesGeometry &curves = *static_cast<const CurvesGeometry *>(owner);
switch (domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
return curves.points_num();
case ATTR_DOMAIN_CURVE:
case AttrDomain::Curve:
return curves.curves_num();
default:
return 0;
}
};
fn.domain_supported = [](const void * /*owner*/, const eAttrDomain domain) {
return ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE);
fn.domain_supported = [](const void * /*owner*/, const AttrDomain domain) {
return ELEM(domain, AttrDomain::Point, AttrDomain::Curve);
};
fn.adapt_domain = [](const void *owner,
const GVArray &varray,
const eAttrDomain from_domain,
const eAttrDomain to_domain) -> GVArray {
const AttrDomain from_domain,
const AttrDomain to_domain) -> GVArray {
if (owner == nullptr) {
return {};
}

View File

@ -117,15 +117,15 @@ static ComponentAttributeProviders create_attribute_providers_for_grease_pencil(
return grease_pencil.layers().size();
}};
static CustomDataAttributeProvider layer_custom_data(ATTR_DOMAIN_LAYER, layers_access);
static CustomDataAttributeProvider layer_custom_data(AttrDomain::Layer, layers_access);
return ComponentAttributeProviders({}, {&layer_custom_data});
}
static GVArray adapt_grease_pencil_attribute_domain(const GreasePencil & /*grease_pencil*/,
const GVArray &varray,
const eAttrDomain from,
const eAttrDomain to)
const AttrDomain from,
const AttrDomain to)
{
if (from == to) {
return varray;
@ -139,25 +139,25 @@ static AttributeAccessorFunctions get_grease_pencil_accessor_functions()
create_attribute_providers_for_grease_pencil();
AttributeAccessorFunctions fn =
attribute_accessor_functions::accessor_functions_for_providers<providers>();
fn.domain_size = [](const void *owner, const eAttrDomain domain) {
fn.domain_size = [](const void *owner, const AttrDomain domain) {
if (owner == nullptr) {
return 0;
}
const GreasePencil &grease_pencil = *static_cast<const GreasePencil *>(owner);
switch (domain) {
case ATTR_DOMAIN_LAYER:
case AttrDomain::Layer:
return int(grease_pencil.layers().size());
default:
return 0;
}
};
fn.domain_supported = [](const void * /*owner*/, const eAttrDomain domain) {
return domain == ATTR_DOMAIN_LAYER;
fn.domain_supported = [](const void * /*owner*/, const AttrDomain domain) {
return domain == AttrDomain::Layer;
};
fn.adapt_domain = [](const void *owner,
const GVArray &varray,
const eAttrDomain from_domain,
const eAttrDomain to_domain) -> GVArray {
const AttrDomain from_domain,
const AttrDomain to_domain) -> GVArray {
if (owner == nullptr) {
return {};
}

View File

@ -118,7 +118,7 @@ class InstancePositionAttributeProvider final : public BuiltinAttributeProvider
public:
InstancePositionAttributeProvider()
: BuiltinAttributeProvider(
"position", ATTR_DOMAIN_INSTANCE, CD_PROP_FLOAT3, NonCreatable, NonDeletable)
"position", AttrDomain::Instance, CD_PROP_FLOAT3, NonCreatable, NonDeletable)
{
}
@ -187,7 +187,7 @@ static ComponentAttributeProviders create_attribute_providers_for_instances()
* instance will be used for the final ID.
*/
static BuiltinCustomDataLayerProvider id("id",
ATTR_DOMAIN_INSTANCE,
AttrDomain::Instance,
CD_PROP_INT32,
CD_PROP_INT32,
BuiltinAttributeProvider::Creatable,
@ -195,7 +195,7 @@ static ComponentAttributeProviders create_attribute_providers_for_instances()
instance_custom_data_access,
nullptr);
static CustomDataAttributeProvider instance_custom_data(ATTR_DOMAIN_INSTANCE,
static CustomDataAttributeProvider instance_custom_data(AttrDomain::Instance,
instance_custom_data_access);
return ComponentAttributeProviders({&position, &id}, {&instance_custom_data});
@ -206,26 +206,26 @@ static AttributeAccessorFunctions get_instances_accessor_functions()
static const ComponentAttributeProviders providers = create_attribute_providers_for_instances();
AttributeAccessorFunctions fn =
attribute_accessor_functions::accessor_functions_for_providers<providers>();
fn.domain_size = [](const void *owner, const eAttrDomain domain) {
fn.domain_size = [](const void *owner, const AttrDomain domain) {
if (owner == nullptr) {
return 0;
}
const Instances *instances = static_cast<const Instances *>(owner);
switch (domain) {
case ATTR_DOMAIN_INSTANCE:
case AttrDomain::Instance:
return instances->instances_num();
default:
return 0;
}
};
fn.domain_supported = [](const void * /*owner*/, const eAttrDomain domain) {
return domain == ATTR_DOMAIN_INSTANCE;
fn.domain_supported = [](const void * /*owner*/, const AttrDomain domain) {
return domain == AttrDomain::Instance;
};
fn.adapt_domain = [](const void * /*owner*/,
const GVArray &varray,
const eAttrDomain from_domain,
const eAttrDomain to_domain) {
if (from_domain == to_domain && from_domain == ATTR_DOMAIN_INSTANCE) {
const AttrDomain from_domain,
const AttrDomain to_domain) {
if (from_domain == to_domain && from_domain == AttrDomain::Instance) {
return varray;
}
return GVArray{};

View File

@ -120,16 +120,16 @@ void MeshComponent::ensure_owns_direct_data()
VArray<float3> mesh_normals_varray(const Mesh &mesh,
const IndexMask &mask,
const eAttrDomain domain)
const AttrDomain domain)
{
switch (domain) {
case ATTR_DOMAIN_FACE: {
case AttrDomain::Face: {
return VArray<float3>::ForSpan(mesh.face_normals());
}
case ATTR_DOMAIN_POINT: {
case AttrDomain::Point: {
return VArray<float3>::ForSpan(mesh.vert_normals());
}
case ATTR_DOMAIN_EDGE: {
case AttrDomain::Edge: {
/* In this case, start with vertex normals and convert to the edge domain, since the
* conversion from edges to vertices is very simple. Use "manual" domain interpolation
* instead of the GeometryComponent API to avoid calculating unnecessary values and to
@ -145,13 +145,13 @@ VArray<float3> mesh_normals_varray(const Mesh &mesh,
return VArray<float3>::ForContainer(std::move(edge_normals));
}
case ATTR_DOMAIN_CORNER: {
case AttrDomain::Corner: {
/* The normals on corners are just the mesh's face normals, so start with the face normal
* array and copy the face normal for each of its corners. In this case using the mesh
* component's generic domain interpolation is fine, the data will still be normalized,
* since the face normal is just copied to every corner. */
return mesh.attributes().adapt_domain(
VArray<float3>::ForSpan(mesh.face_normals()), ATTR_DOMAIN_FACE, ATTR_DOMAIN_CORNER);
VArray<float3>::ForSpan(mesh.face_normals()), AttrDomain::Face, AttrDomain::Corner);
}
default:
return {};
@ -733,34 +733,34 @@ static GVArray adapt_mesh_domain_edge_to_face(const Mesh &mesh, const GVArray &v
}
static bool can_simple_adapt_for_single(const Mesh &mesh,
const eAttrDomain from_domain,
const eAttrDomain to_domain)
const AttrDomain from_domain,
const AttrDomain to_domain)
{
/* For some domain combinations, a single value will always map directly. For others, there may
* be loose elements on the result domain that should have the default value rather than the
* single value from the source. */
switch (from_domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
/* All other domains are always connected to points. */
return true;
case ATTR_DOMAIN_EDGE:
if (to_domain == ATTR_DOMAIN_POINT) {
case AttrDomain::Edge:
if (to_domain == AttrDomain::Point) {
return mesh.loose_verts().count == 0;
}
return true;
case ATTR_DOMAIN_FACE:
if (to_domain == ATTR_DOMAIN_POINT) {
case AttrDomain::Face:
if (to_domain == AttrDomain::Point) {
return mesh.verts_no_face().count == 0;
}
if (to_domain == ATTR_DOMAIN_EDGE) {
if (to_domain == AttrDomain::Edge) {
return mesh.loose_edges().count == 0;
}
return true;
case ATTR_DOMAIN_CORNER:
if (to_domain == ATTR_DOMAIN_POINT) {
case AttrDomain::Corner:
if (to_domain == AttrDomain::Point) {
return mesh.verts_no_face().count == 0;
}
if (to_domain == ATTR_DOMAIN_EDGE) {
if (to_domain == AttrDomain::Edge) {
return mesh.loose_edges().count == 0;
}
return true;
@ -772,8 +772,8 @@ static bool can_simple_adapt_for_single(const Mesh &mesh,
static GVArray adapt_mesh_attribute_domain(const Mesh &mesh,
const GVArray &varray,
const eAttrDomain from_domain,
const eAttrDomain to_domain)
const AttrDomain from_domain,
const AttrDomain to_domain)
{
if (!varray) {
return {};
@ -793,52 +793,52 @@ static GVArray adapt_mesh_attribute_domain(const Mesh &mesh,
}
switch (from_domain) {
case ATTR_DOMAIN_CORNER: {
case AttrDomain::Corner: {
switch (to_domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
return adapt_mesh_domain_corner_to_point(mesh, varray);
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
return adapt_mesh_domain_corner_to_face(mesh, varray);
case ATTR_DOMAIN_EDGE:
case AttrDomain::Edge:
return adapt_mesh_domain_corner_to_edge(mesh, varray);
default:
break;
}
break;
}
case ATTR_DOMAIN_POINT: {
case AttrDomain::Point: {
switch (to_domain) {
case ATTR_DOMAIN_CORNER:
case AttrDomain::Corner:
return adapt_mesh_domain_point_to_corner(mesh, varray);
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
return adapt_mesh_domain_point_to_face(mesh, varray);
case ATTR_DOMAIN_EDGE:
case AttrDomain::Edge:
return adapt_mesh_domain_point_to_edge(mesh, varray);
default:
break;
}
break;
}
case ATTR_DOMAIN_FACE: {
case AttrDomain::Face: {
switch (to_domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
return adapt_mesh_domain_face_to_point(mesh, varray);
case ATTR_DOMAIN_CORNER:
case AttrDomain::Corner:
return adapt_mesh_domain_face_to_corner(mesh, varray);
case ATTR_DOMAIN_EDGE:
case AttrDomain::Edge:
return adapt_mesh_domain_face_to_edge(mesh, varray);
default:
break;
}
break;
}
case ATTR_DOMAIN_EDGE: {
case AttrDomain::Edge: {
switch (to_domain) {
case ATTR_DOMAIN_CORNER:
case AttrDomain::Corner:
return adapt_mesh_domain_edge_to_corner(mesh, varray);
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
return adapt_mesh_domain_edge_to_point(mesh, varray);
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
return adapt_mesh_domain_edge_to_face(mesh, varray);
default:
break;
@ -891,9 +891,9 @@ class MeshVertexGroupsAttributeProvider final : public DynamicAttributesProvider
const Span<MDeformVert> dverts = mesh->deform_verts();
if (dverts.is_empty()) {
static const float default_value = 0.0f;
return {VArray<float>::ForSingle(default_value, mesh->verts_num), ATTR_DOMAIN_POINT};
return {VArray<float>::ForSingle(default_value, mesh->verts_num), AttrDomain::Point};
}
return {bke::varray_for_deform_verts(dverts, vertex_group_index), ATTR_DOMAIN_POINT};
return {bke::varray_for_deform_verts(dverts, vertex_group_index), AttrDomain::Point};
}
GAttributeWriter try_get_for_write(void *owner, const AttributeIDRef &attribute_id) const final
@ -913,7 +913,7 @@ class MeshVertexGroupsAttributeProvider final : public DynamicAttributesProvider
return {};
}
MutableSpan<MDeformVert> dverts = mesh->deform_verts_for_write();
return {bke::varray_for_mutable_deform_verts(dverts, vertex_group_index), ATTR_DOMAIN_POINT};
return {bke::varray_for_mutable_deform_verts(dverts, vertex_group_index), AttrDomain::Point};
}
bool try_delete(void *owner, const AttributeIDRef &attribute_id) const final
@ -952,16 +952,16 @@ class MeshVertexGroupsAttributeProvider final : public DynamicAttributesProvider
}
LISTBASE_FOREACH (const bDeformGroup *, group, &mesh->vertex_group_names) {
if (!callback(group->name, {ATTR_DOMAIN_POINT, CD_PROP_FLOAT})) {
if (!callback(group->name, {AttrDomain::Point, CD_PROP_FLOAT})) {
return false;
}
}
return true;
}
void foreach_domain(const FunctionRef<void(eAttrDomain)> callback) const final
void foreach_domain(const FunctionRef<void(AttrDomain)> callback) const final
{
callback(ATTR_DOMAIN_POINT);
callback(AttrDomain::Point);
}
};
@ -1004,7 +1004,7 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
#undef MAKE_MUTABLE_CUSTOM_DATA_GETTER
static BuiltinCustomDataLayerProvider position("position",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_FLOAT3,
CD_PROP_FLOAT3,
BuiltinAttributeProvider::Creatable,
@ -1013,7 +1013,7 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
tag_component_positions_changed);
static BuiltinCustomDataLayerProvider id("id",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_INT32,
CD_PROP_INT32,
BuiltinAttributeProvider::Creatable,
@ -1029,7 +1029,7 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
},
mf::build::exec_presets::AllSpanOrSingle());
static BuiltinCustomDataLayerProvider material_index("material_index",
ATTR_DOMAIN_FACE,
AttrDomain::Face,
CD_PROP_INT32,
CD_PROP_INT32,
BuiltinAttributeProvider::Creatable,
@ -1043,7 +1043,7 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
[](int2 value) { return math::max(value, int2(0)); },
mf::build::exec_presets::AllSpanOrSingle());
static BuiltinCustomDataLayerProvider edge_verts(".edge_verts",
ATTR_DOMAIN_EDGE,
AttrDomain::Edge,
CD_PROP_INT32_2D,
CD_PROP_INT32_2D,
BuiltinAttributeProvider::Creatable,
@ -1059,7 +1059,7 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
[](int value) { return std::max(value, 0); },
mf::build::exec_presets::AllSpanOrSingle());
static BuiltinCustomDataLayerProvider corner_vert(".corner_vert",
ATTR_DOMAIN_CORNER,
AttrDomain::Corner,
CD_PROP_INT32,
CD_PROP_INT32,
BuiltinAttributeProvider::Creatable,
@ -1068,7 +1068,7 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
nullptr,
AttributeValidator{&int_index_clamp});
static BuiltinCustomDataLayerProvider corner_edge(".corner_edge",
ATTR_DOMAIN_CORNER,
AttrDomain::Corner,
CD_PROP_INT32,
CD_PROP_INT32,
BuiltinAttributeProvider::Creatable,
@ -1078,7 +1078,7 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
AttributeValidator{&int_index_clamp});
static BuiltinCustomDataLayerProvider sharp_face("sharp_face",
ATTR_DOMAIN_FACE,
AttrDomain::Face,
CD_PROP_BOOL,
CD_PROP_BOOL,
BuiltinAttributeProvider::Creatable,
@ -1087,7 +1087,7 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
tag_component_sharpness_changed);
static BuiltinCustomDataLayerProvider sharp_edge("sharp_edge",
ATTR_DOMAIN_EDGE,
AttrDomain::Edge,
CD_PROP_BOOL,
CD_PROP_BOOL,
BuiltinAttributeProvider::Creatable,
@ -1096,10 +1096,10 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
tag_component_sharpness_changed);
static MeshVertexGroupsAttributeProvider vertex_groups;
static CustomDataAttributeProvider corner_custom_data(ATTR_DOMAIN_CORNER, corner_access);
static CustomDataAttributeProvider point_custom_data(ATTR_DOMAIN_POINT, point_access);
static CustomDataAttributeProvider edge_custom_data(ATTR_DOMAIN_EDGE, edge_access);
static CustomDataAttributeProvider face_custom_data(ATTR_DOMAIN_FACE, face_access);
static CustomDataAttributeProvider corner_custom_data(AttrDomain::Corner, corner_access);
static CustomDataAttributeProvider point_custom_data(AttrDomain::Point, point_access);
static CustomDataAttributeProvider edge_custom_data(AttrDomain::Edge, edge_access);
static CustomDataAttributeProvider face_custom_data(AttrDomain::Face, face_access);
return ComponentAttributeProviders({&position,
&edge_verts,
@ -1121,31 +1121,31 @@ static AttributeAccessorFunctions get_mesh_accessor_functions()
static const ComponentAttributeProviders providers = create_attribute_providers_for_mesh();
AttributeAccessorFunctions fn =
attribute_accessor_functions::accessor_functions_for_providers<providers>();
fn.domain_size = [](const void *owner, const eAttrDomain domain) {
fn.domain_size = [](const void *owner, const AttrDomain domain) {
if (owner == nullptr) {
return 0;
}
const Mesh &mesh = *static_cast<const Mesh *>(owner);
switch (domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
return mesh.verts_num;
case ATTR_DOMAIN_EDGE:
case AttrDomain::Edge:
return mesh.edges_num;
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
return mesh.faces_num;
case ATTR_DOMAIN_CORNER:
case AttrDomain::Corner:
return mesh.corners_num;
default:
return 0;
}
};
fn.domain_supported = [](const void * /*owner*/, const eAttrDomain domain) {
return ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_EDGE, ATTR_DOMAIN_FACE, ATTR_DOMAIN_CORNER);
fn.domain_supported = [](const void * /*owner*/, const AttrDomain domain) {
return ELEM(domain, AttrDomain::Point, AttrDomain::Edge, AttrDomain::Face, AttrDomain::Corner);
};
fn.adapt_domain = [](const void *owner,
const GVArray &varray,
const eAttrDomain from_domain,
const eAttrDomain to_domain) -> GVArray {
const AttrDomain from_domain,
const AttrDomain to_domain) -> GVArray {
if (owner == nullptr) {
return {};
}

View File

@ -140,7 +140,7 @@ static ComponentAttributeProviders create_attribute_providers_for_point_cloud()
}};
static BuiltinCustomDataLayerProvider position("position",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_FLOAT3,
CD_PROP_FLOAT3,
BuiltinAttributeProvider::Creatable,
@ -148,7 +148,7 @@ static ComponentAttributeProviders create_attribute_providers_for_point_cloud()
point_access,
tag_component_positions_changed);
static BuiltinCustomDataLayerProvider radius("radius",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_FLOAT,
CD_PROP_FLOAT,
BuiltinAttributeProvider::Creatable,
@ -156,14 +156,14 @@ static ComponentAttributeProviders create_attribute_providers_for_point_cloud()
point_access,
tag_component_radius_changed);
static BuiltinCustomDataLayerProvider id("id",
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_INT32,
CD_PROP_INT32,
BuiltinAttributeProvider::Creatable,
BuiltinAttributeProvider::Deletable,
point_access,
nullptr);
static CustomDataAttributeProvider point_custom_data(ATTR_DOMAIN_POINT, point_access);
static CustomDataAttributeProvider point_custom_data(AttrDomain::Point, point_access);
return ComponentAttributeProviders({&position, &radius, &id}, {&point_custom_data});
}
@ -173,26 +173,26 @@ static AttributeAccessorFunctions get_pointcloud_accessor_functions()
create_attribute_providers_for_point_cloud();
AttributeAccessorFunctions fn =
attribute_accessor_functions::accessor_functions_for_providers<providers>();
fn.domain_size = [](const void *owner, const eAttrDomain domain) {
fn.domain_size = [](const void *owner, const AttrDomain domain) {
if (owner == nullptr) {
return 0;
}
const PointCloud &pointcloud = *static_cast<const PointCloud *>(owner);
switch (domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
return pointcloud.totpoint;
default:
return 0;
}
};
fn.domain_supported = [](const void * /*owner*/, const eAttrDomain domain) {
return domain == ATTR_DOMAIN_POINT;
fn.domain_supported = [](const void * /*owner*/, const AttrDomain domain) {
return domain == AttrDomain::Point;
};
fn.adapt_domain = [](const void * /*owner*/,
const GVArray &varray,
const eAttrDomain from_domain,
const eAttrDomain to_domain) {
if (from_domain == to_domain && from_domain == ATTR_DOMAIN_POINT) {
const AttrDomain from_domain,
const AttrDomain to_domain) {
if (from_domain == to_domain && from_domain == AttrDomain::Point) {
return varray;
}
return GVArray{};

View File

@ -23,13 +23,13 @@
namespace blender::bke {
MeshFieldContext::MeshFieldContext(const Mesh &mesh, const eAttrDomain domain)
MeshFieldContext::MeshFieldContext(const Mesh &mesh, const AttrDomain domain)
: mesh_(mesh), domain_(domain)
{
BLI_assert(mesh.attributes().domain_supported(domain_));
}
CurvesFieldContext::CurvesFieldContext(const CurvesGeometry &curves, const eAttrDomain domain)
CurvesFieldContext::CurvesFieldContext(const CurvesGeometry &curves, const AttrDomain domain)
: curves_(curves), domain_(domain)
{
BLI_assert(curves.attributes().domain_supported(domain));
@ -57,7 +57,7 @@ GVArray GreasePencilLayerFieldContext::get_varray_for_input(const fn::FieldInput
}
GeometryFieldContext::GeometryFieldContext(const GeometryFieldContext &other,
const eAttrDomain domain)
const AttrDomain domain)
: geometry_(other.geometry_),
type_(other.type_),
domain_(domain),
@ -67,7 +67,7 @@ GeometryFieldContext::GeometryFieldContext(const GeometryFieldContext &other,
GeometryFieldContext::GeometryFieldContext(const void *geometry,
const GeometryComponent::Type type,
const eAttrDomain domain,
const AttrDomain domain,
const int grease_pencil_layer_index)
: geometry_(geometry),
type_(type),
@ -83,7 +83,7 @@ GeometryFieldContext::GeometryFieldContext(const void *geometry,
}
GeometryFieldContext::GeometryFieldContext(const GeometryComponent &component,
const eAttrDomain domain)
const AttrDomain domain)
: type_(component.type()), domain_(domain)
{
switch (component.type()) {
@ -109,7 +109,7 @@ GeometryFieldContext::GeometryFieldContext(const GeometryComponent &component,
static_cast<const GreasePencilComponent &>(component);
geometry_ = grease_pencil_component.get();
/* Need to use another constructor for other domains. */
BLI_assert(domain == ATTR_DOMAIN_LAYER);
BLI_assert(domain == AttrDomain::Layer);
break;
}
case GeometryComponent::Type::Instance: {
@ -125,26 +125,26 @@ GeometryFieldContext::GeometryFieldContext(const GeometryComponent &component,
}
}
GeometryFieldContext::GeometryFieldContext(const Mesh &mesh, eAttrDomain domain)
GeometryFieldContext::GeometryFieldContext(const Mesh &mesh, AttrDomain domain)
: geometry_(&mesh), type_(GeometryComponent::Type::Mesh), domain_(domain)
{
}
GeometryFieldContext::GeometryFieldContext(const CurvesGeometry &curves, eAttrDomain domain)
GeometryFieldContext::GeometryFieldContext(const CurvesGeometry &curves, AttrDomain domain)
: geometry_(&curves), type_(GeometryComponent::Type::Curve), domain_(domain)
{
}
GeometryFieldContext::GeometryFieldContext(const PointCloud &points)
: geometry_(&points), type_(GeometryComponent::Type::PointCloud), domain_(ATTR_DOMAIN_POINT)
: geometry_(&points), type_(GeometryComponent::Type::PointCloud), domain_(AttrDomain::Point)
{
}
GeometryFieldContext::GeometryFieldContext(const GreasePencil &grease_pencil)
: geometry_(&grease_pencil),
type_(GeometryComponent::Type::GreasePencil),
domain_(ATTR_DOMAIN_LAYER)
domain_(AttrDomain::Layer)
{
}
GeometryFieldContext::GeometryFieldContext(const GreasePencil &grease_pencil,
const eAttrDomain domain,
const AttrDomain domain,
const int layer_index)
: geometry_(&grease_pencil),
type_(GeometryComponent::Type::GreasePencil),
@ -155,7 +155,7 @@ GeometryFieldContext::GeometryFieldContext(const GreasePencil &grease_pencil,
GeometryFieldContext::GeometryFieldContext(const Instances &instances)
: geometry_(&instances),
type_(GeometryComponent::Type::Instance),
domain_(ATTR_DOMAIN_INSTANCE)
domain_(AttrDomain::Instance)
{
}
@ -171,7 +171,7 @@ std::optional<AttributeAccessor> GeometryFieldContext::attributes() const
return pointcloud->attributes();
}
if (const GreasePencil *grease_pencil = this->grease_pencil()) {
if (domain_ == ATTR_DOMAIN_LAYER) {
if (domain_ == AttrDomain::Layer) {
return grease_pencil->attributes();
}
else if (const greasepencil::Drawing *drawing =
@ -213,7 +213,7 @@ const GreasePencil *GeometryFieldContext::grease_pencil() const
const greasepencil::Drawing *GeometryFieldContext::grease_pencil_layer_drawing() const
{
if (!(this->type() == GeometryComponent::Type::GreasePencil) ||
!ELEM(domain_, ATTR_DOMAIN_CURVE, ATTR_DOMAIN_POINT))
!ELEM(domain_, AttrDomain::Curve, AttrDomain::Point))
{
return nullptr;
}
@ -279,7 +279,7 @@ GVArray GeometryFieldInput::get_varray_for_context(const fn::FieldContext &conte
return {};
}
std::optional<eAttrDomain> GeometryFieldInput::preferred_domain(
std::optional<AttrDomain> GeometryFieldInput::preferred_domain(
const GeometryComponent & /*component*/) const
{
return std::nullopt;
@ -302,7 +302,7 @@ GVArray MeshFieldInput::get_varray_for_context(const fn::FieldContext &context,
return {};
}
std::optional<eAttrDomain> MeshFieldInput::preferred_domain(const Mesh & /*mesh*/) const
std::optional<AttrDomain> MeshFieldInput::preferred_domain(const Mesh & /*mesh*/) const
{
return std::nullopt;
}
@ -325,7 +325,7 @@ GVArray CurvesFieldInput::get_varray_for_context(const fn::FieldContext &context
return {};
}
std::optional<eAttrDomain> CurvesFieldInput::preferred_domain(
std::optional<AttrDomain> CurvesFieldInput::preferred_domain(
const CurvesGeometry & /*curves*/) const
{
return std::nullopt;
@ -373,13 +373,13 @@ GVArray AttributeFieldInput::get_varray_for_context(const GeometryFieldContext &
const IndexMask & /*mask*/) const
{
const eCustomDataType data_type = cpp_type_to_custom_data_type(*type_);
const eAttrDomain domain = context.domain();
const AttrDomain domain = context.domain();
if (const GreasePencil *grease_pencil = context.grease_pencil()) {
const AttributeAccessor layer_attributes = grease_pencil->attributes();
if (domain == ATTR_DOMAIN_LAYER) {
if (domain == AttrDomain::Layer) {
return *layer_attributes.lookup(name_, data_type);
}
else if (ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) {
else if (ELEM(domain, AttrDomain::Point, AttrDomain::Curve)) {
const int layer_index = context.grease_pencil_layer_index();
const AttributeAccessor curves_attributes = *context.attributes();
if (const GAttributeReader reader = curves_attributes.lookup(name_, domain, data_type)) {
@ -428,7 +428,7 @@ bool AttributeFieldInput::is_equal_to(const fn::FieldNode &other) const
return false;
}
std::optional<eAttrDomain> AttributeFieldInput::preferred_domain(
std::optional<AttrDomain> AttributeFieldInput::preferred_domain(
const GeometryComponent &component) const
{
const std::optional<AttributeAccessor> attributes = component.attributes();
@ -442,11 +442,11 @@ std::optional<eAttrDomain> AttributeFieldInput::preferred_domain(
return meta_data->domain;
}
static StringRef get_random_id_attribute_name(const eAttrDomain domain)
static StringRef get_random_id_attribute_name(const AttrDomain domain)
{
switch (domain) {
case ATTR_DOMAIN_POINT:
case ATTR_DOMAIN_INSTANCE:
case AttrDomain::Point:
case AttrDomain::Instance:
return "id";
default:
return "";
@ -512,7 +512,7 @@ bool AnonymousAttributeFieldInput::is_equal_to(const fn::FieldNode &other) const
return false;
}
std::optional<eAttrDomain> AnonymousAttributeFieldInput::preferred_domain(
std::optional<AttrDomain> AnonymousAttributeFieldInput::preferred_domain(
const GeometryComponent &component) const
{
const std::optional<AttributeAccessor> attributes = component.attributes();
@ -530,8 +530,8 @@ GVArray NamedLayerSelectionFieldInput::get_varray_for_context(
const bke::GeometryFieldContext &context, const IndexMask &mask) const
{
using namespace bke::greasepencil;
const eAttrDomain domain = context.domain();
if (!ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE, ATTR_DOMAIN_LAYER)) {
const AttrDomain domain = context.domain();
if (!ELEM(domain, AttrDomain::Point, AttrDomain::Curve, AttrDomain::Layer)) {
return {};
}
@ -546,7 +546,7 @@ GVArray NamedLayerSelectionFieldInput::get_varray_for_context(
return {};
}
if (domain == ATTR_DOMAIN_LAYER) {
if (domain == AttrDomain::Layer) {
Array<bool> selection(mask.min_array_size());
layer_indices.to_bools(selection);
return VArray<bool>::ForContainer(std::move(selection));
@ -574,10 +574,10 @@ bool NamedLayerSelectionFieldInput::is_equal_to(const fn::FieldNode &other) cons
return false;
}
std::optional<eAttrDomain> NamedLayerSelectionFieldInput::preferred_domain(
std::optional<AttrDomain> NamedLayerSelectionFieldInput::preferred_domain(
const bke::GeometryComponent & /*component*/) const
{
return ATTR_DOMAIN_LAYER;
return AttrDomain::Layer;
}
} // namespace blender::bke
@ -627,7 +627,7 @@ static std::optional<AttributeIDRef> try_get_field_direct_attribute_id(const fn:
}
static bool attribute_kind_matches(const AttributeMetaData meta_data,
const eAttrDomain domain,
const AttrDomain domain,
const eCustomDataType data_type)
{
return meta_data.domain == domain && meta_data.data_type == data_type;
@ -639,7 +639,7 @@ static bool attribute_kind_matches(const AttributeMetaData meta_data,
*/
static bool try_add_shared_field_attribute(MutableAttributeAccessor attributes,
const AttributeIDRef &id_to_create,
const eAttrDomain domain,
const AttrDomain domain,
const fn::GField &field)
{
const std::optional<AttributeIDRef> field_id = try_get_field_direct_attribute_id(field);
@ -667,7 +667,7 @@ static bool try_add_shared_field_attribute(MutableAttributeAccessor attributes,
static bool try_capture_field_on_geometry(MutableAttributeAccessor attributes,
const GeometryFieldContext &field_context,
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const fn::Field<bool> &selection,
const fn::GField &field)
{
@ -747,12 +747,12 @@ static bool try_capture_field_on_geometry(MutableAttributeAccessor attributes,
bool try_capture_field_on_geometry(GeometryComponent &component,
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const fn::Field<bool> &selection,
const fn::GField &field)
{
if (component.type() == GeometryComponent::Type::GreasePencil &&
ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE))
ELEM(domain, AttrDomain::Point, AttrDomain::Curve))
{
/* Capture the field on every layer individually. */
auto &grease_pencil_component = static_cast<GreasePencilComponent &>(component);
@ -792,32 +792,32 @@ bool try_capture_field_on_geometry(GeometryComponent &component,
bool try_capture_field_on_geometry(GeometryComponent &component,
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const AttrDomain domain,
const fn::GField &field)
{
const fn::Field<bool> selection = fn::make_constant_field<bool>(true);
return try_capture_field_on_geometry(component, attribute_id, domain, selection, field);
}
std::optional<eAttrDomain> try_detect_field_domain(const GeometryComponent &component,
std::optional<AttrDomain> try_detect_field_domain(const GeometryComponent &component,
const fn::GField &field)
{
const GeometryComponent::Type component_type = component.type();
if (component_type == GeometryComponent::Type::PointCloud) {
return ATTR_DOMAIN_POINT;
return AttrDomain::Point;
}
if (component_type == GeometryComponent::Type::GreasePencil) {
return ATTR_DOMAIN_LAYER;
return AttrDomain::Layer;
}
if (component_type == GeometryComponent::Type::Instance) {
return ATTR_DOMAIN_INSTANCE;
return AttrDomain::Instance;
}
const std::shared_ptr<const fn::FieldInputs> &field_inputs = field.node().field_inputs();
if (!field_inputs) {
return std::nullopt;
}
std::optional<eAttrDomain> output_domain;
auto handle_domain = [&](const std::optional<eAttrDomain> domain) {
std::optional<AttrDomain> output_domain;
auto handle_domain = [&](const std::optional<AttrDomain> domain) {
if (!domain.has_value()) {
return false;
}

View File

@ -60,7 +60,7 @@ GeometryComponentPtr GeometryComponent::create(Type component_type)
return {};
}
int GeometryComponent::attribute_domain_size(const eAttrDomain domain) const
int GeometryComponent::attribute_domain_size(const AttrDomain domain) const
{
if (this->is_empty()) {
return 0;
@ -608,15 +608,15 @@ void GeometrySet::propagate_attributes_from_layer_to_instances(
if (id.is_anonymous() && !propagation_info.propagate(id.anonymous_id())) {
return true;
}
const GAttributeReader src = src_attributes.lookup(id, ATTR_DOMAIN_LAYER);
const GAttributeReader src = src_attributes.lookup(id, AttrDomain::Layer);
if (src.sharing_info && src.varray.is_span()) {
const AttributeInitShared init(src.varray.get_internal_span().data(), *src.sharing_info);
if (dst_attributes.add(id, ATTR_DOMAIN_INSTANCE, meta_data.data_type, init)) {
if (dst_attributes.add(id, AttrDomain::Instance, meta_data.data_type, init)) {
return true;
}
}
GSpanAttributeWriter dst = dst_attributes.lookup_or_add_for_write_only_span(
id, ATTR_DOMAIN_INSTANCE, meta_data.data_type);
id, AttrDomain::Instance, meta_data.data_type);
if (!dst) {
return true;
}
@ -658,10 +658,10 @@ void GeometrySet::gather_attributes_for_propagation(
return;
}
eAttrDomain domain = meta_data.domain;
AttrDomain domain = meta_data.domain;
if (dst_component_type != GeometryComponent::Type::Instance &&
domain == ATTR_DOMAIN_INSTANCE) {
domain = ATTR_DOMAIN_POINT;
domain == AttrDomain::Instance) {
domain = AttrDomain::Point;
}
auto add_info = [&](AttributeKind *attribute_kind) {

View File

@ -2448,6 +2448,7 @@ static void gpencil_generate_edgeloops(Object *ob,
const bool use_vgroups)
{
using namespace blender;
using namespace blender::bke;
Mesh *mesh = (Mesh *)ob->data;
if (mesh->edges_num == 0) {
return;
@ -2458,7 +2459,7 @@ static void gpencil_generate_edgeloops(Object *ob,
const blender::Span<blender::float3> vert_normals = mesh->vert_normals();
const bke::AttributeAccessor attributes = mesh->attributes();
const VArray<bool> uv_seams = *attributes.lookup_or_default<bool>(
".uv_seam", ATTR_DOMAIN_EDGE, false);
".uv_seam", AttrDomain::Edge, false);
/* Arrays for all edge vertices (forward and backward) that form a edge loop.
* This is reused for each edge-loop to create gpencil stroke. */
@ -2707,7 +2708,7 @@ bool BKE_gpencil_convert_mesh(Main *bmain,
int i;
const VArray<int> mesh_material_indices = *me_eval->attributes().lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
"material_index", AttrDomain::Face, 0);
for (i = 0; i < faces_len; i++) {
const IndexRange face = faces[i];

View File

@ -243,17 +243,17 @@ static const std::string ATTR_OPACITY = "opacity";
static const std::string ATTR_VERTEX_COLOR = "vertex_color";
/* Curves attributes getters */
static int domain_num(const CurvesGeometry &curves, const eAttrDomain domain)
static int domain_num(const CurvesGeometry &curves, const AttrDomain domain)
{
return domain == ATTR_DOMAIN_POINT ? curves.points_num() : curves.curves_num();
return domain == AttrDomain::Point ? curves.points_num() : curves.curves_num();
}
static CustomData &domain_custom_data(CurvesGeometry &curves, const eAttrDomain domain)
static CustomData &domain_custom_data(CurvesGeometry &curves, const AttrDomain domain)
{
return domain == ATTR_DOMAIN_POINT ? curves.point_data : curves.curve_data;
return domain == AttrDomain::Point ? curves.point_data : curves.curve_data;
}
template<typename T>
static MutableSpan<T> get_mutable_attribute(CurvesGeometry &curves,
const eAttrDomain domain,
const AttrDomain domain,
const StringRefNull name,
const T default_value = T())
{
@ -370,37 +370,37 @@ bke::CurvesGeometry &Drawing::strokes_for_write()
VArray<float> Drawing::radii() const
{
return *this->strokes().attributes().lookup_or_default<float>(
ATTR_RADIUS, ATTR_DOMAIN_POINT, 0.01f);
ATTR_RADIUS, AttrDomain::Point, 0.01f);
}
MutableSpan<float> Drawing::radii_for_write()
{
return get_mutable_attribute<float>(
this->strokes_for_write(), ATTR_DOMAIN_POINT, ATTR_RADIUS, 0.01f);
this->strokes_for_write(), AttrDomain::Point, ATTR_RADIUS, 0.01f);
}
VArray<float> Drawing::opacities() const
{
return *this->strokes().attributes().lookup_or_default<float>(
ATTR_OPACITY, ATTR_DOMAIN_POINT, 1.0f);
ATTR_OPACITY, AttrDomain::Point, 1.0f);
}
MutableSpan<float> Drawing::opacities_for_write()
{
return get_mutable_attribute<float>(
this->strokes_for_write(), ATTR_DOMAIN_POINT, ATTR_OPACITY, 1.0f);
this->strokes_for_write(), AttrDomain::Point, ATTR_OPACITY, 1.0f);
}
VArray<ColorGeometry4f> Drawing::vertex_colors() const
{
return *this->strokes().attributes().lookup_or_default<ColorGeometry4f>(
ATTR_VERTEX_COLOR, ATTR_DOMAIN_POINT, ColorGeometry4f(0.0f, 0.0f, 0.0f, 0.0f));
ATTR_VERTEX_COLOR, AttrDomain::Point, ColorGeometry4f(0.0f, 0.0f, 0.0f, 0.0f));
}
MutableSpan<ColorGeometry4f> Drawing::vertex_colors_for_write()
{
return get_mutable_attribute<ColorGeometry4f>(this->strokes_for_write(),
ATTR_DOMAIN_POINT,
AttrDomain::Point,
ATTR_VERTEX_COLOR,
ColorGeometry4f(0.0f, 0.0f, 0.0f, 0.0f));
}
@ -1363,7 +1363,7 @@ void BKE_grease_pencil_material_remap(GreasePencil *grease_pencil, const uint *r
greasepencil::Drawing &drawing = reinterpret_cast<GreasePencilDrawing *>(base)->wrap();
MutableAttributeAccessor attributes = drawing.strokes_for_write().attributes_for_write();
SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_span<int>(
"material_index", ATTR_DOMAIN_CURVE);
"material_index", AttrDomain::Curve);
if (!material_indices) {
return;
}
@ -1416,7 +1416,7 @@ bool BKE_grease_pencil_material_index_used(GreasePencil *grease_pencil, int inde
greasepencil::Drawing &drawing = reinterpret_cast<GreasePencilDrawing *>(base)->wrap();
AttributeAccessor attributes = drawing.strokes().attributes();
const VArraySpan<int> material_indices = *attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_CURVE, 0);
"material_index", AttrDomain::Curve, 0);
if (material_indices.contains(index)) {
return true;

View File

@ -58,38 +58,38 @@ void legacy_gpencil_frame_to_grease_pencil_drawing(const bGPDframe &gpf,
MutableSpan<float> radii = drawing.radii_for_write();
MutableSpan<float> opacities = drawing.opacities_for_write();
SpanAttributeWriter<float> delta_times = attributes.lookup_or_add_for_write_span<float>(
"delta_time", ATTR_DOMAIN_POINT);
"delta_time", AttrDomain::Point);
SpanAttributeWriter<float> rotations = attributes.lookup_or_add_for_write_span<float>(
"rotation", ATTR_DOMAIN_POINT);
"rotation", AttrDomain::Point);
SpanAttributeWriter<ColorGeometry4f> vertex_colors =
attributes.lookup_or_add_for_write_span<ColorGeometry4f>("vertex_color", ATTR_DOMAIN_POINT);
attributes.lookup_or_add_for_write_span<ColorGeometry4f>("vertex_color", AttrDomain::Point);
SpanAttributeWriter<bool> selection = attributes.lookup_or_add_for_write_span<bool>(
".selection", ATTR_DOMAIN_POINT);
".selection", AttrDomain::Point);
/* Curve Attributes. */
SpanAttributeWriter<bool> stroke_cyclic = attributes.lookup_or_add_for_write_span<bool>(
"cyclic", ATTR_DOMAIN_CURVE);
"cyclic", AttrDomain::Curve);
/* TODO: This should be a `double` attribute. */
SpanAttributeWriter<float> stroke_init_times = attributes.lookup_or_add_for_write_span<float>(
"init_time", ATTR_DOMAIN_CURVE);
"init_time", AttrDomain::Curve);
SpanAttributeWriter<int8_t> stroke_start_caps = attributes.lookup_or_add_for_write_span<int8_t>(
"start_cap", ATTR_DOMAIN_CURVE);
"start_cap", AttrDomain::Curve);
SpanAttributeWriter<int8_t> stroke_end_caps = attributes.lookup_or_add_for_write_span<int8_t>(
"end_cap", ATTR_DOMAIN_CURVE);
"end_cap", AttrDomain::Curve);
SpanAttributeWriter<float> stroke_hardnesses = attributes.lookup_or_add_for_write_span<float>(
"hardness", ATTR_DOMAIN_CURVE);
"hardness", AttrDomain::Curve);
SpanAttributeWriter<float> stroke_point_aspect_ratios =
attributes.lookup_or_add_for_write_span<float>("point_aspect_ratio", ATTR_DOMAIN_CURVE);
attributes.lookup_or_add_for_write_span<float>("point_aspect_ratio", AttrDomain::Curve);
SpanAttributeWriter<float2> stroke_fill_translations =
attributes.lookup_or_add_for_write_span<float2>("fill_translation", ATTR_DOMAIN_CURVE);
attributes.lookup_or_add_for_write_span<float2>("fill_translation", AttrDomain::Curve);
SpanAttributeWriter<float> stroke_fill_rotations =
attributes.lookup_or_add_for_write_span<float>("fill_rotation", ATTR_DOMAIN_CURVE);
attributes.lookup_or_add_for_write_span<float>("fill_rotation", AttrDomain::Curve);
SpanAttributeWriter<float2> stroke_fill_scales = attributes.lookup_or_add_for_write_span<float2>(
"fill_scale", ATTR_DOMAIN_CURVE);
"fill_scale", AttrDomain::Curve);
SpanAttributeWriter<ColorGeometry4f> stroke_fill_colors =
attributes.lookup_or_add_for_write_span<ColorGeometry4f>("fill_color", ATTR_DOMAIN_CURVE);
attributes.lookup_or_add_for_write_span<ColorGeometry4f>("fill_color", AttrDomain::Curve);
SpanAttributeWriter<int> stroke_materials = attributes.lookup_or_add_for_write_span<int>(
"material_index", ATTR_DOMAIN_CURVE);
"material_index", AttrDomain::Curve);
int stroke_i = 0;
LISTBASE_FOREACH_INDEX (bGPDstroke *, gps, &gpf.strokes, stroke_i) {

View File

@ -184,7 +184,7 @@ void Instances::remove(const IndexMask &mask,
array_utils::gather(transforms_.as_span(), mask, new_instances.transforms_.as_mutable_span());
gather_attributes(this->attributes(),
ATTR_DOMAIN_INSTANCE,
AttrDomain::Instance,
propagation_info,
{"position"},
mask,

View File

@ -2226,6 +2226,7 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
float (*r_loop_normals)[3])
{
using namespace blender;
using namespace blender::bke;
if (r_vert_normals == nullptr && r_face_normals == nullptr && r_loop_normals == nullptr) {
return;
}
@ -2278,8 +2279,8 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
const blender::short2 *clnors = static_cast<const blender::short2 *>(
CustomData_get_layer(&mesh->corner_data, CD_CUSTOMLOOPNORMAL));
const bke::AttributeAccessor attributes = mesh->attributes();
const VArraySpan sharp_edges = *attributes.lookup<bool>("sharp_edge", ATTR_DOMAIN_EDGE);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
const VArraySpan sharp_edges = *attributes.lookup<bool>("sharp_edge", AttrDomain::Edge);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", AttrDomain::Face);
blender::bke::mesh::normals_calc_loop(
positions,
edges,

View File

@ -642,18 +642,22 @@ MutableSpan<MDeformVert> Mesh::deform_verts_for_write()
this->verts_num};
}
namespace blender::bke {
static void mesh_ensure_cdlayers_primary(Mesh &mesh)
{
blender::bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
blender::bke::AttributeInitConstruct attribute_init;
MutableAttributeAccessor attributes = mesh.attributes_for_write();
AttributeInitConstruct attribute_init;
/* Try to create attributes if they do not exist. */
attributes.add("position", ATTR_DOMAIN_POINT, CD_PROP_FLOAT3, attribute_init);
attributes.add(".edge_verts", ATTR_DOMAIN_EDGE, CD_PROP_INT32_2D, attribute_init);
attributes.add(".corner_vert", ATTR_DOMAIN_CORNER, CD_PROP_INT32, attribute_init);
attributes.add(".corner_edge", ATTR_DOMAIN_CORNER, CD_PROP_INT32, attribute_init);
attributes.add("position", AttrDomain::Point, CD_PROP_FLOAT3, attribute_init);
attributes.add(".edge_verts", AttrDomain::Edge, CD_PROP_INT32_2D, attribute_init);
attributes.add(".corner_vert", AttrDomain::Corner, CD_PROP_INT32, attribute_init);
attributes.add(".corner_edge", AttrDomain::Corner, CD_PROP_INT32, attribute_init);
}
} // namespace blender::bke
Mesh *BKE_mesh_new_nomain(const int verts_num,
const int edges_num,
const int faces_num,
@ -668,7 +672,7 @@ Mesh *BKE_mesh_new_nomain(const int verts_num,
mesh->faces_num = faces_num;
mesh->corners_num = corners_num;
mesh_ensure_cdlayers_primary(*mesh);
blender::bke::mesh_ensure_cdlayers_primary(*mesh);
BKE_mesh_face_offsets_ensure_alloc(mesh);
return mesh;
@ -770,7 +774,7 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
/* The destination mesh should at least have valid primary CD layers,
* even in cases where the source mesh does not. */
mesh_ensure_cdlayers_primary(*me_dst);
blender::bke::mesh_ensure_cdlayers_primary(*me_dst);
BKE_mesh_face_offsets_ensure_alloc(me_dst);
if (do_tessface && !CustomData_get_layer(&me_dst->fdata_legacy, CD_MFACE)) {
CustomData_add_layer(&me_dst->fdata_legacy, CD_MFACE, CD_SET_DEFAULT, me_dst->totface_legacy);
@ -1043,7 +1047,7 @@ void BKE_mesh_material_index_remove(Mesh *mesh, short index)
if (!material_indices) {
return;
}
if (material_indices.domain != ATTR_DOMAIN_FACE) {
if (material_indices.domain != AttrDomain::Face) {
BLI_assert_unreachable();
return;
}
@ -1065,7 +1069,7 @@ bool BKE_mesh_material_index_used(Mesh *mesh, short index)
using namespace blender::bke;
const AttributeAccessor attributes = mesh->attributes();
const VArray<int> material_indices = *attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
"material_index", AttrDomain::Face, 0);
if (material_indices.is_single()) {
return material_indices.get_internal_single() == index;
}
@ -1108,7 +1112,7 @@ void BKE_mesh_material_remap(Mesh *mesh, const uint *remap, uint remap_len)
else {
MutableAttributeAccessor attributes = mesh->attributes_for_write();
SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_span<int>(
"material_index", ATTR_DOMAIN_FACE);
"material_index", AttrDomain::Face);
if (!material_indices) {
return;
}
@ -1134,7 +1138,7 @@ void mesh_smooth_set(Mesh &mesh, const bool use_smooth)
else {
attributes.remove("sharp_edge");
SpanAttributeWriter<bool> sharp_faces = attributes.lookup_or_add_for_write_only_span<bool>(
"sharp_face", ATTR_DOMAIN_FACE);
"sharp_face", AttrDomain::Face);
sharp_faces.span.fill(true);
sharp_faces.finish();
}
@ -1153,8 +1157,8 @@ void mesh_sharp_edges_set_from_angle(Mesh &mesh, const float angle)
return;
}
SpanAttributeWriter<bool> sharp_edges = attributes.lookup_or_add_for_write_span<bool>(
"sharp_edge", ATTR_DOMAIN_EDGE);
const VArraySpan<bool> sharp_faces = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
"sharp_edge", AttrDomain::Edge);
const VArraySpan<bool> sharp_faces = *attributes.lookup<bool>("sharp_face", AttrDomain::Face);
mesh::edges_sharp_from_angle_set(mesh.faces(),
mesh.corner_verts(),
mesh.corner_edges(),
@ -1283,11 +1287,11 @@ void BKE_mesh_mselect_validate(Mesh *mesh)
const AttributeAccessor attributes = mesh->attributes();
const VArray<bool> select_vert = *attributes.lookup_or_default<bool>(
".select_vert", ATTR_DOMAIN_POINT, false);
".select_vert", AttrDomain::Point, false);
const VArray<bool> select_edge = *attributes.lookup_or_default<bool>(
".select_edge", ATTR_DOMAIN_EDGE, false);
".select_edge", AttrDomain::Edge, false);
const VArray<bool> select_poly = *attributes.lookup_or_default<bool>(
".select_poly", ATTR_DOMAIN_FACE, false);
".select_poly", AttrDomain::Face, false);
for (i_src = 0, i_dst = 0; i_src < mesh->totselect; i_src++) {
int index = mselect_src[i_src].index;

View File

@ -418,7 +418,7 @@ static void copy_face_attributes(Mesh *dest_mesh,
/* Fix material indices after they have been transferred as a generic attribute. */
const VArray<int> src_material_indices = *orig_me->attributes().lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
"material_index", bke::AttrDomain::Face, 0);
const int src_index = src_material_indices[index_in_orig_me];
if (material_remap.index_range().contains(src_index)) {
const int remapped_index = material_remap[src_index];
@ -738,7 +738,7 @@ static Mesh *imesh_to_mesh(IMesh *im, MeshesToIMeshInfo &mim)
* and set the vertices in the appropriate loops. */
bke::SpanAttributeWriter<int> dst_material_indices =
result->attributes_for_write().lookup_or_add_for_write_only_span<int>("material_index",
ATTR_DOMAIN_FACE);
bke::AttrDomain::Face);
int cur_loop_index = 0;
MutableSpan<int> dst_corner_verts = result->corner_verts_for_write();
MutableSpan<int> dst_face_offsets = result->face_offsets_for_write();

View File

@ -207,7 +207,7 @@ void BKE_mesh_calc_edges(Mesh *mesh, bool keep_existing_edges, const bool select
/* Create new edges. */
MutableAttributeAccessor attributes = mesh->attributes_for_write();
attributes.add<int>(".corner_edge", ATTR_DOMAIN_CORNER, AttributeInitConstruct());
attributes.add<int>(".corner_edge", AttrDomain::Corner, AttributeInitConstruct());
MutableSpan<int2> new_edges{
static_cast<int2 *>(MEM_calloc_arrayN(new_totedge, sizeof(int2), __func__)), new_totedge};
calc_edges::serialize_and_initialize_deduplicated_edges(edge_maps, new_edges);
@ -221,12 +221,12 @@ void BKE_mesh_calc_edges(Mesh *mesh, bool keep_existing_edges, const bool select
CustomData_free(&mesh->edge_data, mesh->edges_num);
CustomData_reset(&mesh->edge_data);
mesh->edges_num = new_totedge;
attributes.add<int2>(".edge_verts", ATTR_DOMAIN_EDGE, AttributeInitMoveArray(new_edges.data()));
attributes.add<int2>(".edge_verts", AttrDomain::Edge, AttributeInitMoveArray(new_edges.data()));
if (select_new_edges) {
MutableAttributeAccessor attributes = mesh->attributes_for_write();
SpanAttributeWriter<bool> select_edge = attributes.lookup_or_add_for_write_span<bool>(
".select_edge", ATTR_DOMAIN_EDGE);
".select_edge", AttrDomain::Edge);
if (select_edge) {
int new_edge_index = 0;
for (const EdgeMap &edge_map : edge_maps) {

View File

@ -530,7 +530,7 @@ static std::optional<MeshMismatch> verify_attributes_compatible(
static std::optional<MeshMismatch> sort_domain_using_attributes(
const AttributeAccessor &mesh1_attributes,
const AttributeAccessor &mesh2_attributes,
const eAttrDomain domain,
const AttrDomain domain,
const Span<StringRef> excluded_attributes,
IndexMapping &maps,
const float threshold)
@ -587,16 +587,16 @@ static std::optional<MeshMismatch> sort_domain_using_attributes(
component_i);
if (!attributes_line_up) {
switch (domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
mismatch = MeshMismatch::VertexAttributes;
return;
case ATTR_DOMAIN_EDGE:
case AttrDomain::Edge:
mismatch = MeshMismatch::EdgeAttributes;
return;
case ATTR_DOMAIN_CORNER:
case AttrDomain::Corner:
mismatch = MeshMismatch::CornerAttributes;
return;
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
mismatch = MeshMismatch::FaceAttributes;
return;
default:
@ -792,7 +792,7 @@ std::optional<MeshMismatch> compare_meshes(const Mesh &mesh1,
IndexMapping verts(mesh1.verts_num);
mismatch = sort_domain_using_attributes(
mesh1_attributes, mesh2_attributes, ATTR_DOMAIN_POINT, {}, verts, threshold);
mesh1_attributes, mesh2_attributes, AttrDomain::Point, {}, verts, threshold);
if (mismatch) {
return mismatch;
};
@ -806,7 +806,7 @@ std::optional<MeshMismatch> compare_meshes(const Mesh &mesh1,
}
mismatch = sort_domain_using_attributes(
mesh1_attributes, mesh2_attributes, ATTR_DOMAIN_EDGE, {".edge_verts"}, edges, threshold);
mesh1_attributes, mesh2_attributes, AttrDomain::Edge, {".edge_verts"}, edges, threshold);
if (mismatch) {
return mismatch;
};
@ -825,7 +825,7 @@ std::optional<MeshMismatch> compare_meshes(const Mesh &mesh1,
mismatch = sort_domain_using_attributes(mesh1_attributes,
mesh2_attributes,
ATTR_DOMAIN_CORNER,
AttrDomain::Corner,
{".corner_vert", ".corner_edge"},
corners,
threshold);
@ -842,7 +842,7 @@ std::optional<MeshMismatch> compare_meshes(const Mesh &mesh1,
}
mismatch = sort_domain_using_attributes(
mesh1_attributes, mesh2_attributes, ATTR_DOMAIN_FACE, {}, faces, threshold);
mesh1_attributes, mesh2_attributes, AttrDomain::Face, {}, faces, threshold);
if (mismatch) {
return mismatch;
};

View File

@ -124,11 +124,11 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
MutableAttributeAccessor attributes = mesh->attributes_for_write();
SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_only_span<int>(
"material_index", ATTR_DOMAIN_FACE);
"material_index", AttrDomain::Face);
SpanAttributeWriter<bool> sharp_faces = attributes.lookup_or_add_for_write_span<bool>(
"sharp_face", ATTR_DOMAIN_FACE);
"sharp_face", AttrDomain::Face);
SpanAttributeWriter<float2> uv_attribute = attributes.lookup_or_add_for_write_span<float2>(
DATA_("UVMap"), ATTR_DOMAIN_CORNER);
DATA_("UVMap"), AttrDomain::Corner);
MutableSpan<float2> uv_map = uv_attribute.span;
int dst_vert = 0;

View File

@ -544,7 +544,7 @@ void mesh_hide_vert_flush(Mesh &mesh)
MutableAttributeAccessor attributes = mesh.attributes_for_write();
const VArray<bool> hide_vert = *attributes.lookup_or_default<bool>(
".hide_vert", ATTR_DOMAIN_POINT, false);
".hide_vert", AttrDomain::Point, false);
if (hide_vert.is_single() && !hide_vert.get_internal_single()) {
attributes.remove(".hide_edge");
attributes.remove(".hide_poly");
@ -553,9 +553,9 @@ void mesh_hide_vert_flush(Mesh &mesh)
const VArraySpan<bool> hide_vert_span{hide_vert};
SpanAttributeWriter<bool> hide_edge = attributes.lookup_or_add_for_write_only_span<bool>(
".hide_edge", ATTR_DOMAIN_EDGE);
".hide_edge", AttrDomain::Edge);
SpanAttributeWriter<bool> hide_poly = attributes.lookup_or_add_for_write_only_span<bool>(
".hide_poly", ATTR_DOMAIN_FACE);
".hide_poly", AttrDomain::Face);
edge_hide_from_vert(mesh.edges(), hide_vert_span, hide_edge.span);
face_hide_from_vert(mesh.faces(), mesh.corner_verts(), hide_vert_span, hide_poly.span);
@ -569,7 +569,7 @@ void mesh_hide_face_flush(Mesh &mesh)
MutableAttributeAccessor attributes = mesh.attributes_for_write();
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", AttrDomain::Face, false);
if (hide_poly.is_single() && !hide_poly.get_internal_single()) {
attributes.remove(".hide_vert");
attributes.remove(".hide_edge");
@ -580,9 +580,9 @@ void mesh_hide_face_flush(Mesh &mesh)
const Span<int> corner_verts = mesh.corner_verts();
const Span<int> corner_edges = mesh.corner_edges();
SpanAttributeWriter<bool> hide_vert = attributes.lookup_or_add_for_write_only_span<bool>(
".hide_vert", ATTR_DOMAIN_POINT);
".hide_vert", AttrDomain::Point);
SpanAttributeWriter<bool> hide_edge = attributes.lookup_or_add_for_write_only_span<bool>(
".hide_edge", ATTR_DOMAIN_EDGE);
".hide_edge", AttrDomain::Edge);
/* Hide all edges or vertices connected to hidden polygons. */
threading::parallel_for(faces.index_range(), 1024, [&](const IndexRange range) {
@ -617,22 +617,22 @@ void mesh_select_face_flush(Mesh &mesh)
{
MutableAttributeAccessor attributes = mesh.attributes_for_write();
const VArray<bool> select_poly = *attributes.lookup_or_default<bool>(
".select_poly", ATTR_DOMAIN_FACE, false);
".select_poly", AttrDomain::Face, false);
if (select_poly.is_single() && !select_poly.get_internal_single()) {
attributes.remove(".select_vert");
attributes.remove(".select_edge");
return;
}
SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_only_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
".select_vert", AttrDomain::Point);
SpanAttributeWriter<bool> select_edge = attributes.lookup_or_add_for_write_only_span<bool>(
".select_edge", ATTR_DOMAIN_EDGE);
".select_edge", AttrDomain::Edge);
/* Use generic domain interpolation to read the face attribute on the other domains.
* Assume selected faces are not hidden and none of their vertices/edges are hidden. */
array_utils::copy(*attributes.lookup_or_default<bool>(".select_poly", ATTR_DOMAIN_POINT, false),
array_utils::copy(*attributes.lookup_or_default<bool>(".select_poly", AttrDomain::Point, false),
select_vert.span);
array_utils::copy(*attributes.lookup_or_default<bool>(".select_poly", ATTR_DOMAIN_EDGE, false),
array_utils::copy(*attributes.lookup_or_default<bool>(".select_poly", AttrDomain::Edge, false),
select_edge.span);
select_vert.finish();
@ -643,31 +643,31 @@ void mesh_select_vert_flush(Mesh &mesh)
{
MutableAttributeAccessor attributes = mesh.attributes_for_write();
const VArray<bool> select_vert = *attributes.lookup_or_default<bool>(
".select_vert", ATTR_DOMAIN_POINT, false);
".select_vert", AttrDomain::Point, false);
if (select_vert.is_single() && !select_vert.get_internal_single()) {
attributes.remove(".select_edge");
attributes.remove(".select_poly");
return;
}
SpanAttributeWriter<bool> select_edge = attributes.lookup_or_add_for_write_only_span<bool>(
".select_edge", ATTR_DOMAIN_EDGE);
".select_edge", AttrDomain::Edge);
SpanAttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write_only_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
".select_poly", AttrDomain::Face);
{
IndexMaskMemory memory;
const VArray<bool> hide_edge = *attributes.lookup_or_default<bool>(
".hide_edge", ATTR_DOMAIN_EDGE, false);
".hide_edge", AttrDomain::Edge, false);
array_utils::copy(
*attributes.lookup_or_default<bool>(".select_vert", ATTR_DOMAIN_EDGE, false),
*attributes.lookup_or_default<bool>(".select_vert", AttrDomain::Edge, false),
IndexMask::from_bools(hide_edge, memory).complement(hide_edge.index_range(), memory),
select_edge.span);
}
{
IndexMaskMemory memory;
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", AttrDomain::Face, false);
array_utils::copy(
*attributes.lookup_or_default<bool>(".select_vert", ATTR_DOMAIN_FACE, false),
*attributes.lookup_or_default<bool>(".select_vert", AttrDomain::Face, false),
IndexMask::from_bools(hide_poly, memory).complement(hide_poly.index_range(), memory),
select_poly.span);
}
@ -679,31 +679,31 @@ void mesh_select_edge_flush(Mesh &mesh)
{
MutableAttributeAccessor attributes = mesh.attributes_for_write();
const VArray<bool> select_edge = *attributes.lookup_or_default<bool>(
".select_edge", ATTR_DOMAIN_POINT, false);
".select_edge", AttrDomain::Point, false);
if (select_edge.is_single() && !select_edge.get_internal_single()) {
attributes.remove(".select_vert");
attributes.remove(".select_poly");
return;
}
SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_only_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
".select_vert", AttrDomain::Point);
SpanAttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write_only_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
".select_poly", AttrDomain::Face);
{
IndexMaskMemory memory;
const VArray<bool> hide_vert = *attributes.lookup_or_default<bool>(
".hide_vert", ATTR_DOMAIN_POINT, false);
".hide_vert", AttrDomain::Point, false);
array_utils::copy(
*attributes.lookup_or_default<bool>(".select_vert", ATTR_DOMAIN_POINT, false),
*attributes.lookup_or_default<bool>(".select_vert", AttrDomain::Point, false),
IndexMask::from_bools(hide_vert, memory).complement(hide_vert.index_range(), memory),
select_vert.span);
}
{
IndexMaskMemory memory;
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", AttrDomain::Face, false);
array_utils::copy(
*attributes.lookup_or_default<bool>(".select_vert", ATTR_DOMAIN_FACE, false),
*attributes.lookup_or_default<bool>(".select_vert", AttrDomain::Face, false),
IndexMask::from_bools(hide_poly, memory).complement(hide_poly.index_range(), memory),
select_poly.span);
}

View File

@ -78,7 +78,7 @@ void mesh_flip_faces(Mesh &mesh, const IndexMask &selection)
if (meta_data.data_type == CD_PROP_STRING) {
return true;
}
if (meta_data.domain != ATTR_DOMAIN_CORNER) {
if (meta_data.domain != AttrDomain::Corner) {
return true;
}
if (ELEM(attribute_id.name(), ".corner_vert", ".corner_edge")) {

View File

@ -1286,7 +1286,7 @@ void BKE_mesh_legacy_sharp_faces_from_flags(Mesh *mesh)
}))
{
SpanAttributeWriter<bool> sharp_faces = attributes.lookup_or_add_for_write_only_span<bool>(
"sharp_face", ATTR_DOMAIN_FACE);
"sharp_face", AttrDomain::Face);
threading::parallel_for(polys.index_range(), 4096, [&](const IndexRange range) {
for (const int i : range) {
sharp_faces.span[i] = !(polys[i].flag_legacy & ME_SMOOTH);
@ -1384,7 +1384,7 @@ static void move_face_map_data_to_attributes(Mesh *mesh)
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
for (const auto item : groups.items()) {
bke::SpanAttributeWriter<bool> attribute = attributes.lookup_or_add_for_write_span<bool>(
".temp_face_map_" + std::to_string(item.key), ATTR_DOMAIN_FACE);
".temp_face_map_" + std::to_string(item.key), bke::AttrDomain::Face);
if (attribute) {
attribute.span.fill_indices(item.value.as_span(), true);
attribute.finish();
@ -1544,7 +1544,7 @@ void BKE_mesh_legacy_sharp_edges_from_flags(Mesh *mesh)
}))
{
SpanAttributeWriter<bool> sharp_edges = attributes.lookup_or_add_for_write_only_span<bool>(
"sharp_edge", ATTR_DOMAIN_EDGE);
"sharp_edge", AttrDomain::Edge);
threading::parallel_for(edges.index_range(), 4096, [&](const IndexRange range) {
for (const int i : range) {
sharp_edges.span[i] = edges[i].flag_legacy & ME_SHARP;
@ -1577,7 +1577,7 @@ void BKE_mesh_legacy_uv_seam_from_flags(Mesh *mesh)
}))
{
SpanAttributeWriter<bool> uv_seams = attributes.lookup_or_add_for_write_only_span<bool>(
".uv_seam", ATTR_DOMAIN_EDGE);
".uv_seam", AttrDomain::Edge);
threading::parallel_for(edges.index_range(), 4096, [&](const IndexRange range) {
for (const int i : range) {
uv_seams.span[i] = edges[i].flag_legacy & ME_SEAM;
@ -1609,7 +1609,7 @@ void BKE_mesh_legacy_convert_flags_to_hide_layers(Mesh *mesh)
}))
{
SpanAttributeWriter<bool> hide_vert = attributes.lookup_or_add_for_write_only_span<bool>(
".hide_vert", ATTR_DOMAIN_POINT);
".hide_vert", AttrDomain::Point);
threading::parallel_for(verts.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
hide_vert.span[i] = verts[i].flag_legacy & ME_HIDE;
@ -1625,7 +1625,7 @@ void BKE_mesh_legacy_convert_flags_to_hide_layers(Mesh *mesh)
}))
{
SpanAttributeWriter<bool> hide_edge = attributes.lookup_or_add_for_write_only_span<bool>(
".hide_edge", ATTR_DOMAIN_EDGE);
".hide_edge", AttrDomain::Edge);
threading::parallel_for(edges.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
hide_edge.span[i] = edges[i].flag_legacy & ME_HIDE;
@ -1643,7 +1643,7 @@ void BKE_mesh_legacy_convert_flags_to_hide_layers(Mesh *mesh)
}))
{
SpanAttributeWriter<bool> hide_poly = attributes.lookup_or_add_for_write_only_span<bool>(
".hide_poly", ATTR_DOMAIN_FACE);
".hide_poly", AttrDomain::Face);
threading::parallel_for(polys.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
hide_poly.span[i] = polys[i].flag_legacy & ME_HIDE;
@ -1674,7 +1674,7 @@ void BKE_mesh_legacy_convert_mpoly_to_material_indices(Mesh *mesh)
polys.begin(), polys.end(), [](const MPoly &poly) { return poly.mat_nr_legacy != 0; }))
{
SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_only_span<int>(
"material_index", ATTR_DOMAIN_FACE);
"material_index", AttrDomain::Face);
threading::parallel_for(polys.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
material_indices.span[i] = polys[i].mat_nr_legacy;
@ -1835,7 +1835,7 @@ void BKE_mesh_legacy_convert_flags_to_selection_layers(Mesh *mesh)
verts.begin(), verts.end(), [](const MVert &vert) { return vert.flag_legacy & SELECT; }))
{
SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_only_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
".select_vert", AttrDomain::Point);
threading::parallel_for(verts.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
select_vert.span[i] = verts[i].flag_legacy & SELECT;
@ -1851,7 +1851,7 @@ void BKE_mesh_legacy_convert_flags_to_selection_layers(Mesh *mesh)
}))
{
SpanAttributeWriter<bool> select_edge = attributes.lookup_or_add_for_write_only_span<bool>(
".select_edge", ATTR_DOMAIN_EDGE);
".select_edge", AttrDomain::Edge);
threading::parallel_for(edges.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
select_edge.span[i] = edges[i].flag_legacy & SELECT;
@ -1869,7 +1869,7 @@ void BKE_mesh_legacy_convert_flags_to_selection_layers(Mesh *mesh)
}))
{
SpanAttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write_only_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
".select_poly", AttrDomain::Face);
threading::parallel_for(polys.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
select_poly.span[i] = polys[i].flag_legacy & ME_FACE_SEL;
@ -2118,6 +2118,7 @@ void BKE_mesh_legacy_convert_polys_to_offsets(Mesh *mesh)
static bNodeTree *add_auto_smooth_node_tree(Main &bmain)
{
using namespace blender;
bNodeTree *group = ntreeAddTree(&bmain, DATA_("Auto Smooth"), "GeometryNodeTree");
if (!group->geometry_node_asset_traits) {
group->geometry_node_asset_traits = MEM_new<GeometryNodeAssetTraits>(__func__);
@ -2156,11 +2157,11 @@ static bNodeTree *add_auto_smooth_node_tree(Main &bmain)
}
}
bNode *shade_smooth_edge = nodeAddNode(nullptr, group, "GeometryNodeSetShadeSmooth");
shade_smooth_edge->custom1 = ATTR_DOMAIN_EDGE;
shade_smooth_edge->custom1 = int16_t(bke::AttrDomain::Edge);
shade_smooth_edge->locx = 120.0f;
shade_smooth_edge->locy = -100.0f;
bNode *shade_smooth_face = nodeAddNode(nullptr, group, "GeometryNodeSetShadeSmooth");
shade_smooth_face->custom1 = ATTR_DOMAIN_FACE;
shade_smooth_face->custom1 = int16_t(bke::AttrDomain::Face);
shade_smooth_face->locx = 300.0f;
shade_smooth_face->locy = -100.0f;
bNode *edge_angle = nodeAddNode(nullptr, group, "GeometryNodeInputMeshEdgeAngle");

View File

@ -125,6 +125,7 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
int *r_vert_merge_map_len)
{
using namespace blender;
using namespace blender::bke;
const float tolerance_sq = mmd->tolerance * mmd->tolerance;
const bool do_vtargetmap = (mmd->flag & MOD_MIR_NO_MERGE) == 0 && r_vert_merge_map != nullptr;
@ -407,8 +408,8 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
/* calculate custom normals into loop_normals, then mirror first half into second half */
const bke::AttributeAccessor attributes = result->attributes();
const VArraySpan sharp_edges = *attributes.lookup<bool>("sharp_edge", ATTR_DOMAIN_EDGE);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
const VArraySpan sharp_edges = *attributes.lookup<bool>("sharp_edge", AttrDomain::Edge);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", AttrDomain::Face);
blender::bke::mesh::normals_calc_loop(result->vert_positions(),
result_edges,
result_faces,

View File

@ -215,7 +215,7 @@ blender::bke::MeshNormalDomain Mesh::normals_domain() const
const AttributeAccessor attributes = this->attributes();
const VArray<bool> sharp_faces = *attributes.lookup_or_default<bool>(
"sharp_face", ATTR_DOMAIN_FACE, false);
"sharp_face", AttrDomain::Face, false);
const array_utils::BooleanMix face_mix = array_utils::booleans_mix_calc(sharp_faces);
if (face_mix == array_utils::BooleanMix::AllTrue) {
@ -223,7 +223,7 @@ blender::bke::MeshNormalDomain Mesh::normals_domain() const
}
const VArray<bool> sharp_edges = *attributes.lookup_or_default<bool>(
"sharp_edge", ATTR_DOMAIN_EDGE, false);
"sharp_edge", AttrDomain::Edge, false);
const array_utils::BooleanMix edge_mix = array_utils::booleans_mix_calc(sharp_edges);
if (edge_mix == array_utils::BooleanMix::AllTrue) {
return MeshNormalDomain::Face;
@ -292,8 +292,8 @@ blender::Span<blender::float3> Mesh::corner_normals() const
}
case MeshNormalDomain::Corner: {
const AttributeAccessor attributes = this->attributes();
const VArraySpan sharp_edges = *attributes.lookup<bool>("sharp_edge", ATTR_DOMAIN_EDGE);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
const VArraySpan sharp_edges = *attributes.lookup<bool>("sharp_edge", AttrDomain::Edge);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", AttrDomain::Face);
const short2 *custom_normals = static_cast<const short2 *>(
CustomData_get_layer(&this->corner_data, CD_CUSTOMLOOPNORMAL));
mesh::normals_calc_loop(this->vert_positions(),
@ -1558,8 +1558,8 @@ static void mesh_set_custom_normals(Mesh *mesh, float (*r_custom_nors)[3], const
}
MutableAttributeAccessor attributes = mesh->attributes_for_write();
SpanAttributeWriter<bool> sharp_edges = attributes.lookup_or_add_for_write_span<bool>(
"sharp_edge", ATTR_DOMAIN_EDGE);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
"sharp_edge", AttrDomain::Edge);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", AttrDomain::Face);
mesh_normals_loop_custom_set(mesh->vert_positions(),
mesh->edges(),

View File

@ -462,7 +462,7 @@ static void find_nearest_edges(const Span<float3> src_positions,
static void gather_attributes(const Span<AttributeIDRef> ids,
const AttributeAccessor src_attributes,
const eAttrDomain domain,
const AttrDomain domain,
const Span<int> index_map,
MutableAttributeAccessor dst_attributes)
{
@ -489,16 +489,16 @@ void mesh_remesh_reproject_attributes(const Mesh &src, Mesh &dst)
return true;
}
switch (meta_data.domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
point_ids.append(id);
break;
case ATTR_DOMAIN_EDGE:
case AttrDomain::Edge:
edge_ids.append(id);
break;
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
face_ids.append(id);
break;
case ATTR_DOMAIN_CORNER:
case AttrDomain::Corner:
corner_ids.append(id);
break;
default:
@ -546,7 +546,7 @@ void mesh_remesh_reproject_attributes(const Mesh &src, Mesh &dst)
Array<int> map(dst.verts_num);
find_nearest_verts(
src_positions, src_corner_verts, src_corner_tris, dst_positions, vert_nearest_tris, map);
gather_attributes(point_ids, src_attributes, ATTR_DOMAIN_POINT, map, dst_attributes);
gather_attributes(point_ids, src_attributes, AttrDomain::Point, map, dst_attributes);
}
if (!corner_ids.is_empty()) {
@ -560,7 +560,7 @@ void mesh_remesh_reproject_attributes(const Mesh &src, Mesh &dst)
dst_corner_verts,
vert_nearest_tris,
map);
gather_attributes(corner_ids, src_attributes, ATTR_DOMAIN_CORNER, map, dst_attributes);
gather_attributes(corner_ids, src_attributes, AttrDomain::Corner, map, dst_attributes);
}
}
@ -579,14 +579,14 @@ void mesh_remesh_reproject_attributes(const Mesh &src, Mesh &dst)
dst_edges,
bvhtree,
map);
gather_attributes(edge_ids, src_attributes, ATTR_DOMAIN_EDGE, map, dst_attributes);
gather_attributes(edge_ids, src_attributes, AttrDomain::Edge, map, dst_attributes);
}
if (!face_ids.is_empty()) {
const Span<int> src_tri_faces = src.corner_tri_faces();
Array<int> map(dst.faces_num);
find_nearest_faces(src_tri_faces, dst_positions, dst_faces, dst_corner_verts, bvhtree, map);
gather_attributes(face_ids, src_attributes, ATTR_DOMAIN_FACE, map, dst_attributes);
gather_attributes(face_ids, src_attributes, AttrDomain::Face, map, dst_attributes);
}
if (src.active_color_attribute) {

View File

@ -483,7 +483,7 @@ void BaryWeightSampleFn::evaluate_source(fn::GField src_field)
/* Use the most complex domain for now, ensuring no information is lost. In the future, it should
* be possible to use the most complex domain required by the field inputs, to simplify sampling
* and avoid domain conversions. */
domain_ = ATTR_DOMAIN_CORNER;
domain_ = AttrDomain::Corner;
source_context_.emplace(bke::MeshFieldContext(mesh, domain_));
const int domain_size = mesh.attributes().domain_size(domain_);
source_evaluator_ = std::make_unique<fn::FieldEvaluator>(*source_context_, domain_size);

View File

@ -123,13 +123,12 @@ void BKE_mesh_calc_loop_tangent_single(Mesh *mesh,
{
using namespace blender;
using namespace blender::bke;
if (!uvmap) {
uvmap = CustomData_get_active_layer_name(&mesh->corner_data, CD_PROP_FLOAT2);
}
const AttributeAccessor attributes = mesh->attributes();
const VArraySpan uv_map = *attributes.lookup<float2>(uvmap, ATTR_DOMAIN_CORNER);
const VArraySpan uv_map = *attributes.lookup<float2>(uvmap, AttrDomain::Corner);
if (uv_map.is_empty()) {
BKE_reportf(reports,
RPT_ERROR,
@ -585,7 +584,7 @@ void BKE_mesh_calc_loop_tangents(Mesh *me_eval,
using namespace blender::bke;
const blender::Span<int3> corner_tris = me_eval->corner_tris();
const bke::AttributeAccessor attributes = me_eval->attributes();
const VArraySpan sharp_face = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
const VArraySpan sharp_face = *attributes.lookup<bool>("sharp_face", AttrDomain::Face);
short tangent_mask = 0;
BKE_mesh_calc_loop_tangent_ex(
reinterpret_cast<const float(*)[3]>(me_eval->vert_positions().data()),

View File

@ -187,6 +187,7 @@ bool multires_reshape_context_create_from_object(MultiresReshapeContext *reshape
MultiresModifierData *mmd)
{
using namespace blender;
using namespace blender::bke;
context_zero(reshape_context);
const bool use_render_params = false;
@ -216,8 +217,8 @@ bool multires_reshape_context_create_from_object(MultiresReshapeContext *reshape
reshape_context->top.grid_size = BKE_subdiv_grid_size_from_level(reshape_context->top.level);
const bke::AttributeAccessor attributes = base_mesh->attributes();
reshape_context->cd_vertex_crease = *attributes.lookup<float>("crease_vert", ATTR_DOMAIN_POINT);
reshape_context->cd_edge_crease = *attributes.lookup<float>("crease_edge", ATTR_DOMAIN_EDGE);
reshape_context->cd_vertex_crease = *attributes.lookup<float>("crease_vert", AttrDomain::Point);
reshape_context->cd_edge_crease = *attributes.lookup<float>("crease_edge", AttrDomain::Edge);
context_init_commoon(reshape_context);
@ -275,6 +276,7 @@ bool multires_reshape_context_create_from_subdiv(MultiresReshapeContext *reshape
int top_level)
{
using namespace blender;
using namespace blender::bke;
context_zero(reshape_context);
Mesh *base_mesh = (Mesh *)object->data;
@ -288,7 +290,7 @@ bool multires_reshape_context_create_from_subdiv(MultiresReshapeContext *reshape
reshape_context->base_corner_edges = base_mesh->corner_edges();
const bke::AttributeAccessor attributes = base_mesh->attributes();
reshape_context->cd_vertex_crease = *attributes.lookup<float>("crease_vert", ATTR_DOMAIN_POINT);
reshape_context->cd_vertex_crease = *attributes.lookup<float>("crease_vert", AttrDomain::Point);
reshape_context->subdiv = subdiv;
reshape_context->need_free_subdiv = false;

View File

@ -79,10 +79,11 @@ using blender::float3;
using blender::MutableSpan;
using blender::Span;
using blender::Vector;
using blender::bke::AttrDomain;
static void sculpt_attribute_update_refs(Object *ob);
static SculptAttribute *sculpt_attribute_ensure_ex(Object *ob,
eAttrDomain domain,
AttrDomain domain,
eCustomDataType proptype,
const char *name,
const SculptAttributeParams *params,
@ -1639,11 +1640,11 @@ static void sculpt_update_persistent_base(Object *ob)
SculptSession *ss = ob->sculpt;
ss->attrs.persistent_co = BKE_sculpt_attribute_get(
ob, ATTR_DOMAIN_POINT, CD_PROP_FLOAT3, SCULPT_ATTRIBUTE_NAME(persistent_co));
ob, AttrDomain::Point, CD_PROP_FLOAT3, SCULPT_ATTRIBUTE_NAME(persistent_co));
ss->attrs.persistent_no = BKE_sculpt_attribute_get(
ob, ATTR_DOMAIN_POINT, CD_PROP_FLOAT3, SCULPT_ATTRIBUTE_NAME(persistent_no));
ob, AttrDomain::Point, CD_PROP_FLOAT3, SCULPT_ATTRIBUTE_NAME(persistent_no));
ss->attrs.persistent_disp = BKE_sculpt_attribute_get(
ob, ATTR_DOMAIN_POINT, CD_PROP_FLOAT, SCULPT_ATTRIBUTE_NAME(persistent_disp));
ob, AttrDomain::Point, CD_PROP_FLOAT, SCULPT_ATTRIBUTE_NAME(persistent_disp));
}
static void sculpt_update_object(Depsgraph *depsgraph,
@ -1705,7 +1706,7 @@ static void sculpt_update_object(Depsgraph *depsgraph,
ss->multires.level = 0;
CustomDataLayer *layer;
eAttrDomain domain;
AttrDomain domain;
if (BKE_pbvh_get_color_layer(mesh, &layer, &domain)) {
if (layer->type == CD_PROP_COLOR) {
ss->vcol = static_cast<MPropCol *>(layer->data);
@ -1722,7 +1723,7 @@ static void sculpt_update_object(Depsgraph *depsgraph,
ss->mcol = nullptr;
ss->vcol_type = (eCustomDataType)-1;
ss->vcol_domain = ATTR_DOMAIN_POINT;
ss->vcol_domain = AttrDomain::Point;
}
}
@ -1824,7 +1825,7 @@ static void sculpt_update_object(Depsgraph *depsgraph,
}
if (is_paint_tool) {
if (ss->vcol_domain == ATTR_DOMAIN_CORNER) {
if (ss->vcol_domain == AttrDomain::Corner) {
/* Ensure pbvh nodes have loop indices; the sculpt undo system
* needs them for color attributes.
*/
@ -1907,7 +1908,7 @@ void BKE_sculpt_color_layer_create_if_needed(Object *object)
char unique_name[MAX_CUSTOMDATA_LAYER_NAME];
BKE_id_attribute_calc_unique_name(&orig_me->id, "Color", unique_name);
if (!orig_me->attributes_for_write().add(
unique_name, ATTR_DOMAIN_POINT, CD_PROP_COLOR, AttributeInitDefaultValue()))
unique_name, AttrDomain::Point, CD_PROP_COLOR, AttributeInitDefaultValue()))
{
return;
}
@ -1969,7 +1970,7 @@ void BKE_sculpt_mask_layers_ensure(Depsgraph *depsgraph,
}
/* If vertices already have mask, copy into multires data. */
if (const VArray<float> mask = *attributes.lookup<float>(".sculpt_mask", ATTR_DOMAIN_POINT)) {
if (const VArray<float> mask = *attributes.lookup<float>(".sculpt_mask", AttrDomain::Point)) {
const VArraySpan<float> mask_span(mask);
for (const int i : faces.index_range()) {
const IndexRange face = faces[i];
@ -2003,7 +2004,7 @@ void BKE_sculpt_mask_layers_ensure(Depsgraph *depsgraph,
}
/* Create vertex paint mask layer if there isn't one already. */
if (attributes.add<float>(".sculpt_mask", ATTR_DOMAIN_POINT, AttributeInitDefaultValue())) {
if (attributes.add<float>(".sculpt_mask", AttrDomain::Point, AttributeInitDefaultValue())) {
/* The evaluated mesh must be updated to contain the new data. */
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
@ -2087,7 +2088,7 @@ void BKE_sculpt_sync_face_visibility_to_grids(Mesh *mesh, SubdivCCG *subdiv_ccg)
const AttributeAccessor attributes = mesh->attributes();
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", AttrDomain::Face, false);
if (hide_poly.is_single() && !hide_poly.get_internal_single()) {
BKE_subdiv_ccg_grid_hidden_free(*subdiv_ccg);
return;
@ -2273,17 +2274,17 @@ int BKE_sculptsession_vertex_count(const SculptSession *ss)
/**
* Returns pointer to a CustomData associated with a given domain, if
* one exists. If not nullptr is returned (this may happen with e.g.
* multires and #ATTR_DOMAIN_POINT).
* multires and #AttrDomain::Point).
*/
static CustomData *sculpt_get_cdata(Object *ob, eAttrDomain domain)
static CustomData *sculpt_get_cdata(Object *ob, AttrDomain domain)
{
SculptSession *ss = ob->sculpt;
if (ss->bm) {
switch (domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
return &ss->bm->vdata;
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
return &ss->bm->pdata;
default:
BLI_assert_unreachable();
@ -2294,14 +2295,14 @@ static CustomData *sculpt_get_cdata(Object *ob, eAttrDomain domain)
Mesh *mesh = BKE_object_get_original_mesh(ob);
switch (domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
/* Cannot get vertex domain for multires grids. */
if (ss->pbvh && BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
return nullptr;
}
return &mesh->vert_data;
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
return &mesh->face_data;
default:
BLI_assert_unreachable();
@ -2310,15 +2311,15 @@ static CustomData *sculpt_get_cdata(Object *ob, eAttrDomain domain)
}
}
static int sculpt_attr_elem_count_get(Object *ob, eAttrDomain domain)
static int sculpt_attr_elem_count_get(Object *ob, AttrDomain domain)
{
SculptSession *ss = ob->sculpt;
switch (domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
return BKE_sculptsession_vertex_count(ss);
break;
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
return ss->totfaces;
break;
default:
@ -2329,7 +2330,7 @@ static int sculpt_attr_elem_count_get(Object *ob, eAttrDomain domain)
static bool sculpt_attribute_create(SculptSession *ss,
Object *ob,
eAttrDomain domain,
AttrDomain domain,
eCustomDataType proptype,
const char *name,
SculptAttribute *out,
@ -2389,10 +2390,10 @@ static bool sculpt_attribute_create(SculptSession *ss,
out->data_for_bmesh = true;
switch (domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
cdata = &bm->vdata;
break;
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
cdata = &bm->pdata;
break;
default:
@ -2418,10 +2419,10 @@ static bool sculpt_attribute_create(SculptSession *ss,
CustomData *cdata = nullptr;
switch (domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
cdata = &mesh->vert_data;
break;
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
cdata = &mesh->face_data;
break;
default:
@ -2504,7 +2505,7 @@ static bool sculpt_attr_update(Object *ob, SculptAttribute *attr)
}
static SculptAttribute *sculpt_get_cached_layer(SculptSession *ss,
eAttrDomain domain,
AttrDomain domain,
eCustomDataType proptype,
const char *name)
{
@ -2537,7 +2538,7 @@ static SculptAttribute *sculpt_alloc_attr(SculptSession *ss)
}
SculptAttribute *BKE_sculpt_attribute_get(Object *ob,
eAttrDomain domain,
AttrDomain domain,
eCustomDataType proptype,
const char *name)
{
@ -2563,10 +2564,10 @@ SculptAttribute *BKE_sculpt_attribute_get(Object *ob,
int totelem = 0;
switch (domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
totelem = BKE_sculptsession_vertex_count(ss);
break;
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
totelem = ss->totfaces;
break;
default:
@ -2594,7 +2595,7 @@ SculptAttribute *BKE_sculpt_attribute_get(Object *ob,
}
static SculptAttribute *sculpt_attribute_ensure_ex(Object *ob,
eAttrDomain domain,
AttrDomain domain,
eCustomDataType proptype,
const char *name,
const SculptAttributeParams *params,
@ -2626,7 +2627,7 @@ static SculptAttribute *sculpt_attribute_ensure_ex(Object *ob,
}
SculptAttribute *BKE_sculpt_attribute_ensure(Object *ob,
eAttrDomain domain,
AttrDomain domain,
eCustomDataType proptype,
const char *name,
const SculptAttributeParams *params)
@ -2658,7 +2659,7 @@ static void sculptsession_bmesh_add_layers(Object *ob)
ss->attrs.dyntopo_node_id_vertex = sculpt_attribute_ensure_ex(
ob,
ATTR_DOMAIN_POINT,
AttrDomain::Point,
CD_PROP_INT32,
SCULPT_ATTRIBUTE_NAME(dyntopo_node_id_vertex),
&params,
@ -2667,7 +2668,7 @@ static void sculptsession_bmesh_add_layers(Object *ob)
ss->attrs.dyntopo_node_id_face = sculpt_attribute_ensure_ex(
ob,
ATTR_DOMAIN_FACE,
AttrDomain::Face,
CD_PROP_INT32,
SCULPT_ATTRIBUTE_NAME(dyntopo_node_id_face),
&params,
@ -2730,7 +2731,7 @@ void BKE_sculpt_attribute_destroy_temporary_all(Object *ob)
bool BKE_sculpt_attribute_destroy(Object *ob, SculptAttribute *attr)
{
SculptSession *ss = ob->sculpt;
eAttrDomain domain = attr->domain;
AttrDomain domain = attr->domain;
BLI_assert(attr->used);
@ -2762,7 +2763,7 @@ bool BKE_sculpt_attribute_destroy(Object *ob, SculptAttribute *attr)
MEM_SAFE_FREE(attr->data);
}
else if (ss->bm) {
CustomData *cdata = attr->domain == ATTR_DOMAIN_POINT ? &ss->bm->vdata : &ss->bm->pdata;
CustomData *cdata = attr->domain == AttrDomain::Point ? &ss->bm->vdata : &ss->bm->pdata;
BM_data_layer_free_named(ss->bm, cdata, attr->name);
}
@ -2771,11 +2772,11 @@ bool BKE_sculpt_attribute_destroy(Object *ob, SculptAttribute *attr)
int totelem = 0;
switch (domain) {
case ATTR_DOMAIN_POINT:
case AttrDomain::Point:
cdata = ss->bm ? &ss->bm->vdata : &mesh->vert_data;
totelem = ss->totvert;
break;
case ATTR_DOMAIN_FACE:
case AttrDomain::Face:
cdata = ss->bm ? &ss->bm->pdata : &mesh->face_data;
totelem = ss->totfaces;
break;

View File

@ -53,6 +53,7 @@ using blender::float3;
using blender::MutableSpan;
using blender::Span;
using blender::Vector;
using blender::bke::AttrDomain;
#define LEAF_LIMIT 10000
@ -760,9 +761,9 @@ PBVH *build_mesh(Mesh *mesh)
if (corner_tris_num) {
const AttributeAccessor attributes = mesh->attributes();
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", ATTR_DOMAIN_FACE);
const VArraySpan material_index = *attributes.lookup<int>("material_index", ATTR_DOMAIN_FACE);
const VArraySpan sharp_face = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", AttrDomain::Face);
const VArraySpan material_index = *attributes.lookup<int>("material_index", AttrDomain::Face);
const VArraySpan sharp_face = *attributes.lookup<bool>("sharp_face", AttrDomain::Face);
pbvh_build(pbvh.get(),
corner_verts,
corner_tris,
@ -842,8 +843,8 @@ PBVH *build_grids(const CCGKey *key, Mesh *mesh, SubdivCCG *subdiv_ccg)
if (!grids.is_empty()) {
const AttributeAccessor attributes = mesh->attributes();
const VArraySpan material_index = *attributes.lookup<int>("material_index", ATTR_DOMAIN_FACE);
const VArraySpan sharp_face = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
const VArraySpan material_index = *attributes.lookup<int>("material_index", AttrDomain::Face);
const VArraySpan sharp_face = *attributes.lookup<bool>("sharp_face", AttrDomain::Face);
pbvh_build(pbvh.get(),
{},
{},
@ -1335,7 +1336,7 @@ void node_update_mask_mesh(const Span<float> mask, PBVHNode &node)
static void update_mask_mesh(const Mesh &mesh, const Span<PBVHNode *> nodes)
{
const AttributeAccessor attributes = mesh.attributes();
const VArraySpan<float> mask = *attributes.lookup<float>(".sculpt_mask", ATTR_DOMAIN_POINT);
const VArraySpan<float> mask = *attributes.lookup<float>(".sculpt_mask", AttrDomain::Point);
if (mask.is_empty()) {
for (PBVHNode *node : nodes) {
node->flag &= ~PBVH_FullyMasked;
@ -1457,7 +1458,7 @@ void node_update_visibility_mesh(const Span<bool> hide_vert, PBVHNode &node)
static void update_visibility_faces(const Mesh &mesh, const Span<PBVHNode *> nodes)
{
const AttributeAccessor attributes = mesh.attributes();
const VArraySpan<bool> hide_vert = *attributes.lookup<bool>(".hide_vert", ATTR_DOMAIN_POINT);
const VArraySpan<bool> hide_vert = *attributes.lookup<bool>(".hide_vert", AttrDomain::Point);
if (hide_vert.is_empty()) {
for (PBVHNode *node : nodes) {
node->flag &= ~PBVH_FullyHidden;
@ -1592,11 +1593,11 @@ IndexMask nodes_to_face_selection_grids(const SubdivCCG &subdiv_ccg,
/***************************** PBVH Access ***********************************/
bool BKE_pbvh_get_color_layer(Mesh *mesh, CustomDataLayer **r_layer, eAttrDomain *r_domain)
bool BKE_pbvh_get_color_layer(Mesh *mesh, CustomDataLayer **r_layer, AttrDomain *r_domain)
{
*r_layer = BKE_id_attribute_search_for_write(
&mesh->id, mesh->active_color_attribute, CD_MASK_COLOR_ALL, ATTR_DOMAIN_MASK_COLOR);
*r_domain = *r_layer ? BKE_id_attribute_domain(&mesh->id, *r_layer) : ATTR_DOMAIN_POINT;
*r_domain = *r_layer ? BKE_id_attribute_domain(&mesh->id, *r_layer) : AttrDomain::Point;
return *r_layer != nullptr;
}
@ -2597,7 +2598,7 @@ static blender::draw::pbvh::PBVH_GPU_Args pbvh_draw_args_init(const Mesh &mesh,
args.face_normals = pbvh.face_normals;
/* Retrieve data from the original mesh. Ideally that would be passed to this function to
* make it clearer when each is used. */
args.hide_poly = *pbvh.mesh->attributes().lookup<bool>(".hide_poly", ATTR_DOMAIN_FACE);
args.hide_poly = *pbvh.mesh->attributes().lookup<bool>(".hide_poly", AttrDomain::Face);
args.prim_indices = node.prim_indices;
args.tri_faces = mesh.corner_tri_faces();
@ -3164,7 +3165,7 @@ void BKE_pbvh_sync_visibility_from_verts(PBVH *pbvh, Mesh *mesh)
}
else {
SpanAttributeWriter<bool> hide_poly = attributes.lookup_or_add_for_write_span<bool>(
".hide_poly", ATTR_DOMAIN_FACE, AttributeInitConstruct());
".hide_poly", AttrDomain::Face, AttributeInitConstruct());
hide_poly.span.fill(false);
index_mask::masked_fill(hide_poly.span, true, hidden_faces);
hide_poly.finish();

View File

@ -8,21 +8,20 @@
#include "MEM_guardedalloc.h"
#include "BLI_math_color.h"
#include "BLI_math_vector.h"
#include "BLI_utildefines.h"
#include "BLI_bitmap.h"
#include "BLI_ghash.h"
#include "BLI_index_range.hh"
#include "BLI_math_color.h"
#include "BLI_math_vector.h"
#include "BLI_rand.h"
#include "BLI_span.hh"
#include "BLI_task.h"
#include "BLI_utildefines.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "BKE_attribute.h"
#include "BKE_attribute.hh"
#include "BKE_ccg.h"
#include "BKE_mesh.hh"
#include "BKE_mesh_mapping.hh"
@ -91,7 +90,7 @@ static void pbvh_vertex_color_get(const PBVH &pbvh, PBVHVertRef vertex, float r_
{
int index = vertex.i;
if (pbvh.color_domain == ATTR_DOMAIN_CORNER) {
if (pbvh.color_domain == AttrDomain::Corner) {
int count = 0;
zero_v4(r_color);
for (const int i_face : pbvh.pmap[index]) {
@ -124,7 +123,7 @@ static void pbvh_vertex_color_set(PBVH &pbvh, PBVHVertRef vertex, const float co
{
int index = vertex.i;
if (pbvh.color_domain == ATTR_DOMAIN_CORNER) {
if (pbvh.color_domain == AttrDomain::Corner) {
for (const int i_face : pbvh.pmap[index]) {
const IndexRange face = pbvh.faces[i_face];
MutableSpan<T> colors{static_cast<T *>(pbvh.color_layer->data) + face.start(), face.size()};
@ -192,7 +191,7 @@ void BKE_pbvh_store_colors_vertex(PBVH *pbvh,
const blender::Span<int> indices,
blender::MutableSpan<blender::float4> r_colors)
{
if (pbvh->color_domain == ATTR_DOMAIN_POINT) {
if (pbvh->color_domain == blender::bke::AttrDomain::Point) {
BKE_pbvh_store_colors(pbvh, indices, r_colors);
}
else {

View File

@ -188,7 +188,7 @@ struct PBVH {
blender::GroupedSpan<int> pmap;
CustomDataLayer *color_layer;
eAttrDomain color_domain;
blender::bke::AttrDomain color_domain;
/* Initialize this to true, instead of waiting for a draw engine
* to set it. Prevents a crash in draw manager instancing code.

View File

@ -670,7 +670,7 @@ static bool update_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image
}
const AttributeAccessor attributes = mesh->attributes();
const VArraySpan uv_map = *attributes.lookup<float2>(active_uv_name, ATTR_DOMAIN_CORNER);
const VArraySpan uv_map = *attributes.lookup<float2>(active_uv_name, AttrDomain::Corner);
uv_islands::MeshData mesh_data(
pbvh->corner_tris, mesh->corner_verts(), uv_map, pbvh->vert_positions);

View File

@ -66,7 +66,7 @@ static void pointcloud_init_data(ID *id)
CustomData_reset(&pointcloud->pdata);
pointcloud->attributes_for_write().add<float3>(
"position", ATTR_DOMAIN_POINT, blender::bke::AttributeInitConstruct());
"position", blender::bke::AttrDomain::Point, blender::bke::AttributeInitConstruct());
pointcloud->runtime = new blender::bke::PointCloudRuntime();
}
@ -183,7 +183,7 @@ static void pointcloud_random(PointCloud *pointcloud)
blender::MutableSpan<float3> positions = pointcloud->positions_for_write();
blender::bke::SpanAttributeWriter<float> radii =
attributes.lookup_or_add_for_write_only_span<float>(POINTCLOUD_ATTR_RADIUS,
ATTR_DOMAIN_POINT);
blender::bke::AttrDomain::Point);
for (const int i : positions.index_range()) {
positions[i] = float3(BLI_rng_get_float(rng), BLI_rng_get_float(rng), BLI_rng_get_float(rng)) *

View File

@ -383,6 +383,7 @@ static void init_user_data(OpenSubdiv_Converter *converter,
const Mesh *mesh)
{
using namespace blender;
using namespace blender::bke;
ConverterStorage *user_data = MEM_new<ConverterStorage>(__func__);
user_data->settings = *settings;
user_data->mesh = mesh;
@ -393,8 +394,8 @@ static void init_user_data(OpenSubdiv_Converter *converter,
user_data->corner_edges = mesh->corner_edges();
if (settings->use_creases) {
const bke::AttributeAccessor attributes = mesh->attributes();
user_data->cd_vertex_crease = *attributes.lookup<float>("crease_vert", ATTR_DOMAIN_POINT);
user_data->cd_edge_crease = *attributes.lookup<float>("crease_edge", ATTR_DOMAIN_EDGE);
user_data->cd_vertex_crease = *attributes.lookup<float>("crease_vert", AttrDomain::Point);
user_data->cd_edge_crease = *attributes.lookup<float>("crease_edge", AttrDomain::Edge);
}
user_data->loop_uv_indices = nullptr;
initialize_manifold_indices(user_data);

View File

@ -695,6 +695,7 @@ static bool do_versions_sequencer_init_retiming_tool_data(Sequence *seq, void *u
static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *ntree)
{
using namespace blender;
using namespace blender::bke;
/* Otherwise `ntree->typeInfo` is null. */
ntreeSetTypes(nullptr, ntree);
LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) {
@ -728,16 +729,18 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt
}
case GEO_NODE_ATTRIBUTE_TRANSFER_NEAREST: {
/* These domains weren't supported by the index transfer mode, but were selectable. */
const eAttrDomain domain = ELEM(storage->domain, ATTR_DOMAIN_INSTANCE, ATTR_DOMAIN_CURVE) ?
ATTR_DOMAIN_POINT :
eAttrDomain(storage->domain);
const AttrDomain domain = ELEM(AttrDomain(storage->domain),
AttrDomain::Instance,
AttrDomain::Curve) ?
AttrDomain::Point :
AttrDomain(storage->domain);
/* Use a sample index node to retrieve the data with this node's index output. */
bNode *sample_index = nodeAddStaticNode(nullptr, ntree, GEO_NODE_SAMPLE_INDEX);
NodeGeometrySampleIndex *sample_storage = static_cast<NodeGeometrySampleIndex *>(
sample_index->storage);
sample_storage->data_type = storage->data_type;
sample_storage->domain = domain;
sample_storage->domain = int8_t(domain);
sample_index->parent = node->parent;
sample_index->locx = node->locx + 25.0f;
sample_index->locy = node->locy;
@ -752,7 +755,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt
bNode *sample_nearest = nodeAddStaticNode(nullptr, ntree, GEO_NODE_SAMPLE_NEAREST);
sample_nearest->parent = node->parent;
sample_nearest->custom1 = storage->data_type;
sample_nearest->custom2 = domain;
sample_nearest->custom2 = int8_t(domain);
sample_nearest->locx = node->locx - 25.0f;
sample_nearest->locy = node->locy;
if (old_geometry_socket->link) {
@ -878,7 +881,7 @@ static void version_geometry_nodes_primitive_uv_maps(bNodeTree &ntree)
store_attribute_node->offsety = node->offsety;
NodeGeometryStoreNamedAttribute &storage = *static_cast<NodeGeometryStoreNamedAttribute *>(
store_attribute_node->storage);
storage.domain = ATTR_DOMAIN_CORNER;
storage.domain = int8_t(blender::bke::AttrDomain::Corner);
/* Intentionally use 3D instead of 2D vectors, because 2D vectors did not exist in older
* releases and would make the file crash when trying to open it. */
storage.data_type = CD_PROP_FLOAT3;
@ -965,7 +968,8 @@ static void version_geometry_nodes_extrude_smooth_propagation(bNodeTree &ntree)
bNode *capture_node = geometry_in_link->fromnode;
const NodeGeometryAttributeCapture &capture_storage =
*static_cast<const NodeGeometryAttributeCapture *>(capture_node->storage);
if (capture_storage.data_type != CD_PROP_BOOL || capture_storage.domain != ATTR_DOMAIN_FACE)
if (capture_storage.data_type != CD_PROP_BOOL ||
bke::AttrDomain(capture_storage.domain) != bke::AttrDomain::Face)
{
return false;
}
@ -1005,7 +1009,8 @@ static void version_geometry_nodes_extrude_smooth_propagation(bNodeTree &ntree)
capture_node->locy = node->locy;
new_nodes.append(capture_node);
static_cast<NodeGeometryAttributeCapture *>(capture_node->storage)->data_type = CD_PROP_BOOL;
static_cast<NodeGeometryAttributeCapture *>(capture_node->storage)->domain = ATTR_DOMAIN_FACE;
static_cast<NodeGeometryAttributeCapture *>(capture_node->storage)->domain = int8_t(
bke::AttrDomain::Face);
bNode *is_smooth_node = nodeAddNode(nullptr, &ntree, "GeometryNodeInputShadeSmooth");
is_smooth_node->parent = node->parent;

View File

@ -47,7 +47,7 @@
#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_armature.hh"
#include "BKE_attribute.h"
#include "BKE_attribute.hh"
#include "BKE_collection.h"
#include "BKE_curve.hh"
#include "BKE_effect.h"
@ -2159,7 +2159,7 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
if (ntree->type == NTREE_GEOMETRY) {
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == GEO_NODE_SET_SHADE_SMOOTH) {
node->custom1 = ATTR_DOMAIN_FACE;
node->custom1 = int8_t(blender::bke::AttrDomain::Face);
}
}
}

View File

@ -115,6 +115,7 @@ using blender::MutableSpan;
using blender::Span;
using blender::StringRef;
using blender::Vector;
using blender::bke::AttrDomain;
bool BM_attribute_stored_in_bmesh_builtin(const StringRef name)
{
@ -415,16 +416,16 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *
-1;
const bke::AttributeAccessor attributes = mesh->attributes();
const VArraySpan select_vert = *attributes.lookup<bool>(".select_vert", ATTR_DOMAIN_POINT);
const VArraySpan select_edge = *attributes.lookup<bool>(".select_edge", ATTR_DOMAIN_EDGE);
const VArraySpan select_poly = *attributes.lookup<bool>(".select_poly", ATTR_DOMAIN_FACE);
const VArraySpan hide_vert = *attributes.lookup<bool>(".hide_vert", ATTR_DOMAIN_POINT);
const VArraySpan hide_edge = *attributes.lookup<bool>(".hide_edge", ATTR_DOMAIN_EDGE);
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", ATTR_DOMAIN_FACE);
const VArraySpan material_indices = *attributes.lookup<int>("material_index", ATTR_DOMAIN_FACE);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
const VArraySpan sharp_edges = *attributes.lookup<bool>("sharp_edge", ATTR_DOMAIN_EDGE);
const VArraySpan uv_seams = *attributes.lookup<bool>(".uv_seam", ATTR_DOMAIN_EDGE);
const VArraySpan select_vert = *attributes.lookup<bool>(".select_vert", AttrDomain::Point);
const VArraySpan select_edge = *attributes.lookup<bool>(".select_edge", AttrDomain::Edge);
const VArraySpan select_poly = *attributes.lookup<bool>(".select_poly", AttrDomain::Face);
const VArraySpan hide_vert = *attributes.lookup<bool>(".hide_vert", AttrDomain::Point);
const VArraySpan hide_edge = *attributes.lookup<bool>(".hide_edge", AttrDomain::Edge);
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", AttrDomain::Face);
const VArraySpan material_indices = *attributes.lookup<int>("material_index", AttrDomain::Face);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", AttrDomain::Face);
const VArraySpan sharp_edges = *attributes.lookup<bool>("sharp_edge", AttrDomain::Edge);
const VArraySpan uv_seams = *attributes.lookup<bool>(".uv_seam", AttrDomain::Edge);
const Span<float3> positions = mesh->vert_positions();
Array<BMVert *> vtable(mesh->verts_num);
@ -1486,35 +1487,35 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *mesh, const BMeshToMeshParam
bke::SpanAttributeWriter<bool> sharp_face;
bke::SpanAttributeWriter<int> material_index;
if (need_select_vert) {
select_vert = attrs.lookup_or_add_for_write_only_span<bool>(".select_vert", ATTR_DOMAIN_POINT);
select_vert = attrs.lookup_or_add_for_write_only_span<bool>(".select_vert", AttrDomain::Point);
}
if (need_hide_vert) {
hide_vert = attrs.lookup_or_add_for_write_only_span<bool>(".hide_vert", ATTR_DOMAIN_POINT);
hide_vert = attrs.lookup_or_add_for_write_only_span<bool>(".hide_vert", AttrDomain::Point);
}
if (need_select_edge) {
select_edge = attrs.lookup_or_add_for_write_only_span<bool>(".select_edge", ATTR_DOMAIN_EDGE);
select_edge = attrs.lookup_or_add_for_write_only_span<bool>(".select_edge", AttrDomain::Edge);
}
if (need_sharp_edge) {
sharp_edge = attrs.lookup_or_add_for_write_only_span<bool>("sharp_edge", ATTR_DOMAIN_EDGE);
sharp_edge = attrs.lookup_or_add_for_write_only_span<bool>("sharp_edge", AttrDomain::Edge);
}
if (need_uv_seams) {
uv_seams = attrs.lookup_or_add_for_write_only_span<bool>(".uv_seam", ATTR_DOMAIN_EDGE);
uv_seams = attrs.lookup_or_add_for_write_only_span<bool>(".uv_seam", AttrDomain::Edge);
}
if (need_hide_edge) {
hide_edge = attrs.lookup_or_add_for_write_only_span<bool>(".hide_edge", ATTR_DOMAIN_EDGE);
hide_edge = attrs.lookup_or_add_for_write_only_span<bool>(".hide_edge", AttrDomain::Edge);
}
if (need_select_poly) {
select_poly = attrs.lookup_or_add_for_write_only_span<bool>(".select_poly", ATTR_DOMAIN_FACE);
select_poly = attrs.lookup_or_add_for_write_only_span<bool>(".select_poly", AttrDomain::Face);
}
if (need_hide_poly) {
hide_poly = attrs.lookup_or_add_for_write_only_span<bool>(".hide_poly", ATTR_DOMAIN_FACE);
hide_poly = attrs.lookup_or_add_for_write_only_span<bool>(".hide_poly", AttrDomain::Face);
}
if (need_sharp_face) {
sharp_face = attrs.lookup_or_add_for_write_only_span<bool>("sharp_face", ATTR_DOMAIN_FACE);
sharp_face = attrs.lookup_or_add_for_write_only_span<bool>("sharp_face", AttrDomain::Face);
}
if (need_material_index) {
material_index = attrs.lookup_or_add_for_write_only_span<int>("material_index",
ATTR_DOMAIN_FACE);
AttrDomain::Face);
}
/* Loop over all elements in parallel, copying attributes and building the Mesh topology. */
@ -1709,35 +1710,35 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *mesh, const CustomData_MeshMasks
bke::SpanAttributeWriter<bool> sharp_face;
bke::SpanAttributeWriter<int> material_index;
if (need_select_vert) {
select_vert = attrs.lookup_or_add_for_write_only_span<bool>(".select_vert", ATTR_DOMAIN_POINT);
select_vert = attrs.lookup_or_add_for_write_only_span<bool>(".select_vert", AttrDomain::Point);
}
if (need_hide_vert) {
hide_vert = attrs.lookup_or_add_for_write_only_span<bool>(".hide_vert", ATTR_DOMAIN_POINT);
hide_vert = attrs.lookup_or_add_for_write_only_span<bool>(".hide_vert", AttrDomain::Point);
}
if (need_select_edge) {
select_edge = attrs.lookup_or_add_for_write_only_span<bool>(".select_edge", ATTR_DOMAIN_EDGE);
select_edge = attrs.lookup_or_add_for_write_only_span<bool>(".select_edge", AttrDomain::Edge);
}
if (need_sharp_edge) {
sharp_edge = attrs.lookup_or_add_for_write_only_span<bool>("sharp_edge", ATTR_DOMAIN_EDGE);
sharp_edge = attrs.lookup_or_add_for_write_only_span<bool>("sharp_edge", AttrDomain::Edge);
}
if (need_uv_seams) {
uv_seams = attrs.lookup_or_add_for_write_only_span<bool>(".uv_seam", ATTR_DOMAIN_EDGE);
uv_seams = attrs.lookup_or_add_for_write_only_span<bool>(".uv_seam", AttrDomain::Edge);
}
if (need_hide_edge) {
hide_edge = attrs.lookup_or_add_for_write_only_span<bool>(".hide_edge", ATTR_DOMAIN_EDGE);
hide_edge = attrs.lookup_or_add_for_write_only_span<bool>(".hide_edge", AttrDomain::Edge);
}
if (need_select_poly) {
select_poly = attrs.lookup_or_add_for_write_only_span<bool>(".select_poly", ATTR_DOMAIN_FACE);
select_poly = attrs.lookup_or_add_for_write_only_span<bool>(".select_poly", AttrDomain::Face);
}
if (need_hide_poly) {
hide_poly = attrs.lookup_or_add_for_write_only_span<bool>(".hide_poly", ATTR_DOMAIN_FACE);
hide_poly = attrs.lookup_or_add_for_write_only_span<bool>(".hide_poly", AttrDomain::Face);
}
if (need_sharp_face) {
sharp_face = attrs.lookup_or_add_for_write_only_span<bool>("sharp_face", ATTR_DOMAIN_FACE);
sharp_face = attrs.lookup_or_add_for_write_only_span<bool>("sharp_face", AttrDomain::Face);
}
if (need_material_index) {
material_index = attrs.lookup_or_add_for_write_only_span<int>("material_index",
ATTR_DOMAIN_FACE);
AttrDomain::Face);
}
/* Loop over all elements in parallel, copying attributes and building the Mesh topology. */

View File

@ -33,8 +33,8 @@ class GenericRequest {
public:
std::string name;
eCustomDataType type;
eAttrDomain domain;
GenericRequest(const StringRef name, const eCustomDataType type, const eAttrDomain domain)
bke::AttrDomain domain;
GenericRequest(const StringRef name, const eCustomDataType type, const bke::AttrDomain domain)
: name(name), type(type), domain(domain)
{
}

View File

@ -6,7 +6,7 @@
* \ingroup draw_engine
*/
#include "BKE_attribute.h"
#include "BKE_attribute.hh"
#include "BKE_curves.h"
#include "DRW_render.h"
@ -21,12 +21,14 @@
void OVERLAY_edit_curves_init(OVERLAY_Data *vedata)
{
using namespace blender;
OVERLAY_PrivateData *pd = vedata->stl->pd;
const DRWContextState *draw_ctx = DRW_context_state_get();
const Object *obact_orig = DEG_get_original_object(draw_ctx->obact);
const Curves &curves_id = *static_cast<const Curves *>(obact_orig->data);
pd->edit_curves.do_points = curves_id.selection_domain == ATTR_DOMAIN_POINT;
pd->edit_curves.do_points = bke::AttrDomain(curves_id.selection_domain) ==
bke::AttrDomain::Point;
pd->edit_curves.do_zbufclip = XRAY_FLAG_ENABLED(draw_ctx->v3d);
/* Create view with depth offset. */

View File

@ -16,10 +16,11 @@
void OVERLAY_edit_grease_pencil_cache_init(OVERLAY_Data *vedata)
{
using namespace blender;
OVERLAY_PassList *psl = vedata->psl;
OVERLAY_PrivateData *pd = vedata->stl->pd;
const DRWContextState *draw_ctx = DRW_context_state_get();
const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(
const bke::AttrDomain selection_domain = ED_grease_pencil_selection_domain_get(
draw_ctx->scene->toolsettings);
const View3D *v3d = draw_ctx->v3d;
@ -30,7 +31,7 @@ void OVERLAY_edit_grease_pencil_cache_init(OVERLAY_Data *vedata)
DRW_STATE_BLEND_ALPHA;
DRW_PASS_CREATE(psl->edit_grease_pencil_ps, (state | pd->clipping_state));
const bool show_points = selection_domain == ATTR_DOMAIN_POINT;
const bool show_points = selection_domain == bke::AttrDomain::Point;
const bool show_lines = (v3d->gp_flag & V3D_GP_SHOW_EDIT_LINES) != 0;
if (show_lines) {

View File

@ -54,7 +54,7 @@ static bool everything_selected(const Curves &curves_id)
using namespace blender;
const bke::CurvesGeometry &curves = curves_id.geometry.wrap();
const VArray<bool> selection = *curves.attributes().lookup_or_default<bool>(
".selection", ATTR_DOMAIN_POINT, true);
".selection", bke::AttrDomain::Point, true);
return selection.is_single() && selection.get_internal_single();
}

View File

@ -64,7 +64,7 @@ void drw_attributes_add_request(DRW_Attributes *attrs,
const char *name,
const eCustomDataType type,
const int layer_index,
const eAttrDomain domain)
const blender::bke::AttrDomain domain)
{
if (attrs->num_requests >= GPU_MAX_ATTR ||
drw_attributes_has_request(attrs, {type, layer_index, domain}))

View File

@ -14,7 +14,7 @@
#include "DNA_customdata_types.h"
#include "BKE_attribute.h"
#include "BKE_attribute.hh"
#include "BLI_sys_types.h"
@ -23,7 +23,7 @@
struct DRW_AttributeRequest {
eCustomDataType cd_type;
int layer_index;
eAttrDomain domain;
blender::bke::AttrDomain domain;
char attribute_name[64];
};
@ -62,7 +62,7 @@ void drw_attributes_add_request(DRW_Attributes *attrs,
const char *name,
eCustomDataType data_type,
int layer_index,
eAttrDomain domain);
blender::bke::AttrDomain domain);
bool drw_custom_data_match_attribute(const CustomData *custom_data,
const char *name,

View File

@ -683,17 +683,17 @@ MeshRenderData *mesh_render_data_create(Object *object,
const bke::AttributeAccessor attributes = mr->mesh->attributes();
mr->material_indices = *attributes.lookup<int>("material_index", ATTR_DOMAIN_FACE);
mr->material_indices = *attributes.lookup<int>("material_index", bke::AttrDomain::Face);
mr->hide_vert = *attributes.lookup<bool>(".hide_vert", ATTR_DOMAIN_POINT);
mr->hide_edge = *attributes.lookup<bool>(".hide_edge", ATTR_DOMAIN_EDGE);
mr->hide_poly = *attributes.lookup<bool>(".hide_poly", ATTR_DOMAIN_FACE);
mr->hide_vert = *attributes.lookup<bool>(".hide_vert", bke::AttrDomain::Point);
mr->hide_edge = *attributes.lookup<bool>(".hide_edge", bke::AttrDomain::Edge);
mr->hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
mr->select_vert = *attributes.lookup<bool>(".select_vert", ATTR_DOMAIN_POINT);
mr->select_edge = *attributes.lookup<bool>(".select_edge", ATTR_DOMAIN_EDGE);
mr->select_poly = *attributes.lookup<bool>(".select_poly", ATTR_DOMAIN_FACE);
mr->select_vert = *attributes.lookup<bool>(".select_vert", bke::AttrDomain::Point);
mr->select_edge = *attributes.lookup<bool>(".select_edge", bke::AttrDomain::Edge);
mr->select_poly = *attributes.lookup<bool>(".select_poly", bke::AttrDomain::Face);
mr->sharp_faces = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
mr->sharp_faces = *attributes.lookup<bool>("sharp_face", bke::AttrDomain::Face);
}
else {
/* #BMesh */

View File

@ -500,7 +500,7 @@ static void curve_create_attribute(CurveRenderData *rdata, GPUVertBuf *vbo_attr)
const bke::CurvesGeometry &curves = rdata->curve_eval->geometry.wrap();
curves.ensure_can_interpolate_to_evaluated();
const VArraySpan colors = *curves.attributes().lookup<ColorGeometry4f>(".viewer",
ATTR_DOMAIN_POINT);
bke::AttrDomain::Point);
ColorGeometry4f *vbo_data = static_cast<ColorGeometry4f *>(GPU_vertbuf_get_data(vbo_attr));
curves.interpolate_to_evaluated(colors, MutableSpan<ColorGeometry4f>{vbo_data, vert_len});
}

View File

@ -271,7 +271,7 @@ static void curves_batch_cache_ensure_edit_points_selection(const bke::CurvesGeo
curves.points_num());
const VArray<float> attribute = *curves.attributes().lookup_or_default<float>(
".selection", ATTR_DOMAIN_POINT, true);
".selection", bke::AttrDomain::Point, true);
attribute.materialize(data);
}
@ -335,8 +335,8 @@ static void curves_batch_ensure_attribute(const Curves &curves,
GPUVertBuf *attr_vbo = cache.proc_attributes_buf[index];
GPU_vertbuf_data_alloc(attr_vbo,
request.domain == ATTR_DOMAIN_POINT ? curves.geometry.point_num :
curves.geometry.curve_num);
request.domain == bke::AttrDomain::Point ? curves.geometry.point_num :
curves.geometry.curve_num);
const bke::AttributeAccessor attributes = curves.geometry.wrap().attributes();
@ -359,7 +359,7 @@ static void curves_batch_ensure_attribute(const Curves &curves,
GPU_VERTBUF_DISCARD_SAFE(cache.final[subdiv].attributes_buf[index]);
/* Ensure final data for points. */
if (request.domain == ATTR_DOMAIN_POINT) {
if (request.domain == bke::AttrDomain::Point) {
curves_batch_cache_ensure_procedural_final_attr(cache, &format, subdiv, index, sampler_name);
}
}
@ -537,12 +537,12 @@ static bool curves_ensure_attributes(const Curves &curves,
int layer_index;
eCustomDataType type;
eAttrDomain domain;
bke::AttrDomain domain;
if (drw_custom_data_match_attribute(cd_curve, name, &layer_index, &type)) {
domain = ATTR_DOMAIN_CURVE;
domain = bke::AttrDomain::Curve;
}
else if (drw_custom_data_match_attribute(cd_point, name, &layer_index, &type)) {
domain = ATTR_DOMAIN_POINT;
domain = bke::AttrDomain::Point;
}
else {
continue;
@ -570,7 +570,7 @@ static bool curves_ensure_attributes(const Curves &curves,
continue;
}
if (request.domain == ATTR_DOMAIN_POINT) {
if (request.domain == bke::AttrDomain::Point) {
need_tf_update = true;
}
@ -596,10 +596,10 @@ static void request_attribute(Curves &curves, const char *name)
if (!meta_data) {
return;
}
const eAttrDomain domain = meta_data->domain;
const bke::AttrDomain domain = meta_data->domain;
const eCustomDataType type = meta_data->data_type;
const CustomData &custom_data = domain == ATTR_DOMAIN_POINT ? curves.geometry.point_data :
curves.geometry.curve_data;
const CustomData &custom_data = domain == bke::AttrDomain::Point ? curves.geometry.point_data :
curves.geometry.curve_data;
drw_attributes_add_request(
&attributes, name, type, CustomData_get_named_layer(&custom_data, type, name), domain);
@ -745,6 +745,7 @@ GPUVertBuf **DRW_curves_texture_for_evaluated_attribute(Curves *curves,
const char *name,
bool *r_is_point_domain)
{
using namespace blender;
using namespace blender::draw;
CurvesBatchCache &cache = curves_batch_cache_get(*curves);
const DRWContextState *draw_ctx = DRW_context_state_get();
@ -766,10 +767,10 @@ GPUVertBuf **DRW_curves_texture_for_evaluated_attribute(Curves *curves,
return nullptr;
}
switch (final_cache.attr_used.requests[request_i].domain) {
case ATTR_DOMAIN_POINT:
case bke::AttrDomain::Point:
*r_is_point_domain = true;
return &final_cache.attributes_buf[request_i];
case ATTR_DOMAIN_CURVE:
case bke::AttrDomain::Curve:
*r_is_point_domain = false;
return &cache.curves_cache.proc_attributes_buf[request_i];
default:

View File

@ -258,7 +258,7 @@ static void grease_pencil_edit_batch_ensure(Object &object,
/* Assumes that if the ".selection" attribute does not exist, all points are selected. */
const VArray<float> selection_float = *attributes.lookup_or_default<float>(
".selection", ATTR_DOMAIN_POINT, true);
".selection", bke::AttrDomain::Point, true);
edit_points.slice(drawing_start_offset, curves.points_num()).copy_from(curves.positions());
MutableSpan<float> selection_slice = edit_points_selection.slice(drawing_start_offset,
@ -289,7 +289,7 @@ static void grease_pencil_edit_batch_ensure(Object &object,
}
const VArray<bool> selection = *attributes.lookup_or_default<bool>(
".selection", ATTR_DOMAIN_POINT, true);
".selection", bke::AttrDomain::Point, true);
editable_strokes.foreach_index([&](const int curve_i) {
const IndexRange points = points_by_curve[curve_i];
@ -340,7 +340,7 @@ static void grease_pencil_edit_batch_ensure(Object &object,
/* Assumes that if the ".selection" attribute does not exist, all points are selected. */
const VArray<bool> selection = *curves.attributes().lookup_or_default<bool>(
".selection", ATTR_DOMAIN_POINT, true);
".selection", bke::AttrDomain::Point, true);
/* Fill point indices. */
if (!layer->is_locked()) {
@ -486,16 +486,16 @@ static void grease_pencil_geom_batch_ensure(Object &object,
const VArray<float> radii = info.drawing.radii();
const VArray<float> opacities = info.drawing.opacities();
const VArray<ColorGeometry4f> vertex_colors = *attributes.lookup_or_default<ColorGeometry4f>(
"vertex_color", ATTR_DOMAIN_POINT, ColorGeometry4f(0.0f, 0.0f, 0.0f, 0.0f));
"vertex_color", bke::AttrDomain::Point, ColorGeometry4f(0.0f, 0.0f, 0.0f, 0.0f));
/* Assumes that if the ".selection" attribute does not exist, all points are selected. */
const VArray<float> selection_float = *attributes.lookup_or_default<float>(
".selection", ATTR_DOMAIN_POINT, true);
".selection", bke::AttrDomain::Point, true);
const VArray<int8_t> start_caps = *attributes.lookup_or_default<int8_t>(
"start_cap", ATTR_DOMAIN_CURVE, 0);
"start_cap", bke::AttrDomain::Curve, 0);
const VArray<int8_t> end_caps = *attributes.lookup_or_default<int8_t>(
"end_cap", ATTR_DOMAIN_CURVE, 0);
"end_cap", bke::AttrDomain::Curve, 0);
const VArray<int> materials = *attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_CURVE, 0);
"material_index", bke::AttrDomain::Curve, 0);
const Span<uint3> triangles = info.drawing.triangles();
const Span<int> verts_start_offsets = verts_start_offsets_per_visible_drawing[drawing_i];
const Span<int> tris_start_offsets = tris_start_offsets_per_visible_drawing[drawing_i];

View File

@ -30,7 +30,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_attribute.h"
#include "BKE_attribute.hh"
#include "BKE_customdata.hh"
#include "BKE_deform.h"
#include "BKE_editmesh.hh"
@ -277,6 +277,7 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
int gpumat_array_len,
DRW_Attributes *attributes)
{
using namespace blender;
const Mesh *me_final = editmesh_final_or_this(object, mesh);
const CustomData *cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
const CustomData *cd_pdata = mesh_cd_pdata_get_from_mesh(me_final);
@ -301,7 +302,7 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
const char *name = gpu_attr->name;
eCustomDataType type = static_cast<eCustomDataType>(gpu_attr->type);
int layer = -1;
std::optional<eAttrDomain> domain;
std::optional<bke::AttrDomain> domain;
if (gpu_attr->is_default_color) {
name = default_color_name.c_str();
@ -326,16 +327,16 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
/* Try to match a generic attribute, we use the first attribute domain with a
* matching name. */
if (drw_custom_data_match_attribute(cd_vdata, name, &layer, &type)) {
domain = ATTR_DOMAIN_POINT;
domain = bke::AttrDomain::Point;
}
else if (drw_custom_data_match_attribute(cd_ldata, name, &layer, &type)) {
domain = ATTR_DOMAIN_CORNER;
domain = bke::AttrDomain::Corner;
}
else if (drw_custom_data_match_attribute(cd_pdata, name, &layer, &type)) {
domain = ATTR_DOMAIN_FACE;
domain = bke::AttrDomain::Face;
}
else if (drw_custom_data_match_attribute(cd_edata, name, &layer, &type)) {
domain = ATTR_DOMAIN_EDGE;
domain = bke::AttrDomain::Edge;
}
else {
layer = -1;
@ -867,6 +868,7 @@ static void request_active_and_default_color_attributes(const Object &object,
const Mesh &mesh,
DRW_Attributes &attributes)
{
using namespace blender;
const Mesh *me_final = editmesh_final_or_this(&object, &mesh);
const CustomData *cd_vdata = mesh_cd_vdata_get_from_mesh(me_final);
const CustomData *cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
@ -876,10 +878,10 @@ static void request_active_and_default_color_attributes(const Object &object,
int layer_index;
eCustomDataType type;
if (drw_custom_data_match_attribute(cd_vdata, name, &layer_index, &type)) {
drw_attributes_add_request(&attributes, name, type, layer_index, ATTR_DOMAIN_POINT);
drw_attributes_add_request(&attributes, name, type, layer_index, bke::AttrDomain::Point);
}
else if (drw_custom_data_match_attribute(cd_ldata, name, &layer_index, &type)) {
drw_attributes_add_request(&attributes, name, type, layer_index, ATTR_DOMAIN_CORNER);
drw_attributes_add_request(&attributes, name, type, layer_index, bke::AttrDomain::Corner);
}
}
};

View File

@ -337,6 +337,7 @@ GPUBatch **pointcloud_surface_shaded_get(PointCloud *pointcloud,
GPUMaterial **gpu_materials,
int mat_len)
{
using namespace blender;
PointCloudBatchCache *cache = pointcloud_batch_cache_get(*pointcloud);
DRW_Attributes attrs_needed;
drw_attributes_clear(&attrs_needed);
@ -348,7 +349,7 @@ GPUBatch **pointcloud_surface_shaded_get(PointCloud *pointcloud,
int layer_index;
eCustomDataType type;
eAttrDomain domain = ATTR_DOMAIN_POINT;
bke::AttrDomain domain = bke::AttrDomain::Point;
if (!drw_custom_data_match_attribute(&pointcloud->pdata, name, &layer_index, &type)) {
continue;
}
@ -397,11 +398,12 @@ GPUVertBuf *DRW_pointcloud_position_and_radius_buffer_get(Object *ob)
GPUVertBuf **DRW_pointcloud_evaluated_attribute(PointCloud *pointcloud, const char *name)
{
using namespace blender;
PointCloudBatchCache &cache = *pointcloud_batch_cache_get(*pointcloud);
int layer_index;
eCustomDataType type;
eAttrDomain domain = ATTR_DOMAIN_POINT;
bke::AttrDomain domain = bke::AttrDomain::Point;
if (drw_custom_data_match_attribute(&pointcloud->pdata, name, &layer_index, &type)) {
DRW_Attributes attributes{};
drw_attributes_add_request(&attributes, name, type, layer_index, domain);

View File

@ -2023,6 +2023,7 @@ static void draw_subdiv_cache_ensure_mat_offsets(DRWSubdivCache &cache,
Mesh *mesh_eval,
uint mat_len)
{
using namespace blender;
draw_subdiv_cache_free_material_data(cache);
const int number_of_quads = cache.num_subdiv_loops / 4;
@ -2037,7 +2038,7 @@ static void draw_subdiv_cache_ensure_mat_offsets(DRWSubdivCache &cache,
const blender::bke::AttributeAccessor attributes = mesh_eval->attributes();
const blender::VArraySpan<int> material_indices = *attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
"material_index", bke::AttrDomain::Face, 0);
/* Count number of subdivided polygons for each material. */
int *mat_start = static_cast<int *>(MEM_callocN(sizeof(int) * mat_len, "subdiv mat_start"));

View File

@ -168,6 +168,7 @@ static void drw_curves_cache_update_compute(CurvesEvalCache *cache,
static void drw_curves_cache_update_compute(CurvesEvalCache *cache, const int subdiv)
{
using namespace blender;
const int strands_len = cache->strands_len;
const int final_points_len = cache->final[subdiv].strands_res * strands_len;
if (final_points_len == 0) {
@ -180,7 +181,7 @@ static void drw_curves_cache_update_compute(CurvesEvalCache *cache, const int su
const DRW_Attributes &attrs = cache->final[subdiv].attr_used;
for (int i = 0; i < attrs.num_requests; i++) {
/* Only refine point attributes. */
if (attrs.requests[i].domain == ATTR_DOMAIN_CURVE) {
if (attrs.requests[i].domain == bke::AttrDomain::Curve) {
continue;
}
@ -225,6 +226,7 @@ static void drw_curves_cache_update_transform_feedback(CurvesEvalCache *cache,
static void drw_curves_cache_update_transform_feedback(CurvesEvalCache *cache, const int subdiv)
{
using namespace blender;
const int final_points_len = cache->final[subdiv].strands_res * cache->strands_len;
if (final_points_len == 0) {
return;
@ -236,7 +238,7 @@ static void drw_curves_cache_update_transform_feedback(CurvesEvalCache *cache, c
const DRW_Attributes &attrs = cache->final[subdiv].attr_used;
for (int i = 0; i < attrs.num_requests; i++) {
/* Only refine point attributes. */
if (attrs.requests[i].domain == ATTR_DOMAIN_CURVE) {
if (attrs.requests[i].domain == bke::AttrDomain::Curve) {
continue;
}
@ -339,7 +341,7 @@ DRWShadingGroup *DRW_shgroup_curves_create_sub(Object *object,
const blender::bke::CurvesGeometry &curves = curves_id.geometry.wrap();
if (curves.curves_num() >= 1) {
blender::VArray<float> radii = *curves.attributes().lookup_or_default(
"radius", ATTR_DOMAIN_POINT, 0.005f);
"radius", bke::AttrDomain::Point, 0.005f);
const blender::IndexRange first_curve_points = curves.points_by_curve()[0];
const float first_radius = radii[first_curve_points.first()];
const float last_radius = radii[first_curve_points.last()];
@ -364,7 +366,7 @@ DRWShadingGroup *DRW_shgroup_curves_create_sub(Object *object,
char sampler_name[32];
drw_curves_get_attribute_sampler_name(request.attribute_name, sampler_name);
if (request.domain == ATTR_DOMAIN_CURVE) {
if (request.domain == bke::AttrDomain::Curve) {
if (!curves_cache->proc_attributes_buf[i]) {
continue;
}
@ -385,7 +387,7 @@ DRWShadingGroup *DRW_shgroup_curves_create_sub(Object *object,
* attributes. */
const int index = attribute_index_in_material(gpu_material, request.attribute_name);
if (index != -1) {
curves_infos.is_point_attribute[index][0] = request.domain == ATTR_DOMAIN_POINT;
curves_infos.is_point_attribute[index][0] = request.domain == bke::AttrDomain::Point;
}
}
@ -616,7 +618,7 @@ static CurvesEvalCache *curves_cache_get(Curves &curves,
const DRW_Attributes &attrs = cache->final[subdiv].attr_used;
for (int i : IndexRange(attrs.num_requests)) {
/* Only refine point attributes. */
if (attrs.requests[i].domain != ATTR_DOMAIN_CURVE) {
if (attrs.requests[i].domain != bke::AttrDomain::Curve) {
cache_update(cache->final[subdiv].attributes_buf[i], cache->proc_attributes_buf[i]);
}
}
@ -685,7 +687,7 @@ GPUBatch *curves_sub_pass_setup_implementation(PassT &sub_ps,
const blender::bke::CurvesGeometry &curves = curves_id.geometry.wrap();
if (curves.curves_num() >= 1) {
blender::VArray<float> radii = *curves.attributes().lookup_or_default(
"radius", ATTR_DOMAIN_POINT, 0.005f);
"radius", bke::AttrDomain::Point, 0.005f);
const blender::IndexRange first_curve_points = curves.points_by_curve()[0];
const float first_radius = radii[first_curve_points.first()];
const float last_radius = radii[first_curve_points.last()];
@ -710,7 +712,7 @@ GPUBatch *curves_sub_pass_setup_implementation(PassT &sub_ps,
char sampler_name[32];
drw_curves_get_attribute_sampler_name(request.attribute_name, sampler_name);
if (request.domain == ATTR_DOMAIN_CURVE) {
if (request.domain == bke::AttrDomain::Curve) {
if (!curves_cache->proc_attributes_buf[i]) {
continue;
}
@ -729,7 +731,7 @@ GPUBatch *curves_sub_pass_setup_implementation(PassT &sub_ps,
* attributes. */
const int index = attribute_index_in_material(gpu_material, request.attribute_name);
if (index != -1) {
curves_infos.is_point_attribute[index][0] = request.domain == ATTR_DOMAIN_POINT;
curves_infos.is_point_attribute[index][0] = request.domain == bke::AttrDomain::Point;
}
}

View File

@ -1433,7 +1433,7 @@ void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup,
if (use_uv) {
if (const char *name = CustomData_get_active_layer_name(&mesh->corner_data, CD_PROP_FLOAT2)) {
attrs.append(pbvh::GenericRequest{name, CD_PROP_FLOAT2, ATTR_DOMAIN_CORNER});
attrs.append(pbvh::GenericRequest{name, CD_PROP_FLOAT2, bke::AttrDomain::Corner});
}
}
@ -1447,6 +1447,7 @@ void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups,
int num_shgroups,
const Object *ob)
{
using namespace blender;
using namespace blender::draw;
DRW_Attributes draw_attrs;
DRW_MeshCDMask cd_needed;
@ -1477,7 +1478,7 @@ void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups,
int layer_i = CustomData_get_layer_index_n(&mesh->corner_data, CD_PROP_FLOAT2, i);
CustomDataLayer *layer = layer_i != -1 ? mesh->corner_data.layers + layer_i : nullptr;
if (layer) {
attrs.append(pbvh::GenericRequest{layer->name, CD_PROP_FLOAT2, ATTR_DOMAIN_CORNER});
attrs.append(pbvh::GenericRequest{layer->name, CD_PROP_FLOAT2, bke::AttrDomain::Corner});
}
}
}

View File

@ -66,7 +66,7 @@ static bool pbvh_attr_supported(const AttributeRequest &request)
return true;
}
const GenericRequest &attr = std::get<GenericRequest>(request);
if (!ELEM(attr.domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_FACE, ATTR_DOMAIN_CORNER)) {
if (!ELEM(attr.domain, bke::AttrDomain::Point, bke::AttrDomain::Face, bke::AttrDomain::Corner)) {
/* PBVH drawing does not support edge domain attributes. */
return false;
}
@ -91,7 +91,7 @@ static std::string calc_request_key(const AttributeRequest &request)
else {
const GenericRequest &attr = std::get<GenericRequest>(request);
const StringRefNull name = attr.name;
const eAttrDomain domain = attr.domain;
const bke::AttrDomain domain = attr.domain;
const eCustomDataType data_type = attr.type;
SNPRINTF(buf, "%d:%d:%s", int(data_type), int(domain), name.c_str());
}
@ -301,14 +301,14 @@ struct PBVHBatch {
}
};
static const CustomData *get_cdata(eAttrDomain domain, const PBVH_GPU_Args &args)
static const CustomData *get_cdata(bke::AttrDomain domain, const PBVH_GPU_Args &args)
{
switch (domain) {
case ATTR_DOMAIN_POINT:
case bke::AttrDomain::Point:
return args.vert_data;
case ATTR_DOMAIN_CORNER:
case bke::AttrDomain::Corner:
return args.corner_data;
case ATTR_DOMAIN_FACE:
case bke::AttrDomain::Face:
return args.face_data;
default:
return nullptr;
@ -438,7 +438,7 @@ struct PBVHBatches {
void fill_vbo_normal_faces(const PBVH_GPU_Args &args, GPUVertBuf &vert_buf)
{
const bke::AttributeAccessor attributes = args.mesh->attributes();
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", bke::AttrDomain::Face);
short4 *data = static_cast<short4 *>(GPU_vertbuf_get_data(&vert_buf));
@ -500,7 +500,8 @@ struct PBVHBatches {
case CustomRequest::Normal: {
const Span<int> grid_to_face_map = args.subdiv_ccg->grid_to_face_map;
const bke::AttributeAccessor attributes = args.mesh->attributes();
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face",
bke::AttrDomain::Face);
foreach_grids([&](int /*x*/, int /*y*/, int grid_index, CCGElem *elems[4], int /*i*/) {
float3 no(0.0f, 0.0f, 0.0f);
@ -545,7 +546,8 @@ struct PBVHBatches {
case CustomRequest::FaceSet: {
const bke::AttributeAccessor attributes = args.mesh->attributes();
if (const VArray<int> face_sets = *attributes.lookup<int>(".sculpt_face_set",
ATTR_DOMAIN_FACE)) {
bke::AttrDomain::Face))
{
const VArraySpan<int> face_sets_span(face_sets);
foreach_grids(
[&](int /*x*/, int /*y*/, int grid_index, CCGElem * /*elems*/[4], int /*i*/) {
@ -681,7 +683,7 @@ struct PBVHBatches {
case CustomRequest::Mask: {
float *data = static_cast<float *>(GPU_vertbuf_get_data(&vert_buf));
if (const VArray<float> mask = *attributes.lookup<float>(".sculpt_mask",
ATTR_DOMAIN_POINT)) {
bke::AttrDomain::Point)) {
const VArraySpan<float> mask_span(mask);
const Span<int> corner_verts = args.corner_verts;
const Span<int3> corner_tris = args.corner_tris;
@ -707,7 +709,8 @@ struct PBVHBatches {
case CustomRequest::FaceSet: {
uchar4 *data = static_cast<uchar4 *>(GPU_vertbuf_get_data(vbo.vert_buf));
if (const VArray<int> face_sets = *attributes.lookup<int>(".sculpt_face_set",
ATTR_DOMAIN_FACE)) {
bke::AttrDomain::Face))
{
const VArraySpan<int> face_sets_span(face_sets);
int last_face = -1;
uchar4 fset_color(UCHAR_MAX);
@ -746,19 +749,19 @@ struct PBVHBatches {
const bke::AttributeAccessor attributes = args.mesh->attributes();
const GenericRequest &request = std::get<GenericRequest>(vbo.request);
const StringRef name = request.name;
const eAttrDomain domain = request.domain;
const bke::AttrDomain domain = request.domain;
const eCustomDataType data_type = request.type;
const GVArraySpan attribute = *attributes.lookup_or_default(name, domain, data_type);
bke::attribute_math::convert_to_static_type(data_type, [&](auto dummy) {
using T = decltype(dummy);
switch (domain) {
case ATTR_DOMAIN_POINT:
case bke::AttrDomain::Point:
extract_data_vert_faces<T>(args, attribute.typed<T>(), vert_buf);
break;
case ATTR_DOMAIN_FACE:
case bke::AttrDomain::Face:
extract_data_face_faces<T>(args, attribute.typed<T>(), vert_buf);
break;
case ATTR_DOMAIN_CORNER:
case bke::AttrDomain::Corner:
extract_data_corner_faces<T>(args, attribute.typed<T>(), vert_buf);
break;
default:
@ -912,20 +915,20 @@ struct PBVHBatches {
else {
const GenericRequest &request = std::get<GenericRequest>(vbo.request);
const StringRefNull name = request.name;
const eAttrDomain domain = request.domain;
const bke::AttrDomain domain = request.domain;
const eCustomDataType data_type = request.type;
const CustomData &custom_data = *get_cdata(domain, args);
const int cd_offset = CustomData_get_offset_named(&custom_data, data_type, name.c_str());
bke::attribute_math::convert_to_static_type(data_type, [&](auto dummy) {
using T = decltype(dummy);
switch (domain) {
case ATTR_DOMAIN_POINT:
case bke::AttrDomain::Point:
extract_data_vert_bmesh<T>(args, cd_offset, *vbo.vert_buf);
break;
case ATTR_DOMAIN_FACE:
case bke::AttrDomain::Face:
extract_data_face_bmesh<T>(args, cd_offset, *vbo.vert_buf);
break;
case ATTR_DOMAIN_CORNER:
case bke::AttrDomain::Corner:
extract_data_corner_bmesh<T>(args, cd_offset, *vbo.vert_buf);
break;
default:
@ -974,7 +977,7 @@ struct PBVHBatches {
else {
const GenericRequest &attr = std::get<GenericRequest>(request);
const StringRefNull name = attr.name;
const eAttrDomain domain = attr.domain;
const bke::AttrDomain domain = attr.domain;
const eCustomDataType data_type = attr.type;
format = draw::init_format_for_attribute(data_type, "data");
@ -1030,7 +1033,7 @@ struct PBVHBatches {
{
const bke::AttributeAccessor attributes = args.mesh->attributes();
const VArray material_indices = *attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
"material_index", bke::AttrDomain::Face, 0);
material_index = material_indices[args.tri_faces[args.prim_indices.first()]];
const Span<int2> edges = args.mesh->edges();
@ -1113,9 +1116,9 @@ struct PBVHBatches {
void create_index_grids(const PBVH_GPU_Args &args, bool do_coarse)
{
const bke::AttributeAccessor attributes = args.mesh->attributes();
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", bke::AttrDomain::Face);
const VArray material_indices = *attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
"material_index", bke::AttrDomain::Face, 0);
const BitGroupVector<> &grid_hidden = args.subdiv_ccg->grid_hidden;
const Span<int> grid_to_face_map = args.subdiv_ccg->grid_to_face_map;

View File

@ -147,7 +147,7 @@ Vector<SculptBatch> sculpt_batches_get(const Object *ob, SculptBatchFeature feat
if (features & SCULPT_BATCH_UV) {
if (const char *name = CustomData_get_active_layer_name(&mesh->corner_data, CD_PROP_FLOAT2)) {
attrs.append(pbvh::GenericRequest{name, CD_PROP_FLOAT2, ATTR_DOMAIN_CORNER});
attrs.append(pbvh::GenericRequest{name, CD_PROP_FLOAT2, bke::AttrDomain::Corner});
}
}
@ -180,7 +180,7 @@ Vector<SculptBatch> sculpt_batches_per_material_get(const Object *ob,
int layer_i = CustomData_get_layer_index_n(&mesh->corner_data, CD_PROP_FLOAT2, i);
CustomDataLayer *layer = layer_i != -1 ? mesh->corner_data.layers + layer_i : nullptr;
if (layer) {
attrs.append(pbvh::GenericRequest{layer->name, CD_PROP_FLOAT2, ATTR_DOMAIN_CORNER});
attrs.append(pbvh::GenericRequest{layer->name, CD_PROP_FLOAT2, bke::AttrDomain::Corner});
}
}
}

View File

@ -172,16 +172,16 @@ static void extract_data_bmesh_loop(const BMesh &bm, const int cd_offset, GPUVer
}
}
static const CustomData *get_custom_data_for_domain(const BMesh &bm, eAttrDomain domain)
static const CustomData *get_custom_data_for_domain(const BMesh &bm, bke::AttrDomain domain)
{
switch (domain) {
case ATTR_DOMAIN_POINT:
case bke::AttrDomain::Point:
return &bm.vdata;
case ATTR_DOMAIN_CORNER:
case bke::AttrDomain::Corner:
return &bm.ldata;
case ATTR_DOMAIN_FACE:
case bke::AttrDomain::Face:
return &bm.pdata;
case ATTR_DOMAIN_EDGE:
case bke::AttrDomain::Edge:
return &bm.edata;
default:
return nullptr;
@ -200,16 +200,16 @@ static void extract_attr(const MeshRenderData &mr,
bke::attribute_math::convert_to_static_type(request.cd_type, [&](auto dummy) {
using T = decltype(dummy);
switch (request.domain) {
case ATTR_DOMAIN_POINT:
case bke::AttrDomain::Point:
extract_data_bmesh_vert<T>(*mr.bm, cd_offset, vbo);
break;
case ATTR_DOMAIN_EDGE:
case bke::AttrDomain::Edge:
extract_data_bmesh_edge<T>(*mr.bm, cd_offset, vbo);
break;
case ATTR_DOMAIN_FACE:
case bke::AttrDomain::Face:
extract_data_bmesh_face<T>(*mr.bm, cd_offset, vbo);
break;
case ATTR_DOMAIN_CORNER:
case bke::AttrDomain::Corner:
extract_data_bmesh_loop<T>(*mr.bm, cd_offset, vbo);
break;
default:
@ -226,16 +226,16 @@ static void extract_attr(const MeshRenderData &mr,
bke::attribute_math::convert_to_static_type(request.cd_type, [&](auto dummy) {
using T = decltype(dummy);
switch (request.domain) {
case ATTR_DOMAIN_POINT:
case bke::AttrDomain::Point:
extract_data_mesh_mapped_corner(attribute.typed<T>(), mr.corner_verts, vbo);
break;
case ATTR_DOMAIN_EDGE:
case bke::AttrDomain::Edge:
extract_data_mesh_mapped_corner(attribute.typed<T>(), mr.corner_edges, vbo);
break;
case ATTR_DOMAIN_FACE:
case bke::AttrDomain::Face:
extract_data_mesh_face(mr.faces, attribute.typed<T>(), vbo);
break;
case ATTR_DOMAIN_CORNER:
case bke::AttrDomain::Corner:
vertbuf_data_extract_direct(attribute.typed<T>(), vbo);
break;
default:
@ -358,7 +358,7 @@ static void extract_mesh_attr_viewer_init(const MeshRenderData &mr,
const StringRefNull attr_name = ".viewer";
const bke::AttributeAccessor attributes = mr.mesh->attributes();
const bke::AttributeReader attribute = attributes.lookup_or_default<ColorGeometry4f>(
attr_name, ATTR_DOMAIN_CORNER, {1.0f, 0.0f, 1.0f, 1.0f});
attr_name, bke::AttrDomain::Corner, {1.0f, 0.0f, 1.0f, 1.0f});
attribute.varray.materialize(attr);
}

View File

@ -81,8 +81,9 @@ static void extract_sculpt_data_init(const MeshRenderData &mr,
}
else {
const bke::AttributeAccessor attributes = mr.mesh->attributes();
const VArray<float> mask = *attributes.lookup<float>(".sculpt_mask", ATTR_DOMAIN_POINT);
const VArray<int> face_set = *attributes.lookup<int>(".sculpt_face_set", ATTR_DOMAIN_FACE);
const VArray<float> mask = *attributes.lookup<float>(".sculpt_mask", bke::AttrDomain::Point);
const VArray<int> face_set = *attributes.lookup<int>(".sculpt_face_set",
bke::AttrDomain::Face);
for (int face_index = 0; face_index < mr.face_len; face_index++) {
for (const int corner : mr.faces[face_index]) {
@ -123,7 +124,7 @@ static void extract_sculpt_data_init_subdiv(const DRWSubdivCache &subdiv_cache,
GPUVertBuf *subdiv_mask_vbo = nullptr;
const bke::AttributeAccessor attributes = coarse_mesh->attributes();
const VArray<float> mask = *attributes.lookup<float>(".sculpt_mask", ATTR_DOMAIN_POINT);
const VArray<float> mask = *attributes.lookup<float>(".sculpt_mask", bke::AttrDomain::Point);
const OffsetIndices coarse_faces = coarse_mesh->faces();
const Span<int> coarse_corner_verts = coarse_mesh->corner_verts();
@ -163,7 +164,8 @@ static void extract_sculpt_data_init_subdiv(const DRWSubdivCache &subdiv_cache,
};
gpuFaceSet *face_sets = (gpuFaceSet *)GPU_vertbuf_get_data(face_set_vbo);
const VArray<int> cd_face_sets = *attributes.lookup<int>(".sculpt_face_set", ATTR_DOMAIN_FACE);
const VArray<int> cd_face_sets = *attributes.lookup<int>(".sculpt_face_set",
bke::AttrDomain::Face);
GPUVertFormat *format = get_sculpt_data_format();
GPU_vertbuf_init_build_on_device(vbo, format, subdiv_cache.num_subdiv_loops);

View File

@ -110,7 +110,7 @@ bke::CurvesGeometry primitive_random_sphere(const int curves_size, const int poi
MutableSpan<float3> positions = curves.positions_for_write();
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
bke::SpanAttributeWriter<float> radius = attributes.lookup_or_add_for_write_only_span<float>(
"radius", ATTR_DOMAIN_POINT);
"radius", bke::AttrDomain::Point);
for (const int i : offsets.index_range()) {
offsets[i] = points_per_curve * i;

View File

@ -62,13 +62,13 @@ static bool active_attribute_poll(bContext *C)
}
static IndexMask retrieve_selected_elements(const Curves &curves_id,
const eAttrDomain domain,
const bke::AttrDomain domain,
IndexMaskMemory &memory)
{
switch (domain) {
case ATTR_DOMAIN_POINT:
case bke::AttrDomain::Point:
return retrieve_selected_points(curves_id, memory);
case ATTR_DOMAIN_CURVE:
case bke::AttrDomain::Curve:
return retrieve_selected_curves(curves_id, memory);
default:
BLI_assert_unreachable();
@ -161,7 +161,7 @@ static int set_attribute_invoke(bContext *C, wmOperator *op, const wmEvent *even
const bke::CurvesGeometry &curves = active_curves_id.geometry.wrap();
const bke::AttributeAccessor attributes = curves.attributes();
const bke::GAttributeReader attribute = attributes.lookup(active_attribute->name);
const eAttrDomain domain = attribute.domain;
const bke::AttrDomain domain = attribute.domain;
IndexMaskMemory memory;
const IndexMask selection = retrieve_selected_elements(active_curves_id, domain, memory);

View File

@ -775,7 +775,7 @@ static int curves_draw_exec(bContext *C, wmOperator *op)
const IndexRange new_points = curves.points_by_curve()[curve_index];
bke::SpanAttributeWriter<float> radii = attributes.lookup_or_add_for_write_only_span<float>(
"radius", ATTR_DOMAIN_POINT);
"radius", bke::AttrDomain::Point);
float *co = cubic_spline;
@ -819,7 +819,7 @@ static int curves_draw_exec(bContext *C, wmOperator *op)
radii.finish();
bke::AttributeWriter<bool> selection = attributes.lookup_or_add_for_write<bool>(
".selection", ATTR_DOMAIN_CURVE);
".selection", bke::AttrDomain::Curve);
selection.varray.set(curve_index, true);
selection.finish();
@ -832,7 +832,7 @@ static int curves_draw_exec(bContext *C, wmOperator *op)
}
bke::fill_attribute_range_default(attributes,
ATTR_DOMAIN_POINT,
bke::AttrDomain::Point,
{"position",
"radius",
"handle_left",
@ -842,7 +842,7 @@ static int curves_draw_exec(bContext *C, wmOperator *op)
".selection"},
new_points);
bke::fill_attribute_range_default(attributes,
ATTR_DOMAIN_CURVE,
bke::AttrDomain::Curve,
{"curve_type", "resolution", "cyclic", ".selection"},
IndexRange(curve_index, 1));
}
@ -861,7 +861,7 @@ static int curves_draw_exec(bContext *C, wmOperator *op)
MutableSpan<float3> positions = curves.positions_for_write();
bke::SpanAttributeWriter<float> radii = attributes.lookup_or_add_for_write_only_span<float>(
"radius", ATTR_DOMAIN_POINT);
"radius", bke::AttrDomain::Point);
const IndexRange new_points = curves.points_by_curve()[curve_index];
@ -885,14 +885,16 @@ static int curves_draw_exec(bContext *C, wmOperator *op)
radii.finish();
bke::AttributeWriter<bool> selection = attributes.lookup_or_add_for_write<bool>(
".selection", ATTR_DOMAIN_CURVE);
".selection", bke::AttrDomain::Curve);
selection.varray.set(curve_index, true);
selection.finish();
bke::fill_attribute_range_default(
attributes, ATTR_DOMAIN_POINT, {"position", "radius", ".selection"}, new_points);
bke::fill_attribute_range_default(
attributes, ATTR_DOMAIN_CURVE, {"curve_type", ".selection"}, IndexRange(curve_index, 1));
attributes, bke::AttrDomain::Point, {"position", "radius", ".selection"}, new_points);
bke::fill_attribute_range_default(attributes,
bke::AttrDomain::Curve,
{"curve_type", ".selection"},
IndexRange(curve_index, 1));
}
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);

View File

@ -14,7 +14,7 @@
namespace blender::ed::curves {
bool remove_selection(bke::CurvesGeometry &curves, const eAttrDomain selection_domain)
bool remove_selection(bke::CurvesGeometry &curves, const bke::AttrDomain selection_domain)
{
const bke::AttributeAccessor attributes = curves.attributes();
const VArray<bool> selection = *attributes.lookup_or_default<bool>(
@ -23,10 +23,10 @@ bool remove_selection(bke::CurvesGeometry &curves, const eAttrDomain selection_d
IndexMaskMemory memory;
const IndexMask mask = IndexMask::from_bools(selection, memory);
switch (selection_domain) {
case ATTR_DOMAIN_POINT:
case bke::AttrDomain::Point:
curves.remove_points(mask);
break;
case ATTR_DOMAIN_CURVE:
case bke::AttrDomain::Curve:
curves.remove_curves(mask);
break;
default:
@ -122,7 +122,7 @@ void duplicate_points(bke::CurvesGeometry &curves, const IndexMask &mask)
}
switch (meta_data.domain) {
case ATTR_DOMAIN_CURVE: {
case bke::AttrDomain::Curve: {
if (id.name() == "cyclic") {
return true;
}
@ -132,7 +132,7 @@ void duplicate_points(bke::CurvesGeometry &curves, const IndexMask &mask)
attribute.span.slice(IndexRange(old_curves_num, num_curves_to_add)));
break;
}
case ATTR_DOMAIN_POINT: {
case bke::AttrDomain::Point: {
bke::attribute_math::gather(
attribute.span,
dst_to_src_point,
@ -159,7 +159,7 @@ void duplicate_points(bke::CurvesGeometry &curves, const IndexMask &mask)
curves.tag_topology_changed();
bke::SpanAttributeWriter<bool> selection = attributes.lookup_or_add_for_write_span<bool>(
".selection", ATTR_DOMAIN_POINT);
".selection", bke::AttrDomain::Point);
selection.span.take_back(num_points_to_add).fill(true);
selection.finish();
}
@ -192,14 +192,14 @@ void duplicate_curves(bke::CurvesGeometry &curves, const IndexMask &mask)
attributes.for_all([&](const bke::AttributeIDRef &id, const bke::AttributeMetaData meta_data) {
bke::GSpanAttributeWriter attribute = attributes.lookup_for_write_span(id);
switch (meta_data.domain) {
case ATTR_DOMAIN_POINT:
case bke::AttrDomain::Point:
bke::attribute_math::gather_group_to_group(points_by_curve.slice(orig_curves_range),
points_by_curve.slice(new_curves_range),
mask,
attribute.span,
attribute.span);
break;
case ATTR_DOMAIN_CURVE:
case bke::AttrDomain::Curve:
array_utils::gather(attribute.span, mask, attribute.span.take_back(mask.size()));
break;
default:
@ -214,7 +214,7 @@ void duplicate_curves(bke::CurvesGeometry &curves, const IndexMask &mask)
curves.tag_topology_changed();
bke::SpanAttributeWriter<bool> selection = attributes.lookup_or_add_for_write_span<bool>(
".selection", ATTR_DOMAIN_CURVE);
".selection", bke::AttrDomain::Curve);
selection.span.take_back(mask.size()).fill(true);
selection.finish();
}

View File

@ -44,7 +44,7 @@ IndexMask end_points(const bke::CurvesGeometry &curves,
IndexMask random_mask(const bke::CurvesGeometry &curves,
const IndexMask &mask,
const eAttrDomain selection_domain,
const bke::AttrDomain selection_domain,
const uint32_t random_seed,
const float probability,
IndexMaskMemory &memory)
@ -62,7 +62,7 @@ IndexMask random_mask(const bke::CurvesGeometry &curves,
}
IndexMask random_mask(const bke::CurvesGeometry &curves,
const eAttrDomain selection_domain,
const bke::AttrDomain selection_domain,
const uint32_t random_seed,
const float probability,
IndexMaskMemory &memory)

View File

@ -169,7 +169,7 @@ static bool editable_curves_point_domain_poll(bContext *C)
return false;
}
const Curves *curves_id = static_cast<const Curves *>(CTX_data_active_object(C)->data);
if (curves_id->selection_domain != ATTR_DOMAIN_POINT) {
if (bke::AttrDomain(curves_id->selection_domain) != bke::AttrDomain::Point) {
CTX_wm_operator_poll_msg_set(C, "Only available in point selection mode");
return false;
}
@ -593,7 +593,7 @@ static void snap_curves_to_surface_exec_object(Object &curves_ob,
if (curves_id.surface_uv_map != nullptr) {
const bke::AttributeAccessor surface_attributes = surface_mesh.attributes();
surface_uv_map = *surface_attributes.lookup<float2>(curves_id.surface_uv_map,
ATTR_DOMAIN_CORNER);
bke::AttrDomain::Corner);
}
const OffsetIndices points_by_curve = curves.points_by_curve();
@ -778,14 +778,14 @@ namespace set_selection_domain {
static int curves_set_selection_domain_exec(bContext *C, wmOperator *op)
{
const eAttrDomain domain = eAttrDomain(RNA_enum_get(op->ptr, "domain"));
const bke::AttrDomain domain = bke::AttrDomain(RNA_enum_get(op->ptr, "domain"));
for (Curves *curves_id : get_unique_editable_curves(*C)) {
if (curves_id->selection_domain == domain) {
if (bke::AttrDomain(curves_id->selection_domain) == domain) {
continue;
}
curves_id->selection_domain = domain;
curves_id->selection_domain = char(domain);
CurvesGeometry &curves = curves_id->geometry.wrap();
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
@ -870,7 +870,7 @@ static int select_all_exec(bContext *C, wmOperator *op)
for (Curves *curves_id : unique_curves) {
/* (De)select all the curves. */
select_all(curves_id->geometry.wrap(), eAttrDomain(curves_id->selection_domain), action);
select_all(curves_id->geometry.wrap(), bke::AttrDomain(curves_id->selection_domain), action);
/* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
* attribute for now. */
@ -904,7 +904,7 @@ static int select_random_exec(bContext *C, wmOperator *op)
for (Curves *curves_id : unique_curves) {
CurvesGeometry &curves = curves_id->geometry.wrap();
const eAttrDomain selection_domain = eAttrDomain(curves_id->selection_domain);
const bke::AttrDomain selection_domain = bke::AttrDomain(curves_id->selection_domain);
const int domain_size = curves.attributes().domain_size(selection_domain);
IndexMaskMemory memory;
@ -985,7 +985,7 @@ static int select_ends_exec(bContext *C, wmOperator *op)
const bool was_anything_selected = has_anything_selected(curves);
bke::GSpanAttributeWriter selection = ensure_selection_attribute(
curves, ATTR_DOMAIN_POINT, CD_PROP_BOOL);
curves, bke::AttrDomain::Point, CD_PROP_BOOL);
if (!was_anything_selected) {
fill_selection_true(selection.span);
}
@ -1221,7 +1221,7 @@ static int delete_exec(bContext *C, wmOperator * /*op*/)
{
for (Curves *curves_id : get_unique_editable_curves(*C)) {
bke::CurvesGeometry &curves = curves_id->geometry.wrap();
if (remove_selection(curves, eAttrDomain(curves_id->selection_domain))) {
if (remove_selection(curves, bke::AttrDomain(curves_id->selection_domain))) {
DEG_id_tag_update(&curves_id->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, curves_id);
}
@ -1251,11 +1251,11 @@ static int delete_exec(bContext *C, wmOperator * /*op*/)
for (Curves *curves_id : get_unique_editable_curves(*C)) {
bke::CurvesGeometry &curves = curves_id->geometry.wrap();
IndexMaskMemory memory;
switch (eAttrDomain(curves_id->selection_domain)) {
case ATTR_DOMAIN_POINT:
switch (bke::AttrDomain(curves_id->selection_domain)) {
case bke::AttrDomain::Point:
duplicate_points(curves, retrieve_selected_points(*curves_id, memory));
break;
case ATTR_DOMAIN_CURVE:
case bke::AttrDomain::Curve:
duplicate_curves(curves, retrieve_selected_curves(*curves_id, memory));
break;
default:

View File

@ -32,11 +32,11 @@ IndexMask retrieve_selected_curves(const bke::CurvesGeometry &curves, IndexMaskM
* interested in whether any point in each curve is selected. Retrieve meta data since
* #lookup_or_default from the attribute API doesn't give the domain of the attribute. */
std::optional<bke::AttributeMetaData> meta_data = attributes.lookup_meta_data(".selection");
if (meta_data && meta_data->domain == ATTR_DOMAIN_POINT) {
if (meta_data && meta_data->domain == bke::AttrDomain::Point) {
/* Avoid the interpolation from interpolating the attribute to the
* curve domain by retrieving the point domain values directly. */
const VArray<bool> selection = *attributes.lookup_or_default<bool>(
".selection", ATTR_DOMAIN_POINT, true);
".selection", bke::AttrDomain::Point, true);
if (selection.is_single()) {
return selection.get_internal_single() ? IndexMask(curves_range) : IndexMask();
}
@ -51,7 +51,7 @@ IndexMask retrieve_selected_curves(const bke::CurvesGeometry &curves, IndexMaskM
});
}
const VArray<bool> selection = *attributes.lookup_or_default<bool>(
".selection", ATTR_DOMAIN_CURVE, true);
".selection", bke::AttrDomain::Curve, true);
return IndexMask::from_bools(curves_range, selection, memory);
}
@ -64,7 +64,8 @@ IndexMask retrieve_selected_curves(const Curves &curves_id, IndexMaskMemory &mem
IndexMask retrieve_selected_points(const bke::CurvesGeometry &curves, IndexMaskMemory &memory)
{
return IndexMask::from_bools(
*curves.attributes().lookup_or_default<bool>(".selection", ATTR_DOMAIN_POINT, true), memory);
*curves.attributes().lookup_or_default<bool>(".selection", bke::AttrDomain::Point, true),
memory);
}
IndexMask retrieve_selected_points(const Curves &curves_id, IndexMaskMemory &memory)
@ -74,7 +75,7 @@ IndexMask retrieve_selected_points(const Curves &curves_id, IndexMaskMemory &mem
}
bke::GSpanAttributeWriter ensure_selection_attribute(bke::CurvesGeometry &curves,
const eAttrDomain selection_domain,
const bke::AttrDomain selection_domain,
const eCustomDataType create_type)
{
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
@ -284,7 +285,7 @@ static void invert_selection(GMutableSpan selection, const IndexMask &mask)
void select_all(bke::CurvesGeometry &curves,
const IndexMask &mask,
const eAttrDomain selection_domain,
const bke::AttrDomain selection_domain,
int action)
{
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
@ -311,7 +312,7 @@ void select_all(bke::CurvesGeometry &curves,
selection.finish();
}
void select_all(bke::CurvesGeometry &curves, const eAttrDomain selection_domain, int action)
void select_all(bke::CurvesGeometry &curves, const bke::AttrDomain selection_domain, int action)
{
const IndexRange selection(curves.attributes().domain_size(selection_domain));
select_all(curves, selection, selection_domain, action);
@ -321,7 +322,7 @@ void select_linked(bke::CurvesGeometry &curves, const IndexMask &curves_mask)
{
const OffsetIndices points_by_curve = curves.points_by_curve();
bke::GSpanAttributeWriter selection = ensure_selection_attribute(
curves, ATTR_DOMAIN_POINT, CD_PROP_BOOL);
curves, bke::AttrDomain::Point, CD_PROP_BOOL);
curves_mask.foreach_index(GrainSize(256), [&](const int64_t curve_i) {
GMutableSpan selection_curve = selection.span.slice(points_by_curve[curve_i]);
@ -348,7 +349,7 @@ void select_alternate(bke::CurvesGeometry &curves,
const OffsetIndices points_by_curve = curves.points_by_curve();
bke::GSpanAttributeWriter selection = ensure_selection_attribute(
curves, ATTR_DOMAIN_POINT, CD_PROP_BOOL);
curves, bke::AttrDomain::Point, CD_PROP_BOOL);
const VArray<bool> cyclic = curves.cyclic();
MutableSpan<bool> selection_typed = selection.span.typed<bool>();
@ -394,7 +395,7 @@ void select_adjacent(bke::CurvesGeometry &curves,
{
const OffsetIndices points_by_curve = curves.points_by_curve();
bke::GSpanAttributeWriter selection = ensure_selection_attribute(
curves, ATTR_DOMAIN_POINT, CD_PROP_BOOL);
curves, bke::AttrDomain::Point, CD_PROP_BOOL);
const VArray<bool> cyclic = curves.cyclic();
if (deselect) {
@ -655,12 +656,12 @@ std::optional<FindClosestData> closest_elem_find_screen_space(
const OffsetIndices<int> points_by_curve,
const Span<float3> positions,
const IndexMask &mask,
const eAttrDomain domain,
const bke::AttrDomain domain,
const int2 coord,
const FindClosestData &initial_closest)
{
switch (domain) {
case ATTR_DOMAIN_POINT:
case bke::AttrDomain::Point:
return find_closest_point_to_screen_co(vc.region,
vc.rv3d,
object,
@ -669,7 +670,7 @@ std::optional<FindClosestData> closest_elem_find_screen_space(
float2(coord),
ED_view3d_select_dist_px(),
initial_closest);
case ATTR_DOMAIN_CURVE:
case bke::AttrDomain::Curve:
return find_closest_curve_to_screen_co(vc.region,
vc.rv3d,
object,
@ -689,7 +690,7 @@ bool select_box(const ViewContext &vc,
bke::CurvesGeometry &curves,
const Span<float3> positions,
const IndexMask &mask,
const eAttrDomain selection_domain,
const bke::AttrDomain selection_domain,
const rcti &rect,
const eSelectOp sel_op)
{
@ -705,7 +706,7 @@ bool select_box(const ViewContext &vc,
const float4x4 projection = ED_view3d_ob_project_mat_get(vc.rv3d, vc.obact);
const OffsetIndices points_by_curve = curves.points_by_curve();
if (selection_domain == ATTR_DOMAIN_POINT) {
if (selection_domain == bke::AttrDomain::Point) {
mask.foreach_index(GrainSize(1024), [&](const int point_i) {
const float2 pos_proj = ED_view3d_project_float_v2_m4(
vc.region, positions[point_i], projection);
@ -715,7 +716,7 @@ bool select_box(const ViewContext &vc,
}
});
}
else if (selection_domain == ATTR_DOMAIN_CURVE) {
else if (selection_domain == bke::AttrDomain::Curve) {
mask.foreach_index(GrainSize(512), [&](const int curve_i) {
const IndexRange points = points_by_curve[curve_i];
if (points.size() == 1) {
@ -751,7 +752,7 @@ bool select_lasso(const ViewContext &vc,
bke::CurvesGeometry &curves,
const Span<float3> positions,
const IndexMask &mask,
const eAttrDomain selection_domain,
const bke::AttrDomain selection_domain,
const Span<int2> coords,
const eSelectOp sel_op)
{
@ -771,7 +772,7 @@ bool select_lasso(const ViewContext &vc,
const float4x4 projection = ED_view3d_ob_project_mat_get(vc.rv3d, vc.obact);
const OffsetIndices points_by_curve = curves.points_by_curve();
if (selection_domain == ATTR_DOMAIN_POINT) {
if (selection_domain == bke::AttrDomain::Point) {
mask.foreach_index(GrainSize(1024), [&](const int point_i) {
const float2 pos_proj = ED_view3d_project_float_v2_m4(
vc.region, positions[point_i], projection);
@ -785,7 +786,7 @@ bool select_lasso(const ViewContext &vc,
}
});
}
else if (selection_domain == ATTR_DOMAIN_CURVE) {
else if (selection_domain == bke::AttrDomain::Curve) {
mask.foreach_index(GrainSize(512), [&](const int curve_i) {
const IndexRange points = points_by_curve[curve_i];
if (points.size() == 1) {
@ -834,7 +835,7 @@ bool select_circle(const ViewContext &vc,
bke::CurvesGeometry &curves,
const Span<float3> positions,
const IndexMask &mask,
const eAttrDomain selection_domain,
const bke::AttrDomain selection_domain,
const int2 coord,
const float radius,
const eSelectOp sel_op)
@ -852,7 +853,7 @@ bool select_circle(const ViewContext &vc,
const float4x4 projection = ED_view3d_ob_project_mat_get(vc.rv3d, vc.obact);
const OffsetIndices points_by_curve = curves.points_by_curve();
if (selection_domain == ATTR_DOMAIN_POINT) {
if (selection_domain == bke::AttrDomain::Point) {
mask.foreach_index(GrainSize(1024), [&](const int point_i) {
const float2 pos_proj = ED_view3d_project_float_v2_m4(
vc.region, positions[point_i], projection);
@ -862,7 +863,7 @@ bool select_circle(const ViewContext &vc,
}
});
}
else if (selection_domain == ATTR_DOMAIN_CURVE) {
else if (selection_domain == bke::AttrDomain::Curve) {
mask.foreach_index(GrainSize(512), [&](const int curve_i) {
const IndexRange points = points_by_curve[curve_i];
if (points.size() == 1) {

View File

@ -230,7 +230,7 @@ static int geometry_attribute_add_exec(bContext *C, wmOperator *op)
char name[MAX_NAME];
RNA_string_get(op->ptr, "name", name);
eCustomDataType type = (eCustomDataType)RNA_enum_get(op->ptr, "data_type");
eAttrDomain domain = (eAttrDomain)RNA_enum_get(op->ptr, "domain");
bke::AttrDomain domain = bke::AttrDomain(RNA_enum_get(op->ptr, "domain"));
CustomDataLayer *layer = BKE_id_attribute_new(id, name, type, domain, op->reports);
if (layer == nullptr) {
@ -282,7 +282,7 @@ void GEOMETRY_OT_attribute_add(wmOperatorType *ot)
prop = RNA_def_enum(ot->srna,
"domain",
rna_enum_attribute_domain_items,
ATTR_DOMAIN_POINT,
int(bke::AttrDomain::Point),
"Domain",
"Type of element that attribute is stored on");
RNA_def_enum_funcs(prop, geometry_attribute_domain_itemf);
@ -341,7 +341,7 @@ static int geometry_color_attribute_add_exec(bContext *C, wmOperator *op)
char name[MAX_NAME];
RNA_string_get(op->ptr, "name", name);
eCustomDataType type = (eCustomDataType)RNA_enum_get(op->ptr, "data_type");
eAttrDomain domain = (eAttrDomain)RNA_enum_get(op->ptr, "domain");
bke::AttrDomain domain = bke::AttrDomain(RNA_enum_get(op->ptr, "domain"));
CustomDataLayer *layer = BKE_id_attribute_new(id, name, type, domain, op->reports);
float color[4];
@ -423,7 +423,7 @@ static int geometry_attribute_convert_exec(bContext *C, wmOperator *op)
if (!ED_geometry_attribute_convert(mesh,
name.c_str(),
eCustomDataType(RNA_enum_get(op->ptr, "data_type")),
eAttrDomain(RNA_enum_get(op->ptr, "domain")),
bke::AttrDomain(RNA_enum_get(op->ptr, "domain")),
op->reports))
{
return OPERATOR_CANCELLED;
@ -433,7 +433,7 @@ static int geometry_attribute_convert_exec(bContext *C, wmOperator *op)
case ConvertAttributeMode::VertexGroup: {
Array<float> src_weights(mesh->verts_num);
VArray<float> src_varray = *attributes.lookup_or_default<float>(
name, ATTR_DOMAIN_POINT, 0.0f);
name, bke::AttrDomain::Point, 0.0f);
src_varray.materialize(src_weights);
attributes.remove(name);
@ -500,7 +500,7 @@ void GEOMETRY_OT_color_attribute_add(wmOperatorType *ot)
prop = RNA_def_enum(ot->srna,
"domain",
rna_enum_color_attribute_domain_items,
ATTR_DOMAIN_POINT,
int(bke::AttrDomain::Point),
"Domain",
"Type of element that attribute is stored on");
@ -679,7 +679,7 @@ static int geometry_attribute_convert_invoke(bContext *C,
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "domain");
if (!RNA_property_is_set(op->ptr, prop)) {
RNA_property_enum_set(op->ptr, prop, meta_data.domain);
RNA_property_enum_set(op->ptr, prop, int(meta_data.domain));
}
prop = RNA_struct_find_property(op->ptr, "data_type");
if (!RNA_property_is_set(op->ptr, prop)) {
@ -746,7 +746,7 @@ static int geometry_color_attribute_convert_exec(bContext *C, wmOperator *op)
ED_geometry_attribute_convert(mesh,
name,
eCustomDataType(RNA_enum_get(op->ptr, "data_type")),
eAttrDomain(RNA_enum_get(op->ptr, "domain")),
bke::AttrDomain(RNA_enum_get(op->ptr, "domain")),
op->reports);
return OPERATOR_FINISHED;
}
@ -762,7 +762,7 @@ static int geometry_color_attribute_convert_invoke(bContext *C,
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "domain");
if (!RNA_property_is_set(op->ptr, prop)) {
RNA_property_enum_set(op->ptr, prop, meta_data.domain);
RNA_property_enum_set(op->ptr, prop, int(meta_data.domain));
}
prop = RNA_struct_find_property(op->ptr, "data_type");
if (!RNA_property_is_set(op->ptr, prop)) {
@ -800,7 +800,7 @@ void GEOMETRY_OT_color_attribute_convert(wmOperatorType *ot)
prop = RNA_def_enum(ot->srna,
"domain",
rna_enum_color_attribute_domain_items,
ATTR_DOMAIN_POINT,
int(bke::AttrDomain::Point),
"Domain",
"Type of element that attribute is stored on");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
@ -840,7 +840,7 @@ void GEOMETRY_OT_attribute_convert(wmOperatorType *ot)
prop = RNA_def_enum(ot->srna,
"domain",
rna_enum_attribute_domain_items,
ATTR_DOMAIN_POINT,
int(bke::AttrDomain::Point),
"Domain",
"Which geometry element to move the attribute to");
RNA_def_enum_funcs(prop, geometry_attribute_domain_itemf);
@ -854,7 +854,7 @@ void GEOMETRY_OT_attribute_convert(wmOperatorType *ot)
bool ED_geometry_attribute_convert(Mesh *mesh,
const char *name,
const eCustomDataType dst_type,
const eAttrDomain dst_domain,
const blender::bke::AttrDomain dst_domain,
ReportList *reports)
{
using namespace blender;

View File

@ -1148,19 +1148,19 @@ static bke::CurvesGeometry create_drawing_data(const Span<float3> positions,
curves.transform(matrix);
SpanAttributeWriter<float> point_radii = attributes.lookup_or_add_for_write_only_span<float>(
"radius", ATTR_DOMAIN_POINT);
"radius", AttrDomain::Point);
point_radii.span.copy_from(radii);
SpanAttributeWriter<float> point_opacities = attributes.lookup_or_add_for_write_span<float>(
"opacity", ATTR_DOMAIN_POINT);
"opacity", AttrDomain::Point);
point_opacities.span.copy_from(opacities);
SpanAttributeWriter<bool> stroke_cyclic = attributes.lookup_or_add_for_write_span<bool>(
"cyclic", ATTR_DOMAIN_CURVE);
"cyclic", AttrDomain::Curve);
stroke_cyclic.span.fill(false);
SpanAttributeWriter<int> stroke_materials = attributes.lookup_or_add_for_write_span<int>(
"material_index", ATTR_DOMAIN_CURVE);
"material_index", AttrDomain::Curve);
stroke_materials.span.copy_from(materials);
point_radii.finish();

View File

@ -329,7 +329,7 @@ static int grease_pencil_stroke_smooth_exec(bContext *C, wmOperator *op)
const OffsetIndices points_by_curve = curves.points_by_curve();
const VArray<bool> cyclic = curves.cyclic();
const VArray<bool> point_selection = *curves.attributes().lookup_or_default<bool>(
".selection", ATTR_DOMAIN_POINT, true);
".selection", bke::AttrDomain::Point, true);
if (smooth_position) {
bke::GSpanAttributeWriter positions = attributes.lookup_for_write_span("position");
@ -517,7 +517,7 @@ static int grease_pencil_stroke_simplify_exec(bContext *C, wmOperator *op)
const VArray<bool> cyclic = curves.cyclic();
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
const VArray<bool> selection = *curves.attributes().lookup_or_default<bool>(
".selection", ATTR_DOMAIN_POINT, true);
".selection", bke::AttrDomain::Point, true);
/* Mark all points in the editable curves to be deleted. */
Array<bool> points_to_delete(curves.points_num(), false);
@ -663,11 +663,12 @@ static bke::CurvesGeometry remove_points_and_split(const bke::CurvesGeometry &cu
/* Transfer curve attributes. */
gather_attributes(
src_attributes, ATTR_DOMAIN_CURVE, {}, {"cyclic"}, dst_to_src_curve, dst_attributes);
src_attributes, bke::AttrDomain::Curve, {}, {"cyclic"}, dst_to_src_curve, dst_attributes);
array_utils::copy(dst_cyclic.as_span(), dst_curves.cyclic_for_write());
/* Transfer point attributes. */
gather_attributes(src_attributes, ATTR_DOMAIN_POINT, {}, {}, dst_to_src_point, dst_attributes);
gather_attributes(
src_attributes, bke::AttrDomain::Point, {}, {}, dst_to_src_point, dst_attributes);
dst_curves.remove_attributes_based_on_types();
@ -680,7 +681,8 @@ static int grease_pencil_delete_exec(bContext *C, wmOperator * /*op*/)
Object *object = CTX_data_active_object(C);
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(scene->toolsettings);
const bke::AttrDomain selection_domain = ED_grease_pencil_selection_domain_get(
scene->toolsettings);
bool changed = false;
const Array<MutableDrawingInfo> drawings = retrieve_editable_drawings(*scene, grease_pencil);
@ -693,10 +695,10 @@ static int grease_pencil_delete_exec(bContext *C, wmOperator * /*op*/)
}
bke::CurvesGeometry &curves = info.drawing.strokes_for_write();
if (selection_domain == ATTR_DOMAIN_CURVE) {
if (selection_domain == bke::AttrDomain::Curve) {
curves.remove_curves(elements);
}
else if (selection_domain == ATTR_DOMAIN_POINT) {
else if (selection_domain == bke::AttrDomain::Point) {
curves = remove_points_and_split(curves, elements);
}
info.drawing.tag_topology_changed();
@ -760,7 +762,7 @@ static Array<bool> get_points_to_dissolve(bke::CurvesGeometry &curves,
const DissolveMode mode)
{
const VArray<bool> selection = *curves.attributes().lookup_or_default<bool>(
".selection", ATTR_DOMAIN_POINT, true);
".selection", bke::AttrDomain::Point, true);
Array<bool> points_to_dissolve(curves.points_num(), false);
selection.materialize(mask, points_to_dissolve);
@ -994,7 +996,7 @@ static int grease_pencil_stroke_material_set_exec(bContext *C, wmOperator * /*op
bke::CurvesGeometry &curves = info.drawing.strokes_for_write();
bke::SpanAttributeWriter<int> materials =
curves.attributes_for_write().lookup_or_add_for_write_span<int>("material_index",
ATTR_DOMAIN_CURVE);
bke::AttrDomain::Curve);
index_mask::masked_fill(materials.span, material_index, strokes);
materials.finish();
});
@ -1139,7 +1141,7 @@ static int grease_pencil_set_active_material_exec(bContext *C, wmOperator * /*op
bke::CurvesGeometry &curves = info.drawing.strokes_for_write();
const VArray<int> materials = *curves.attributes().lookup_or_default<int>(
"material_index", ATTR_DOMAIN_CURVE, 0);
"material_index", bke::AttrDomain::Curve, 0);
object->actcol = materials[strokes.first()] + 1;
break;
};
@ -1378,9 +1380,9 @@ static int grease_pencil_caps_set_exec(bContext *C, wmOperator *op)
if (ELEM(mode, CapsMode::ROUND, CapsMode::FLAT)) {
bke::SpanAttributeWriter<int8_t> start_caps =
attributes.lookup_or_add_for_write_span<int8_t>("start_cap", ATTR_DOMAIN_CURVE);
attributes.lookup_or_add_for_write_span<int8_t>("start_cap", bke::AttrDomain::Curve);
bke::SpanAttributeWriter<int8_t> end_caps = attributes.lookup_or_add_for_write_span<int8_t>(
"end_cap", ATTR_DOMAIN_CURVE);
"end_cap", bke::AttrDomain::Curve);
const int8_t flag_set = (mode == CapsMode::ROUND) ? int8_t(GP_STROKE_CAP_TYPE_ROUND) :
int8_t(GP_STROKE_CAP_TYPE_FLAT);
@ -1394,14 +1396,14 @@ static int grease_pencil_caps_set_exec(bContext *C, wmOperator *op)
switch (mode) {
case CapsMode::START: {
bke::SpanAttributeWriter<int8_t> caps = attributes.lookup_or_add_for_write_span<int8_t>(
"start_cap", ATTR_DOMAIN_CURVE);
"start_cap", bke::AttrDomain::Curve);
toggle_caps(caps.span, strokes);
caps.finish();
break;
}
case CapsMode::END: {
bke::SpanAttributeWriter<int8_t> caps = attributes.lookup_or_add_for_write_span<int8_t>(
"end_cap", ATTR_DOMAIN_CURVE);
"end_cap", bke::AttrDomain::Curve);
toggle_caps(caps.span, strokes);
caps.finish();
break;
@ -1536,7 +1538,8 @@ static int grease_pencil_duplicate_exec(bContext *C, wmOperator * /*op*/)
Object *object = CTX_data_active_object(C);
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(scene->toolsettings);
const bke::AttrDomain selection_domain = ED_grease_pencil_selection_domain_get(
scene->toolsettings);
std::atomic<bool> changed = false;
const Array<MutableDrawingInfo> drawings = retrieve_editable_drawings(*scene, grease_pencil);
@ -1549,10 +1552,10 @@ static int grease_pencil_duplicate_exec(bContext *C, wmOperator * /*op*/)
}
bke::CurvesGeometry &curves = info.drawing.strokes_for_write();
if (selection_domain == ATTR_DOMAIN_CURVE) {
if (selection_domain == bke::AttrDomain::Curve) {
curves::duplicate_curves(curves, elements);
}
else if (selection_domain == ATTR_DOMAIN_POINT) {
else if (selection_domain == bke::AttrDomain::Point) {
curves::duplicate_points(curves, elements);
}
info.drawing.tag_topology_changed();

View File

@ -285,7 +285,7 @@ static int grease_pencil_material_lock_unselected_exec(bContext *C, wmOperator *
AttributeAccessor attributes = info.drawing.strokes().attributes();
const VArray<int> material_indices = *attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_CURVE, 0);
"material_index", AttrDomain::Curve, 0);
if (const std::optional<int> single = material_indices.get_if_single()) {
materials_used.add(*single);

View File

@ -34,7 +34,7 @@ static int select_all_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *object = CTX_data_active_object(C);
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(scene->toolsettings);
bke::AttrDomain selection_domain = ED_grease_pencil_selection_domain_get(scene->toolsettings);
const Array<MutableDrawingInfo> drawings = retrieve_editable_drawings(*scene, grease_pencil);
threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
@ -191,7 +191,7 @@ static int select_random_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *object = CTX_data_active_object(C);
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(scene->toolsettings);
bke::AttrDomain selection_domain = ED_grease_pencil_selection_domain_get(scene->toolsettings);
const Array<MutableDrawingInfo> drawings = retrieve_editable_drawings(*scene, grease_pencil);
threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
@ -310,7 +310,7 @@ static int select_ends_exec(bContext *C, wmOperator *op)
const bool was_anything_selected = ed::curves::has_anything_selected(curves,
selectable_points);
bke::GSpanAttributeWriter selection = ed::curves::ensure_selection_attribute(
curves, ATTR_DOMAIN_POINT, CD_PROP_BOOL);
curves, bke::AttrDomain::Point, CD_PROP_BOOL);
if (!was_anything_selected) {
ed::curves::fill_selection_true(selection.span, selectable_points);
}
@ -375,7 +375,7 @@ static int select_set_mode_exec(bContext *C, wmOperator *op)
ts->gpencil_selectmode_edit = mode_new;
/* Convert all drawings of the active GP to the new selection domain. */
const eAttrDomain domain = ED_grease_pencil_selection_domain_get(ts);
const bke::AttrDomain domain = ED_grease_pencil_selection_domain_get(ts);
Object *object = CTX_data_active_object(C);
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
Span<GreasePencilDrawingBase *> drawings = grease_pencil.drawings();
@ -403,7 +403,7 @@ static int select_set_mode_exec(bContext *C, wmOperator *op)
/* When the new selection domain is 'curve', ensure all curves with a point selection
* are selected. */
if (domain == ATTR_DOMAIN_CURVE) {
if (domain == bke::AttrDomain::Curve) {
blender::ed::curves::select_linked(curves);
}
@ -461,20 +461,17 @@ static void GREASE_PENCIL_OT_set_selection_mode(wmOperatorType *ot)
} // namespace blender::ed::greasepencil
eAttrDomain ED_grease_pencil_selection_domain_get(const ToolSettings *tool_settings)
blender::bke::AttrDomain ED_grease_pencil_selection_domain_get(const ToolSettings *tool_settings)
{
switch (tool_settings->gpencil_selectmode_edit) {
case GP_SELECTMODE_POINT:
return ATTR_DOMAIN_POINT;
break;
return blender::bke::AttrDomain::Point;
case GP_SELECTMODE_STROKE:
return ATTR_DOMAIN_CURVE;
break;
return blender::bke::AttrDomain::Curve;
case GP_SELECTMODE_SEGMENT:
return ATTR_DOMAIN_POINT;
break;
return blender::bke::AttrDomain::Point;
}
return ATTR_DOMAIN_POINT;
return blender::bke::AttrDomain::Point;
}
void ED_operatortypes_grease_pencil_select()

View File

@ -353,7 +353,7 @@ IndexMask retrieve_editable_strokes(Object &object,
const IndexRange curves_range = drawing.strokes().curves_range();
const bke::AttributeAccessor attributes = curves.attributes();
const VArray<int> materials = *attributes.lookup<int>("material_index", ATTR_DOMAIN_CURVE);
const VArray<int> materials = *attributes.lookup<int>("material_index", bke::AttrDomain::Curve);
if (!materials) {
/* If the attribute does not exist then the default is the first material. */
if (editable_material_indices.contains(0)) {
@ -384,7 +384,7 @@ IndexMask retrieve_editable_points(Object &object,
const bke::AttributeAccessor attributes = curves.attributes();
/* Propagate the material index to the points. */
const VArray<int> materials = *attributes.lookup<int>("material_index", ATTR_DOMAIN_POINT);
const VArray<int> materials = *attributes.lookup<int>("material_index", bke::AttrDomain::Point);
if (!materials) {
/* If the attribute does not exist then the default is the first material. */
if (editable_material_indices.contains(0)) {
@ -402,13 +402,13 @@ IndexMask retrieve_editable_points(Object &object,
IndexMask retrieve_editable_elements(Object &object,
const bke::greasepencil::Drawing &drawing,
const eAttrDomain selection_domain,
const bke::AttrDomain selection_domain,
IndexMaskMemory &memory)
{
if (selection_domain == ATTR_DOMAIN_CURVE) {
if (selection_domain == bke::AttrDomain::Curve) {
return ed::greasepencil::retrieve_editable_strokes(object, drawing, memory);
}
else if (selection_domain == ATTR_DOMAIN_POINT) {
else if (selection_domain == bke::AttrDomain::Point) {
return ed::greasepencil::retrieve_editable_points(object, drawing, memory);
}
return {};
@ -433,7 +433,7 @@ IndexMask retrieve_visible_strokes(Object &object,
/* Get all the strokes that have their material visible. */
const VArray<int> materials = *attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_CURVE, -1);
"material_index", bke::AttrDomain::Curve, -1);
return IndexMask::from_predicate(
curves_range, GrainSize(4096), memory, [&](const int64_t curve_i) {
const int material_index = materials[curve_i];
@ -483,13 +483,13 @@ IndexMask retrieve_editable_and_selected_points(Object &object,
IndexMask retrieve_editable_and_selected_elements(Object &object,
const bke::greasepencil::Drawing &drawing,
const eAttrDomain selection_domain,
const bke::AttrDomain selection_domain,
IndexMaskMemory &memory)
{
if (selection_domain == ATTR_DOMAIN_CURVE) {
if (selection_domain == bke::AttrDomain::Curve) {
return ed::greasepencil::retrieve_editable_and_selected_strokes(object, drawing, memory);
}
else if (selection_domain == ATTR_DOMAIN_POINT) {
else if (selection_domain == bke::AttrDomain::Point) {
return ed::greasepencil::retrieve_editable_and_selected_points(object, drawing, memory);
}
return {};

View File

@ -112,13 +112,13 @@ IndexMask end_points(const bke::CurvesGeometry &curves,
* If set to 0.0, nothing will be in the mask, if set to 1.0 everything will be in the mask.
*/
IndexMask random_mask(const bke::CurvesGeometry &curves,
eAttrDomain selection_domain,
bke::AttrDomain selection_domain,
uint32_t random_seed,
float probability,
IndexMaskMemory &memory);
IndexMask random_mask(const bke::CurvesGeometry &curves,
const IndexMask &mask,
eAttrDomain selection_domain,
bke::AttrDomain selection_domain,
uint32_t random_seed,
float probability,
IndexMaskMemory &memory);
@ -174,7 +174,7 @@ IndexMask retrieve_selected_points(const Curves &curves_id, IndexMaskMemory &mem
* If the ".selection" attribute doesn't exist, create it with the requested type (bool or float).
*/
bke::GSpanAttributeWriter ensure_selection_attribute(bke::CurvesGeometry &curves,
eAttrDomain selection_domain,
bke::AttrDomain selection_domain,
eCustomDataType create_type);
/** Apply a change to a single curve or point. Avoid using this when affecting many elements. */
@ -188,10 +188,10 @@ void apply_selection_operation_at_index(GMutableSpan selection, int index, eSele
* \param action: One of SEL_TOGGLE, SEL_SELECT, SEL_DESELECT, or SEL_INVERT. See
* "ED_select_utils.hh".
*/
void select_all(bke::CurvesGeometry &curves, eAttrDomain selection_domain, int action);
void select_all(bke::CurvesGeometry &curves, bke::AttrDomain selection_domain, int action);
void select_all(bke::CurvesGeometry &curves,
const IndexMask &mask,
eAttrDomain selection_domain,
bke::AttrDomain selection_domain,
int action);
/**
@ -238,7 +238,7 @@ std::optional<FindClosestData> closest_elem_find_screen_space(const ViewContext
OffsetIndices<int> points_by_curve,
Span<float3> deformed_positions,
const IndexMask &mask,
eAttrDomain domain,
bke::AttrDomain domain,
int2 coord,
const FindClosestData &initial);
@ -249,7 +249,7 @@ bool select_box(const ViewContext &vc,
bke::CurvesGeometry &curves,
Span<float3> deformed_positions,
const IndexMask &mask,
eAttrDomain selection_domain,
bke::AttrDomain selection_domain,
const rcti &rect,
eSelectOp sel_op);
@ -260,7 +260,7 @@ bool select_lasso(const ViewContext &vc,
bke::CurvesGeometry &curves,
Span<float3> deformed_positions,
const IndexMask &mask,
eAttrDomain selection_domain,
bke::AttrDomain selection_domain,
Span<int2> coords,
eSelectOp sel_op);
@ -271,7 +271,7 @@ bool select_circle(const ViewContext &vc,
bke::CurvesGeometry &curves,
Span<float3> deformed_positions,
const IndexMask &mask,
eAttrDomain selection_domain,
bke::AttrDomain selection_domain,
int2 coord,
float radius,
eSelectOp sel_op);
@ -285,7 +285,7 @@ bool select_circle(const ViewContext &vc,
* Remove (dissolve) selected curves or points based on the ".selection" attribute.
* \returns true if any point or curve was removed.
*/
bool remove_selection(bke::CurvesGeometry &curves, eAttrDomain selection_domain);
bool remove_selection(bke::CurvesGeometry &curves, bke::AttrDomain selection_domain);
void duplicate_points(bke::CurvesGeometry &curves, const IndexMask &mask);
void duplicate_curves(bke::CurvesGeometry &curves, const IndexMask &mask);

View File

@ -56,7 +56,7 @@ void ED_operatortypes_geometry();
bool ED_geometry_attribute_convert(Mesh *mesh,
const char *name,
eCustomDataType dst_type,
eAttrDomain dst_domain,
blender::bke::AttrDomain dst_domain,
ReportList *reports);
namespace blender::ed::geometry {

View File

@ -8,7 +8,7 @@
#pragma once
#include "BKE_attribute.h"
#include "BKE_attribute.hh"
#include "BKE_grease_pencil.hh"
#include "BLI_generic_span.hh"
@ -48,7 +48,7 @@ void ED_keymap_grease_pencil(wmKeyConfig *keyconf);
/**
* Get the selection mode for Grease Pencil selection operators: point, stroke, segment.
*/
eAttrDomain ED_grease_pencil_selection_domain_get(const ToolSettings *tool_settings);
blender::bke::AttrDomain ED_grease_pencil_selection_domain_get(const ToolSettings *tool_settings);
/** \} */
@ -178,7 +178,7 @@ IndexMask retrieve_editable_points(Object &object,
IndexMaskMemory &memory);
IndexMask retrieve_editable_elements(Object &object,
const bke::greasepencil::Drawing &drawing,
eAttrDomain selection_domain,
bke::AttrDomain selection_domain,
IndexMaskMemory &memory);
IndexMask retrieve_visible_strokes(Object &grease_pencil_object,
@ -193,7 +193,7 @@ IndexMask retrieve_editable_and_selected_points(Object &object,
IndexMaskMemory &memory);
IndexMask retrieve_editable_and_selected_elements(Object &object,
const bke::greasepencil::Drawing &drawing,
eAttrDomain selection_domain,
bke::AttrDomain selection_domain,
IndexMaskMemory &memory);
void create_blank(Main &bmain, Object &object, int frame_number);

View File

@ -34,10 +34,10 @@ static StringRef attribute_data_type_string(const eCustomDataType type)
return StringRef(IFACE_(name));
}
static StringRef attribute_domain_string(const eAttrDomain domain)
static StringRef attribute_domain_string(const bke::AttrDomain domain)
{
const char *name = nullptr;
RNA_enum_name_from_value(rna_enum_attribute_domain_items, domain, &name);
RNA_enum_name_from_value(rna_enum_attribute_domain_items, int(domain), &name);
return StringRef(IFACE_(name));
}

View File

@ -87,18 +87,19 @@ void paintface_flush_flags(bContext *C,
/* Update the COW copy of the mesh. */
if (flush_hidden) {
const VArray<bool> hide_poly_me = *attributes_me.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", bke::AttrDomain::Face, false);
bke::SpanAttributeWriter<bool> hide_poly_orig =
attributes_orig.lookup_or_add_for_write_only_span<bool>(".hide_poly", ATTR_DOMAIN_FACE);
attributes_orig.lookup_or_add_for_write_only_span<bool>(".hide_poly",
bke::AttrDomain::Face);
hide_poly_me.materialize(hide_poly_orig.span);
hide_poly_orig.finish();
}
if (flush_selection) {
const VArray<bool> select_poly_me = *attributes_me.lookup_or_default<bool>(
".select_poly", ATTR_DOMAIN_FACE, false);
".select_poly", bke::AttrDomain::Face, false);
bke::SpanAttributeWriter<bool> select_poly_orig =
attributes_orig.lookup_or_add_for_write_only_span<bool>(".select_poly",
ATTR_DOMAIN_FACE);
bke::AttrDomain::Face);
select_poly_me.materialize(select_poly_orig.span);
select_poly_orig.finish();
}
@ -107,10 +108,10 @@ void paintface_flush_flags(bContext *C,
if ((index_array = (const int *)CustomData_get_layer(&me_eval->face_data, CD_ORIGINDEX))) {
if (flush_hidden) {
const VArray<bool> hide_poly_orig = *attributes_orig.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", bke::AttrDomain::Face, false);
bke::SpanAttributeWriter<bool> hide_poly_eval =
attributes_eval.lookup_or_add_for_write_only_span<bool>(".hide_poly",
ATTR_DOMAIN_FACE);
bke::AttrDomain::Face);
for (const int i : IndexRange(me_eval->faces_num)) {
const int orig_face_index = index_array[i];
if (orig_face_index != ORIGINDEX_NONE) {
@ -121,10 +122,10 @@ void paintface_flush_flags(bContext *C,
}
if (flush_selection) {
const VArray<bool> select_poly_orig = *attributes_orig.lookup_or_default<bool>(
".select_poly", ATTR_DOMAIN_FACE, false);
".select_poly", bke::AttrDomain::Face, false);
bke::SpanAttributeWriter<bool> select_poly_eval =
attributes_eval.lookup_or_add_for_write_only_span<bool>(".select_poly",
ATTR_DOMAIN_FACE);
bke::AttrDomain::Face);
for (const int i : IndexRange(me_eval->faces_num)) {
const int orig_face_index = index_array[i];
if (orig_face_index != ORIGINDEX_NONE) {
@ -165,9 +166,9 @@ void paintface_hide(bContext *C, Object *ob, const bool unselected)
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<bool> hide_poly = attributes.lookup_or_add_for_write_span<bool>(
".hide_poly", ATTR_DOMAIN_FACE);
".hide_poly", bke::AttrDomain::Face);
bke::SpanAttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
".select_poly", bke::AttrDomain::Face);
for (int i = 0; i < mesh->faces_num; i++) {
if (!hide_poly.span[i]) {
@ -201,9 +202,9 @@ void paintface_reveal(bContext *C, Object *ob, const bool select)
if (select) {
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", bke::AttrDomain::Face, false);
bke::SpanAttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
".select_poly", bke::AttrDomain::Face);
for (const int i : hide_poly.index_range()) {
if (hide_poly[i]) {
select_poly.span[i] = true;
@ -235,9 +236,9 @@ static void build_poly_connections(blender::AtomicDisjointSet &islands,
const bke::AttributeAccessor attributes = mesh.attributes();
const VArray<bool> uv_seams = *attributes.lookup_or_default<bool>(
".uv_seam", ATTR_DOMAIN_EDGE, false);
".uv_seam", bke::AttrDomain::Edge, false);
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", bke::AttrDomain::Face, false);
/* Faces are connected if they share edges. By connecting all edges of a loop (as long as they
* are not a seam) we can find connected faces. */
@ -284,9 +285,9 @@ static void paintface_select_linked_faces(Mesh &mesh,
bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
const VArray<bool> uv_seams = *attributes.lookup_or_default<bool>(
".uv_seam", ATTR_DOMAIN_EDGE, false);
".uv_seam", bke::AttrDomain::Edge, false);
bke::SpanAttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
".select_poly", bke::AttrDomain::Face);
Set<int> selected_roots;
for (const int i : face_indices) {
@ -324,7 +325,7 @@ void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const b
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
".select_poly", bke::AttrDomain::Face);
Vector<int> indices;
if (mval) {
@ -493,7 +494,7 @@ void paintface_select_loop(bContext *C, Object *ob, const int mval[2], const boo
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", bke::AttrDomain::Face, false);
const Span<int> faces_to_closest_edge = edge_to_face_map[closest_edge_index];
const bool traced_full_loop = follow_face_loop(faces_to_closest_edge[0],
@ -516,7 +517,7 @@ void paintface_select_loop(bContext *C, Object *ob, const int mval[2], const boo
}
bke::SpanAttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
".select_poly", bke::AttrDomain::Face);
/* Toggling behavior. When one of the faces of the picked edge is already selected,
* it deselects the loop instead. */
@ -560,11 +561,11 @@ void paintface_select_more(Mesh *mesh, const bool face_step)
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
".select_poly", bke::AttrDomain::Face);
bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
".select_vert", bke::AttrDomain::Point);
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", bke::AttrDomain::Face, false);
const OffsetIndices faces = mesh->faces();
const Span<int> corner_edges = mesh->corner_edges();
@ -614,9 +615,9 @@ void paintface_select_less(Mesh *mesh, const bool face_step)
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
".select_poly", bke::AttrDomain::Face);
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", bke::AttrDomain::Face, false);
const OffsetIndices faces = mesh->faces();
const Span<int> corner_verts = mesh->corner_verts();
@ -663,9 +664,9 @@ bool paintface_deselect_all_visible(bContext *C, Object *ob, int action, bool fl
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", bke::AttrDomain::Face, false);
bke::SpanAttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
".select_poly", bke::AttrDomain::Face);
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
@ -730,9 +731,9 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3])
const Span<int> corner_verts = mesh->corner_verts();
bke::AttributeAccessor attributes = mesh->attributes();
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", bke::AttrDomain::Face, false);
const VArray<bool> select_poly = *attributes.lookup_or_default<bool>(
".select_poly", ATTR_DOMAIN_FACE, false);
".select_poly", bke::AttrDomain::Face, false);
for (int i = 0; i < mesh->faces_num; i++) {
if (hide_poly[i] || !select_poly[i]) {
@ -766,9 +767,9 @@ bool paintface_mouse_select(bContext *C,
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", bke::AttrDomain::Face, false);
bke::AttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write<bool>(
".select_poly", ATTR_DOMAIN_FACE);
".select_poly", bke::AttrDomain::Face);
if (ED_mesh_pick_face(C, ob, mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) {
if (index < mesh->faces_num) {
@ -840,9 +841,10 @@ void paintvert_flush_flags(Object *ob)
const int *orig_indices = (const int *)CustomData_get_layer(&me_eval->vert_data, CD_ORIGINDEX);
const VArray<bool> hide_vert_orig = *attributes_orig.lookup_or_default<bool>(
".hide_vert", ATTR_DOMAIN_POINT, false);
".hide_vert", bke::AttrDomain::Point, false);
bke::SpanAttributeWriter<bool> hide_vert_eval =
attributes_eval.lookup_or_add_for_write_only_span<bool>(".hide_vert", ATTR_DOMAIN_POINT);
attributes_eval.lookup_or_add_for_write_only_span<bool>(".hide_vert",
bke::AttrDomain::Point);
if (orig_indices) {
for (const int i : hide_vert_eval.span.index_range()) {
if (orig_indices[i] != ORIGINDEX_NONE) {
@ -856,9 +858,10 @@ void paintvert_flush_flags(Object *ob)
hide_vert_eval.finish();
const VArray<bool> select_vert_orig = *attributes_orig.lookup_or_default<bool>(
".select_vert", ATTR_DOMAIN_POINT, false);
".select_vert", bke::AttrDomain::Point, false);
bke::SpanAttributeWriter<bool> select_vert_eval =
attributes_eval.lookup_or_add_for_write_only_span<bool>(".select_vert", ATTR_DOMAIN_POINT);
attributes_eval.lookup_or_add_for_write_only_span<bool>(".select_vert",
bke::AttrDomain::Point);
if (orig_indices) {
for (const int i : select_vert_eval.span.index_range()) {
if (orig_indices[i] != ORIGINDEX_NONE) {
@ -900,7 +903,7 @@ static void paintvert_select_linked_vertices(bContext *C,
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
".select_vert", bke::AttrDomain::Point);
Set<int> selected_roots;
@ -940,6 +943,7 @@ void paintvert_select_linked_pick(bContext *C,
void paintvert_select_linked(bContext *C, Object *ob)
{
using namespace blender;
Mesh *mesh = BKE_mesh_from_object(ob);
if (mesh == nullptr || mesh->faces_num == 0) {
return;
@ -947,7 +951,7 @@ void paintvert_select_linked(bContext *C, Object *ob)
blender::bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
blender::bke::SpanAttributeWriter<bool> select_vert =
attributes.lookup_or_add_for_write_span<bool>(".select_vert", ATTR_DOMAIN_POINT);
attributes.lookup_or_add_for_write_span<bool>(".select_vert", bke::AttrDomain::Point);
blender::Vector<int> indices;
for (const int i : select_vert.span.index_range()) {
@ -966,11 +970,11 @@ void paintvert_select_more(Mesh *mesh, const bool face_step)
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
".select_vert", bke::AttrDomain::Point);
const VArray<bool> hide_edge = *attributes.lookup_or_default<bool>(
".hide_edge", ATTR_DOMAIN_EDGE, false);
".hide_edge", bke::AttrDomain::Edge, false);
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", bke::AttrDomain::Face, false);
const OffsetIndices faces = mesh->faces();
const Span<int> corner_edges = mesh->corner_edges();
@ -1024,11 +1028,11 @@ void paintvert_select_less(Mesh *mesh, const bool face_step)
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
".select_vert", bke::AttrDomain::Point);
const VArray<bool> hide_edge = *attributes.lookup_or_default<bool>(
".hide_edge", ATTR_DOMAIN_EDGE, false);
".hide_edge", bke::AttrDomain::Edge, false);
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
".hide_poly", bke::AttrDomain::Face, false);
const OffsetIndices faces = mesh->faces();
const Span<int> corner_edges = mesh->corner_edges();
@ -1089,9 +1093,9 @@ bool paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
const VArray<bool> hide_vert = *attributes.lookup_or_default<bool>(
".hide_vert", ATTR_DOMAIN_POINT, false);
".hide_vert", bke::AttrDomain::Point, false);
bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
".select_vert", bke::AttrDomain::Point);
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
@ -1165,9 +1169,9 @@ void paintvert_select_ungrouped(Object *ob, bool extend, bool flush_flags)
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
const VArray<bool> hide_vert = *attributes.lookup_or_default<bool>(
".hide_vert", ATTR_DOMAIN_POINT, false);
".hide_vert", bke::AttrDomain::Point, false);
bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
".select_vert", bke::AttrDomain::Point);
for (const int i : select_vert.span.index_range()) {
if (!hide_vert[i]) {
@ -1195,9 +1199,9 @@ void paintvert_hide(bContext *C, Object *ob, const bool unselected)
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<bool> hide_vert = attributes.lookup_or_add_for_write_span<bool>(
".hide_vert", ATTR_DOMAIN_POINT);
".hide_vert", bke::AttrDomain::Point);
bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
".select_vert", bke::AttrDomain::Point);
for (const int i : hide_vert.span.index_range()) {
if (!hide_vert.span[i]) {
@ -1229,9 +1233,9 @@ void paintvert_reveal(bContext *C, Object *ob, const bool select)
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
const VArray<bool> hide_vert = *attributes.lookup_or_default<bool>(
".hide_vert", ATTR_DOMAIN_POINT, false);
".hide_vert", bke::AttrDomain::Point, false);
bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
".select_vert", bke::AttrDomain::Point);
for (const int i : select_vert.span.index_range()) {
if (hide_vert[i]) {

View File

@ -10,7 +10,7 @@
#include "BLI_generic_pointer.hh"
#include "BLI_math_quaternion.hh"
#include "BKE_attribute.h"
#include "BKE_attribute.hh"
#include "BKE_context.hh"
#include "BKE_editmesh.hh"
#include "BKE_layer.h"
@ -52,16 +52,16 @@
namespace blender::ed::mesh {
static char domain_to_htype(const eAttrDomain domain)
static char domain_to_htype(const bke::AttrDomain domain)
{
switch (domain) {
case ATTR_DOMAIN_POINT:
case bke::AttrDomain::Point:
return BM_VERT;
case ATTR_DOMAIN_EDGE:
case bke::AttrDomain::Edge:
return BM_EDGE;
case ATTR_DOMAIN_FACE:
case bke::AttrDomain::Face:
return BM_FACE;
case ATTR_DOMAIN_CORNER:
case bke::AttrDomain::Corner:
return BM_LOOP;
default:
BLI_assert_unreachable();
@ -188,19 +188,19 @@ static int mesh_set_attribute_exec(bContext *C, wmOperator *op)
conversions.convert_to_uninitialized(type, dst_type, value.get(), dst_buffer);
const GPointer dst_value(dst_type, dst_buffer);
switch (BKE_id_attribute_domain(&mesh->id, layer)) {
case ATTR_DOMAIN_POINT:
case bke::AttrDomain::Point:
bmesh_vert_edge_face_layer_selected_values_set(
*bm, BM_VERTS_OF_MESH, dst_value, layer->offset);
break;
case ATTR_DOMAIN_EDGE:
case bke::AttrDomain::Edge:
bmesh_vert_edge_face_layer_selected_values_set(
*bm, BM_EDGES_OF_MESH, dst_value, layer->offset);
break;
case ATTR_DOMAIN_FACE:
case bke::AttrDomain::Face:
bmesh_vert_edge_face_layer_selected_values_set(
*bm, BM_FACES_OF_MESH, dst_value, layer->offset);
break;
case ATTR_DOMAIN_CORNER:
case bke::AttrDomain::Corner:
bmesh_loop_layer_selected_values_set(*em, dst_value, layer->offset);
break;
default:
@ -228,7 +228,7 @@ static int mesh_set_attribute_invoke(bContext *C, wmOperator *op, const wmEvent
const CustomDataLayer *layer = BKE_id_attributes_active_get(&mesh->id);
const eCustomDataType data_type = eCustomDataType(layer->type);
const eAttrDomain domain = BKE_id_attribute_domain(&mesh->id, layer);
const bke::AttrDomain domain = BKE_id_attribute_domain(&mesh->id, layer);
const BMElem *active_elem = BM_mesh_active_elem_get(bm);
if (!active_elem) {
return WM_operator_props_popup(C, op, event);

View File

@ -24,7 +24,7 @@
#include "BLI_utildefines_stack.h"
#include "BLI_vector.hh"
#include "BKE_attribute.h"
#include "BKE_attribute.hh"
#include "BKE_context.hh"
#include "BKE_customdata.hh"
#include "BKE_deform.h"
@ -5358,6 +5358,7 @@ void MESH_OT_loop_to_region(wmOperatorType *ot)
static bool edbm_select_by_attribute_poll(bContext *C)
{
using namespace blender;
if (!ED_operator_editmesh(C)) {
return false;
}
@ -5372,7 +5373,7 @@ static bool edbm_select_by_attribute_poll(bContext *C)
CTX_wm_operator_poll_msg_set(C, "The active attribute must have a boolean type");
return false;
}
if (BKE_id_attribute_domain(&mesh->id, layer) == ATTR_DOMAIN_CORNER) {
if (BKE_id_attribute_domain(&mesh->id, layer) == bke::AttrDomain::Corner) {
CTX_wm_operator_poll_msg_set(
C, "The active attribute must be on the vertex, edge, or face domain");
return false;
@ -5380,14 +5381,15 @@ static bool edbm_select_by_attribute_poll(bContext *C)
return true;
}
static std::optional<BMIterType> domain_to_iter_type(const eAttrDomain domain)
static std::optional<BMIterType> domain_to_iter_type(const blender::bke::AttrDomain domain)
{
using namespace blender;
switch (domain) {
case ATTR_DOMAIN_POINT:
case bke::AttrDomain::Point:
return BM_VERTS_OF_MESH;
case ATTR_DOMAIN_EDGE:
case bke::AttrDomain::Edge:
return BM_EDGES_OF_MESH;
case ATTR_DOMAIN_FACE:
case bke::AttrDomain::Face:
return BM_FACES_OF_MESH;
default:
return std::nullopt;
@ -5396,6 +5398,7 @@ static std::optional<BMIterType> domain_to_iter_type(const eAttrDomain domain)
static int edbm_select_by_attribute_exec(bContext *C, wmOperator * /*op*/)
{
using namespace blender;
const Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
@ -5414,7 +5417,7 @@ static int edbm_select_by_attribute_exec(bContext *C, wmOperator * /*op*/)
if (layer->type != CD_PROP_BOOL) {
continue;
}
if (BKE_id_attribute_domain(&mesh->id, layer) == ATTR_DOMAIN_CORNER) {
if (BKE_id_attribute_domain(&mesh->id, layer) == bke::AttrDomain::Corner) {
continue;
}
const std::optional<BMIterType> iter_type = domain_to_iter_type(

Some files were not shown because too many files have changed in this diff Show More