diff --git a/intern/cycles/blender/curves.cpp b/intern/cycles/blender/curves.cpp index 132178297a9..18f9160bf2e 100644 --- a/intern/cycles/blender/curves.cpp +++ b/intern/cycles/blender/curves.cpp @@ -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(id, - ATTR_DOMAIN_POINT); + const blender::VArraySpan b_attr = *b_attributes.lookup( + 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(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("radius", - ATTR_DOMAIN_POINT); + const blender::VArraySpan b_radius = *b_curves.attributes().lookup( + "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 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("radius", - ATTR_DOMAIN_POINT); + const blender::VArraySpan b_radius = *b_curves.attributes().lookup( + "radius", blender::bke::AttrDomain::Point); for (const int i : points_by_curve.index_range()) { const blender::IndexRange points = points_by_curve[i]; diff --git a/intern/cycles/blender/mesh.cpp b/intern/cycles/blender/mesh.cpp index ba29b31cd20..307fc6549f9 100644 --- a/intern/cycles/blender/mesh.cpp +++ b/intern/cycles/blender/mesh.cpp @@ -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( - 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(); 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 get_blender_uv_names(const ::Mesh &b_mesh) set 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( - 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( - 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("material_index", - ATTR_DOMAIN_FACE); - const blender::VArraySpan sharp_faces = *b_attributes.lookup("sharp_face", - ATTR_DOMAIN_FACE); + const blender::VArraySpan material_indices = *b_attributes.lookup( + "material_index", blender::bke::AttrDomain::Face); + const blender::VArraySpan sharp_faces = *b_attributes.lookup( + "sharp_face", blender::bke::AttrDomain::Face); blender::Span 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("crease_edge", - ATTR_DOMAIN_EDGE); + const blender::VArraySpan creases = *b_mesh.attributes().lookup( + "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("crease_vert", - ATTR_DOMAIN_POINT); + const blender::VArraySpan vert_creases = *b_mesh.attributes().lookup( + "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) { diff --git a/intern/cycles/blender/pointcloud.cpp b/intern/cycles/blender/pointcloud.cpp index e0b5fd874ad..f98a8e0c23d 100644 --- a/intern/cycles/blender/pointcloud.cpp +++ b/intern/cycles/blender/pointcloud.cpp @@ -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 b_positions = b_pointcloud.positions(); - const blender::VArraySpan b_radius = *b_pointcloud.attributes().lookup("radius", - ATTR_DOMAIN_POINT); + const blender::VArraySpan b_radius = *b_pointcloud.attributes().lookup( + "radius", blender::bke::AttrDomain::Point); pointcloud->resize(b_positions.size()); @@ -158,8 +158,8 @@ static void export_pointcloud_motion(PointCloud *pointcloud, const array &pointcloud_points = pointcloud->get_points(); const blender::Span b_positions = b_pointcloud.positions(); - const blender::VArraySpan b_radius = *b_pointcloud.attributes().lookup("radius", - ATTR_DOMAIN_POINT); + const blender::VArraySpan b_radius = *b_pointcloud.attributes().lookup( + "radius", blender::bke::AttrDomain::Point); for (int i = 0; i < std::min(num_points, b_positions.size()); i++) { const float3 P = make_float3(b_positions[i][0], b_positions[i][1], b_positions[i][2]); diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h index b191e39df88..7bf93a09dd8 100644 --- a/source/blender/blenkernel/BKE_attribute.h +++ b/source/blender/blenkernel/BKE_attribute.h @@ -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 diff --git a/source/blender/blenkernel/BKE_attribute.hh b/source/blender/blenkernel/BKE_attribute.hh index dcd1918d7e8..85f85dc7db7 100644 --- a/source/blender/blenkernel/BKE_attribute.hh +++ b/source/blender/blenkernel/BKE_attribute.hh @@ -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 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 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 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 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 tag_modified_fn; operator bool() const @@ -351,7 +371,7 @@ struct GAttributeWriter { */ struct GSpanAttributeWriter { GMutableVArraySpan span; - eAttrDomain domain; + AttrDomain domain; std::function tag_modified_fn; GSpanAttributeWriter() = default; @@ -391,14 +411,14 @@ struct AttributeAccessorFunctions { bool (*contains)(const void *owner, const AttributeIDRef &attribute_id); std::optional (*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 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 domain, + const std::optional domain, const std::optional 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 AttributeReader lookup(const AttributeIDRef &attribute_id, - const std::optional domain = std::nullopt) const + const std::optional domain = std::nullopt) const { const CPPType &cpp_type = CPPType::get(); 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 AttributeReader lookup_or_default(const AttributeIDRef &attribute_id, - const eAttrDomain domain, + const AttrDomain domain, const T &default_value) const { if (AttributeReader varray = this->lookup(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 VArray adapt_domain(const VArray &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(); } @@ -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 bool add(const AttributeIDRef &attribute_id, - const eAttrDomain domain, + const AttrDomain domain, const AttributeInit &initializer) { const CPPType &cpp_type = CPPType::get(); @@ -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 AttributeWriter 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(); @@ -723,7 +743,7 @@ class MutableAttributeAccessor : public AttributeAccessor { template SpanAttributeWriter lookup_or_add_for_write_span( const AttributeIDRef &attribute_id, - const eAttrDomain domain, + const AttrDomain domain, const AttributeInit &initializer = AttributeInitDefaultValue()) { AttributeWriter attribute = this->lookup_or_add_for_write( @@ -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 SpanAttributeWriter lookup_or_add_for_write_only_span(const AttributeIDRef &attribute_id, - const eAttrDomain domain) + const AttrDomain domain) { AttributeWriter attribute = this->lookup_or_add_for_write( attribute_id, domain, AttributeInitConstruct()); @@ -793,7 +813,7 @@ struct AttributeTransferData { Vector retrieve_attributes_for_transfer( const AttributeAccessor src_attributes, MutableAttributeAccessor dst_attributes, - eAttrDomainMask domain_mask, + AttrDomainMask domain_mask, const AnonymousAttributePropagationInfo &propagation_info, const Set &skip = {}); @@ -805,7 +825,7 @@ eCustomDataType attribute_data_type_highest_complexity(Span 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 domains); +AttrDomain attribute_domain_highest_priority(Span 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 &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 &skip, Span 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 &skip, OffsetIndices 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 &skip, OffsetIndices 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 &skip, MutableAttributeAccessor dst_attributes); void copy_attributes_group_to_group(AttributeAccessor src_attributes, - eAttrDomain domain, + AttrDomain domain, const AnonymousAttributePropagationInfo &propagation_info, const Set &skip, OffsetIndices 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 &skip, IndexRange range); diff --git a/source/blender/blenkernel/BKE_bake_items_socket.hh b/source/blender/blenkernel/BKE_bake_items_socket.hh index 07a62f459a3..c01419e3287 100644 --- a/source/blender/blenkernel/BKE_bake_items_socket.hh +++ b/source/blender/blenkernel/BKE_bake_items_socket.hh @@ -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 domains; + Vector 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. diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh index ac2137c9f72..5a7b6b94234 100644 --- a/source/blender/blenkernel/BKE_curves.hh +++ b/source/blender/blenkernel/BKE_curves.hh @@ -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 - VArray adapt_domain(const VArray &varray, eAttrDomain from, eAttrDomain to) const + VArray adapt_domain(const VArray &varray, AttrDomain from, AttrDomain to) const { return this->adapt_domain(GVArray(varray), from, to).typed(); } diff --git a/source/blender/blenkernel/BKE_geometry_fields.hh b/source/blender/blenkernel/BKE_geometry_fields.hh index 6e0b8b8879f..094e5bab524 100644 --- a/source/blender/blenkernel/BKE_geometry_fields.hh +++ b/source/blender/blenkernel/BKE_geometry_fields.hh @@ -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 preferred_domain(const GeometryComponent &component) const; + virtual std::optional 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 preferred_domain(const Mesh &mesh) const; + virtual std::optional 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 preferred_domain(const CurvesGeometry &curves) const; + virtual std::optional 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 preferred_domain(const GeometryComponent &component) const override; + std::optional 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 preferred_domain(const GeometryComponent &component) const override; + std::optional 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 curve_normals_varray(const CurvesGeometry &curves, eAttrDomain domain); +VArray curve_normals_varray(const CurvesGeometry &curves, AttrDomain domain); -VArray mesh_normals_varray(const Mesh &mesh, const IndexMask &mask, eAttrDomain domain); +VArray 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 preferred_domain(const GeometryComponent &component) const override; + std::optional 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 preferred_domain(const bke::CurvesGeometry &curves) const final; + std::optional 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 &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 try_detect_field_domain(const GeometryComponent &component, +std::optional try_detect_field_domain(const GeometryComponent &component, const fn::GField &field); } // namespace blender::bke diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index 814fd302a71..c881408e60a 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -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 diff --git a/source/blender/blenkernel/BKE_mesh_sample.hh b/source/blender/blenkernel/BKE_mesh_sample.hh index 788c35ce975..c90bcb4ecae 100644 --- a/source/blender/blenkernel/BKE_mesh_sample.hh +++ b/source/blender/blenkernel/BKE_mesh_sample.hh @@ -178,7 +178,7 @@ class BaryWeightSampleFn : public mf::MultiFunction { std::optional source_context_; std::unique_ptr source_evaluator_; const GVArray *source_data_; - eAttrDomain domain_; + AttrDomain domain_; public: BaryWeightSampleFn(GeometrySet geometry, fn::GField src_field); diff --git a/source/blender/blenkernel/BKE_paint.hh b/source/blender/blenkernel/BKE_paint.hh index c0f210ef5f7..84e1a22c864 100644 --- a/source/blender/blenkernel/BKE_paint.hh +++ b/source/blender/blenkernel/BKE_paint.hh @@ -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); diff --git a/source/blender/blenkernel/BKE_pbvh_api.hh b/source/blender/blenkernel/BKE_pbvh_api.hh index 0ff34f2b260..4092445609b 100644 --- a/source/blender/blenkernel/BKE_pbvh_api.hh +++ b/source/blender/blenkernel/BKE_pbvh_api.hh @@ -528,7 +528,9 @@ blender::Span 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. */ diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc index 9173f83cd93..be9d5dfde5e 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.cc +++ b/source/blender/blenkernel/intern/DerivedMesh.cc @@ -537,13 +537,13 @@ static void set_rest_position(Mesh &mesh) if (positions) { if (positions.sharing_info && positions.varray.is_span()) { attributes.add("rest_position", - ATTR_DOMAIN_POINT, + AttrDomain::Point, AttributeInitShared(positions.varray.get_internal_span().data(), *positions.sharing_info)); } else { attributes.add( - "rest_position", ATTR_DOMAIN_POINT, AttributeInitVArray(positions.varray)); + "rest_position", AttrDomain::Point, AttributeInitVArray(positions.varray)); } } } diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index 9b5703adfbd..a2de6149a25 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -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(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(domain); + return AttrDomain(domain); } } BLI_assert_msg(0, "Custom data layer not found in geometry"); - return static_cast(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) { diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index dca531519f6..1bee8d14486 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -132,22 +132,22 @@ eCustomDataType attribute_data_type_highest_complexity(Span 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 domains) +AttrDomain attribute_domain_highest_priority(Span 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 domain, + const std::optional domain, const std::optional 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 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 &skip) { @@ -836,7 +836,7 @@ Vector retrieve_attributes_for_transfer( /** \} */ void gather_attributes(const AttributeAccessor src_attributes, - const eAttrDomain domain, + const AttrDomain domain, const AnonymousAttributePropagationInfo &propagation_info, const Set &skip, const IndexMask &selection, @@ -895,7 +895,7 @@ static bool indices_are_range(const Span indices, const IndexRange range) } void gather_attributes(const AttributeAccessor src_attributes, - const eAttrDomain domain, + const AttrDomain domain, const AnonymousAttributePropagationInfo &propagation_info, const Set &skip, const Span 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 &skip, const OffsetIndices 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 &skip, const OffsetIndices 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 &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 &skip, const OffsetIndices 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 &skip, const IndexRange range) { diff --git a/source/blender/blenkernel/intern/attribute_access_intern.hh b/source/blender/blenkernel/intern/attribute_access_intern.hh index 890ba7c9944..4f4ec8d85a6 100644 --- a/source/blender/blenkernel/intern/attribute_access_intern.hh +++ b/source/blender/blenkernel/intern/attribute_access_intern.hh @@ -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 callback) const = 0; + virtual void foreach_domain(const FunctionRef 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 callback) const final + void foreach_domain(const FunctionRef 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 supported_domains_; + VectorSet supported_domains_; public: ComponentAttributeProviders(Span 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 supported_domains() const + Span supported_domains() const { return supported_domains_; } @@ -414,7 +414,7 @@ inline bool remove(void *owner, const AttributeIDRef &attribute_id) template inline bool add(void *owner, const AttributeIDRef &attribute_id, - eAttrDomain domain, + AttrDomain domain, eCustomDataType data_type, const AttributeInit &initializer) { diff --git a/source/blender/blenkernel/intern/bake_items_serialize.cc b/source/blender/blenkernel/intern/bake_items_serialize.cc index c7f928b2d25..524ab6181fe 100644 --- a/source/blender/blenkernel/intern/bake_items_serialize.cc +++ b/source/blender/blenkernel/intern/bake_items_serialize.cc @@ -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 get_domain_from_io_name(const StringRefNull io_name) +static std::optional 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 get_data_type_from_io_name(const StringRefNull io_name) @@ -382,7 +382,7 @@ template return false; } - const std::optional domain = get_domain_from_io_name(*domain_str); + const std::optional domain = get_domain_from_io_name(*domain_str); const std::optional data_type = get_data_type_from_io_name(*type_str); if (!domain || !data_type) { return false; diff --git a/source/blender/blenkernel/intern/bake_items_socket.cc b/source/blender/blenkernel/intern/bake_items_socket.cc index e53613713bf..ddd30a5da7d 100644 --- a/source/blender/blenkernel/intern/bake_items_socket.cc +++ b/source/blender/blenkernel/intern/bake_items_socket.cc @@ -61,7 +61,7 @@ Array> move_socket_values_to_bake_items(const Span(socket_value); if (value_variant.is_context_dependent_field()) { const fn::GField &field = value_variant.get(); - const eAttrDomain domain = config.domains[i]; + const AttrDomain domain = config.domains[i]; const std::string attribute_name = ".bake_" + std::to_string(i); const Span geometry_indices = config.geometries_by_attribute[i]; for (const int geometry_i : geometry_indices) { diff --git a/source/blender/blenkernel/intern/bvhutils.cc b/source/blender/blenkernel/intern/bvhutils.cc index 9f37433d480..f934c46307a 100644 --- a/source/blender/blenkernel/intern/bvhutils.cc +++ b/source/blender/blenkernel/intern/bvhutils.cc @@ -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 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( diff --git a/source/blender/blenkernel/intern/curve_legacy_convert.cc b/source/blender/blenkernel/intern/curve_legacy_convert.cc index 9ed3446b30f..be31983e6a6 100644 --- a/source/blender/blenkernel/intern/curve_legacy_convert.cc +++ b/source/blender/blenkernel/intern/curve_legacy_convert.cc @@ -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 positions = curves.positions_for_write(); SpanAttributeWriter radius_attribute = - curves_attributes.lookup_or_add_for_write_only_span("radius", ATTR_DOMAIN_POINT); + curves_attributes.lookup_or_add_for_write_only_span("radius", AttrDomain::Point); MutableSpan radii = radius_attribute.span; MutableSpan tilts = curves.tilt_for_write(); diff --git a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc index 8013f72d0b2..b2ddffc5605 100644 --- a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc +++ b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc @@ -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 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("position", ATTR_DOMAIN_POINT, init)) { + if (mesh.attributes_for_write().add("position", AttrDomain::Point, init)) { return; } } } } const Span main_positions = curves_info.main.evaluated_positions(); - mesh.attributes_for_write().add("position", ATTR_DOMAIN_POINT, AttributeInitConstruct()); + mesh.attributes_for_write().add("position", AttrDomain::Point, AttributeInitConstruct()); MutableSpan 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 tangents = curves_info.main.evaluated_tangents(); const Span normals = curves_info.main.evaluated_normals(); Span 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(); } 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 &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 src = src_all.typed(); MutableSpan dst = dst_attribute.span.typed(); 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 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 src = src_all.typed(); MutableSpan dst = dst_all.typed(); 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 &src, static void copy_curve_domain_attribute_to_mesh(const ResultOffsets &mesh_offsets, const Span curve_indices, - const eAttrDomain dst_domain, + const AttrDomain dst_domain, const GVArray &src, GMutableSpan dst) { Span 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("sharp_edge", ATTR_DOMAIN_EDGE); + sharp_edges = mesh_attributes.lookup_or_add_for_write_span("sharp_edge", AttrDomain::Edge); const OffsetIndices profile_points_by_curve = profile.points_by_curve(); const VArray 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 sharp_faces = mesh_attributes.lookup_or_add_for_write_span( - "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("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); } diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index 8640a7c8827..3d27b01f9b8 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -347,7 +347,7 @@ bool CurvesEditHints::is_valid() const void curves_normals_point_domain_calc(const CurvesGeometry &curves, MutableSpan 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 field(std::make_shared()); evaluator.add_with_destination(std::move(field), normals); diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc index 5ca662e89f6..e27c4082135 100644 --- a/source/blender/blenkernel/intern/curves_geometry.cc +++ b/source/blender/blenkernel/intern/curves_geometry.cc @@ -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( - "position", ATTR_DOMAIN_POINT, AttributeInitConstruct()); + "position", AttrDomain::Point, AttributeInitConstruct()); this->runtime = MEM_new(__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 static VArray 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 get_varray_attribute(const CurvesGeometry &curves, template static Span 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 get_span_attribute(const CurvesGeometry &curves, template static MutableSpan 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 get_mutable_attribute(CurvesGeometry &curves, VArray CurvesGeometry::curve_types() const { return get_varray_attribute( - *this, ATTR_DOMAIN_CURVE, ATTR_CURVE_TYPE, CURVE_TYPE_CATMULL_ROM); + *this, AttrDomain::Curve, ATTR_CURVE_TYPE, CURVE_TYPE_CATMULL_ROM); } MutableSpan CurvesGeometry::curve_types_for_write() { - return get_mutable_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_CURVE_TYPE); + return get_mutable_attribute(*this, AttrDomain::Curve, ATTR_CURVE_TYPE); } void CurvesGeometry::fill_curve_types(const CurveType type) @@ -338,11 +338,11 @@ void CurvesGeometry::update_curve_types() Span CurvesGeometry::positions() const { - return get_span_attribute(*this, ATTR_DOMAIN_POINT, ATTR_POSITION); + return get_span_attribute(*this, AttrDomain::Point, ATTR_POSITION); } MutableSpan CurvesGeometry::positions_for_write() { - return get_mutable_attribute(*this, ATTR_DOMAIN_POINT, ATTR_POSITION); + return get_mutable_attribute(*this, AttrDomain::Point, ATTR_POSITION); } Span CurvesGeometry::offsets() const @@ -361,111 +361,111 @@ MutableSpan CurvesGeometry::offsets_for_write() VArray CurvesGeometry::cyclic() const { - return get_varray_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_CYCLIC, false); + return get_varray_attribute(*this, AttrDomain::Curve, ATTR_CYCLIC, false); } MutableSpan CurvesGeometry::cyclic_for_write() { - return get_mutable_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_CYCLIC, false); + return get_mutable_attribute(*this, AttrDomain::Curve, ATTR_CYCLIC, false); } VArray CurvesGeometry::resolution() const { - return get_varray_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_RESOLUTION, 12); + return get_varray_attribute(*this, AttrDomain::Curve, ATTR_RESOLUTION, 12); } MutableSpan CurvesGeometry::resolution_for_write() { - return get_mutable_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_RESOLUTION, 12); + return get_mutable_attribute(*this, AttrDomain::Curve, ATTR_RESOLUTION, 12); } VArray CurvesGeometry::normal_mode() const { - return get_varray_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_NORMAL_MODE, 0); + return get_varray_attribute(*this, AttrDomain::Curve, ATTR_NORMAL_MODE, 0); } MutableSpan CurvesGeometry::normal_mode_for_write() { - return get_mutable_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_NORMAL_MODE); + return get_mutable_attribute(*this, AttrDomain::Curve, ATTR_NORMAL_MODE); } VArray CurvesGeometry::tilt() const { - return get_varray_attribute(*this, ATTR_DOMAIN_POINT, ATTR_TILT, 0.0f); + return get_varray_attribute(*this, AttrDomain::Point, ATTR_TILT, 0.0f); } MutableSpan CurvesGeometry::tilt_for_write() { - return get_mutable_attribute(*this, ATTR_DOMAIN_POINT, ATTR_TILT); + return get_mutable_attribute(*this, AttrDomain::Point, ATTR_TILT); } VArray CurvesGeometry::handle_types_left() const { - return get_varray_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_LEFT, 0); + return get_varray_attribute(*this, AttrDomain::Point, ATTR_HANDLE_TYPE_LEFT, 0); } MutableSpan CurvesGeometry::handle_types_left_for_write() { - return get_mutable_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_LEFT, 0); + return get_mutable_attribute(*this, AttrDomain::Point, ATTR_HANDLE_TYPE_LEFT, 0); } VArray CurvesGeometry::handle_types_right() const { - return get_varray_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_RIGHT, 0); + return get_varray_attribute(*this, AttrDomain::Point, ATTR_HANDLE_TYPE_RIGHT, 0); } MutableSpan CurvesGeometry::handle_types_right_for_write() { - return get_mutable_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_TYPE_RIGHT, 0); + return get_mutable_attribute(*this, AttrDomain::Point, ATTR_HANDLE_TYPE_RIGHT, 0); } Span CurvesGeometry::handle_positions_left() const { - return get_span_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_LEFT); + return get_span_attribute(*this, AttrDomain::Point, ATTR_HANDLE_POSITION_LEFT); } MutableSpan CurvesGeometry::handle_positions_left_for_write() { - return get_mutable_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_LEFT); + return get_mutable_attribute(*this, AttrDomain::Point, ATTR_HANDLE_POSITION_LEFT); } Span CurvesGeometry::handle_positions_right() const { - return get_span_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_RIGHT); + return get_span_attribute(*this, AttrDomain::Point, ATTR_HANDLE_POSITION_RIGHT); } MutableSpan CurvesGeometry::handle_positions_right_for_write() { - return get_mutable_attribute(*this, ATTR_DOMAIN_POINT, ATTR_HANDLE_POSITION_RIGHT); + return get_mutable_attribute(*this, AttrDomain::Point, ATTR_HANDLE_POSITION_RIGHT); } VArray CurvesGeometry::nurbs_orders() const { - return get_varray_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_ORDER, 4); + return get_varray_attribute(*this, AttrDomain::Curve, ATTR_NURBS_ORDER, 4); } MutableSpan CurvesGeometry::nurbs_orders_for_write() { - return get_mutable_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_ORDER, 4); + return get_mutable_attribute(*this, AttrDomain::Curve, ATTR_NURBS_ORDER, 4); } Span CurvesGeometry::nurbs_weights() const { - return get_span_attribute(*this, ATTR_DOMAIN_POINT, ATTR_NURBS_WEIGHT); + return get_span_attribute(*this, AttrDomain::Point, ATTR_NURBS_WEIGHT); } MutableSpan CurvesGeometry::nurbs_weights_for_write() { - return get_mutable_attribute(*this, ATTR_DOMAIN_POINT, ATTR_NURBS_WEIGHT); + return get_mutable_attribute(*this, AttrDomain::Point, ATTR_NURBS_WEIGHT); } VArray CurvesGeometry::nurbs_knots_modes() const { - return get_varray_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_KNOTS_MODE, 0); + return get_varray_attribute(*this, AttrDomain::Curve, ATTR_NURBS_KNOTS_MODE, 0); } MutableSpan CurvesGeometry::nurbs_knots_modes_for_write() { - return get_mutable_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_KNOTS_MODE, 0); + return get_mutable_attribute(*this, AttrDomain::Curve, ATTR_NURBS_KNOTS_MODE, 0); } Span CurvesGeometry::surface_uv_coords() const { - return get_span_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_UV_COORDINATE); + return get_span_attribute(*this, AttrDomain::Curve, ATTR_SURFACE_UV_COORDINATE); } MutableSpan CurvesGeometry::surface_uv_coords_for_write() { - return get_mutable_attribute(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_UV_COORDINATE); + return get_mutable_attribute(*this, AttrDomain::Curve, ATTR_SURFACE_UV_COORDINATE); } Span 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); } diff --git a/source/blender/blenkernel/intern/data_transfer.cc b/source/blender/blenkernel/intern/data_transfer.cc index 90570a81fbf..72ea687360a 100644 --- a/source/blender/blenkernel/intern/data_transfer.cc +++ b/source/blender/blenkernel/intern/data_transfer.cc @@ -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 sharp_edges = attributes.lookup_or_add_for_write_span( - "sharp_edge", ATTR_DOMAIN_EDGE); - const VArraySpan sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + "sharp_edge", bke::AttrDomain::Edge); + const VArraySpan sharp_faces = *attributes.lookup("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(), diff --git a/source/blender/blenkernel/intern/fluid.cc b/source/blender/blenkernel/intern/fluid.cc index 87bb7b3c39b..5dd0c927a0b 100644 --- a/source/blender/blenkernel/intern/fluid.cc +++ b/source/blender/blenkernel/intern/fluid.cc @@ -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("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 corner_verts = mesh->corner_verts_for_write(); const bool is_sharp = orgmesh->attributes() - .lookup_or_default("sharp_face", ATTR_DOMAIN_FACE, false) + .lookup_or_default("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(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( - "material_index", ATTR_DOMAIN_FACE); + "material_index", AttrDomain::Face); /* Loop for triangles. */ for (const int i : face_offsets.index_range().drop_back(1)) { diff --git a/source/blender/blenkernel/intern/geometry_component_curves.cc b/source/blender/blenkernel/intern/geometry_component_curves.cc index 84196ada76b..722739aa8a5 100644 --- a/source/blender/blenkernel/intern/geometry_component_curves.cc +++ b/source/blender/blenkernel/intern/geometry_component_curves.cc @@ -211,23 +211,23 @@ static Array curve_normal_point_domain(const bke::CurvesGeometry &curves return results; } -VArray curve_normals_varray(const CurvesGeometry &curves, const eAttrDomain domain) +VArray curve_normals_varray(const CurvesGeometry &curves, const AttrDomain domain) { const VArray types = curves.curve_types(); if (curves.is_single_type(CURVE_TYPE_POLY)) { return curves.adapt_domain( - VArray::ForSpan(curves.evaluated_normals()), ATTR_DOMAIN_POINT, domain); + VArray::ForSpan(curves.evaluated_normals()), AttrDomain::Point, domain); } Array normals = curve_normal_point_domain(curves); - if (domain == ATTR_DOMAIN_POINT) { + if (domain == AttrDomain::Point) { return VArray::ForContainer(std::move(normals)); } - if (domain == ATTR_DOMAIN_CURVE) { + if (domain == AttrDomain::Curve) { return curves.adapt_domain( - VArray::ForContainer(std::move(normals)), ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE); + VArray::ForContainer(std::move(normals)), AttrDomain::Point, AttrDomain::Curve); } return nullptr; @@ -240,7 +240,7 @@ VArray curve_normals_varray(const CurvesGeometry &curves, const eAttrDom * \{ */ static VArray construct_curve_length_gvarray(const CurvesGeometry &curves, - const eAttrDomain domain) + const AttrDomain domain) { curves.ensure_evaluated_lengths(); @@ -250,12 +250,12 @@ static VArray 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(std::move(lengths), ATTR_DOMAIN_CURVE, ATTR_DOMAIN_POINT); + if (domain == AttrDomain::Point) { + return curves.adapt_domain(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(&other) != nullptr; } -std::optional CurveLengthFieldInput::preferred_domain( +std::optional 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 dverts = curves->deform_verts(); if (dverts.is_empty()) { static const float default_value = 0.0f; - return {VArray::ForSingle(default_value, curves->points_num()), ATTR_DOMAIN_POINT}; + return {VArray::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 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 callback) const final + void foreach_domain(const FunctionRef 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(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(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(); - 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(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 {}; } diff --git a/source/blender/blenkernel/intern/geometry_component_grease_pencil.cc b/source/blender/blenkernel/intern/geometry_component_grease_pencil.cc index 491964bd437..1b837a916ec 100644 --- a/source/blender/blenkernel/intern/geometry_component_grease_pencil.cc +++ b/source/blender/blenkernel/intern/geometry_component_grease_pencil.cc @@ -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(); - 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(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 {}; } diff --git a/source/blender/blenkernel/intern/geometry_component_instances.cc b/source/blender/blenkernel/intern/geometry_component_instances.cc index 6e9d8e5ab48..f602b32bd0f 100644 --- a/source/blender/blenkernel/intern/geometry_component_instances.cc +++ b/source/blender/blenkernel/intern/geometry_component_instances.cc @@ -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(); - 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(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{}; diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc index b1c376f6c54..64c26a50c08 100644 --- a/source/blender/blenkernel/intern/geometry_component_mesh.cc +++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc @@ -120,16 +120,16 @@ void MeshComponent::ensure_owns_direct_data() VArray 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::ForSpan(mesh.face_normals()); } - case ATTR_DOMAIN_POINT: { + case AttrDomain::Point: { return VArray::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 mesh_normals_varray(const Mesh &mesh, return VArray::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::ForSpan(mesh.face_normals()), ATTR_DOMAIN_FACE, ATTR_DOMAIN_CORNER); + VArray::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 dverts = mesh->deform_verts(); if (dverts.is_empty()) { static const float default_value = 0.0f; - return {VArray::ForSingle(default_value, mesh->verts_num), ATTR_DOMAIN_POINT}; + return {VArray::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 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 callback) const final + void foreach_domain(const FunctionRef 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(); - 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(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 {}; } diff --git a/source/blender/blenkernel/intern/geometry_component_pointcloud.cc b/source/blender/blenkernel/intern/geometry_component_pointcloud.cc index e72136979df..03d0ee786cf 100644 --- a/source/blender/blenkernel/intern/geometry_component_pointcloud.cc +++ b/source/blender/blenkernel/intern/geometry_component_pointcloud.cc @@ -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(); - 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(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{}; diff --git a/source/blender/blenkernel/intern/geometry_fields.cc b/source/blender/blenkernel/intern/geometry_fields.cc index f1ee5c44833..60052df4d84 100644 --- a/source/blender/blenkernel/intern/geometry_fields.cc +++ b/source/blender/blenkernel/intern/geometry_fields.cc @@ -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(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 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 GeometryFieldInput::preferred_domain( +std::optional 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 MeshFieldInput::preferred_domain(const Mesh & /*mesh*/) const +std::optional 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 CurvesFieldInput::preferred_domain( +std::optional 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 AttributeFieldInput::preferred_domain( +std::optional AttributeFieldInput::preferred_domain( const GeometryComponent &component) const { const std::optional attributes = component.attributes(); @@ -442,11 +442,11 @@ std::optional 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 AnonymousAttributeFieldInput::preferred_domain( +std::optional AnonymousAttributeFieldInput::preferred_domain( const GeometryComponent &component) const { const std::optional 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 selection(mask.min_array_size()); layer_indices.to_bools(selection); return VArray::ForContainer(std::move(selection)); @@ -574,10 +574,10 @@ bool NamedLayerSelectionFieldInput::is_equal_to(const fn::FieldNode &other) cons return false; } -std::optional NamedLayerSelectionFieldInput::preferred_domain( +std::optional 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 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 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 &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 &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(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 selection = fn::make_constant_field(true); return try_capture_field_on_geometry(component, attribute_id, domain, selection, field); } -std::optional try_detect_field_domain(const GeometryComponent &component, +std::optional 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 &field_inputs = field.node().field_inputs(); if (!field_inputs) { return std::nullopt; } - std::optional output_domain; - auto handle_domain = [&](const std::optional domain) { + std::optional output_domain; + auto handle_domain = [&](const std::optional domain) { if (!domain.has_value()) { return false; } diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 7a1c3ff3297..13af9883547 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -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) { diff --git a/source/blender/blenkernel/intern/gpencil_geom_legacy.cc b/source/blender/blenkernel/intern/gpencil_geom_legacy.cc index c580fd6294f..3a1d2a606c9 100644 --- a/source/blender/blenkernel/intern/gpencil_geom_legacy.cc +++ b/source/blender/blenkernel/intern/gpencil_geom_legacy.cc @@ -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 vert_normals = mesh->vert_normals(); const bke::AttributeAccessor attributes = mesh->attributes(); const VArray uv_seams = *attributes.lookup_or_default( - ".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 mesh_material_indices = *me_eval->attributes().lookup_or_default( - "material_index", ATTR_DOMAIN_FACE, 0); + "material_index", AttrDomain::Face, 0); for (i = 0; i < faces_len; i++) { const IndexRange face = faces[i]; diff --git a/source/blender/blenkernel/intern/grease_pencil.cc b/source/blender/blenkernel/intern/grease_pencil.cc index 736fa24d815..0b42939b1d0 100644 --- a/source/blender/blenkernel/intern/grease_pencil.cc +++ b/source/blender/blenkernel/intern/grease_pencil.cc @@ -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 static MutableSpan 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 Drawing::radii() const { return *this->strokes().attributes().lookup_or_default( - ATTR_RADIUS, ATTR_DOMAIN_POINT, 0.01f); + ATTR_RADIUS, AttrDomain::Point, 0.01f); } MutableSpan Drawing::radii_for_write() { return get_mutable_attribute( - this->strokes_for_write(), ATTR_DOMAIN_POINT, ATTR_RADIUS, 0.01f); + this->strokes_for_write(), AttrDomain::Point, ATTR_RADIUS, 0.01f); } VArray Drawing::opacities() const { return *this->strokes().attributes().lookup_or_default( - ATTR_OPACITY, ATTR_DOMAIN_POINT, 1.0f); + ATTR_OPACITY, AttrDomain::Point, 1.0f); } MutableSpan Drawing::opacities_for_write() { return get_mutable_attribute( - this->strokes_for_write(), ATTR_DOMAIN_POINT, ATTR_OPACITY, 1.0f); + this->strokes_for_write(), AttrDomain::Point, ATTR_OPACITY, 1.0f); } VArray Drawing::vertex_colors() const { return *this->strokes().attributes().lookup_or_default( - 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 Drawing::vertex_colors_for_write() { return get_mutable_attribute(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(base)->wrap(); MutableAttributeAccessor attributes = drawing.strokes_for_write().attributes_for_write(); SpanAttributeWriter material_indices = attributes.lookup_or_add_for_write_span( - "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(base)->wrap(); AttributeAccessor attributes = drawing.strokes().attributes(); const VArraySpan material_indices = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_CURVE, 0); + "material_index", AttrDomain::Curve, 0); if (material_indices.contains(index)) { return true; diff --git a/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc b/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc index 2b1cf683e12..5515c8f3594 100644 --- a/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc +++ b/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc @@ -58,38 +58,38 @@ void legacy_gpencil_frame_to_grease_pencil_drawing(const bGPDframe &gpf, MutableSpan radii = drawing.radii_for_write(); MutableSpan opacities = drawing.opacities_for_write(); SpanAttributeWriter delta_times = attributes.lookup_or_add_for_write_span( - "delta_time", ATTR_DOMAIN_POINT); + "delta_time", AttrDomain::Point); SpanAttributeWriter rotations = attributes.lookup_or_add_for_write_span( - "rotation", ATTR_DOMAIN_POINT); + "rotation", AttrDomain::Point); SpanAttributeWriter vertex_colors = - attributes.lookup_or_add_for_write_span("vertex_color", ATTR_DOMAIN_POINT); + attributes.lookup_or_add_for_write_span("vertex_color", AttrDomain::Point); SpanAttributeWriter selection = attributes.lookup_or_add_for_write_span( - ".selection", ATTR_DOMAIN_POINT); + ".selection", AttrDomain::Point); /* Curve Attributes. */ SpanAttributeWriter stroke_cyclic = attributes.lookup_or_add_for_write_span( - "cyclic", ATTR_DOMAIN_CURVE); + "cyclic", AttrDomain::Curve); /* TODO: This should be a `double` attribute. */ SpanAttributeWriter stroke_init_times = attributes.lookup_or_add_for_write_span( - "init_time", ATTR_DOMAIN_CURVE); + "init_time", AttrDomain::Curve); SpanAttributeWriter stroke_start_caps = attributes.lookup_or_add_for_write_span( - "start_cap", ATTR_DOMAIN_CURVE); + "start_cap", AttrDomain::Curve); SpanAttributeWriter stroke_end_caps = attributes.lookup_or_add_for_write_span( - "end_cap", ATTR_DOMAIN_CURVE); + "end_cap", AttrDomain::Curve); SpanAttributeWriter stroke_hardnesses = attributes.lookup_or_add_for_write_span( - "hardness", ATTR_DOMAIN_CURVE); + "hardness", AttrDomain::Curve); SpanAttributeWriter stroke_point_aspect_ratios = - attributes.lookup_or_add_for_write_span("point_aspect_ratio", ATTR_DOMAIN_CURVE); + attributes.lookup_or_add_for_write_span("point_aspect_ratio", AttrDomain::Curve); SpanAttributeWriter stroke_fill_translations = - attributes.lookup_or_add_for_write_span("fill_translation", ATTR_DOMAIN_CURVE); + attributes.lookup_or_add_for_write_span("fill_translation", AttrDomain::Curve); SpanAttributeWriter stroke_fill_rotations = - attributes.lookup_or_add_for_write_span("fill_rotation", ATTR_DOMAIN_CURVE); + attributes.lookup_or_add_for_write_span("fill_rotation", AttrDomain::Curve); SpanAttributeWriter stroke_fill_scales = attributes.lookup_or_add_for_write_span( - "fill_scale", ATTR_DOMAIN_CURVE); + "fill_scale", AttrDomain::Curve); SpanAttributeWriter stroke_fill_colors = - attributes.lookup_or_add_for_write_span("fill_color", ATTR_DOMAIN_CURVE); + attributes.lookup_or_add_for_write_span("fill_color", AttrDomain::Curve); SpanAttributeWriter stroke_materials = attributes.lookup_or_add_for_write_span( - "material_index", ATTR_DOMAIN_CURVE); + "material_index", AttrDomain::Curve); int stroke_i = 0; LISTBASE_FOREACH_INDEX (bGPDstroke *, gps, &gpf.strokes, stroke_i) { diff --git a/source/blender/blenkernel/intern/instances.cc b/source/blender/blenkernel/intern/instances.cc index 86d9c7eb7b9..fb37e5fa6e8 100644 --- a/source/blender/blenkernel/intern/instances.cc +++ b/source/blender/blenkernel/intern/instances.cc @@ -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, diff --git a/source/blender/blenkernel/intern/key.cc b/source/blender/blenkernel/intern/key.cc index 667eafc338a..8a15e0c51fd 100644 --- a/source/blender/blenkernel/intern/key.cc +++ b/source/blender/blenkernel/intern/key.cc @@ -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( CustomData_get_layer(&mesh->corner_data, CD_CUSTOMLOOPNORMAL)); const bke::AttributeAccessor attributes = mesh->attributes(); - const VArraySpan sharp_edges = *attributes.lookup("sharp_edge", ATTR_DOMAIN_EDGE); - const VArraySpan sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + const VArraySpan sharp_edges = *attributes.lookup("sharp_edge", AttrDomain::Edge); + const VArraySpan sharp_faces = *attributes.lookup("sharp_face", AttrDomain::Face); blender::bke::mesh::normals_calc_loop( positions, edges, diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index e49fdd9d13b..855769c6fb9 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -642,18 +642,22 @@ MutableSpan 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 material_indices = *attributes.lookup_or_default( - "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 material_indices = attributes.lookup_or_add_for_write_span( - "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 sharp_faces = attributes.lookup_or_add_for_write_only_span( - "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 sharp_edges = attributes.lookup_or_add_for_write_span( - "sharp_edge", ATTR_DOMAIN_EDGE); - const VArraySpan sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + "sharp_edge", AttrDomain::Edge); + const VArraySpan sharp_faces = *attributes.lookup("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 select_vert = *attributes.lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", AttrDomain::Point, false); const VArray select_edge = *attributes.lookup_or_default( - ".select_edge", ATTR_DOMAIN_EDGE, false); + ".select_edge", AttrDomain::Edge, false); const VArray select_poly = *attributes.lookup_or_default( - ".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; diff --git a/source/blender/blenkernel/intern/mesh_boolean_convert.cc b/source/blender/blenkernel/intern/mesh_boolean_convert.cc index be865e6b39f..b2cee48627e 100644 --- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc +++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc @@ -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 src_material_indices = *orig_me->attributes().lookup_or_default( - "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 dst_material_indices = result->attributes_for_write().lookup_or_add_for_write_only_span("material_index", - ATTR_DOMAIN_FACE); + bke::AttrDomain::Face); int cur_loop_index = 0; MutableSpan dst_corner_verts = result->corner_verts_for_write(); MutableSpan dst_face_offsets = result->face_offsets_for_write(); diff --git a/source/blender/blenkernel/intern/mesh_calc_edges.cc b/source/blender/blenkernel/intern/mesh_calc_edges.cc index 429a686b880..f9168c65ff4 100644 --- a/source/blender/blenkernel/intern/mesh_calc_edges.cc +++ b/source/blender/blenkernel/intern/mesh_calc_edges.cc @@ -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(".corner_edge", ATTR_DOMAIN_CORNER, AttributeInitConstruct()); + attributes.add(".corner_edge", AttrDomain::Corner, AttributeInitConstruct()); MutableSpan new_edges{ static_cast(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(".edge_verts", ATTR_DOMAIN_EDGE, AttributeInitMoveArray(new_edges.data())); + attributes.add(".edge_verts", AttrDomain::Edge, AttributeInitMoveArray(new_edges.data())); if (select_new_edges) { MutableAttributeAccessor attributes = mesh->attributes_for_write(); SpanAttributeWriter select_edge = attributes.lookup_or_add_for_write_span( - ".select_edge", ATTR_DOMAIN_EDGE); + ".select_edge", AttrDomain::Edge); if (select_edge) { int new_edge_index = 0; for (const EdgeMap &edge_map : edge_maps) { diff --git a/source/blender/blenkernel/intern/mesh_compare.cc b/source/blender/blenkernel/intern/mesh_compare.cc index 145457c960c..ec1efb9cde4 100644 --- a/source/blender/blenkernel/intern/mesh_compare.cc +++ b/source/blender/blenkernel/intern/mesh_compare.cc @@ -530,7 +530,7 @@ static std::optional verify_attributes_compatible( static std::optional sort_domain_using_attributes( const AttributeAccessor &mesh1_attributes, const AttributeAccessor &mesh2_attributes, - const eAttrDomain domain, + const AttrDomain domain, const Span excluded_attributes, IndexMapping &maps, const float threshold) @@ -587,16 +587,16 @@ static std::optional 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 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 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 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 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; }; diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index 217fefe0e8a..f446306b724 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -124,11 +124,11 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba MutableAttributeAccessor attributes = mesh->attributes_for_write(); SpanAttributeWriter material_indices = attributes.lookup_or_add_for_write_only_span( - "material_index", ATTR_DOMAIN_FACE); + "material_index", AttrDomain::Face); SpanAttributeWriter sharp_faces = attributes.lookup_or_add_for_write_span( - "sharp_face", ATTR_DOMAIN_FACE); + "sharp_face", AttrDomain::Face); SpanAttributeWriter uv_attribute = attributes.lookup_or_add_for_write_span( - DATA_("UVMap"), ATTR_DOMAIN_CORNER); + DATA_("UVMap"), AttrDomain::Corner); MutableSpan uv_map = uv_attribute.span; int dst_vert = 0; diff --git a/source/blender/blenkernel/intern/mesh_evaluate.cc b/source/blender/blenkernel/intern/mesh_evaluate.cc index c2a764c91b3..2e5cd85bf07 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.cc +++ b/source/blender/blenkernel/intern/mesh_evaluate.cc @@ -544,7 +544,7 @@ void mesh_hide_vert_flush(Mesh &mesh) MutableAttributeAccessor attributes = mesh.attributes_for_write(); const VArray hide_vert = *attributes.lookup_or_default( - ".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 hide_vert_span{hide_vert}; SpanAttributeWriter hide_edge = attributes.lookup_or_add_for_write_only_span( - ".hide_edge", ATTR_DOMAIN_EDGE); + ".hide_edge", AttrDomain::Edge); SpanAttributeWriter hide_poly = attributes.lookup_or_add_for_write_only_span( - ".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 hide_poly = *attributes.lookup_or_default( - ".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 corner_verts = mesh.corner_verts(); const Span corner_edges = mesh.corner_edges(); SpanAttributeWriter hide_vert = attributes.lookup_or_add_for_write_only_span( - ".hide_vert", ATTR_DOMAIN_POINT); + ".hide_vert", AttrDomain::Point); SpanAttributeWriter hide_edge = attributes.lookup_or_add_for_write_only_span( - ".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 select_poly = *attributes.lookup_or_default( - ".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 select_vert = attributes.lookup_or_add_for_write_only_span( - ".select_vert", ATTR_DOMAIN_POINT); + ".select_vert", AttrDomain::Point); SpanAttributeWriter select_edge = attributes.lookup_or_add_for_write_only_span( - ".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(".select_poly", ATTR_DOMAIN_POINT, false), + array_utils::copy(*attributes.lookup_or_default(".select_poly", AttrDomain::Point, false), select_vert.span); - array_utils::copy(*attributes.lookup_or_default(".select_poly", ATTR_DOMAIN_EDGE, false), + array_utils::copy(*attributes.lookup_or_default(".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 select_vert = *attributes.lookup_or_default( - ".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 select_edge = attributes.lookup_or_add_for_write_only_span( - ".select_edge", ATTR_DOMAIN_EDGE); + ".select_edge", AttrDomain::Edge); SpanAttributeWriter select_poly = attributes.lookup_or_add_for_write_only_span( - ".select_poly", ATTR_DOMAIN_FACE); + ".select_poly", AttrDomain::Face); { IndexMaskMemory memory; const VArray hide_edge = *attributes.lookup_or_default( - ".hide_edge", ATTR_DOMAIN_EDGE, false); + ".hide_edge", AttrDomain::Edge, false); array_utils::copy( - *attributes.lookup_or_default(".select_vert", ATTR_DOMAIN_EDGE, false), + *attributes.lookup_or_default(".select_vert", AttrDomain::Edge, false), IndexMask::from_bools(hide_edge, memory).complement(hide_edge.index_range(), memory), select_edge.span); } { IndexMaskMemory memory; const VArray hide_poly = *attributes.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", AttrDomain::Face, false); array_utils::copy( - *attributes.lookup_or_default(".select_vert", ATTR_DOMAIN_FACE, false), + *attributes.lookup_or_default(".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 select_edge = *attributes.lookup_or_default( - ".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 select_vert = attributes.lookup_or_add_for_write_only_span( - ".select_vert", ATTR_DOMAIN_POINT); + ".select_vert", AttrDomain::Point); SpanAttributeWriter select_poly = attributes.lookup_or_add_for_write_only_span( - ".select_poly", ATTR_DOMAIN_FACE); + ".select_poly", AttrDomain::Face); { IndexMaskMemory memory; const VArray hide_vert = *attributes.lookup_or_default( - ".hide_vert", ATTR_DOMAIN_POINT, false); + ".hide_vert", AttrDomain::Point, false); array_utils::copy( - *attributes.lookup_or_default(".select_vert", ATTR_DOMAIN_POINT, false), + *attributes.lookup_or_default(".select_vert", AttrDomain::Point, false), IndexMask::from_bools(hide_vert, memory).complement(hide_vert.index_range(), memory), select_vert.span); } { IndexMaskMemory memory; const VArray hide_poly = *attributes.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", AttrDomain::Face, false); array_utils::copy( - *attributes.lookup_or_default(".select_vert", ATTR_DOMAIN_FACE, false), + *attributes.lookup_or_default(".select_vert", AttrDomain::Face, false), IndexMask::from_bools(hide_poly, memory).complement(hide_poly.index_range(), memory), select_poly.span); } diff --git a/source/blender/blenkernel/intern/mesh_flip_faces.cc b/source/blender/blenkernel/intern/mesh_flip_faces.cc index 5a5b82fc6ff..95513443e3a 100644 --- a/source/blender/blenkernel/intern/mesh_flip_faces.cc +++ b/source/blender/blenkernel/intern/mesh_flip_faces.cc @@ -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")) { diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index 87278303727..bc84078045a 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -1286,7 +1286,7 @@ void BKE_mesh_legacy_sharp_faces_from_flags(Mesh *mesh) })) { SpanAttributeWriter sharp_faces = attributes.lookup_or_add_for_write_only_span( - "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 attribute = attributes.lookup_or_add_for_write_span( - ".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 sharp_edges = attributes.lookup_or_add_for_write_only_span( - "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 uv_seams = attributes.lookup_or_add_for_write_only_span( - ".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 hide_vert = attributes.lookup_or_add_for_write_only_span( - ".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 hide_edge = attributes.lookup_or_add_for_write_only_span( - ".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 hide_poly = attributes.lookup_or_add_for_write_only_span( - ".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 material_indices = attributes.lookup_or_add_for_write_only_span( - "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 select_vert = attributes.lookup_or_add_for_write_only_span( - ".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 select_edge = attributes.lookup_or_add_for_write_only_span( - ".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 select_poly = attributes.lookup_or_add_for_write_only_span( - ".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(__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"); diff --git a/source/blender/blenkernel/intern/mesh_mirror.cc b/source/blender/blenkernel/intern/mesh_mirror.cc index 7fe7c98b5f2..f65c771da60 100644 --- a/source/blender/blenkernel/intern/mesh_mirror.cc +++ b/source/blender/blenkernel/intern/mesh_mirror.cc @@ -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("sharp_edge", ATTR_DOMAIN_EDGE); - const VArraySpan sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + const VArraySpan sharp_edges = *attributes.lookup("sharp_edge", AttrDomain::Edge); + const VArraySpan sharp_faces = *attributes.lookup("sharp_face", AttrDomain::Face); blender::bke::mesh::normals_calc_loop(result->vert_positions(), result_edges, result_faces, diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index e161af6a6ab..80e1574105b 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -215,7 +215,7 @@ blender::bke::MeshNormalDomain Mesh::normals_domain() const const AttributeAccessor attributes = this->attributes(); const VArray sharp_faces = *attributes.lookup_or_default( - "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 sharp_edges = *attributes.lookup_or_default( - "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 Mesh::corner_normals() const } case MeshNormalDomain::Corner: { const AttributeAccessor attributes = this->attributes(); - const VArraySpan sharp_edges = *attributes.lookup("sharp_edge", ATTR_DOMAIN_EDGE); - const VArraySpan sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + const VArraySpan sharp_edges = *attributes.lookup("sharp_edge", AttrDomain::Edge); + const VArraySpan sharp_faces = *attributes.lookup("sharp_face", AttrDomain::Face); const short2 *custom_normals = static_cast( 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 sharp_edges = attributes.lookup_or_add_for_write_span( - "sharp_edge", ATTR_DOMAIN_EDGE); - const VArraySpan sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + "sharp_edge", AttrDomain::Edge); + const VArraySpan sharp_faces = *attributes.lookup("sharp_face", AttrDomain::Face); mesh_normals_loop_custom_set(mesh->vert_positions(), mesh->edges(), diff --git a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc index ad4d6f3d445..08134c2e9f1 100644 --- a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc +++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc @@ -462,7 +462,7 @@ static void find_nearest_edges(const Span src_positions, static void gather_attributes(const Span ids, const AttributeAccessor src_attributes, - const eAttrDomain domain, + const AttrDomain domain, const Span 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 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 src_tri_faces = src.corner_tri_faces(); Array 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) { diff --git a/source/blender/blenkernel/intern/mesh_sample.cc b/source/blender/blenkernel/intern/mesh_sample.cc index 85e6b5f884d..2edacc60555 100644 --- a/source/blender/blenkernel/intern/mesh_sample.cc +++ b/source/blender/blenkernel/intern/mesh_sample.cc @@ -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(*source_context_, domain_size); diff --git a/source/blender/blenkernel/intern/mesh_tangent.cc b/source/blender/blenkernel/intern/mesh_tangent.cc index da6073d11c5..69aff2eed19 100644 --- a/source/blender/blenkernel/intern/mesh_tangent.cc +++ b/source/blender/blenkernel/intern/mesh_tangent.cc @@ -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(uvmap, ATTR_DOMAIN_CORNER); + const VArraySpan uv_map = *attributes.lookup(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 corner_tris = me_eval->corner_tris(); const bke::AttributeAccessor attributes = me_eval->attributes(); - const VArraySpan sharp_face = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + const VArraySpan sharp_face = *attributes.lookup("sharp_face", AttrDomain::Face); short tangent_mask = 0; BKE_mesh_calc_loop_tangent_ex( reinterpret_cast(me_eval->vert_positions().data()), diff --git a/source/blender/blenkernel/intern/multires_reshape_util.cc b/source/blender/blenkernel/intern/multires_reshape_util.cc index 8cbd14014fe..f3b33e5c4c7 100644 --- a/source/blender/blenkernel/intern/multires_reshape_util.cc +++ b/source/blender/blenkernel/intern/multires_reshape_util.cc @@ -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("crease_vert", ATTR_DOMAIN_POINT); - reshape_context->cd_edge_crease = *attributes.lookup("crease_edge", ATTR_DOMAIN_EDGE); + reshape_context->cd_vertex_crease = *attributes.lookup("crease_vert", AttrDomain::Point); + reshape_context->cd_edge_crease = *attributes.lookup("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("crease_vert", ATTR_DOMAIN_POINT); + reshape_context->cd_vertex_crease = *attributes.lookup("crease_vert", AttrDomain::Point); reshape_context->subdiv = subdiv; reshape_context->need_free_subdiv = false; diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 412fb332e12..758d54bbdb7 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -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(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 mask = *attributes.lookup(".sculpt_mask", ATTR_DOMAIN_POINT)) { + if (const VArray mask = *attributes.lookup(".sculpt_mask", AttrDomain::Point)) { const VArraySpan 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(".sculpt_mask", ATTR_DOMAIN_POINT, AttributeInitDefaultValue())) { + if (attributes.add(".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 hide_poly = *attributes.lookup_or_default( - ".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), ¶ms, @@ -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), ¶ms, @@ -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; diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index bc7cfaaf935..92748aeeccf 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -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(".hide_poly", ATTR_DOMAIN_FACE); - const VArraySpan material_index = *attributes.lookup("material_index", ATTR_DOMAIN_FACE); - const VArraySpan sharp_face = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + const VArraySpan hide_poly = *attributes.lookup(".hide_poly", AttrDomain::Face); + const VArraySpan material_index = *attributes.lookup("material_index", AttrDomain::Face); + const VArraySpan sharp_face = *attributes.lookup("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("material_index", ATTR_DOMAIN_FACE); - const VArraySpan sharp_face = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + const VArraySpan material_index = *attributes.lookup("material_index", AttrDomain::Face); + const VArraySpan sharp_face = *attributes.lookup("sharp_face", AttrDomain::Face); pbvh_build(pbvh.get(), {}, {}, @@ -1335,7 +1336,7 @@ void node_update_mask_mesh(const Span mask, PBVHNode &node) static void update_mask_mesh(const Mesh &mesh, const Span nodes) { const AttributeAccessor attributes = mesh.attributes(); - const VArraySpan mask = *attributes.lookup(".sculpt_mask", ATTR_DOMAIN_POINT); + const VArraySpan mask = *attributes.lookup(".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 hide_vert, PBVHNode &node) static void update_visibility_faces(const Mesh &mesh, const Span nodes) { const AttributeAccessor attributes = mesh.attributes(); - const VArraySpan hide_vert = *attributes.lookup(".hide_vert", ATTR_DOMAIN_POINT); + const VArraySpan hide_vert = *attributes.lookup(".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(".hide_poly", ATTR_DOMAIN_FACE); + args.hide_poly = *pbvh.mesh->attributes().lookup(".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 hide_poly = attributes.lookup_or_add_for_write_span( - ".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(); diff --git a/source/blender/blenkernel/intern/pbvh_colors.cc b/source/blender/blenkernel/intern/pbvh_colors.cc index b483b83e806..cff85227c2a 100644 --- a/source/blender/blenkernel/intern/pbvh_colors.cc +++ b/source/blender/blenkernel/intern/pbvh_colors.cc @@ -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 colors{static_cast(pbvh.color_layer->data) + face.start(), face.size()}; @@ -192,7 +191,7 @@ void BKE_pbvh_store_colors_vertex(PBVH *pbvh, const blender::Span indices, blender::MutableSpan 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 { diff --git a/source/blender/blenkernel/intern/pbvh_intern.hh b/source/blender/blenkernel/intern/pbvh_intern.hh index cdbbe881117..6948e8e6183 100644 --- a/source/blender/blenkernel/intern/pbvh_intern.hh +++ b/source/blender/blenkernel/intern/pbvh_intern.hh @@ -188,7 +188,7 @@ struct PBVH { blender::GroupedSpan 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. diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc index 5b3abd59885..305dc4b776d 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels.cc @@ -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(active_uv_name, ATTR_DOMAIN_CORNER); + const VArraySpan uv_map = *attributes.lookup(active_uv_name, AttrDomain::Corner); uv_islands::MeshData mesh_data( pbvh->corner_tris, mesh->corner_verts(), uv_map, pbvh->vert_positions); diff --git a/source/blender/blenkernel/intern/pointcloud.cc b/source/blender/blenkernel/intern/pointcloud.cc index 7281f84dae1..4f47eec89f1 100644 --- a/source/blender/blenkernel/intern/pointcloud.cc +++ b/source/blender/blenkernel/intern/pointcloud.cc @@ -66,7 +66,7 @@ static void pointcloud_init_data(ID *id) CustomData_reset(&pointcloud->pdata); pointcloud->attributes_for_write().add( - "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 positions = pointcloud->positions_for_write(); blender::bke::SpanAttributeWriter radii = attributes.lookup_or_add_for_write_only_span(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)) * diff --git a/source/blender/blenkernel/intern/subdiv_converter_mesh.cc b/source/blender/blenkernel/intern/subdiv_converter_mesh.cc index 67da43953f8..a6c1fd37db9 100644 --- a/source/blender/blenkernel/intern/subdiv_converter_mesh.cc +++ b/source/blender/blenkernel/intern/subdiv_converter_mesh.cc @@ -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(__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("crease_vert", ATTR_DOMAIN_POINT); - user_data->cd_edge_crease = *attributes.lookup("crease_edge", ATTR_DOMAIN_EDGE); + user_data->cd_vertex_crease = *attributes.lookup("crease_vert", AttrDomain::Point); + user_data->cd_edge_crease = *attributes.lookup("crease_edge", AttrDomain::Edge); } user_data->loop_uv_indices = nullptr; initialize_manifold_indices(user_data); diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index a6d9e9150ed..c11812a04a1 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -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( 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( 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(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(capture_node->storage)->data_type = CD_PROP_BOOL; - static_cast(capture_node->storage)->domain = ATTR_DOMAIN_FACE; + static_cast(capture_node->storage)->domain = int8_t( + bke::AttrDomain::Face); bNode *is_smooth_node = nodeAddNode(nullptr, &ntree, "GeometryNodeInputShadeSmooth"); is_smooth_node->parent = node->parent; diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index 95d887a12da..c9ea6b2a452 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -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); } } } diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc index 47f4322fce7..8a4a16c8c0b 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc @@ -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(".select_vert", ATTR_DOMAIN_POINT); - const VArraySpan select_edge = *attributes.lookup(".select_edge", ATTR_DOMAIN_EDGE); - const VArraySpan select_poly = *attributes.lookup(".select_poly", ATTR_DOMAIN_FACE); - const VArraySpan hide_vert = *attributes.lookup(".hide_vert", ATTR_DOMAIN_POINT); - const VArraySpan hide_edge = *attributes.lookup(".hide_edge", ATTR_DOMAIN_EDGE); - const VArraySpan hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); - const VArraySpan material_indices = *attributes.lookup("material_index", ATTR_DOMAIN_FACE); - const VArraySpan sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); - const VArraySpan sharp_edges = *attributes.lookup("sharp_edge", ATTR_DOMAIN_EDGE); - const VArraySpan uv_seams = *attributes.lookup(".uv_seam", ATTR_DOMAIN_EDGE); + const VArraySpan select_vert = *attributes.lookup(".select_vert", AttrDomain::Point); + const VArraySpan select_edge = *attributes.lookup(".select_edge", AttrDomain::Edge); + const VArraySpan select_poly = *attributes.lookup(".select_poly", AttrDomain::Face); + const VArraySpan hide_vert = *attributes.lookup(".hide_vert", AttrDomain::Point); + const VArraySpan hide_edge = *attributes.lookup(".hide_edge", AttrDomain::Edge); + const VArraySpan hide_poly = *attributes.lookup(".hide_poly", AttrDomain::Face); + const VArraySpan material_indices = *attributes.lookup("material_index", AttrDomain::Face); + const VArraySpan sharp_faces = *attributes.lookup("sharp_face", AttrDomain::Face); + const VArraySpan sharp_edges = *attributes.lookup("sharp_edge", AttrDomain::Edge); + const VArraySpan uv_seams = *attributes.lookup(".uv_seam", AttrDomain::Edge); const Span positions = mesh->vert_positions(); Array vtable(mesh->verts_num); @@ -1486,35 +1487,35 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *mesh, const BMeshToMeshParam bke::SpanAttributeWriter sharp_face; bke::SpanAttributeWriter material_index; if (need_select_vert) { - select_vert = attrs.lookup_or_add_for_write_only_span(".select_vert", ATTR_DOMAIN_POINT); + select_vert = attrs.lookup_or_add_for_write_only_span(".select_vert", AttrDomain::Point); } if (need_hide_vert) { - hide_vert = attrs.lookup_or_add_for_write_only_span(".hide_vert", ATTR_DOMAIN_POINT); + hide_vert = attrs.lookup_or_add_for_write_only_span(".hide_vert", AttrDomain::Point); } if (need_select_edge) { - select_edge = attrs.lookup_or_add_for_write_only_span(".select_edge", ATTR_DOMAIN_EDGE); + select_edge = attrs.lookup_or_add_for_write_only_span(".select_edge", AttrDomain::Edge); } if (need_sharp_edge) { - sharp_edge = attrs.lookup_or_add_for_write_only_span("sharp_edge", ATTR_DOMAIN_EDGE); + sharp_edge = attrs.lookup_or_add_for_write_only_span("sharp_edge", AttrDomain::Edge); } if (need_uv_seams) { - uv_seams = attrs.lookup_or_add_for_write_only_span(".uv_seam", ATTR_DOMAIN_EDGE); + uv_seams = attrs.lookup_or_add_for_write_only_span(".uv_seam", AttrDomain::Edge); } if (need_hide_edge) { - hide_edge = attrs.lookup_or_add_for_write_only_span(".hide_edge", ATTR_DOMAIN_EDGE); + hide_edge = attrs.lookup_or_add_for_write_only_span(".hide_edge", AttrDomain::Edge); } if (need_select_poly) { - select_poly = attrs.lookup_or_add_for_write_only_span(".select_poly", ATTR_DOMAIN_FACE); + select_poly = attrs.lookup_or_add_for_write_only_span(".select_poly", AttrDomain::Face); } if (need_hide_poly) { - hide_poly = attrs.lookup_or_add_for_write_only_span(".hide_poly", ATTR_DOMAIN_FACE); + hide_poly = attrs.lookup_or_add_for_write_only_span(".hide_poly", AttrDomain::Face); } if (need_sharp_face) { - sharp_face = attrs.lookup_or_add_for_write_only_span("sharp_face", ATTR_DOMAIN_FACE); + sharp_face = attrs.lookup_or_add_for_write_only_span("sharp_face", AttrDomain::Face); } if (need_material_index) { material_index = attrs.lookup_or_add_for_write_only_span("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 sharp_face; bke::SpanAttributeWriter material_index; if (need_select_vert) { - select_vert = attrs.lookup_or_add_for_write_only_span(".select_vert", ATTR_DOMAIN_POINT); + select_vert = attrs.lookup_or_add_for_write_only_span(".select_vert", AttrDomain::Point); } if (need_hide_vert) { - hide_vert = attrs.lookup_or_add_for_write_only_span(".hide_vert", ATTR_DOMAIN_POINT); + hide_vert = attrs.lookup_or_add_for_write_only_span(".hide_vert", AttrDomain::Point); } if (need_select_edge) { - select_edge = attrs.lookup_or_add_for_write_only_span(".select_edge", ATTR_DOMAIN_EDGE); + select_edge = attrs.lookup_or_add_for_write_only_span(".select_edge", AttrDomain::Edge); } if (need_sharp_edge) { - sharp_edge = attrs.lookup_or_add_for_write_only_span("sharp_edge", ATTR_DOMAIN_EDGE); + sharp_edge = attrs.lookup_or_add_for_write_only_span("sharp_edge", AttrDomain::Edge); } if (need_uv_seams) { - uv_seams = attrs.lookup_or_add_for_write_only_span(".uv_seam", ATTR_DOMAIN_EDGE); + uv_seams = attrs.lookup_or_add_for_write_only_span(".uv_seam", AttrDomain::Edge); } if (need_hide_edge) { - hide_edge = attrs.lookup_or_add_for_write_only_span(".hide_edge", ATTR_DOMAIN_EDGE); + hide_edge = attrs.lookup_or_add_for_write_only_span(".hide_edge", AttrDomain::Edge); } if (need_select_poly) { - select_poly = attrs.lookup_or_add_for_write_only_span(".select_poly", ATTR_DOMAIN_FACE); + select_poly = attrs.lookup_or_add_for_write_only_span(".select_poly", AttrDomain::Face); } if (need_hide_poly) { - hide_poly = attrs.lookup_or_add_for_write_only_span(".hide_poly", ATTR_DOMAIN_FACE); + hide_poly = attrs.lookup_or_add_for_write_only_span(".hide_poly", AttrDomain::Face); } if (need_sharp_face) { - sharp_face = attrs.lookup_or_add_for_write_only_span("sharp_face", ATTR_DOMAIN_FACE); + sharp_face = attrs.lookup_or_add_for_write_only_span("sharp_face", AttrDomain::Face); } if (need_material_index) { material_index = attrs.lookup_or_add_for_write_only_span("material_index", - ATTR_DOMAIN_FACE); + AttrDomain::Face); } /* Loop over all elements in parallel, copying attributes and building the Mesh topology. */ diff --git a/source/blender/draw/DRW_pbvh.hh b/source/blender/draw/DRW_pbvh.hh index 68ab1746e8f..62aad0d019e 100644 --- a/source/blender/draw/DRW_pbvh.hh +++ b/source/blender/draw/DRW_pbvh.hh @@ -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) { } diff --git a/source/blender/draw/engines/overlay/overlay_edit_curves.cc b/source/blender/draw/engines/overlay/overlay_edit_curves.cc index 9ba19ec85e7..ebef0e0eb52 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_curves.cc @@ -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(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. */ diff --git a/source/blender/draw/engines/overlay/overlay_grease_pencil.cc b/source/blender/draw/engines/overlay/overlay_grease_pencil.cc index e1f1222232f..f12026d959d 100644 --- a/source/blender/draw/engines/overlay/overlay_grease_pencil.cc +++ b/source/blender/draw/engines/overlay/overlay_grease_pencil.cc @@ -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) { diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index 6c5cde0a4cb..0d5e6cf4bf9 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -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 selection = *curves.attributes().lookup_or_default( - ".selection", ATTR_DOMAIN_POINT, true); + ".selection", bke::AttrDomain::Point, true); return selection.is_single() && selection.get_internal_single(); } diff --git a/source/blender/draw/intern/draw_attributes.cc b/source/blender/draw/intern/draw_attributes.cc index bfc67c82e3c..80661465443 100644 --- a/source/blender/draw/intern/draw_attributes.cc +++ b/source/blender/draw/intern/draw_attributes.cc @@ -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})) diff --git a/source/blender/draw/intern/draw_attributes.hh b/source/blender/draw/intern/draw_attributes.hh index d754903bea9..848ca1c4784 100644 --- a/source/blender/draw/intern/draw_attributes.hh +++ b/source/blender/draw/intern/draw_attributes.hh @@ -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, diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc index f9bc675619d..721ab76ba70 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc @@ -683,17 +683,17 @@ MeshRenderData *mesh_render_data_create(Object *object, const bke::AttributeAccessor attributes = mr->mesh->attributes(); - mr->material_indices = *attributes.lookup("material_index", ATTR_DOMAIN_FACE); + mr->material_indices = *attributes.lookup("material_index", bke::AttrDomain::Face); - mr->hide_vert = *attributes.lookup(".hide_vert", ATTR_DOMAIN_POINT); - mr->hide_edge = *attributes.lookup(".hide_edge", ATTR_DOMAIN_EDGE); - mr->hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); + mr->hide_vert = *attributes.lookup(".hide_vert", bke::AttrDomain::Point); + mr->hide_edge = *attributes.lookup(".hide_edge", bke::AttrDomain::Edge); + mr->hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); - mr->select_vert = *attributes.lookup(".select_vert", ATTR_DOMAIN_POINT); - mr->select_edge = *attributes.lookup(".select_edge", ATTR_DOMAIN_EDGE); - mr->select_poly = *attributes.lookup(".select_poly", ATTR_DOMAIN_FACE); + mr->select_vert = *attributes.lookup(".select_vert", bke::AttrDomain::Point); + mr->select_edge = *attributes.lookup(".select_edge", bke::AttrDomain::Edge); + mr->select_poly = *attributes.lookup(".select_poly", bke::AttrDomain::Face); - mr->sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + mr->sharp_faces = *attributes.lookup("sharp_face", bke::AttrDomain::Face); } else { /* #BMesh */ diff --git a/source/blender/draw/intern/draw_cache_impl_curve.cc b/source/blender/draw/intern/draw_cache_impl_curve.cc index 1d3e6ab089d..856d6e4f411 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.cc +++ b/source/blender/draw/intern/draw_cache_impl_curve.cc @@ -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(".viewer", - ATTR_DOMAIN_POINT); + bke::AttrDomain::Point); ColorGeometry4f *vbo_data = static_cast(GPU_vertbuf_get_data(vbo_attr)); curves.interpolate_to_evaluated(colors, MutableSpan{vbo_data, vert_len}); } diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 2371ac6ad5b..90baa34bdda 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -271,7 +271,7 @@ static void curves_batch_cache_ensure_edit_points_selection(const bke::CurvesGeo curves.points_num()); const VArray attribute = *curves.attributes().lookup_or_default( - ".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: diff --git a/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc b/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc index 0034c944f67..36a24ee85dc 100644 --- a/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc +++ b/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc @@ -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 selection_float = *attributes.lookup_or_default( - ".selection", ATTR_DOMAIN_POINT, true); + ".selection", bke::AttrDomain::Point, true); edit_points.slice(drawing_start_offset, curves.points_num()).copy_from(curves.positions()); MutableSpan selection_slice = edit_points_selection.slice(drawing_start_offset, @@ -289,7 +289,7 @@ static void grease_pencil_edit_batch_ensure(Object &object, } const VArray selection = *attributes.lookup_or_default( - ".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 selection = *curves.attributes().lookup_or_default( - ".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 radii = info.drawing.radii(); const VArray opacities = info.drawing.opacities(); const VArray vertex_colors = *attributes.lookup_or_default( - "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 selection_float = *attributes.lookup_or_default( - ".selection", ATTR_DOMAIN_POINT, true); + ".selection", bke::AttrDomain::Point, true); const VArray start_caps = *attributes.lookup_or_default( - "start_cap", ATTR_DOMAIN_CURVE, 0); + "start_cap", bke::AttrDomain::Curve, 0); const VArray end_caps = *attributes.lookup_or_default( - "end_cap", ATTR_DOMAIN_CURVE, 0); + "end_cap", bke::AttrDomain::Curve, 0); const VArray materials = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_CURVE, 0); + "material_index", bke::AttrDomain::Curve, 0); const Span triangles = info.drawing.triangles(); const Span verts_start_offsets = verts_start_offsets_per_visible_drawing[drawing_i]; const Span tris_start_offsets = tris_start_offsets_per_visible_drawing[drawing_i]; diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.cc b/source/blender/draw/intern/draw_cache_impl_mesh.cc index 5acc13ccd6b..70c45e6ed4b 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.cc +++ b/source/blender/draw/intern/draw_cache_impl_mesh.cc @@ -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(gpu_attr->type); int layer = -1; - std::optional domain; + std::optional 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); } } }; diff --git a/source/blender/draw/intern/draw_cache_impl_pointcloud.cc b/source/blender/draw/intern/draw_cache_impl_pointcloud.cc index 5451a615a6b..9a4d2f11729 100644 --- a/source/blender/draw/intern/draw_cache_impl_pointcloud.cc +++ b/source/blender/draw/intern/draw_cache_impl_pointcloud.cc @@ -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); diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index a82cf8e68d5..42ca5af5a00 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -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 material_indices = *attributes.lookup_or_default( - "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(MEM_callocN(sizeof(int) * mat_len, "subdiv mat_start")); diff --git a/source/blender/draw/intern/draw_curves.cc b/source/blender/draw/intern/draw_curves.cc index 3e2a9a60df9..44758adf14a 100644 --- a/source/blender/draw/intern/draw_curves.cc +++ b/source/blender/draw/intern/draw_curves.cc @@ -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 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 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; } } diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc index 68941ae5f27..251284cbee0 100644 --- a/source/blender/draw/intern/draw_manager_data.cc +++ b/source/blender/draw/intern/draw_manager_data.cc @@ -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}); } } } diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc index 6882652696f..420db9ba40b 100644 --- a/source/blender/draw/intern/draw_pbvh.cc +++ b/source/blender/draw/intern/draw_pbvh.cc @@ -66,7 +66,7 @@ static bool pbvh_attr_supported(const AttributeRequest &request) return true; } const GenericRequest &attr = std::get(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(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("sharp_face", ATTR_DOMAIN_FACE); + const VArraySpan sharp_faces = *attributes.lookup("sharp_face", bke::AttrDomain::Face); short4 *data = static_cast(GPU_vertbuf_get_data(&vert_buf)); @@ -500,7 +500,8 @@ struct PBVHBatches { case CustomRequest::Normal: { const Span grid_to_face_map = args.subdiv_ccg->grid_to_face_map; const bke::AttributeAccessor attributes = args.mesh->attributes(); - const VArraySpan sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + const VArraySpan sharp_faces = *attributes.lookup("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 face_sets = *attributes.lookup(".sculpt_face_set", - ATTR_DOMAIN_FACE)) { + bke::AttrDomain::Face)) + { const VArraySpan 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(GPU_vertbuf_get_data(&vert_buf)); if (const VArray mask = *attributes.lookup(".sculpt_mask", - ATTR_DOMAIN_POINT)) { + bke::AttrDomain::Point)) { const VArraySpan mask_span(mask); const Span corner_verts = args.corner_verts; const Span corner_tris = args.corner_tris; @@ -707,7 +709,8 @@ struct PBVHBatches { case CustomRequest::FaceSet: { uchar4 *data = static_cast(GPU_vertbuf_get_data(vbo.vert_buf)); if (const VArray face_sets = *attributes.lookup(".sculpt_face_set", - ATTR_DOMAIN_FACE)) { + bke::AttrDomain::Face)) + { const VArraySpan 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(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(args, attribute.typed(), vert_buf); break; - case ATTR_DOMAIN_FACE: + case bke::AttrDomain::Face: extract_data_face_faces(args, attribute.typed(), vert_buf); break; - case ATTR_DOMAIN_CORNER: + case bke::AttrDomain::Corner: extract_data_corner_faces(args, attribute.typed(), vert_buf); break; default: @@ -912,20 +915,20 @@ struct PBVHBatches { else { const GenericRequest &request = std::get(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(args, cd_offset, *vbo.vert_buf); break; - case ATTR_DOMAIN_FACE: + case bke::AttrDomain::Face: extract_data_face_bmesh(args, cd_offset, *vbo.vert_buf); break; - case ATTR_DOMAIN_CORNER: + case bke::AttrDomain::Corner: extract_data_corner_bmesh(args, cd_offset, *vbo.vert_buf); break; default: @@ -974,7 +977,7 @@ struct PBVHBatches { else { const GenericRequest &attr = std::get(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( - "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 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("sharp_face", ATTR_DOMAIN_FACE); + const VArraySpan sharp_faces = *attributes.lookup("sharp_face", bke::AttrDomain::Face); const VArray material_indices = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_FACE, 0); + "material_index", bke::AttrDomain::Face, 0); const BitGroupVector<> &grid_hidden = args.subdiv_ccg->grid_hidden; const Span grid_to_face_map = args.subdiv_ccg->grid_to_face_map; diff --git a/source/blender/draw/intern/draw_sculpt.cc b/source/blender/draw/intern/draw_sculpt.cc index fd674bb4d57..19d20cb9bba 100644 --- a/source/blender/draw/intern/draw_sculpt.cc +++ b/source/blender/draw/intern/draw_sculpt.cc @@ -147,7 +147,7 @@ Vector 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 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}); } } } diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc index 9404aa7e3f9..c7f13056b1e 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc @@ -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(*mr.bm, cd_offset, vbo); break; - case ATTR_DOMAIN_EDGE: + case bke::AttrDomain::Edge: extract_data_bmesh_edge(*mr.bm, cd_offset, vbo); break; - case ATTR_DOMAIN_FACE: + case bke::AttrDomain::Face: extract_data_bmesh_face(*mr.bm, cd_offset, vbo); break; - case ATTR_DOMAIN_CORNER: + case bke::AttrDomain::Corner: extract_data_bmesh_loop(*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(), mr.corner_verts, vbo); break; - case ATTR_DOMAIN_EDGE: + case bke::AttrDomain::Edge: extract_data_mesh_mapped_corner(attribute.typed(), mr.corner_edges, vbo); break; - case ATTR_DOMAIN_FACE: + case bke::AttrDomain::Face: extract_data_mesh_face(mr.faces, attribute.typed(), vbo); break; - case ATTR_DOMAIN_CORNER: + case bke::AttrDomain::Corner: vertbuf_data_extract_direct(attribute.typed(), 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( - 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); } diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc index f802c99ece0..a68292fb65a 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc @@ -81,8 +81,9 @@ static void extract_sculpt_data_init(const MeshRenderData &mr, } else { const bke::AttributeAccessor attributes = mr.mesh->attributes(); - const VArray mask = *attributes.lookup(".sculpt_mask", ATTR_DOMAIN_POINT); - const VArray face_set = *attributes.lookup(".sculpt_face_set", ATTR_DOMAIN_FACE); + const VArray mask = *attributes.lookup(".sculpt_mask", bke::AttrDomain::Point); + const VArray face_set = *attributes.lookup(".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 mask = *attributes.lookup(".sculpt_mask", ATTR_DOMAIN_POINT); + const VArray mask = *attributes.lookup(".sculpt_mask", bke::AttrDomain::Point); const OffsetIndices coarse_faces = coarse_mesh->faces(); const Span 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 cd_face_sets = *attributes.lookup(".sculpt_face_set", ATTR_DOMAIN_FACE); + const VArray cd_face_sets = *attributes.lookup(".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); diff --git a/source/blender/editors/curves/intern/curves_add.cc b/source/blender/editors/curves/intern/curves_add.cc index 58f15783f35..c0b2034a455 100644 --- a/source/blender/editors/curves/intern/curves_add.cc +++ b/source/blender/editors/curves/intern/curves_add.cc @@ -110,7 +110,7 @@ bke::CurvesGeometry primitive_random_sphere(const int curves_size, const int poi MutableSpan positions = curves.positions_for_write(); bke::MutableAttributeAccessor attributes = curves.attributes_for_write(); bke::SpanAttributeWriter radius = attributes.lookup_or_add_for_write_only_span( - "radius", ATTR_DOMAIN_POINT); + "radius", bke::AttrDomain::Point); for (const int i : offsets.index_range()) { offsets[i] = points_per_curve * i; diff --git a/source/blender/editors/curves/intern/curves_attribute_set.cc b/source/blender/editors/curves/intern/curves_attribute_set.cc index f2335f0f890..871bd4a1c86 100644 --- a/source/blender/editors/curves/intern/curves_attribute_set.cc +++ b/source/blender/editors/curves/intern/curves_attribute_set.cc @@ -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); diff --git a/source/blender/editors/curves/intern/curves_draw.cc b/source/blender/editors/curves/intern/curves_draw.cc index ea23c1ffd10..94038811f21 100644 --- a/source/blender/editors/curves/intern/curves_draw.cc +++ b/source/blender/editors/curves/intern/curves_draw.cc @@ -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 radii = attributes.lookup_or_add_for_write_only_span( - "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 selection = attributes.lookup_or_add_for_write( - ".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 positions = curves.positions_for_write(); bke::SpanAttributeWriter radii = attributes.lookup_or_add_for_write_only_span( - "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 selection = attributes.lookup_or_add_for_write( - ".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); diff --git a/source/blender/editors/curves/intern/curves_edit.cc b/source/blender/editors/curves/intern/curves_edit.cc index 6e5f7b4bd10..7f296ff9a8a 100644 --- a/source/blender/editors/curves/intern/curves_edit.cc +++ b/source/blender/editors/curves/intern/curves_edit.cc @@ -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 selection = *attributes.lookup_or_default( @@ -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 selection = attributes.lookup_or_add_for_write_span( - ".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 selection = attributes.lookup_or_add_for_write_span( - ".selection", ATTR_DOMAIN_CURVE); + ".selection", bke::AttrDomain::Curve); selection.span.take_back(mask.size()).fill(true); selection.finish(); } diff --git a/source/blender/editors/curves/intern/curves_masks.cc b/source/blender/editors/curves/intern/curves_masks.cc index 0e9e4bcc899..0459d6465f7 100644 --- a/source/blender/editors/curves/intern/curves_masks.cc +++ b/source/blender/editors/curves/intern/curves_masks.cc @@ -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) diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index 231cf2bb067..30ddd154cb1 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -169,7 +169,7 @@ static bool editable_curves_point_domain_poll(bContext *C) return false; } const Curves *curves_id = static_cast(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(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: diff --git a/source/blender/editors/curves/intern/curves_selection.cc b/source/blender/editors/curves/intern/curves_selection.cc index 67c3bd7ef8e..d3f25e3a699 100644 --- a/source/blender/editors/curves/intern/curves_selection.cc +++ b/source/blender/editors/curves/intern/curves_selection.cc @@ -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 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 selection = *attributes.lookup_or_default( - ".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 selection = *attributes.lookup_or_default( - ".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(".selection", ATTR_DOMAIN_POINT, true), memory); + *curves.attributes().lookup_or_default(".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 cyclic = curves.cyclic(); MutableSpan selection_typed = selection.span.typed(); @@ -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 cyclic = curves.cyclic(); if (deselect) { @@ -655,12 +656,12 @@ std::optional closest_elem_find_screen_space( const OffsetIndices points_by_curve, const Span 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 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 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 positions, const IndexMask &mask, - const eAttrDomain selection_domain, + const bke::AttrDomain selection_domain, const Span 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 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) { diff --git a/source/blender/editors/geometry/geometry_attributes.cc b/source/blender/editors/geometry/geometry_attributes.cc index c0fb7237b84..32c5730505f 100644 --- a/source/blender/editors/geometry/geometry_attributes.cc +++ b/source/blender/editors/geometry/geometry_attributes.cc @@ -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 src_weights(mesh->verts_num); VArray src_varray = *attributes.lookup_or_default( - 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; diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_add.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_add.cc index 10ecbf0a535..ae2262acb4d 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_add.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_add.cc @@ -1148,19 +1148,19 @@ static bke::CurvesGeometry create_drawing_data(const Span positions, curves.transform(matrix); SpanAttributeWriter point_radii = attributes.lookup_or_add_for_write_only_span( - "radius", ATTR_DOMAIN_POINT); + "radius", AttrDomain::Point); point_radii.span.copy_from(radii); SpanAttributeWriter point_opacities = attributes.lookup_or_add_for_write_span( - "opacity", ATTR_DOMAIN_POINT); + "opacity", AttrDomain::Point); point_opacities.span.copy_from(opacities); SpanAttributeWriter stroke_cyclic = attributes.lookup_or_add_for_write_span( - "cyclic", ATTR_DOMAIN_CURVE); + "cyclic", AttrDomain::Curve); stroke_cyclic.span.fill(false); SpanAttributeWriter stroke_materials = attributes.lookup_or_add_for_write_span( - "material_index", ATTR_DOMAIN_CURVE); + "material_index", AttrDomain::Curve); stroke_materials.span.copy_from(materials); point_radii.finish(); diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc index 9da7baa2235..a776f4d4490 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc @@ -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 cyclic = curves.cyclic(); const VArray point_selection = *curves.attributes().lookup_or_default( - ".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 cyclic = curves.cyclic(); const OffsetIndices points_by_curve = curves.points_by_curve(); const VArray selection = *curves.attributes().lookup_or_default( - ".selection", ATTR_DOMAIN_POINT, true); + ".selection", bke::AttrDomain::Point, true); /* Mark all points in the editable curves to be deleted. */ Array 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(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 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 get_points_to_dissolve(bke::CurvesGeometry &curves, const DissolveMode mode) { const VArray selection = *curves.attributes().lookup_or_default( - ".selection", ATTR_DOMAIN_POINT, true); + ".selection", bke::AttrDomain::Point, true); Array 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 materials = curves.attributes_for_write().lookup_or_add_for_write_span("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 materials = *curves.attributes().lookup_or_default( - "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 start_caps = - attributes.lookup_or_add_for_write_span("start_cap", ATTR_DOMAIN_CURVE); + attributes.lookup_or_add_for_write_span("start_cap", bke::AttrDomain::Curve); bke::SpanAttributeWriter end_caps = attributes.lookup_or_add_for_write_span( - "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 caps = attributes.lookup_or_add_for_write_span( - "start_cap", ATTR_DOMAIN_CURVE); + "start_cap", bke::AttrDomain::Curve); toggle_caps(caps.span, strokes); caps.finish(); break; } case CapsMode::END: { bke::SpanAttributeWriter caps = attributes.lookup_or_add_for_write_span( - "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(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 changed = false; const Array 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(); diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_material.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_material.cc index 060104342d0..aea8264185d 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_material.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_material.cc @@ -285,7 +285,7 @@ static int grease_pencil_material_lock_unselected_exec(bContext *C, wmOperator * AttributeAccessor attributes = info.drawing.strokes().attributes(); const VArray material_indices = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_CURVE, 0); + "material_index", AttrDomain::Curve, 0); if (const std::optional single = material_indices.get_if_single()) { materials_used.add(*single); diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc index 3ba86e76bec..e6cb2cfa62f 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc @@ -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(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 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(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 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(object->data); Span 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() diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc index 9b8e7990fd7..4ae394d1545 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc @@ -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 materials = *attributes.lookup("material_index", ATTR_DOMAIN_CURVE); + const VArray materials = *attributes.lookup("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 materials = *attributes.lookup("material_index", ATTR_DOMAIN_POINT); + const VArray materials = *attributes.lookup("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 materials = *attributes.lookup_or_default( - "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 {}; diff --git a/source/blender/editors/include/ED_curves.hh b/source/blender/editors/include/ED_curves.hh index ccf4630d39f..505d6a6b516 100644 --- a/source/blender/editors/include/ED_curves.hh +++ b/source/blender/editors/include/ED_curves.hh @@ -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 closest_elem_find_screen_space(const ViewContext OffsetIndices points_by_curve, Span 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 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 deformed_positions, const IndexMask &mask, - eAttrDomain selection_domain, + bke::AttrDomain selection_domain, Span coords, eSelectOp sel_op); @@ -271,7 +271,7 @@ bool select_circle(const ViewContext &vc, bke::CurvesGeometry &curves, Span 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); diff --git a/source/blender/editors/include/ED_geometry.hh b/source/blender/editors/include/ED_geometry.hh index 72172d50f3c..b8ed845412b 100644 --- a/source/blender/editors/include/ED_geometry.hh +++ b/source/blender/editors/include/ED_geometry.hh @@ -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 { diff --git a/source/blender/editors/include/ED_grease_pencil.hh b/source/blender/editors/include/ED_grease_pencil.hh index f2a498a2475..37b7d370447 100644 --- a/source/blender/editors/include/ED_grease_pencil.hh +++ b/source/blender/editors/include/ED_grease_pencil.hh @@ -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); diff --git a/source/blender/editors/interface/interface_template_attribute_search.cc b/source/blender/editors/interface/interface_template_attribute_search.cc index d91cee813c5..434f9c53bb0 100644 --- a/source/blender/editors/interface/interface_template_attribute_search.cc +++ b/source/blender/editors/interface/interface_template_attribute_search.cc @@ -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)); } diff --git a/source/blender/editors/mesh/editface.cc b/source/blender/editors/mesh/editface.cc index 56c7b7d0e68..01588560bbb 100644 --- a/source/blender/editors/mesh/editface.cc +++ b/source/blender/editors/mesh/editface.cc @@ -87,18 +87,19 @@ void paintface_flush_flags(bContext *C, /* Update the COW copy of the mesh. */ if (flush_hidden) { const VArray hide_poly_me = *attributes_me.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", bke::AttrDomain::Face, false); bke::SpanAttributeWriter hide_poly_orig = - attributes_orig.lookup_or_add_for_write_only_span(".hide_poly", ATTR_DOMAIN_FACE); + attributes_orig.lookup_or_add_for_write_only_span(".hide_poly", + bke::AttrDomain::Face); hide_poly_me.materialize(hide_poly_orig.span); hide_poly_orig.finish(); } if (flush_selection) { const VArray select_poly_me = *attributes_me.lookup_or_default( - ".select_poly", ATTR_DOMAIN_FACE, false); + ".select_poly", bke::AttrDomain::Face, false); bke::SpanAttributeWriter select_poly_orig = attributes_orig.lookup_or_add_for_write_only_span(".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 hide_poly_orig = *attributes_orig.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", bke::AttrDomain::Face, false); bke::SpanAttributeWriter hide_poly_eval = attributes_eval.lookup_or_add_for_write_only_span(".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 select_poly_orig = *attributes_orig.lookup_or_default( - ".select_poly", ATTR_DOMAIN_FACE, false); + ".select_poly", bke::AttrDomain::Face, false); bke::SpanAttributeWriter select_poly_eval = attributes_eval.lookup_or_add_for_write_only_span(".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 hide_poly = attributes.lookup_or_add_for_write_span( - ".hide_poly", ATTR_DOMAIN_FACE); + ".hide_poly", bke::AttrDomain::Face); bke::SpanAttributeWriter select_poly = attributes.lookup_or_add_for_write_span( - ".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 hide_poly = *attributes.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", bke::AttrDomain::Face, false); bke::SpanAttributeWriter select_poly = attributes.lookup_or_add_for_write_span( - ".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 uv_seams = *attributes.lookup_or_default( - ".uv_seam", ATTR_DOMAIN_EDGE, false); + ".uv_seam", bke::AttrDomain::Edge, false); const VArray hide_poly = *attributes.lookup_or_default( - ".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 uv_seams = *attributes.lookup_or_default( - ".uv_seam", ATTR_DOMAIN_EDGE, false); + ".uv_seam", bke::AttrDomain::Edge, false); bke::SpanAttributeWriter select_poly = attributes.lookup_or_add_for_write_span( - ".select_poly", ATTR_DOMAIN_FACE); + ".select_poly", bke::AttrDomain::Face); Set 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 select_poly = attributes.lookup_or_add_for_write_span( - ".select_poly", ATTR_DOMAIN_FACE); + ".select_poly", bke::AttrDomain::Face); Vector 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 hide_poly = *attributes.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", bke::AttrDomain::Face, false); const Span 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 select_poly = attributes.lookup_or_add_for_write_span( - ".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 select_poly = attributes.lookup_or_add_for_write_span( - ".select_poly", ATTR_DOMAIN_FACE); + ".select_poly", bke::AttrDomain::Face); bke::SpanAttributeWriter select_vert = attributes.lookup_or_add_for_write_span( - ".select_vert", ATTR_DOMAIN_POINT); + ".select_vert", bke::AttrDomain::Point); const VArray hide_poly = *attributes.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", bke::AttrDomain::Face, false); const OffsetIndices faces = mesh->faces(); const Span 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 select_poly = attributes.lookup_or_add_for_write_span( - ".select_poly", ATTR_DOMAIN_FACE); + ".select_poly", bke::AttrDomain::Face); const VArray hide_poly = *attributes.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", bke::AttrDomain::Face, false); const OffsetIndices faces = mesh->faces(); const Span 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 hide_poly = *attributes.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", bke::AttrDomain::Face, false); bke::SpanAttributeWriter select_poly = attributes.lookup_or_add_for_write_span( - ".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 corner_verts = mesh->corner_verts(); bke::AttributeAccessor attributes = mesh->attributes(); const VArray hide_poly = *attributes.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", bke::AttrDomain::Face, false); const VArray select_poly = *attributes.lookup_or_default( - ".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 hide_poly = *attributes.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", bke::AttrDomain::Face, false); bke::AttributeWriter select_poly = attributes.lookup_or_add_for_write( - ".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 hide_vert_orig = *attributes_orig.lookup_or_default( - ".hide_vert", ATTR_DOMAIN_POINT, false); + ".hide_vert", bke::AttrDomain::Point, false); bke::SpanAttributeWriter hide_vert_eval = - attributes_eval.lookup_or_add_for_write_only_span(".hide_vert", ATTR_DOMAIN_POINT); + attributes_eval.lookup_or_add_for_write_only_span(".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 select_vert_orig = *attributes_orig.lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", bke::AttrDomain::Point, false); bke::SpanAttributeWriter select_vert_eval = - attributes_eval.lookup_or_add_for_write_only_span(".select_vert", ATTR_DOMAIN_POINT); + attributes_eval.lookup_or_add_for_write_only_span(".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 select_vert = attributes.lookup_or_add_for_write_span( - ".select_vert", ATTR_DOMAIN_POINT); + ".select_vert", bke::AttrDomain::Point); Set 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 select_vert = - attributes.lookup_or_add_for_write_span(".select_vert", ATTR_DOMAIN_POINT); + attributes.lookup_or_add_for_write_span(".select_vert", bke::AttrDomain::Point); blender::Vector 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 select_vert = attributes.lookup_or_add_for_write_span( - ".select_vert", ATTR_DOMAIN_POINT); + ".select_vert", bke::AttrDomain::Point); const VArray hide_edge = *attributes.lookup_or_default( - ".hide_edge", ATTR_DOMAIN_EDGE, false); + ".hide_edge", bke::AttrDomain::Edge, false); const VArray hide_poly = *attributes.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", bke::AttrDomain::Face, false); const OffsetIndices faces = mesh->faces(); const Span 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 select_vert = attributes.lookup_or_add_for_write_span( - ".select_vert", ATTR_DOMAIN_POINT); + ".select_vert", bke::AttrDomain::Point); const VArray hide_edge = *attributes.lookup_or_default( - ".hide_edge", ATTR_DOMAIN_EDGE, false); + ".hide_edge", bke::AttrDomain::Edge, false); const VArray hide_poly = *attributes.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", bke::AttrDomain::Face, false); const OffsetIndices faces = mesh->faces(); const Span 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 hide_vert = *attributes.lookup_or_default( - ".hide_vert", ATTR_DOMAIN_POINT, false); + ".hide_vert", bke::AttrDomain::Point, false); bke::SpanAttributeWriter select_vert = attributes.lookup_or_add_for_write_span( - ".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 hide_vert = *attributes.lookup_or_default( - ".hide_vert", ATTR_DOMAIN_POINT, false); + ".hide_vert", bke::AttrDomain::Point, false); bke::SpanAttributeWriter select_vert = attributes.lookup_or_add_for_write_span( - ".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 hide_vert = attributes.lookup_or_add_for_write_span( - ".hide_vert", ATTR_DOMAIN_POINT); + ".hide_vert", bke::AttrDomain::Point); bke::SpanAttributeWriter select_vert = attributes.lookup_or_add_for_write_span( - ".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 hide_vert = *attributes.lookup_or_default( - ".hide_vert", ATTR_DOMAIN_POINT, false); + ".hide_vert", bke::AttrDomain::Point, false); bke::SpanAttributeWriter select_vert = attributes.lookup_or_add_for_write_span( - ".select_vert", ATTR_DOMAIN_POINT); + ".select_vert", bke::AttrDomain::Point); for (const int i : select_vert.span.index_range()) { if (hide_vert[i]) { diff --git a/source/blender/editors/mesh/editmesh_attribute.cc b/source/blender/editors/mesh/editmesh_attribute.cc index 66fa655753b..c9da8a0b5b0 100644 --- a/source/blender/editors/mesh/editmesh_attribute.cc +++ b/source/blender/editors/mesh/editmesh_attribute.cc @@ -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); diff --git a/source/blender/editors/mesh/editmesh_select.cc b/source/blender/editors/mesh/editmesh_select.cc index 03ea5a3979e..28fcbfc9934 100644 --- a/source/blender/editors/mesh/editmesh_select.cc +++ b/source/blender/editors/mesh/editmesh_select.cc @@ -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 domain_to_iter_type(const eAttrDomain domain) +static std::optional 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 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 iter_type = domain_to_iter_type( diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc index 02c28bbe5af..557d7ba0bd2 100644 --- a/source/blender/editors/mesh/mesh_data.cc +++ b/source/blender/editors/mesh/mesh_data.cc @@ -395,13 +395,14 @@ void ED_mesh_uv_ensure(Mesh *mesh, const char *name) int ED_mesh_color_add( Mesh *mesh, const char *name, const bool active_set, const bool do_init, ReportList *reports) { + using namespace blender; /* If no name is supplied, provide a backwards compatible default. */ if (!name) { name = "Col"; } CustomDataLayer *layer = BKE_id_attribute_new( - &mesh->id, name, CD_PROP_BYTE_COLOR, ATTR_DOMAIN_CORNER, reports); + &mesh->id, name, CD_PROP_BYTE_COLOR, bke::AttrDomain::Corner, reports); if (do_init) { const char *active_name = mesh->active_color_attribute; @@ -442,8 +443,10 @@ bool ED_mesh_color_ensure(Mesh *mesh, const char *name) char unique_name[MAX_CUSTOMDATA_LAYER_NAME]; BKE_id_attribute_calc_unique_name(&mesh->id, name, unique_name); - if (!mesh->attributes_for_write().add( - unique_name, ATTR_DOMAIN_CORNER, CD_PROP_BYTE_COLOR, bke::AttributeInitDefaultValue())) + if (!mesh->attributes_for_write().add(unique_name, + bke::AttrDomain::Corner, + CD_PROP_BYTE_COLOR, + bke::AttributeInitDefaultValue())) { return false; } @@ -810,7 +813,7 @@ static void mesh_add_verts(Mesh *mesh, int len) bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter select_vert = attributes.lookup_or_add_for_write_span( - ".select_vert", ATTR_DOMAIN_POINT); + ".select_vert", bke::AttrDomain::Point); select_vert.span.take_back(len).fill(true); select_vert.finish(); } @@ -846,7 +849,7 @@ static void mesh_add_edges(Mesh *mesh, int len) bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter select_edge = attributes.lookup_or_add_for_write_span( - ".select_edge", ATTR_DOMAIN_EDGE); + ".select_edge", bke::AttrDomain::Edge); select_edge.span.take_back(len).fill(true); select_edge.finish(); } @@ -921,7 +924,7 @@ static void mesh_add_faces(Mesh *mesh, int len) bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter select_poly = attributes.lookup_or_add_for_write_span( - ".select_poly", ATTR_DOMAIN_FACE); + ".select_poly", bke::AttrDomain::Face); select_poly.span.take_back(len).fill(true); select_poly.finish(); } @@ -1137,7 +1140,7 @@ void ED_mesh_split_faces(Mesh *mesh) const Span corner_edges = mesh->corner_edges(); const bke::AttributeAccessor attributes = mesh->attributes(); const VArray mesh_sharp_edges = *attributes.lookup_or_default( - "sharp_edge", ATTR_DOMAIN_EDGE, false); + "sharp_edge", bke::AttrDomain::Edge, false); const bool *sharp_faces = static_cast( CustomData_get_layer_named(&mesh->face_data, CD_PROP_BOOL, "sharp_face")); diff --git a/source/blender/editors/mesh/meshtools.cc b/source/blender/editors/mesh/meshtools.cc index 636b99bee76..2ba2dbf0a69 100644 --- a/source/blender/editors/mesh/meshtools.cc +++ b/source/blender/editors/mesh/meshtools.cc @@ -1390,7 +1390,7 @@ bool ED_mesh_pick_vert( data.mval_f = mval_f; data.len_best = FLT_MAX; data.v_idx_best = -1; - data.hide_vert = *attributes.lookup(".hide_vert", ATTR_DOMAIN_POINT); + data.hide_vert = *attributes.lookup(".hide_vert", bke::AttrDomain::Point); BKE_mesh_foreach_mapped_vert(me_eval, ed_mesh_pick_vert__mapFunc, &data, MESH_FOREACH_NOP); diff --git a/source/blender/editors/object/object_bake.cc b/source/blender/editors/object/object_bake.cc index e0e1925f7d8..4687a1a3d34 100644 --- a/source/blender/editors/object/object_bake.cc +++ b/source/blender/editors/object/object_bake.cc @@ -167,7 +167,7 @@ static bool multiresbake_check(bContext *C, wmOperator *op) else { const bke::AttributeAccessor attributes = mesh->attributes(); const VArraySpan material_indices = *attributes.lookup("material_index", - ATTR_DOMAIN_FACE); + bke::AttrDomain::Face); a = mesh->faces_num; while (ok && a--) { Image *ima = bake_object_image_get(ob, diff --git a/source/blender/editors/object/object_bake_api.cc b/source/blender/editors/object/object_bake_api.cc index 679a8824a4f..04a217ff3d6 100644 --- a/source/blender/editors/object/object_bake_api.cc +++ b/source/blender/editors/object/object_bake_api.cc @@ -23,7 +23,7 @@ #include "BLI_path_util.h" #include "BLI_string.h" -#include "BKE_attribute.h" +#include "BKE_attribute.hh" #include "BKE_callbacks.h" #include "BKE_context.hh" #include "BKE_editmesh.hh" @@ -1177,18 +1177,19 @@ static void convert_float_color_to_byte_color(const MPropCol *float_colors, static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob) { + using namespace blender; Mesh *mesh = static_cast(ob->data); BMEditMesh *em = mesh->edit_mesh; const CustomDataLayer *active_color_layer = BKE_id_attributes_color_find( &mesh->id, mesh->active_color_attribute); BLI_assert(active_color_layer != nullptr); - const eAttrDomain domain = BKE_id_attribute_domain(&mesh->id, active_color_layer); + const bke::AttrDomain domain = BKE_id_attribute_domain(&mesh->id, active_color_layer); const int channels_num = targets->channels_num; const bool is_noncolor = targets->is_noncolor; const float *result = targets->result; - if (domain == ATTR_DOMAIN_POINT) { + if (domain == bke::AttrDomain::Point) { const int totvert = mesh->verts_num; const int totloop = mesh->corners_num; @@ -1248,7 +1249,7 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob) MEM_SAFE_FREE(num_loops_for_vertex); } - else if (domain == ATTR_DOMAIN_CORNER) { + else if (domain == bke::AttrDomain::Corner) { if (em) { /* Copy to bmesh. */ const int active_color_offset = CustomData_get_offset_named( diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index 3aef5b4703c..aa04f82c00b 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -668,7 +668,7 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList * /*reports*/, bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter select_vert = attributes.lookup_or_add_for_write_span( - ".select_vert", ATTR_DOMAIN_POINT); + ".select_vert", bke::AttrDomain::Point); int edge_index = 0; @@ -911,7 +911,7 @@ static bool modifier_apply_shape(Main *bmain, } static bool meta_data_matches(const std::optional meta_data, - const eAttrDomainMask domains, + const AttrDomainMask domains, const eCustomDataMask types) { if (!meta_data) { diff --git a/source/blender/editors/object/object_remesh.cc b/source/blender/editors/object/object_remesh.cc index 5d5badd40a6..6911765766c 100644 --- a/source/blender/editors/object/object_remesh.cc +++ b/source/blender/editors/object/object_remesh.cc @@ -167,7 +167,7 @@ static int voxel_remesh_exec(bContext *C, wmOperator *op) } else { const VArray sharp_face = *mesh->attributes().lookup_or_default( - "sharp_face", ATTR_DOMAIN_FACE, false); + "sharp_face", bke::AttrDomain::Face, false); bke::mesh_smooth_set(*new_mesh, !sharp_face[0]); } diff --git a/source/blender/editors/object/object_transform.cc b/source/blender/editors/object/object_transform.cc index 1bc319f8620..eb8a8f38e6d 100644 --- a/source/blender/editors/object/object_transform.cc +++ b/source/blender/editors/object/object_transform.cc @@ -960,7 +960,7 @@ static int apply_objects_internal(bContext *C, PointCloud &pointcloud = *static_cast(ob->data); bke::MutableAttributeAccessor attributes = pointcloud.attributes_for_write(); bke::SpanAttributeWriter position = attributes.lookup_or_add_for_write_span( - "position", ATTR_DOMAIN_POINT); + "position", bke::AttrDomain::Point); transform_positions(position.span, float4x4(mat)); position.finish(); } @@ -1723,7 +1723,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) PointCloud &pointcloud = *static_cast(ob->data); bke::MutableAttributeAccessor attributes = pointcloud.attributes_for_write(); bke::SpanAttributeWriter positions = attributes.lookup_or_add_for_write_span( - "position", ATTR_DOMAIN_POINT); + "position", bke::AttrDomain::Point); if (ELEM(centermode, ORIGIN_TO_CENTER_OF_MASS_SURFACE, ORIGIN_TO_CENTER_OF_MASS_VOLUME) || !ELEM(around, V3D_AROUND_CENTER_BOUNDS, V3D_AROUND_CENTER_MEDIAN)) { diff --git a/source/blender/editors/object/object_vgroup.cc b/source/blender/editors/object/object_vgroup.cc index d0d2990802e..cfd08d91089 100644 --- a/source/blender/editors/object/object_vgroup.cc +++ b/source/blender/editors/object/object_vgroup.cc @@ -212,7 +212,7 @@ bool ED_vgroup_parray_alloc(ID *id, if (use_vert_sel) { const bke::AttributeAccessor attributes = mesh->attributes(); const VArray select_vert = *attributes.lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", bke::AttrDomain::Point, false); for (int i = 0; i < mesh->verts_num; i++) { (*dvert_arr)[i] = select_vert[i] ? &dverts[i] : nullptr; @@ -676,7 +676,7 @@ static void vgroup_copy_active_to_sel(Object *ob, eVGroupSelect subset_type) else { const bke::AttributeAccessor attributes = mesh->attributes(); const VArray select_vert = *attributes.lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", bke::AttrDomain::Point, false); int v_act; @@ -1062,9 +1062,10 @@ static void vgroup_select_verts(Object *ob, int select) if (!dverts.is_empty()) { bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); const VArray hide_vert = *attributes.lookup_or_default( - ".hide_vert", ATTR_DOMAIN_POINT, false); + ".hide_vert", bke::AttrDomain::Point, false); bke::SpanAttributeWriter select_vert = - attributes.lookup_or_add_for_write_only_span(".select_vert", ATTR_DOMAIN_POINT); + attributes.lookup_or_add_for_write_only_span(".select_vert", + bke::AttrDomain::Point); for (const int i : select_vert.span.index_range()) { if (!hide_vert[i]) { @@ -1625,7 +1626,7 @@ static void vgroup_smooth_subset(Object *ob, else { const bke::AttributeAccessor attributes = mesh->attributes(); const VArray select_vert = *attributes.lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", bke::AttrDomain::Point, false); const blender::Span edges = mesh->edges(); for (int i = 0; i < dvert_tot; i++) { @@ -1701,7 +1702,7 @@ static void vgroup_smooth_subset(Object *ob, else { const bke::AttributeAccessor attributes = mesh->attributes(); const VArray select_vert = *attributes.lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", bke::AttrDomain::Point, false); int j; const blender::Span edges = mesh->edges(); @@ -2108,7 +2109,7 @@ void ED_vgroup_mirror(Object *ob, MutableSpan dverts = mesh->deform_verts_for_write(); const bke::AttributeAccessor attributes = mesh->attributes(); const VArray select_vert = *attributes.lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", bke::AttrDomain::Point, false); for (int vidx = 0; vidx < mesh->verts_num; vidx++) { if (!BLI_BITMAP_TEST(vert_tag, vidx)) { @@ -2268,7 +2269,7 @@ static void vgroup_assign_verts(Object *ob, const float weight) else { const bke::AttributeAccessor attributes = mesh->attributes(); const VArray select_vert = *attributes.lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", bke::AttrDomain::Point, false); MutableSpan dverts = mesh->deform_verts_for_write(); @@ -3925,7 +3926,7 @@ static void vgroup_copy_active_to_sel_single(Object *ob, const int def_nr) MutableSpan dverts = mesh->deform_verts_for_write(); const bke::AttributeAccessor attributes = mesh->attributes(); const VArray select_vert = *attributes.lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", bke::AttrDomain::Point, false); for (i = 0; i < mesh->verts_num; i++) { if (select_vert[i] && (&dverts[i] != dvert_act)) { diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc index 0525fe3b133..f3e5acfac2f 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc @@ -168,9 +168,9 @@ struct AddOperationExecutor { VArraySpan surface_uv_map; if (curves_id_orig_->surface_uv_map != nullptr) { surface_uv_map = *surface_orig.attributes().lookup(curves_id_orig_->surface_uv_map, - ATTR_DOMAIN_CORNER); + bke::AttrDomain::Corner); surface_uv_map_eval_ = *surface_eval_->attributes().lookup( - curves_id_orig_->surface_uv_map, ATTR_DOMAIN_CORNER); + curves_id_orig_->surface_uv_map, bke::AttrDomain::Corner); } if (surface_uv_map.is_empty()) { @@ -238,7 +238,7 @@ struct AddOperationExecutor { *curves_orig_, add_inputs); bke::MutableAttributeAccessor attributes = curves_orig_->attributes_for_write(); if (bke::GSpanAttributeWriter selection = attributes.lookup_for_write_span(".selection")) { - curves::fill_selection_true(selection.span.slice(selection.domain == ATTR_DOMAIN_POINT ? + curves::fill_selection_true(selection.span.slice(selection.domain == bke::AttrDomain::Point ? add_outputs.new_points_range : add_outputs.new_curves_range)); selection.finish(); diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc b/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc index aee02fbef6d..2f8c88a968b 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_comb.cc @@ -135,7 +135,7 @@ struct CombOperationExecutor { transforms_ = CurvesSurfaceTransforms(*curves_ob_orig_, curves_id_orig_->surface); point_factors_ = *curves_orig_->attributes().lookup_or_default( - ".selection", ATTR_DOMAIN_POINT, 1.0f); + ".selection", bke::AttrDomain::Point, 1.0f); curve_selection_ = curves::retrieve_selected_curves(*curves_id_orig_, selected_curve_memory_); brush_pos_prev_re_ = self_->brush_pos_last_re_; diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_density.cc b/source/blender/editors/sculpt_paint/curves_sculpt_density.cc index 875b8d6c660..f6b058317f6 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_density.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_density.cc @@ -138,9 +138,9 @@ struct DensityAddOperationExecutor { VArraySpan surface_uv_map; if (curves_id_orig_->surface_uv_map != nullptr) { surface_uv_map = *surface_orig_->attributes().lookup(curves_id_orig_->surface_uv_map, - ATTR_DOMAIN_CORNER); + bke::AttrDomain::Corner); surface_uv_map_eval_ = *surface_eval_->attributes().lookup( - curves_id_orig_->surface_uv_map, ATTR_DOMAIN_CORNER); + curves_id_orig_->surface_uv_map, bke::AttrDomain::Corner); } if (surface_uv_map.is_empty()) { report_missing_uv_map_on_original_surface(stroke_extension.reports); @@ -283,7 +283,7 @@ struct DensityAddOperationExecutor { *curves_orig_, add_inputs); bke::MutableAttributeAccessor attributes = curves_orig_->attributes_for_write(); if (bke::GSpanAttributeWriter selection = attributes.lookup_for_write_span(".selection")) { - curves::fill_selection_true(selection.span.slice(selection.domain == ATTR_DOMAIN_POINT ? + curves::fill_selection_true(selection.span.slice(selection.domain == bke::AttrDomain::Point ? add_outputs.new_points_range : add_outputs.new_curves_range)); selection.finish(); diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc b/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc index 16c9afc839b..ba40fe7b491 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc @@ -273,7 +273,7 @@ struct CurvesEffectOperationExecutor { } curve_selection_factors_ = *curves_->attributes().lookup_or_default( - ".selection", ATTR_DOMAIN_CURVE, 1.0f); + ".selection", bke::AttrDomain::Curve, 1.0f); curve_selection_ = curves::retrieve_selected_curves(*curves_id_, selected_curve_memory_); const CurvesSculpt &curves_sculpt = *ctx_.scene->toolsettings->curves_sculpt; diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index 2aade1eb6e0..7425b8cf33a 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -379,8 +379,8 @@ static int select_random_exec(bContext *C, wmOperator *op) selection.fill(1.0f); } const OffsetIndices points_by_curve = curves.points_by_curve(); - switch (curves_id->selection_domain) { - case ATTR_DOMAIN_POINT: { + switch (bke::AttrDomain(curves_id->selection_domain)) { + case bke::AttrDomain::Point: { if (partial) { if (constant_per_curve) { for (const int curve_i : curves.curves_range()) { @@ -419,7 +419,7 @@ static int select_random_exec(bContext *C, wmOperator *op) } break; } - case ATTR_DOMAIN_CURVE: { + case bke::AttrDomain::Curve: { if (partial) { for (const int curve_i : curves.curves_range()) { const float random_value = next_partial_random_value(); @@ -436,6 +436,9 @@ static int select_random_exec(bContext *C, wmOperator *op) } break; } + default: + BLI_assert_unreachable(); + break; } const bool was_any_selected = std::any_of( selection.begin(), selection.end(), [](const float v) { return v > 0.0f; }); @@ -585,11 +588,11 @@ static int select_grow_update(bContext *C, wmOperator *op, const float mouse_dif /* Grow or shrink selection based on precomputed distances. */ switch (selection.domain) { - case ATTR_DOMAIN_POINT: { + case bke::AttrDomain::Point: { update_points_selection(*curve_op_data, distance, selection.span); break; } - case ATTR_DOMAIN_CURVE: { + case bke::AttrDomain::Curve: { Array new_points_selection(curves.points_num()); update_points_selection(*curve_op_data, distance, new_points_selection); /* Propagate grown point selection to the curve selection. */ @@ -777,7 +780,7 @@ static int select_grow_modal(bContext *C, wmOperator *op, const wmEvent *event) if (!curve_op_data->original_selection.is_empty()) { attributes.add( ".selection", - eAttrDomain(curves_id.selection_domain), + bke::AttrDomain(curves_id.selection_domain), bke::cpp_type_to_custom_data_type(curve_op_data->original_selection.type()), bke::AttributeInitVArray(GVArray::ForSpan(curve_op_data->original_selection))); } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_pinch.cc b/source/blender/editors/sculpt_paint/curves_sculpt_pinch.cc index e70404f425b..5bb9d811361 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_pinch.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_pinch.cc @@ -107,7 +107,7 @@ struct PinchOperationExecutor { transforms_ = CurvesSurfaceTransforms(*object_, curves_id_->surface); point_factors_ = *curves_->attributes().lookup_or_default( - ".selection", ATTR_DOMAIN_POINT, 1.0f); + ".selection", bke::AttrDomain::Point, 1.0f); curve_selection_ = curves::retrieve_selected_curves(*curves_id_, selected_curve_memory_); brush_pos_re_ = stroke_extension.mouse_position; diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_puff.cc b/source/blender/editors/sculpt_paint/curves_sculpt_puff.cc index ffc941a182c..9914165c076 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_puff.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_puff.cc @@ -107,7 +107,7 @@ struct PuffOperationExecutor { brush_pos_re_ = stroke_extension.mouse_position; point_factors_ = *curves_->attributes().lookup_or_default( - ".selection", ATTR_DOMAIN_POINT, 1.0f); + ".selection", bke::AttrDomain::Point, 1.0f); curve_selection_ = curves::retrieve_selected_curves(*curves_id_, selected_curve_memory_); falloff_shape_ = static_cast(brush_->falloff_shape); diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_selection.cc b/source/blender/editors/sculpt_paint/curves_sculpt_selection.cc index 2105de78c30..6bda4751388 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_selection.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_selection.cc @@ -29,7 +29,7 @@ bke::SpanAttributeWriter float_selection_ensure(Curves &curves_id) } } else { - const eAttrDomain domain = eAttrDomain(curves_id.selection_domain); + const bke::AttrDomain domain = bke::AttrDomain(curves_id.selection_domain); const int64_t size = attributes.domain_size(domain); attributes.add(".selection", domain, diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_selection_paint.cc b/source/blender/editors/sculpt_paint/curves_sculpt_selection_paint.cc index 14b9901aaec..e5b9a3dab54 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_selection_paint.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_selection_paint.cc @@ -120,7 +120,7 @@ struct SelectionPaintOperationExecutor { } } - if (selection_.domain == ATTR_DOMAIN_POINT) { + if (selection_.domain == bke::AttrDomain::Point) { if (falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) { this->paint_point_selection_projected_with_symmetry(selection_.span); } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc index 82fb3074a97..3a0213e0890 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc @@ -158,7 +158,7 @@ struct SlideOperationExecutor { brush_strength_ = brush_strength_get(*ctx_.scene, *brush_, stroke_extension); curve_factors_ = *curves_orig_->attributes().lookup_or_default( - ".selection", ATTR_DOMAIN_CURVE, 1.0f); + ".selection", bke::AttrDomain::Curve, 1.0f); curve_selection_ = curves::retrieve_selected_curves(*curves_id_orig_, selected_curve_memory_); brush_pos_re_ = stroke_extension.mouse_position; @@ -174,7 +174,7 @@ struct SlideOperationExecutor { surface_corner_tris_orig_ = surface_orig_->corner_tris(); corner_normals_orig_su_ = surface_orig_->corner_normals(); surface_uv_map_orig_ = *surface_orig_->attributes().lookup(uv_map_name, - ATTR_DOMAIN_CORNER); + bke::AttrDomain::Corner); if (surface_uv_map_orig_.is_empty()) { report_missing_uv_map_on_original_surface(stroke_extension.reports); return; @@ -195,7 +195,7 @@ struct SlideOperationExecutor { surface_positions_eval_ = surface_eval_->vert_positions(); surface_corner_verts_eval_ = surface_eval_->corner_verts(); surface_uv_map_eval_ = *surface_eval_->attributes().lookup(uv_map_name, - ATTR_DOMAIN_CORNER); + bke::AttrDomain::Corner); if (surface_uv_map_eval_.is_empty()) { report_missing_uv_map_on_evaluated_surface(stroke_extension.reports); return; diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_smooth.cc b/source/blender/editors/sculpt_paint/curves_sculpt_smooth.cc index 29277285800..61605c1809c 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_smooth.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_smooth.cc @@ -80,7 +80,7 @@ struct SmoothOperationExecutor { brush_pos_re_ = stroke_extension.mouse_position; point_factors_ = *curves_->attributes().lookup_or_default( - ".selection", ATTR_DOMAIN_POINT, 1.0f); + ".selection", bke::AttrDomain::Point, 1.0f); curve_selection_ = curves::retrieve_selected_curves(*curves_id_, selected_curve_memory_); transforms_ = CurvesSurfaceTransforms(*object_, curves_id_->surface); diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc b/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc index 3e7442f811a..e76fc82f75a 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc @@ -126,7 +126,7 @@ struct SnakeHookOperatorExecutor { transforms_ = CurvesSurfaceTransforms(*object_, curves_id_->surface); curve_factors_ = *curves_->attributes().lookup_or_default( - ".selection", ATTR_DOMAIN_CURVE, 1.0f); + ".selection", bke::AttrDomain::Curve, 1.0f); curve_selection_ = curves::retrieve_selected_curves(*curves_id_, selected_curve_memory_); brush_pos_prev_re_ = self.last_mouse_position_re_; diff --git a/source/blender/editors/sculpt_paint/grease_pencil_erase.cc b/source/blender/editors/sculpt_paint/grease_pencil_erase.cc index 695c001aef7..ef92224ced0 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_erase.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_erase.cc @@ -533,7 +533,7 @@ struct EraseOperationExecutor { /* Copy curves attributes. */ bke::gather_attributes(src_attributes, - ATTR_DOMAIN_CURVE, + bke::AttrDomain::Curve, propagation_info, {"cyclic"}, dst_to_src_curve, @@ -548,9 +548,9 @@ struct EraseOperationExecutor { /* Display intersections with flat caps. */ if (!keep_caps) { bke::SpanAttributeWriter dst_start_caps = - dst_attributes.lookup_or_add_for_write_span("start_cap", ATTR_DOMAIN_CURVE); + dst_attributes.lookup_or_add_for_write_span("start_cap", bke::AttrDomain::Curve); bke::SpanAttributeWriter dst_end_caps = - dst_attributes.lookup_or_add_for_write_span("end_cap", ATTR_DOMAIN_CURVE); + dst_attributes.lookup_or_add_for_write_span("end_cap", bke::AttrDomain::Curve); threading::parallel_for(dst.curves_range(), 4096, [&](const IndexRange dst_curves) { for (const int dst_curve : dst_curves) { diff --git a/source/blender/editors/sculpt_paint/grease_pencil_paint.cc b/source/blender/editors/sculpt_paint/grease_pencil_paint.cc index e32fbba1a67..f18e506f250 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_paint.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_paint.cc @@ -227,9 +227,9 @@ struct PaintOperationExecutor { bke::MutableAttributeAccessor attributes = curves.attributes_for_write(); bke::SpanAttributeWriter materials = attributes.lookup_or_add_for_write_span( - "material_index", ATTR_DOMAIN_CURVE); + "material_index", bke::AttrDomain::Curve); bke::SpanAttributeWriter cyclic = attributes.lookup_or_add_for_write_span( - "cyclic", ATTR_DOMAIN_CURVE); + "cyclic", bke::AttrDomain::Curve); cyclic.span.last() = false; materials.span.last() = material_index; @@ -241,11 +241,11 @@ struct PaintOperationExecutor { /* Initialize the rest of the attributes with default values. */ bke::fill_attribute_range_default(attributes, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, {"position", "radius", "opacity", "vertex_color"}, curves.points_range().take_back(1)); bke::fill_attribute_range_default(attributes, - ATTR_DOMAIN_CURVE, + bke::AttrDomain::Curve, {"curve_type", "material_index", "cyclic"}, curves.curves_range().take_back(1)); @@ -407,7 +407,7 @@ struct PaintOperationExecutor { /* Initialize the rest of the attributes with default values. */ bke::fill_attribute_range_default(attributes, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, {"position", "radius", "opacity", "vertex_color"}, curves.points_range().take_back(1)); } diff --git a/source/blender/editors/sculpt_paint/paint_hide.cc b/source/blender/editors/sculpt_paint/paint_hide.cc index 91fa102d174..0aaecb3c69e 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.cc +++ b/source/blender/editors/sculpt_paint/paint_hide.cc @@ -158,7 +158,8 @@ void mesh_show_all(Object &object, const Span nodes) { Mesh &mesh = *static_cast(object.data); bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); - if (const VArray attribute = *attributes.lookup(".hide_vert", ATTR_DOMAIN_POINT)) { + if (const VArray attribute = *attributes.lookup(".hide_vert", + bke::AttrDomain::Point)) { const VArraySpan hide_vert(attribute); threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) { for (PBVHNode *node : nodes.slice(range)) { @@ -184,7 +185,7 @@ static void vert_hide_update(Object &object, Mesh &mesh = *static_cast(object.data); bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); bke::SpanAttributeWriter hide_vert = attributes.lookup_or_add_for_write_span( - ".hide_vert", ATTR_DOMAIN_POINT); + ".hide_vert", bke::AttrDomain::Point); bool any_changed = false; threading::EnumerableThreadSpecific> all_new_hide; @@ -256,7 +257,8 @@ static void partialvis_update_mesh(Object &object, } break; case VisArea::Masked: { - const VArraySpan mask = *attributes.lookup(".sculpt_mask", ATTR_DOMAIN_POINT); + const VArraySpan mask = *attributes.lookup(".sculpt_mask", + bke::AttrDomain::Point); if (action == VisAction::Show && mask.is_empty()) { mesh_show_all(object, nodes); } @@ -675,7 +677,7 @@ static void invert_visibility_mesh(Object &object, const Span nodes) Mesh &mesh = *static_cast(object.data); bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); bke::SpanAttributeWriter hide_vert = attributes.lookup_or_add_for_write_span( - ".hide_vert", ATTR_DOMAIN_POINT); + ".hide_vert", bke::AttrDomain::Point); threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) { for (PBVHNode *node : nodes.slice(range)) { diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.cc b/source/blender/editors/sculpt_paint/paint_image_proj.cc index 9357b1bbc83..561ee5a22f2 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.cc +++ b/source/blender/editors/sculpt_paint/paint_image_proj.cc @@ -49,7 +49,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BKE_attribute.h" +#include "BKE_attribute.hh" #include "BKE_brush.hh" #include "BKE_camera.h" #include "BKE_colorband.h" @@ -6585,15 +6585,16 @@ static Image *proj_paint_image_create(wmOperator *op, Main *bmain, bool is_data) */ static const char *proj_paint_color_attribute_create(wmOperator *op, Object *ob) { + using namespace blender; char name[MAX_NAME] = ""; float color[4] = {0.0f, 0.0f, 0.0f, 1.0f}; - eAttrDomain domain = ATTR_DOMAIN_POINT; + bke::AttrDomain domain = bke::AttrDomain::Point; eCustomDataType type = CD_PROP_COLOR; if (op) { RNA_string_get(op->ptr, "name", name); RNA_float_get_array(op->ptr, "color", color); - domain = (eAttrDomain)RNA_enum_get(op->ptr, "domain"); + domain = bke::AttrDomain(RNA_enum_get(op->ptr, "domain")); type = (eCustomDataType)RNA_enum_get(op->ptr, "data_type"); } @@ -6916,6 +6917,7 @@ static void texture_paint_add_texture_paint_slot_ui(bContext *C, wmOperator *op) void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot) { + using namespace blender; PropertyRNA *prop; static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f}; @@ -6986,7 +6988,7 @@ void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot) 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"); diff --git a/source/blender/editors/sculpt_paint/paint_mask.cc b/source/blender/editors/sculpt_paint/paint_mask.cc index 9781e02d92d..615daaa9a8e 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.cc +++ b/source/blender/editors/sculpt_paint/paint_mask.cc @@ -149,7 +149,7 @@ static bool try_remove_mask_mesh(Object &object, const Span nodes) { Mesh &mesh = *static_cast(object.data); bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); - const VArraySpan mask = *attributes.lookup(".sculpt_mask", ATTR_DOMAIN_POINT); + const VArraySpan mask = *attributes.lookup(".sculpt_mask", bke::AttrDomain::Point); if (mask.is_empty()) { return true; } @@ -157,7 +157,7 @@ static bool try_remove_mask_mesh(Object &object, const Span nodes) /* If there are any hidden vertices that shouldn't be affected with a mask value set, the * attribute cannot be removed. This could also be done by building an IndexMask in the full * vertex domain. */ - const VArraySpan hide_vert = *attributes.lookup(".hide_vert", ATTR_DOMAIN_POINT); + const VArraySpan hide_vert = *attributes.lookup(".hide_vert", bke::AttrDomain::Point); threading::EnumerableThreadSpecific> all_index_data; const bool hidden_masked_verts = threading::parallel_reduce( nodes.index_range(), @@ -201,7 +201,7 @@ static void fill_mask_mesh(Object &object, const float value, const Span(object.data); bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); - const VArraySpan hide_vert = *attributes.lookup(".hide_vert", ATTR_DOMAIN_POINT); + const VArraySpan hide_vert = *attributes.lookup(".hide_vert", bke::AttrDomain::Point); if (value == 0.0f) { if (try_remove_mask_mesh(object, nodes)) { return; @@ -209,7 +209,7 @@ static void fill_mask_mesh(Object &object, const float value, const Span mask = attributes.lookup_or_add_for_write_only_span( - ".sculpt_mask", ATTR_DOMAIN_POINT); + ".sculpt_mask", bke::AttrDomain::Point); threading::EnumerableThreadSpecific> all_index_data; threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) { @@ -356,9 +356,9 @@ static void invert_mask_mesh(Object &object, const Span nodes) Mesh &mesh = *static_cast(object.data); bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); - const VArraySpan hide_vert = *attributes.lookup(".hide_vert", ATTR_DOMAIN_POINT); + const VArraySpan hide_vert = *attributes.lookup(".hide_vert", bke::AttrDomain::Point); bke::SpanAttributeWriter mask = attributes.lookup_or_add_for_write_span( - ".sculpt_mask", ATTR_DOMAIN_POINT); + ".sculpt_mask", bke::AttrDomain::Point); threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) { for (PBVHNode *node : nodes.slice(range)) { undo::push_node(&object, node, undo::Type::Mask); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index 0d3ead3efc9..fc903e68daf 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -73,6 +73,7 @@ #include "sculpt_intern.hh" using blender::IndexRange; +using blender::bke::AttrDomain; using namespace blender; using namespace blender::color; using namespace blender::ed::sculpt_paint; /* For vwpaint namespace. */ @@ -927,7 +928,7 @@ static void to_static_color_type(const eCustomDataType type, const Func &func) struct VPaintData { ViewContext vc; - eAttrDomain domain; + AttrDomain domain; eCustomDataType type; NormalAnglePrecalc normal_angle_precalc; @@ -953,7 +954,7 @@ static VPaintData *vpaint_init_vpaint(bContext *C, VPaint *vp, Object *ob, Mesh *mesh, - const eAttrDomain domain, + const AttrDomain domain, const eCustomDataType type, const Brush *brush) { @@ -1064,9 +1065,9 @@ static void do_vpaint_brush_blur_loops(bContext *C, GMutableSpan g_previous_color = ss->cache->prev_colors_vpaint; const blender::VArray select_vert = *mesh->attributes().lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", AttrDomain::Point, false); const blender::VArray select_poly = *mesh->attributes().lookup_or_default( - ".select_poly", ATTR_DOMAIN_FACE, false); + ".select_poly", AttrDomain::Face, false); blender::threading::parallel_for(nodes.index_range(), 1LL, [&](IndexRange range) { SculptBrushTest test = test_init; @@ -1215,9 +1216,9 @@ static void do_vpaint_brush_blur_verts(bContext *C, GMutableSpan g_previous_color = ss->cache->prev_colors_vpaint; const blender::VArray select_vert = *mesh->attributes().lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", AttrDomain::Point, false); const blender::VArray select_poly = *mesh->attributes().lookup_or_default( - ".select_poly", ATTR_DOMAIN_FACE, false); + ".select_poly", AttrDomain::Face, false); blender::threading::parallel_for(nodes.index_range(), 1LL, [&](IndexRange range) { SculptBrushTest test = test_init; @@ -1364,9 +1365,9 @@ static void do_vpaint_brush_smear(bContext *C, ss, brush->falloff_shape); const blender::VArray select_vert = *mesh->attributes().lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", AttrDomain::Point, false); const blender::VArray select_poly = *mesh->attributes().lookup_or_default( - ".select_poly", ATTR_DOMAIN_FACE, false); + ".select_poly", AttrDomain::Face, false); blender::threading::parallel_for(nodes.index_range(), 1LL, [&](IndexRange range) { SculptBrushTest test = test_init; @@ -1447,7 +1448,7 @@ static void do_vpaint_brush_smear(bContext *C, const float stroke_dot = dot_v3v3(other_dir, brush_dir); int elem_index; - if (vpd->domain == ATTR_DOMAIN_POINT) { + if (vpd->domain == AttrDomain::Point) { elem_index = v_other_index; } else { @@ -1475,7 +1476,7 @@ static void do_vpaint_brush_smear(bContext *C, const int p_index = gmap->vert_to_face[v_index][j]; int elem_index; - if (vpd->domain == ATTR_DOMAIN_POINT) { + if (vpd->domain == AttrDomain::Point) { elem_index = v_index; } else { @@ -1536,7 +1537,7 @@ static void calculate_average_color(VPaintData *vpd, ss, &test_init, brush->falloff_shape); const blender::VArray select_vert = *mesh->attributes().lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", AttrDomain::Point, false); to_static_color_type(vpd->type, [&](auto dummy) { using T = decltype(dummy); @@ -1576,7 +1577,7 @@ static void calculate_average_color(VPaintData *vpd, for (int j = 0; j < gmap->vert_to_face[v_index].size(); j++) { int elem_index; - if (vpd->domain == ATTR_DOMAIN_CORNER) { + if (vpd->domain == AttrDomain::Corner) { elem_index = gmap->vert_to_loop[v_index][j]; } else { @@ -1669,9 +1670,9 @@ static void vpaint_do_draw(bContext *C, GMutableSpan g_previous_color = ss->cache->prev_colors_vpaint; const blender::VArray select_vert = *mesh->attributes().lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", AttrDomain::Point, false); const blender::VArray select_poly = *mesh->attributes().lookup_or_default( - ".select_poly", ATTR_DOMAIN_FACE, false); + ".select_poly", AttrDomain::Face, false); blender::threading::parallel_for(nodes.index_range(), 1LL, [&](IndexRange range) { for (int n : range) { @@ -1726,7 +1727,7 @@ static void vpaint_do_draw(bContext *C, Color color_orig(0, 0, 0, 0); - if (vpd->domain == ATTR_DOMAIN_POINT) { + if (vpd->domain == AttrDomain::Point) { int v_index = vd.index; if (!previous_color.is_empty()) { @@ -1792,7 +1793,7 @@ static void vpaint_do_blur(bContext *C, Span nodes, GMutableSpan attribute) { - if (vpd->domain == ATTR_DOMAIN_POINT) { + if (vpd->domain == AttrDomain::Point) { do_vpaint_brush_blur_verts(C, sd, vp, vpd, ob, mesh, nodes, attribute); } else { @@ -2098,7 +2099,7 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot) template static void fill_bm_face_or_corner_attribute(BMesh &bm, const T &value, - const eAttrDomain domain, + const AttrDomain domain, const int cd_offset, const bool use_vert_sel) { @@ -2108,10 +2109,10 @@ static void fill_bm_face_or_corner_attribute(BMesh &bm, BMLoop *l = f->l_first; do { if (!(use_vert_sel && !BM_elem_flag_test(l->v, BM_ELEM_SELECT))) { - if (domain == ATTR_DOMAIN_CORNER) { + if (domain == AttrDomain::Corner) { *static_cast(BM_ELEM_CD_GET_VOID_P(l, cd_offset)) = value; } - else if (domain == ATTR_DOMAIN_POINT) { + else if (domain == AttrDomain::Point) { *static_cast(BM_ELEM_CD_GET_VOID_P(l->v, cd_offset)) = value; } } @@ -2122,16 +2123,16 @@ static void fill_bm_face_or_corner_attribute(BMesh &bm, template static void fill_mesh_face_or_corner_attribute(Mesh &mesh, const T &value, - const eAttrDomain domain, + const AttrDomain domain, const MutableSpan data, const bool use_vert_sel, const bool use_face_sel, const bool affect_alpha) { const VArray select_vert = *mesh.attributes().lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", AttrDomain::Point, false); const VArray select_poly = *mesh.attributes().lookup_or_default( - ".select_poly", ATTR_DOMAIN_FACE, false); + ".select_poly", AttrDomain::Face, false); const OffsetIndices faces = mesh.faces(); const Span corner_verts = mesh.corner_verts(); @@ -2145,7 +2146,7 @@ static void fill_mesh_face_or_corner_attribute(Mesh &mesh, if (use_vert_sel && !select_vert[vert]) { continue; } - const int data_index = domain == ATTR_DOMAIN_CORNER ? corner : vert; + const int data_index = domain == AttrDomain::Corner ? corner : vert; data[data_index].r = value.r; data[data_index].g = value.g; data[data_index].b = value.b; @@ -2169,7 +2170,7 @@ static void fill_mesh_color(Mesh &mesh, BMesh *bm = mesh.edit_mesh->bm; const std::string name = attribute_name; const CustomDataLayer *layer = BKE_id_attributes_color_find(&mesh.id, name.c_str()); - const eAttrDomain domain = BKE_id_attribute_domain(&mesh.id, layer); + const AttrDomain domain = BKE_id_attribute_domain(&mesh.id, layer); if (layer->type == CD_PROP_COLOR) { fill_bm_face_or_corner_attribute( *bm, color, domain, layer->offset, use_vert_sel); diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc index 555b2384409..24675969560 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc @@ -110,7 +110,7 @@ static bool vertex_paint_from_weight(Object *ob) * attribute, in order to let the attribute API handle both conversions. */ const GVArray vertex_group = *attributes.lookup( deform_group->name, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, bke::cpp_type_to_custom_data_type(color_attribute.varray.type())); if (!vertex_group) { BLI_assert_unreachable(); @@ -118,7 +118,7 @@ static bool vertex_paint_from_weight(Object *ob) } GVArraySpan interpolated{ - attributes.adapt_domain(vertex_group, ATTR_DOMAIN_POINT, color_attribute.domain)}; + attributes.adapt_domain(vertex_group, bke::AttrDomain::Point, color_attribute.domain)}; color_attribute.varray.set_all(interpolated.data()); color_attribute.finish(); @@ -161,7 +161,7 @@ void PAINT_OT_vertex_color_from_weight(wmOperatorType *ot) * \{ */ static IndexMask get_selected_indices(const Mesh &mesh, - const eAttrDomain domain, + const blender::bke::AttrDomain domain, IndexMaskMemory &memory) { using namespace blender; @@ -190,19 +190,20 @@ static void face_corner_color_equalize_verts(Mesh &mesh, const IndexMask selecti BLI_assert_unreachable(); return; } - if (attribute.domain == ATTR_DOMAIN_POINT) { + if (attribute.domain == bke::AttrDomain::Point) { return; } - GVArray color_attribute_point = *attributes.lookup(name, ATTR_DOMAIN_POINT); + GVArray color_attribute_point = *attributes.lookup(name, bke::AttrDomain::Point); GVArray color_attribute_corner = attributes.adapt_domain( - color_attribute_point, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CORNER); + color_attribute_point, bke::AttrDomain::Point, bke::AttrDomain::Corner); color_attribute_corner.materialize(selection, attribute.span.data()); attribute.finish(); } static bool vertex_color_smooth(Object *ob) { + using namespace blender; Mesh *mesh; if (((mesh = BKE_mesh_from_object(ob)) == nullptr) || (ED_mesh_color_ensure(mesh, nullptr) == false)) @@ -211,7 +212,7 @@ static bool vertex_color_smooth(Object *ob) } IndexMaskMemory memory; - const IndexMask selection = get_selected_indices(*mesh, ATTR_DOMAIN_CORNER, memory); + const IndexMask selection = get_selected_indices(*mesh, bke::AttrDomain::Corner, memory); face_corner_color_equalize_verts(*mesh, selection); diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.cc b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.cc index 8254e799d40..4bdd81b4887 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.cc @@ -433,8 +433,8 @@ static bool weight_paint_set(Object *ob, float paintweight) wpaint_prev_create(&wpp, dvert, mesh->verts_num); const bke::AttributeAccessor attributes = mesh->attributes(); - const VArraySpan select_vert = *attributes.lookup(".select_vert", ATTR_DOMAIN_POINT); - const VArraySpan select_poly = *attributes.lookup(".select_poly", ATTR_DOMAIN_FACE); + const VArraySpan select_vert = *attributes.lookup(".select_vert", bke::AttrDomain::Point); + const VArraySpan select_poly = *attributes.lookup(".select_poly", bke::AttrDomain::Face); for (const int i : faces.index_range()) { if ((paint_selmode == SCE_SELECT_FACE) && !(!select_poly.is_empty() && select_poly[i])) { @@ -799,8 +799,9 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) data.scene = scene; data.mesh = mesh; data.dvert = dverts; - data.select_vert = *attributes.lookup(".select_vert", ATTR_DOMAIN_POINT); - data.hide_vert = *attributes.lookup_or_default(".hide_vert", ATTR_DOMAIN_POINT, false); + data.select_vert = *attributes.lookup(".select_vert", bke::AttrDomain::Point); + data.hide_vert = *attributes.lookup_or_default( + ".hide_vert", bke::AttrDomain::Point, false); data.sco_start = sco_start; data.sco_end = sco_end; data.sco_line_div = 1.0f / len_v2v2(sco_start, sco_end); diff --git a/source/blender/editors/sculpt_paint/paint_weight.cc b/source/blender/editors/sculpt_paint/paint_weight.cc index ded3bc87864..4422e3dc296 100644 --- a/source/blender/editors/sculpt_paint/paint_weight.cc +++ b/source/blender/editors/sculpt_paint/paint_weight.cc @@ -1074,6 +1074,7 @@ static void do_wpaint_brush_blur_task(const Scene *scene, Mesh *mesh, PBVHNode *node) { + using namespace blender; SculptSession *ss = ob->sculpt; const PBVHType pbvh_type = BKE_pbvh_type(ss->pbvh); const bool has_grids = (pbvh_type == PBVH_GRIDS); @@ -1096,7 +1097,7 @@ static void do_wpaint_brush_blur_task(const Scene *scene, const blender::bke::AttributeAccessor attributes = mesh->attributes(); const blender::VArray select_vert = *attributes.lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + ".select_vert", bke::AttrDomain::Point, false); /* For each vertex */ PBVHVertexIter vd; @@ -1168,6 +1169,7 @@ static void do_wpaint_brush_smear_task(const Scene *scene, Mesh *mesh, PBVHNode *node) { + using namespace blender; SculptSession *ss = ob->sculpt; const PBVHType pbvh_type = BKE_pbvh_type(ss->pbvh); const bool has_grids = (pbvh_type == PBVH_GRIDS); @@ -1192,9 +1194,9 @@ static void do_wpaint_brush_smear_task(const Scene *scene, return; } - const blender::bke::AttributeAccessor attributes = mesh->attributes(); - const blender::VArray select_vert = *attributes.lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + const bke::AttributeAccessor attributes = mesh->attributes(); + const VArray select_vert = *attributes.lookup_or_default( + ".select_vert", bke::AttrDomain::Point, false); SculptBrushTest test; SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( @@ -1287,6 +1289,7 @@ static void do_wpaint_brush_draw_task(const Scene *scene, const float strength, PBVHNode *node) { + using namespace blender; SculptSession *ss = ob->sculpt; const PBVHType pbvh_type = BKE_pbvh_type(ss->pbvh); const bool has_grids = (pbvh_type == PBVH_GRIDS); @@ -1308,9 +1311,9 @@ static void do_wpaint_brush_draw_task(const Scene *scene, const float *sculpt_normal_frontface = SCULPT_brush_frontface_normal_from_falloff_shape( ss, brush->falloff_shape); - const blender::bke::AttributeAccessor attributes = mesh->attributes(); - const blender::VArray select_vert = *attributes.lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + const bke::AttributeAccessor attributes = mesh->attributes(); + const VArray select_vert = *attributes.lookup_or_default( + ".select_vert", bke::AttrDomain::Point, false); /* For each vertex */ PBVHVertexIter vd; @@ -1362,6 +1365,7 @@ static WPaintAverageAccum do_wpaint_brush_calc_average_weight(Object *ob, WeightPaintInfo *wpi, PBVHNode *node) { + using namespace blender; SculptSession *ss = ob->sculpt; StrokeCache *cache = ss->cache; const PBVHType pbvh_type = BKE_pbvh_type(ss->pbvh); @@ -1381,9 +1385,9 @@ static WPaintAverageAccum do_wpaint_brush_calc_average_weight(Object *ob, const float *sculpt_normal_frontface = SCULPT_brush_frontface_normal_from_falloff_shape( ss, brush->falloff_shape); - const blender::bke::AttributeAccessor attributes = mesh->attributes(); - const blender::VArray select_vert = *attributes.lookup_or_default( - ".select_vert", ATTR_DOMAIN_POINT, false); + const bke::AttributeAccessor attributes = mesh->attributes(); + const VArray select_vert = *attributes.lookup_or_default( + ".select_vert", bke::AttrDomain::Point, false); /* For each vertex */ PBVHVertexIter vd; diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 3b06e343c38..af747148980 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -187,7 +187,7 @@ bool SCULPT_has_loop_colors(const Object *ob) if (!meta_data) { return false; } - if (meta_data->domain != ATTR_DOMAIN_CORNER) { + if (meta_data->domain != bke::AttrDomain::Corner) { return false; } if (!(CD_TYPE_AS_MASK(meta_data->data_type) & CD_MASK_COLOR_ALL)) { @@ -300,7 +300,7 @@ float SCULPT_vertex_mask_get(SculptSession *ss, PBVHVertRef vertex) const Mesh *mesh = BKE_pbvh_get_mesh(ss->pbvh); const bke::AttributeAccessor attributes = mesh->attributes(); const VArray mask = *attributes.lookup_or_default( - ".sculpt_mask", ATTR_DOMAIN_POINT, 0.0f); + ".sculpt_mask", bke::AttrDomain::Point, 0.0f); return mask[vertex.i]; } case PBVH_BMESH: { @@ -412,7 +412,7 @@ bool vert_visible_get(const SculptSession *ss, PBVHVertRef vertex) const Mesh *mesh = BKE_pbvh_get_mesh(ss->pbvh); const bke::AttributeAccessor attributes = mesh->attributes(); const VArray hide_vert = *attributes.lookup_or_default( - ".hide_vert", ATTR_DOMAIN_POINT, false); + ".hide_vert", bke::AttrDomain::Point, false); return !hide_vert[vertex.i]; } case PBVH_BMESH: @@ -1338,7 +1338,7 @@ static void paint_mesh_restore_node(Object *ob, const undo::Type type, PBVHNode Mesh &mesh = *static_cast(ob->data); bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); bke::SpanAttributeWriter mask = attributes.lookup_or_add_for_write_span( - ".sculpt_mask", ATTR_DOMAIN_POINT); + ".sculpt_mask", bke::AttrDomain::Point); array_utils::scatter( unode->mask.as_span(), BKE_pbvh_node_get_unique_vert_indices(node), mask.span); mask.finish(); @@ -4927,7 +4927,7 @@ bool SCULPT_cursor_geometry_info_update(bContext *C, const Mesh &mesh = *static_cast(ob->data); srd.corner_verts = mesh.corner_verts(); const bke::AttributeAccessor attributes = mesh.attributes(); - srd.hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); + srd.hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); } srd.ray_start = ray_start; srd.ray_normal = ray_normal; @@ -5080,7 +5080,7 @@ bool SCULPT_stroke_get_location_ex(bContext *C, const Mesh &mesh = *static_cast(ob->data); srd.corner_verts = mesh.corner_verts(); const bke::AttributeAccessor attributes = mesh.attributes(); - srd.hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); + srd.hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); } srd.depth = depth; srd.original = original; @@ -5113,7 +5113,7 @@ bool SCULPT_stroke_get_location_ex(bContext *C, const Mesh &mesh = *static_cast(ob->data); srd.corner_verts = mesh.corner_verts(); const bke::AttributeAccessor attributes = mesh.attributes(); - srd.hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); + srd.hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); } srd.ray_start = ray_start; srd.ray_normal = ray_normal; @@ -6079,13 +6079,14 @@ void SCULPT_stroke_id_next(Object *ob) void SCULPT_stroke_id_ensure(Object *ob) { + using namespace blender; SculptSession *ss = ob->sculpt; if (!ss->attrs.automasking_stroke_id) { SculptAttributeParams params = {0}; ss->attrs.automasking_stroke_id = BKE_sculpt_attribute_ensure( ob, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, CD_PROP_INT8, SCULPT_ATTRIBUTE_NAME(automasking_stroke_id), ¶ms); @@ -6108,6 +6109,7 @@ void SCULPT_topology_islands_invalidate(SculptSession *ss) void SCULPT_topology_islands_ensure(Object *ob) { + using namespace blender; using namespace blender::ed::sculpt_paint; SculptSession *ss = ob->sculpt; @@ -6120,7 +6122,11 @@ void SCULPT_topology_islands_ensure(Object *ob) params.permanent = params.stroke_only = params.simple_array = false; ss->attrs.topology_island_key = BKE_sculpt_attribute_ensure( - ob, ATTR_DOMAIN_POINT, CD_PROP_INT8, SCULPT_ATTRIBUTE_NAME(topology_island_key), ¶ms); + ob, + bke::AttrDomain::Point, + CD_PROP_INT8, + SCULPT_ATTRIBUTE_NAME(topology_island_key), + ¶ms); SCULPT_vertex_random_access_ensure(ss); int totvert = SCULPT_vertex_count_get(ss); diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc b/source/blender/editors/sculpt_paint/sculpt_automasking.cc index 118d659b0f1..720314174f9 100644 --- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc +++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc @@ -836,7 +836,7 @@ Cache *cache_init(Sculpt *sd, Brush *brush, Object *ob) SculptAttributeParams params = {0}; ss->attrs.automasking_occlusion = BKE_sculpt_attribute_ensure( ob, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, CD_PROP_INT8, SCULPT_ATTRIBUTE_NAME(automasking_occlusion), ¶ms); @@ -858,7 +858,7 @@ Cache *cache_init(Sculpt *sd, Brush *brush, Object *ob) SculptAttributeParams params = {0}; ss->attrs.automasking_cavity = BKE_sculpt_attribute_ensure( ob, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, CD_PROP_FLOAT, SCULPT_ATTRIBUTE_NAME(automasking_cavity), ¶ms); @@ -896,7 +896,11 @@ Cache *cache_init(Sculpt *sd, Brush *brush, Object *ob) params.stroke_only = true; ss->attrs.automasking_factor = BKE_sculpt_attribute_ensure( - ob, ATTR_DOMAIN_POINT, CD_PROP_FLOAT, SCULPT_ATTRIBUTE_NAME(automasking_factor), ¶ms); + ob, + bke::AttrDomain::Point, + CD_PROP_FLOAT, + SCULPT_ATTRIBUTE_NAME(automasking_factor), + ¶ms); float initial_value; diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.cc b/source/blender/editors/sculpt_paint/sculpt_expand.cc index 37a44f3e32f..4709c2fc9e1 100644 --- a/source/blender/editors/sculpt_paint/sculpt_expand.cc +++ b/source/blender/editors/sculpt_paint/sculpt_expand.cc @@ -1201,7 +1201,7 @@ static void write_mask_data(SculptSession *ss, const Span mask) Mesh *mesh = BKE_pbvh_get_mesh(ss->pbvh); bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter attribute = attributes.lookup_or_add_for_write_span( - ".sculpt_mask", ATTR_DOMAIN_POINT); + ".sculpt_mask", bke::AttrDomain::Point); for (PBVHNode *node : nodes) { PBVHVertexIter vd; BKE_pbvh_vertex_iter_begin (ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { @@ -1344,7 +1344,7 @@ static void sculpt_expand_face_sets_update(Object &object, Cache *expand_cache) bke::SpanAttributeWriter face_sets = face_set::ensure_face_sets_mesh(object); Mesh &mesh = *static_cast(object.data); const bke::AttributeAccessor attributes = mesh.attributes(); - const VArraySpan hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); + const VArraySpan hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); for (const int f : face_sets.span.index_range()) { const bool enabled = sculpt_expand_face_state_get( object.sculpt, hide_poly, face_sets.span, expand_cache, f); diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index 35a5a4e6312..a3fd7193e30 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -73,7 +73,7 @@ int find_next_available_id(Object &object) Mesh &mesh = *static_cast(object.data); const bke::AttributeAccessor attributes = mesh.attributes(); const VArraySpan face_sets = *attributes.lookup(".sculpt_face_set", - ATTR_DOMAIN_FACE); + bke::AttrDomain::Face); const int max = threading::parallel_reduce( face_sets.index_range(), 4096, @@ -147,13 +147,13 @@ bke::SpanAttributeWriter ensure_face_sets_mesh(Object &object) bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); if (!attributes.contains(".sculpt_face_set")) { attributes.add(".sculpt_face_set", - ATTR_DOMAIN_FACE, + bke::AttrDomain::Face, bke::AttributeInitVArray(VArray::ForSingle(1, mesh.faces_num))); mesh.face_sets_color_default = 1; } object.sculpt->face_sets = static_cast( CustomData_get_layer_named(&mesh.face_data, CD_PROP_INT32, ".sculpt_face_set")); - return attributes.lookup_or_add_for_write_span(".sculpt_face_set", ATTR_DOMAIN_FACE); + return attributes.lookup_or_add_for_write_span(".sculpt_face_set", bke::AttrDomain::Face); } int ensure_face_sets_bmesh(Object &object) @@ -191,7 +191,7 @@ static void do_draw_face_sets_brush_faces(Object *ob, Mesh &mesh = *static_cast(ob->data); const bke::AttributeAccessor attributes = mesh.attributes(); - const VArraySpan hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); + const VArraySpan hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); bke::SpanAttributeWriter attribute = ensure_face_sets_mesh(*ob); MutableSpan face_sets = attribute.span; @@ -551,8 +551,10 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op) case CreateMode::Masked: { const OffsetIndices faces = mesh.faces(); const Span corner_verts = mesh.corner_verts(); - const VArraySpan hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); - const VArraySpan mask = *attributes.lookup(".sculpt_mask", ATTR_DOMAIN_POINT); + const VArraySpan hide_poly = *attributes.lookup(".hide_poly", + bke::AttrDomain::Face); + const VArraySpan mask = *attributes.lookup(".sculpt_mask", + bke::AttrDomain::Point); if (!mask.is_empty()) { face_sets_update(object, nodes, [&](const Span indices, MutableSpan face_sets) { for (const int i : indices.index_range()) { @@ -573,7 +575,7 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op) break; } case CreateMode::Visible: { - const VArray hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); + const VArray hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); switch (array_utils::booleans_mix_calc(hide_poly)) { case array_utils::BooleanMix::None: case array_utils::BooleanMix::AllTrue: @@ -606,7 +608,7 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op) } case CreateMode::Selection: { const VArraySpan select_poly = *attributes.lookup_or_default( - ".select_poly", ATTR_DOMAIN_FACE, false); + ".select_poly", bke::AttrDomain::Face, false); face_sets_update(object, nodes, [&](const Span indices, MutableSpan face_sets) { for (const int i : indices.index_range()) { if (select_poly[indices[i]]) { @@ -739,7 +741,7 @@ Array duplicate_face_sets(const Mesh &mesh) { const bke::AttributeAccessor attributes = mesh.attributes(); const VArray attribute = *attributes.lookup_or_default( - ".sculpt_face_set", ATTR_DOMAIN_FACE, 0); + ".sculpt_face_set", bke::AttrDomain::Face, 0); Array face_sets(attribute.size()); array_utils::copy(attribute, face_sets.as_mutable_span()); return face_sets; @@ -780,7 +782,7 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op) switch (mode) { case InitMode::LooseParts: { const VArray hide_poly = *attributes.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", bke::AttrDomain::Face, false); sculpt_face_sets_init_flood_fill( ob, [&](const int from_face, const int /*edge*/, const int to_face) { return hide_poly[from_face] == hide_poly[to_face]; @@ -790,7 +792,7 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op) case InitMode::Materials: { bke::SpanAttributeWriter face_sets = ensure_face_sets_mesh(*ob); const VArraySpan material_indices = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_FACE, 0); + "material_index", bke::AttrDomain::Face, 0); for (const int i : IndexRange(mesh->faces_num)) { face_sets.span[i] = material_indices[i] + 1; } @@ -807,7 +809,7 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op) } case InitMode::UVSeams: { const VArraySpan uv_seams = *mesh->attributes().lookup_or_default( - ".uv_seam", ATTR_DOMAIN_EDGE, false); + ".uv_seam", bke::AttrDomain::Edge, false); sculpt_face_sets_init_flood_fill( ob, [&](const int /*from_face*/, const int edge, const int /*to_face*/) -> bool { return !uv_seams[edge]; @@ -816,7 +818,7 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op) } case InitMode::Creases: { const VArraySpan creases = *attributes.lookup_or_default( - "crease_edge", ATTR_DOMAIN_EDGE, 0.0f); + "crease_edge", bke::AttrDomain::Edge, 0.0f); sculpt_face_sets_init_flood_fill( ob, [&](const int /*from_face*/, const int edge, const int /*to_face*/) -> bool { return creases[edge] < threshold; @@ -825,7 +827,7 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op) } case InitMode::SharpEdges: { const VArraySpan sharp_edges = *mesh->attributes().lookup_or_default( - "sharp_edge", ATTR_DOMAIN_EDGE, false); + "sharp_edge", bke::AttrDomain::Edge, false); sculpt_face_sets_init_flood_fill( ob, [&](const int /*from_face*/, const int edge, const int /*to_face*/) -> bool { return !sharp_edges[edge]; @@ -834,7 +836,7 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op) } case InitMode::BevelWeight: { const VArraySpan bevel_weights = *attributes.lookup_or_default( - "bevel_weight_edge", ATTR_DOMAIN_EDGE, 0.0f); + "bevel_weight_edge", bke::AttrDomain::Edge, 0.0f); sculpt_face_sets_init_flood_fill( ob, [&](const int /*from_face*/, const int edge, const int /*to_face*/) -> bool { return bevel_weights[edge] < threshold; @@ -939,7 +941,7 @@ static void face_hide_update(Object &object, Mesh &mesh = *static_cast(object.data); bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); bke::SpanAttributeWriter hide_poly = attributes.lookup_or_add_for_write_span( - ".hide_poly", ATTR_DOMAIN_FACE); + ".hide_poly", bke::AttrDomain::Face); struct TLS { Vector face_indices; @@ -1013,8 +1015,9 @@ static int sculpt_face_set_change_visibility_exec(bContext *C, wmOperator *op) Vector nodes = bke::pbvh::search_gather(pbvh, {}); const bke::AttributeAccessor attributes = mesh->attributes(); - const VArraySpan hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); - const VArraySpan face_sets = *attributes.lookup(".sculpt_face_set", ATTR_DOMAIN_FACE); + const VArraySpan hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); + const VArraySpan face_sets = *attributes.lookup(".sculpt_face_set", + bke::AttrDomain::Face); switch (mode) { case VisibilityMode::Toggle: { @@ -1153,7 +1156,7 @@ static int sculpt_face_sets_randomize_colors_exec(bContext *C, wmOperator * /*op return OPERATOR_CANCELLED; } - const VArray face_sets = *attributes.lookup(".sculpt_face_set", ATTR_DOMAIN_FACE); + const VArray face_sets = *attributes.lookup(".sculpt_face_set", bke::AttrDomain::Face); const int random_index = clamp_i( ss->totfaces * BLI_hash_int_01(mesh->face_sets_color_seed), 0, max_ii(0, ss->totfaces - 1)); mesh->face_sets_color_default = face_sets[random_index]; @@ -1202,7 +1205,7 @@ static void sculpt_face_set_grow_shrink(Object &object, const Span corner_verts = mesh.corner_verts(); const GroupedSpan vert_to_face_map = ss.pmap; const bke::AttributeAccessor attributes = mesh.attributes(); - const VArraySpan hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); + const VArraySpan hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); Array prev_face_sets = duplicate_face_sets(mesh); bke::SpanAttributeWriter face_sets = ensure_face_sets_mesh(object); @@ -1252,8 +1255,9 @@ static bool check_single_face_set(const Object &object, const bool check_visible { const Mesh &mesh = *static_cast(object.data); const bke::AttributeAccessor attributes = mesh.attributes(); - const VArraySpan hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); - const VArraySpan face_sets = *attributes.lookup(".sculpt_face_set", ATTR_DOMAIN_FACE); + const VArraySpan hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); + const VArraySpan face_sets = *attributes.lookup(".sculpt_face_set", + bke::AttrDomain::Face); if (face_sets.is_empty()) { return true; @@ -1293,8 +1297,9 @@ static void sculpt_face_set_delete_geometry(Object *ob, { Mesh &mesh = *static_cast(ob->data); const bke::AttributeAccessor attributes = mesh.attributes(); - const VArraySpan hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); - const VArraySpan face_sets = *attributes.lookup(".sculpt_face_set", ATTR_DOMAIN_FACE); + const VArraySpan hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); + const VArraySpan face_sets = *attributes.lookup(".sculpt_face_set", + bke::AttrDomain::Face); const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(&mesh); BMeshCreateParams create_params{}; diff --git a/source/blender/editors/sculpt_paint/sculpt_geodesic.cc b/source/blender/editors/sculpt_paint/sculpt_geodesic.cc index 42879e39ff5..15f1f439fe0 100644 --- a/source/blender/editors/sculpt_paint/sculpt_geodesic.cc +++ b/source/blender/editors/sculpt_paint/sculpt_geodesic.cc @@ -94,7 +94,7 @@ static float *geodesic_mesh_create(Object *ob, GSet *initial_verts, const float const Span corner_verts = mesh->corner_verts(); const Span corner_edges = mesh->corner_edges(); const bke::AttributeAccessor attributes = mesh->attributes(); - const VArraySpan hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); + const VArraySpan hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); float *dists = static_cast(MEM_malloc_arrayN(totvert, sizeof(float), __func__)); BLI_bitmap *edge_tag = BLI_BITMAP_NEW(totedge, "edge tag"); diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.hh b/source/blender/editors/sculpt_paint/sculpt_intern.hh index 3295b02ee66..510c3257270 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.hh +++ b/source/blender/editors/sculpt_paint/sculpt_intern.hh @@ -896,7 +896,7 @@ bool SCULPT_vertex_is_occluded(SculptSession *ss, PBVHVertRef vertex, bool origi /** Returns true if a color attribute exists in the current sculpt session. */ bool SCULPT_has_colors(const SculptSession *ss); -/** Returns true if the active color attribute is on loop (ATTR_DOMAIN_CORNER) domain. */ +/** Returns true if the active color attribute is on loop (AttrDomain::Corner) domain. */ bool SCULPT_has_loop_colors(const Object *ob); const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, PBVHVertRef vertex); diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.cc b/source/blender/editors/sculpt_paint/sculpt_ops.cc index 7d63f23d490..15a5e92fade 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/sculpt_ops.cc @@ -77,6 +77,7 @@ static int sculpt_set_persistent_base_exec(bContext *C, wmOperator * /*op*/) { + using namespace blender; Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; @@ -92,11 +93,11 @@ static int sculpt_set_persistent_base_exec(bContext *C, wmOperator * /*op*/) params.permanent = true; ss->attrs.persistent_co = BKE_sculpt_attribute_ensure( - ob, ATTR_DOMAIN_POINT, CD_PROP_FLOAT3, SCULPT_ATTRIBUTE_NAME(persistent_co), ¶ms); + ob, bke::AttrDomain::Point, CD_PROP_FLOAT3, SCULPT_ATTRIBUTE_NAME(persistent_co), ¶ms); ss->attrs.persistent_no = BKE_sculpt_attribute_ensure( - ob, ATTR_DOMAIN_POINT, CD_PROP_FLOAT3, SCULPT_ATTRIBUTE_NAME(persistent_no), ¶ms); + ob, bke::AttrDomain::Point, CD_PROP_FLOAT3, SCULPT_ATTRIBUTE_NAME(persistent_no), ¶ms); ss->attrs.persistent_disp = BKE_sculpt_attribute_ensure( - ob, ATTR_DOMAIN_POINT, CD_PROP_FLOAT, SCULPT_ATTRIBUTE_NAME(persistent_disp), ¶ms); + ob, bke::AttrDomain::Point, CD_PROP_FLOAT, SCULPT_ATTRIBUTE_NAME(persistent_disp), ¶ms); const int totvert = SCULPT_vertex_count_get(ss); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index ad4da90cc61..ddfc515f16d 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -125,7 +125,7 @@ namespace blender::ed::sculpt_paint::undo { * End of dynamic topology and symmetrize in this mode are handled in a special * manner as well. */ -#define NO_ACTIVE_LAYER ATTR_DOMAIN_AUTO +#define NO_ACTIVE_LAYER bke::AttrDomain::Auto struct UndoSculpt { Vector> nodes; @@ -134,7 +134,7 @@ struct UndoSculpt { }; struct SculptAttrRef { - eAttrDomain domain; + bke::AttrDomain domain; eCustomDataType type; char name[MAX_CUSTOMDATA_LAYER_NAME]; bool was_set; @@ -520,7 +520,7 @@ static bool restore_hidden(Object *ob, Node &unode, MutableSpan modified_v Mesh &mesh = *static_cast(ob->data); bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); bke::SpanAttributeWriter hide_vert = attributes.lookup_or_add_for_write_span( - ".hide_vert", ATTR_DOMAIN_POINT); + ".hide_vert", bke::AttrDomain::Point); for (const int i : unode.vert_indices.index_range().take_front(unode.unique_verts_num)) { const int vert = unode.vert_indices[i]; if (unode.vert_hidden[i].test() != hide_vert.span[vert]) { @@ -560,7 +560,7 @@ static bool restore_hidden_face(Object &object, Node &unode, MutableSpan m Mesh &mesh = *static_cast(object.data); bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); bke::SpanAttributeWriter hide_poly = attributes.lookup_or_add_for_write_span( - ".hide_poly", ATTR_DOMAIN_FACE); + ".hide_poly", bke::AttrDomain::Face); const Span face_indices = unode.face_indices; @@ -615,7 +615,7 @@ static bool restore_mask(Object *ob, Node &unode, MutableSpan modified_ver if (unode.mesh_verts_num) { bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter mask = attributes.lookup_or_add_for_write_span( - ".sculpt_mask", ATTR_DOMAIN_POINT); + ".sculpt_mask", bke::AttrDomain::Point); const Span index = unode.vert_indices.as_span().take_front(unode.unique_verts_num); @@ -1244,7 +1244,7 @@ static Node *alloc_node(Object *ob, PBVHNode *node, Type type) usculpt->undo_size += unode->col.as_span().size_in_bytes(); /* Allocate loop colors separately too. */ - if (ss->vcol_domain == ATTR_DOMAIN_CORNER) { + if (ss->vcol_domain == bke::AttrDomain::Corner) { unode->loop_col.reinitialize(unode->corner_indices.size()); unode->undo_size += unode->loop_col.as_span().size_in_bytes(); } @@ -1324,7 +1324,8 @@ static void store_hidden(Object *ob, Node *unode) const Mesh &mesh = *static_cast(ob->data); const bke::AttributeAccessor attributes = mesh.attributes(); - const VArraySpan hide_vert = *attributes.lookup(".hide_vert", ATTR_DOMAIN_POINT); + const VArraySpan hide_vert = *attributes.lookup(".hide_vert", + bke::AttrDomain::Point); if (hide_vert.is_empty()) { return; } @@ -1339,7 +1340,7 @@ static void store_face_hidden(Object &object, Node &unode) { const Mesh &mesh = *static_cast(object.data); const bke::AttributeAccessor attributes = mesh.attributes(); - const VArraySpan hide_poly = *attributes.lookup(".hide_poly", ATTR_DOMAIN_FACE); + const VArraySpan hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); if (hide_poly.is_empty()) { unode.face_hidden.fill(false); return; @@ -1374,7 +1375,7 @@ static void store_mask(Object *ob, Node *unode) else { const Mesh &mesh = *static_cast(ob->data); const bke::AttributeAccessor attributes = mesh.attributes(); - if (const VArray mask = *attributes.lookup(".sculpt_mask", ATTR_DOMAIN_POINT)) { + if (const VArray mask = *attributes.lookup(".sculpt_mask", bke::AttrDomain::Point)) { array_utils::gather(mask, unode->vert_indices.as_span(), unode->mask.as_mutable_span()); } else { @@ -1424,7 +1425,7 @@ static Node *geometry_push(Object *object, Type type) static void store_face_sets(const Mesh &mesh, Node &unode) { array_utils::gather( - *mesh.attributes().lookup_or_default(".sculpt_face_set", ATTR_DOMAIN_FACE, 0), + *mesh.attributes().lookup_or_default(".sculpt_face_set", bke::AttrDomain::Face, 0), unode.face_indices.as_span(), unode.face_sets.as_mutable_span()); } @@ -1692,7 +1693,7 @@ void push_end_ex(Object *ob, const bool use_nested_undo) static void set_active_layer(bContext *C, SculptAttrRef *attr) { - if (attr->domain == ATTR_DOMAIN_AUTO) { + if (attr->domain == bke::AttrDomain::Auto) { return; } diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc index 014d07f8fd9..d068c108f56 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc @@ -75,29 +75,29 @@ std::unique_ptr ExtraColumns::get_column_values( static void add_mesh_debug_column_names( const Mesh &mesh, - const eAttrDomain domain, + const bke::AttrDomain domain, FunctionRef fn) { switch (domain) { - case ATTR_DOMAIN_POINT: + case bke::AttrDomain::Point: if (CustomData_has_layer(&mesh.vert_data, CD_ORIGINDEX)) { fn({(char *)"Original Index"}, false); } break; - case ATTR_DOMAIN_EDGE: + case bke::AttrDomain::Edge: if (CustomData_has_layer(&mesh.edge_data, CD_ORIGINDEX)) { fn({(char *)"Original Index"}, false); } fn({(char *)"Vertices"}, false); break; - case ATTR_DOMAIN_FACE: + case bke::AttrDomain::Face: if (CustomData_has_layer(&mesh.face_data, CD_ORIGINDEX)) { fn({(char *)"Original Index"}, false); } fn({(char *)"Corner Start"}, false); fn({(char *)"Corner Size"}, false); break; - case ATTR_DOMAIN_CORNER: + case bke::AttrDomain::Corner: fn({(char *)"Vertex"}, false); fn({(char *)"Edge"}, false); break; @@ -108,11 +108,11 @@ static void add_mesh_debug_column_names( } static std::unique_ptr build_mesh_debug_columns(const Mesh &mesh, - const eAttrDomain domain, + const bke::AttrDomain domain, const StringRef name) { switch (domain) { - case ATTR_DOMAIN_POINT: { + case bke::AttrDomain::Point: { if (name == "Original Index") { const int *data = static_cast( CustomData_get_layer(&mesh.vert_data, CD_ORIGINDEX)); @@ -123,7 +123,7 @@ static std::unique_ptr build_mesh_debug_columns(const Mesh &mesh, } return {}; } - case ATTR_DOMAIN_EDGE: { + case bke::AttrDomain::Edge: { if (name == "Original Index") { const int *data = static_cast( CustomData_get_layer(&mesh.edge_data, CD_ORIGINDEX)); @@ -137,7 +137,7 @@ static std::unique_ptr build_mesh_debug_columns(const Mesh &mesh, } return {}; } - case ATTR_DOMAIN_FACE: { + case bke::AttrDomain::Face: { if (name == "Original Index") { const int *data = static_cast( CustomData_get_layer(&mesh.face_data, CD_ORIGINDEX)); @@ -159,7 +159,7 @@ static std::unique_ptr build_mesh_debug_columns(const Mesh &mesh, } return {}; } - case ATTR_DOMAIN_CORNER: { + case bke::AttrDomain::Corner: { if (name == "Vertex") { return std::make_unique(name, VArray::ForSpan(mesh.corner_verts())); } @@ -277,7 +277,7 @@ std::unique_ptr GeometryDataSource::get_column_values( if (const GreasePencil *grease_pencil = static_cast(*component_).get()) { - if (domain_ == ATTR_DOMAIN_LAYER && STREQ(column_id.name, "Name")) { + if (domain_ == bke::AttrDomain::Layer && STREQ(column_id.name, "Name")) { const Span layers = grease_pencil->layers(); return std::make_unique( column_id.name, VArray::ForFunc(domain_num, [layers](int64_t index) { @@ -395,7 +395,7 @@ IndexMask GeometryDataSource::apply_selection_filter(IndexMaskMemory &memory) co const BMVert *vert = BM_vert_at_index(bm, i_orig); return BM_elem_flag_test(vert, BM_ELEM_SELECT); }), - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, domain_); return IndexMask::from_bools(selection, memory); } @@ -408,7 +408,7 @@ IndexMask GeometryDataSource::apply_selection_filter(IndexMaskMemory &memory) co const BMVert *vert = BM_vert_at_index(bm, vertex_index); return BM_elem_flag_test(vert, BM_ELEM_SELECT); }), - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, domain_); return IndexMask::from_bools(selection, memory); } @@ -420,9 +420,9 @@ IndexMask GeometryDataSource::apply_selection_filter(IndexMaskMemory &memory) co const bke::CurveComponent &component = static_cast(*component_); const Curves &curves_id = *component.get(); switch (domain_) { - case ATTR_DOMAIN_POINT: + case bke::AttrDomain::Point: return curves::retrieve_selected_points(curves_id, memory); - case ATTR_DOMAIN_CURVE: + case bke::AttrDomain::Curve: return curves::retrieve_selected_curves(curves_id, memory); default: BLI_assert_unreachable(); @@ -433,7 +433,7 @@ IndexMask GeometryDataSource::apply_selection_filter(IndexMaskMemory &memory) co BLI_assert(object_eval_->type == OB_POINTCLOUD); const bke::AttributeAccessor attributes = *component_->attributes(); const VArray &selection = *attributes.lookup_or_default( - ".selection", ATTR_DOMAIN_POINT, false); + ".selection", bke::AttrDomain::Point, false); return IndexMask::from_bools(selection, memory); } default: @@ -450,7 +450,7 @@ std::optional GeometryDataSource::get_component_at if (!grease_pencil) { return {}; } - if (domain_ == ATTR_DOMAIN_LAYER) { + if (domain_ == bke::AttrDomain::Layer) { return grease_pencil->attributes(); } if (layer_index_ >= 0 && layer_index_ < grease_pencil->layers().size()) { @@ -599,7 +599,7 @@ bke::GeometrySet spreadsheet_get_display_geometry_set(const SpaceSpreadsheet *ss std::unique_ptr data_source_from_geometry(const bContext *C, Object *object_eval) { SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C); - const eAttrDomain domain = (eAttrDomain)sspreadsheet->attribute_domain; + const bke::AttrDomain domain = (bke::AttrDomain)sspreadsheet->attribute_domain; const auto component_type = bke::GeometryComponent::Type(sspreadsheet->geometry_component_type); const int active_layer_index = sspreadsheet->active_layer_index; bke::GeometrySet geometry_set = spreadsheet_get_display_geometry_set(sspreadsheet, object_eval); diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.hh b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.hh index dfc7f5429eb..592c1e6958e 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.hh +++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.hh @@ -42,7 +42,7 @@ class GeometryDataSource : public DataSource { Object *object_eval_; const bke::GeometrySet geometry_set_; const bke::GeometryComponent *component_; - eAttrDomain domain_; + bke::AttrDomain domain_; /* Layer index for grease pencil component. */ int layer_index_; ExtraColumns extra_columns_; @@ -57,7 +57,7 @@ class GeometryDataSource : public DataSource { GeometryDataSource(Object *object_eval, bke::GeometrySet geometry_set, const bke::GeometryComponent::Type component_type, - const eAttrDomain domain, + const bke::AttrDomain domain, const int layer_index = -1, ExtraColumns extra_columns = {}) : object_eval_(object_eval), diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc index e6fdced70dc..3c9507edce0 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc @@ -33,7 +33,7 @@ class GeometryDataSetTreeView; class GeometryDataSetTreeViewItem : public ui::AbstractTreeViewItem { bke::GeometryComponent::Type component_type_; std::optional layer_index_; - std::optional domain_; + std::optional domain_; BIFIconID icon_; public: @@ -45,12 +45,12 @@ class GeometryDataSetTreeViewItem : public ui::AbstractTreeViewItem { StringRef label, BIFIconID icon); GeometryDataSetTreeViewItem(bke::GeometryComponent::Type component_type, - eAttrDomain domain, + bke::AttrDomain domain, StringRef label, BIFIconID icon); GeometryDataSetTreeViewItem(bke::GeometryComponent::Type component_type, int layer_index, - eAttrDomain domain, + bke::AttrDomain domain, StringRef label, BIFIconID icon); @@ -95,7 +95,7 @@ class GeometryDataSetTreeView : public ui::AbstractTreeView { GeometryDataSetTreeViewItem &grease_pencil_layers = grease_pencil.add_tree_item( bke::GeometryComponent::Type::GreasePencil, - ATTR_DOMAIN_LAYER, + bke::AttrDomain::Layer, IFACE_("Layer"), ICON_OUTLINER_DATA_GP_LAYER); @@ -112,12 +112,12 @@ class GeometryDataSetTreeView : public ui::AbstractTreeView { bke::GeometryComponent::Type::GreasePencil, layer_i, layer->name(), ICON_CURVE_DATA); curve.add_tree_item(bke::GeometryComponent::Type::GreasePencil, layer_i, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, IFACE_("Control Point"), ICON_CURVE_BEZCIRCLE); curve.add_tree_item(bke::GeometryComponent::Type::GreasePencil, layer_i, - ATTR_DOMAIN_CURVE, + bke::AttrDomain::Curve, IFACE_("Spline"), ICON_CURVE_PATH); } @@ -127,32 +127,36 @@ class GeometryDataSetTreeView : public ui::AbstractTreeView { { GeometryDataSetTreeViewItem &mesh = this->add_tree_item( bke::GeometryComponent::Type::Mesh, IFACE_("Mesh"), ICON_MESH_DATA); - mesh.add_tree_item( - bke::GeometryComponent::Type::Mesh, ATTR_DOMAIN_POINT, IFACE_("Vertex"), ICON_VERTEXSEL); - mesh.add_tree_item( - bke::GeometryComponent::Type::Mesh, ATTR_DOMAIN_EDGE, IFACE_("Edge"), ICON_EDGESEL); - mesh.add_tree_item( - bke::GeometryComponent::Type::Mesh, ATTR_DOMAIN_FACE, IFACE_("Face"), ICON_FACESEL); mesh.add_tree_item(bke::GeometryComponent::Type::Mesh, - ATTR_DOMAIN_CORNER, + bke::AttrDomain::Point, + IFACE_("Vertex"), + ICON_VERTEXSEL); + mesh.add_tree_item( + bke::GeometryComponent::Type::Mesh, bke::AttrDomain::Edge, IFACE_("Edge"), ICON_EDGESEL); + mesh.add_tree_item( + bke::GeometryComponent::Type::Mesh, bke::AttrDomain::Face, IFACE_("Face"), ICON_FACESEL); + mesh.add_tree_item(bke::GeometryComponent::Type::Mesh, + bke::AttrDomain::Corner, IFACE_("Face Corner"), ICON_NODE_CORNER); GeometryDataSetTreeViewItem &curve = this->add_tree_item( bke::GeometryComponent::Type::Curve, IFACE_("Curve"), ICON_CURVE_DATA); curve.add_tree_item(bke::GeometryComponent::Type::Curve, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, IFACE_("Control Point"), ICON_CURVE_BEZCIRCLE); - curve.add_tree_item( - bke::GeometryComponent::Type::Curve, ATTR_DOMAIN_CURVE, IFACE_("Spline"), ICON_CURVE_PATH); + curve.add_tree_item(bke::GeometryComponent::Type::Curve, + bke::AttrDomain::Curve, + IFACE_("Spline"), + ICON_CURVE_PATH); this->build_grease_pencil(); GeometryDataSetTreeViewItem &pointcloud = this->add_tree_item( bke::GeometryComponent::Type::PointCloud, IFACE_("Point Cloud"), ICON_POINTCLOUD_DATA); pointcloud.add_tree_item(bke::GeometryComponent::Type::PointCloud, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, IFACE_("Point"), ICON_PARTICLE_POINT); @@ -160,7 +164,7 @@ class GeometryDataSetTreeView : public ui::AbstractTreeView { bke::GeometryComponent::Type::Volume, IFACE_("Volume Grids"), ICON_VOLUME_DATA); this->add_tree_item(bke::GeometryComponent::Type::Instance, - ATTR_DOMAIN_INSTANCE, + bke::AttrDomain::Instance, IFACE_("Instances"), ICON_EMPTY_AXIS); } @@ -181,7 +185,7 @@ GeometryDataSetTreeViewItem::GeometryDataSetTreeViewItem( } GeometryDataSetTreeViewItem::GeometryDataSetTreeViewItem( bke::GeometryComponent::Type component_type, - eAttrDomain domain, + bke::AttrDomain domain, StringRef label, BIFIconID icon) : component_type_(component_type), domain_(domain), icon_(icon) @@ -191,7 +195,7 @@ GeometryDataSetTreeViewItem::GeometryDataSetTreeViewItem( GeometryDataSetTreeViewItem::GeometryDataSetTreeViewItem( bke::GeometryComponent::Type component_type, int layer_index, - eAttrDomain domain, + bke::AttrDomain domain, StringRef label, BIFIconID icon) : component_type_(component_type), layer_index_(layer_index), domain_(domain), icon_(icon) @@ -205,7 +209,7 @@ void GeometryDataSetTreeViewItem::on_activate(bContext &C) SpaceSpreadsheet &sspreadsheet = tree_view.sspreadsheet_; tree_view.sspreadsheet_.geometry_component_type = uint8_t(component_type_); if (domain_) { - tree_view.sspreadsheet_.attribute_domain = *domain_; + tree_view.sspreadsheet_.attribute_domain = uint8_t(*domain_); } if (layer_index_) { tree_view.sspreadsheet_.active_layer_index = *layer_index_; @@ -243,11 +247,11 @@ std::optional GeometryDataSetTreeViewItem::should_be_active() const if (!layer_index_) { return sspreadsheet.geometry_component_type == uint8_t(component_type_) && - sspreadsheet.attribute_domain == *domain_; + sspreadsheet.attribute_domain == uint8_t(*domain_); } return sspreadsheet.geometry_component_type == uint8_t(component_type_) && - sspreadsheet.attribute_domain == *domain_ && + sspreadsheet.attribute_domain == uint8_t(*domain_) && sspreadsheet.active_layer_index == *layer_index_; } diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc b/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc index 342010d4c93..021719194cc 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc @@ -82,14 +82,14 @@ static void SPREADSHEET_OT_remove_row_filter_rule(wmOperatorType *ot) static int select_component_domain_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { + using namespace blender; const auto component_type = blender::bke::GeometryComponent::Type( RNA_int_get(op->ptr, "component_type")); - eAttrDomain attribute_domain = static_cast( - RNA_int_get(op->ptr, "attribute_domain_type")); + bke::AttrDomain domain = bke::AttrDomain(RNA_int_get(op->ptr, "attribute_domain_type")); SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C); sspreadsheet->geometry_component_type = uint8_t(component_type); - sspreadsheet->attribute_domain = attribute_domain; + sspreadsheet->attribute_domain = uint8_t(domain); /* Refresh header and main region. */ WM_main_add_notifier(NC_SPACE | ND_SPACE_SPREADSHEET, nullptr); diff --git a/source/blender/editors/space_view3d/view3d_iterators.cc b/source/blender/editors/space_view3d/view3d_iterators.cc index 927cfd94f64..bbbf34468b5 100644 --- a/source/blender/editors/space_view3d/view3d_iterators.cc +++ b/source/blender/editors/space_view3d/view3d_iterators.cc @@ -295,12 +295,13 @@ void meshobject_foreachScreenVert(ViewContext *vc, void *user_data, eV3DProjTest clip_flag) { + using namespace blender; BLI_assert((clip_flag & V3D_PROJ_TEST_CLIP_CONTENT) == 0); foreachScreenObjectVert_userData data; const Object *ob_eval = DEG_get_evaluated_object(vc->depsgraph, vc->obact); const Mesh *mesh = BKE_object_get_evaluated_mesh(ob_eval); - const blender::bke::AttributeAccessor attributes = mesh->attributes(); + const bke::AttributeAccessor attributes = mesh->attributes(); ED_view3d_check_mats_rv3d(vc->rv3d); @@ -308,7 +309,7 @@ void meshobject_foreachScreenVert(ViewContext *vc, data.func = func; data.user_data = user_data; data.clip_flag = clip_flag; - data.hide_vert = *attributes.lookup(".hide_vert", ATTR_DOMAIN_POINT); + data.hide_vert = *attributes.lookup(".hide_vert", bke::AttrDomain::Point); if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { ED_view3d_clipping_local(vc->rv3d, vc->obact->object_to_world); diff --git a/source/blender/editors/space_view3d/view3d_select.cc b/source/blender/editors/space_view3d/view3d_select.cc index 99f6d6aa418..8415e8a75cc 100644 --- a/source/blender/editors/space_view3d/view3d_select.cc +++ b/source/blender/editors/space_view3d/view3d_select.cc @@ -356,9 +356,9 @@ static bool edbm_backbuf_check_and_select_verts_obmode(Mesh *mesh, bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter select_vert = attributes.lookup_or_add_for_write_span( - ".select_vert", ATTR_DOMAIN_POINT); + ".select_vert", bke::AttrDomain::Point); const VArray hide_vert = *attributes.lookup_or_default( - ".hide_vert", ATTR_DOMAIN_POINT, false); + ".hide_vert", bke::AttrDomain::Point, false); for (int index = 0; index < mesh->verts_num; index++) { if (!hide_vert[index]) { @@ -387,9 +387,9 @@ static bool edbm_backbuf_check_and_select_faces_obmode(Mesh *mesh, bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter select_poly = attributes.lookup_or_add_for_write_span( - ".select_poly", ATTR_DOMAIN_FACE); + ".select_poly", bke::AttrDomain::Face); const VArray hide_poly = *attributes.lookup_or_default( - ".hide_poly", ATTR_DOMAIN_FACE, false); + ".hide_poly", bke::AttrDomain::Face, false); for (int index = 0; index < mesh->faces_num; index++) { if (!hide_poly[index]) { @@ -1190,7 +1190,7 @@ static bool do_lasso_select_grease_pencil(ViewContext *vc, GreasePencil &grease_pencil = *static_cast(vc->obedit->data); /* Get selection domain from tool settings. */ - const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get( + const bke::AttrDomain selection_domain = ED_grease_pencil_selection_domain_get( vc->scene->toolsettings); bool changed = false; @@ -1292,7 +1292,7 @@ static bool do_lasso_select_paintvert(ViewContext *vc, else { bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter select_vert = attributes.lookup_or_add_for_write_span( - ".select_vert", ATTR_DOMAIN_POINT); + ".select_vert", bke::AttrDomain::Point); LassoSelectUserData_ForMeshVert data; data.select_vert = select_vert.span; @@ -1429,7 +1429,7 @@ static bool view3d_lasso_select(bContext *C, bke::CurvesGeometry &curves = curves_id.geometry.wrap(); bke::crazyspace::GeometryDeformation deformation = bke::crazyspace::get_evaluated_curves_deformation(*vc->depsgraph, *vc->obedit); - const eAttrDomain selection_domain = eAttrDomain(curves_id.selection_domain); + const bke::AttrDomain selection_domain = bke::AttrDomain(curves_id.selection_domain); const IndexRange elements(curves.attributes().domain_size(selection_domain)); changed = ed::curves::select_lasso( *vc, @@ -3010,7 +3010,7 @@ static bool ed_wpaint_vertex_select_pick(bContext *C, bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::AttributeWriter select_vert = attributes.lookup_or_add_for_write( - ".select_vert", ATTR_DOMAIN_POINT); + ".select_vert", bke::AttrDomain::Point); if (params->sel_op == SEL_OP_SET) { if ((found && params->select_passthrough) && select_vert.varray[index]) { @@ -3095,7 +3095,7 @@ static bool ed_curves_select_pick(bContext &C, const int mval[2], const SelectPi Span bases(bases_ptr, bases_len); Curves &active_curves_id = *static_cast(vc.obedit->data); - const eAttrDomain selection_domain = eAttrDomain(active_curves_id.selection_domain); + const bke::AttrDomain selection_domain = bke::AttrDomain(active_curves_id.selection_domain); const ClosestCurveDataBlock closest = threading::parallel_reduce( bases.index_range(), @@ -3200,7 +3200,7 @@ static bool ed_grease_pencil_select_pick(bContext *C, ed::greasepencil::retrieve_editable_drawings(*vc.scene, grease_pencil); /* Get selection domain from tool settings. */ - const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get( + const bke::AttrDomain selection_domain = ED_grease_pencil_selection_domain_get( vc.scene->toolsettings); const ClosestGreasePencilDrawing closest = threading::parallel_reduce( @@ -3577,7 +3577,7 @@ static bool do_paintvert_box_select(ViewContext *vc, else { bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter select_vert = attributes.lookup_or_add_for_write_span( - ".select_vert", ATTR_DOMAIN_POINT); + ".select_vert", bke::AttrDomain::Point); BoxSelectUserData_ForMeshVert data; data.select_vert = select_vert.span; @@ -4217,7 +4217,8 @@ static bool do_grease_pencil_box_select(ViewContext *vc, const rcti *rect, const GreasePencil &grease_pencil = *static_cast(vc->obedit->data); /* Get selection domain from tool settings. */ - 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 drawings = @@ -4319,7 +4320,7 @@ static int view3d_box_select_exec(bContext *C, wmOperator *op) bke::CurvesGeometry &curves = curves_id.geometry.wrap(); bke::crazyspace::GeometryDeformation deformation = bke::crazyspace::get_evaluated_curves_deformation(*vc.depsgraph, *vc.obedit); - const eAttrDomain selection_domain = eAttrDomain(curves_id.selection_domain); + const bke::AttrDomain selection_domain = bke::AttrDomain(curves_id.selection_domain); const IndexRange elements(curves.attributes().domain_size(selection_domain)); changed = ed::curves::select_box( vc, curves, deformation.positions, elements, selection_domain, rect, sel_op); @@ -4661,7 +4662,7 @@ static bool paint_vertsel_circle_select(ViewContext *vc, else { bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter select_vert = attributes.lookup_or_add_for_write_span( - ".select_vert", ATTR_DOMAIN_POINT); + ".select_vert", bke::AttrDomain::Point); CircleSelectUserData_ForMeshVert data; data.select_vert = select_vert.span; @@ -5070,7 +5071,7 @@ static bool grease_pencil_circle_select(ViewContext *vc, GreasePencil &grease_pencil = *static_cast(vc->obedit->data); /* Get selection domain from tool settings. */ - const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get( + const bke::AttrDomain selection_domain = ED_grease_pencil_selection_domain_get( vc->scene->toolsettings); bool changed = false; @@ -5144,7 +5145,7 @@ static bool obedit_circle_select(bContext *C, bke::CurvesGeometry &curves = curves_id.geometry.wrap(); bke::crazyspace::GeometryDeformation deformation = bke::crazyspace::get_evaluated_curves_deformation(*vc->depsgraph, *vc->obedit); - const eAttrDomain selection_domain = eAttrDomain(curves_id.selection_domain); + const bke::AttrDomain selection_domain = bke::AttrDomain(curves_id.selection_domain); const IndexRange elements(curves.attributes().domain_size(selection_domain)); changed = ed::curves::select_circle( *vc, curves, deformation.positions, elements, selection_domain, mval, rad, sel_op); diff --git a/source/blender/editors/transform/transform_convert_curves.cc b/source/blender/editors/transform/transform_convert_curves.cc index b1d28b541f1..854af6b87c8 100644 --- a/source/blender/editors/transform/transform_convert_curves.cc +++ b/source/blender/editors/transform/transform_convert_curves.cc @@ -103,13 +103,14 @@ static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t) bke::MutableAttributeAccessor attributes = curves.attributes_for_write(); attribute_writer = attributes.lookup_or_add_for_write_span( "radius", - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, bke::AttributeInitVArray(VArray::ForSingle(0.01f, curves.points_num()))); value_attribute = attribute_writer.span; } else if (t->mode == TFM_TILT) { bke::MutableAttributeAccessor attributes = curves.attributes_for_write(); - attribute_writer = attributes.lookup_or_add_for_write_span("tilt", ATTR_DOMAIN_POINT); + attribute_writer = attributes.lookup_or_add_for_write_span("tilt", + bke::AttrDomain::Point); value_attribute = attribute_writer.span; } @@ -168,7 +169,7 @@ void curve_populate_trans_data_structs(TransDataContainer &tc, if (use_proportional_edit) { const OffsetIndices points_by_curve = curves.points_by_curve(); const VArray selection = *curves.attributes().lookup_or_default( - ".selection", ATTR_DOMAIN_POINT, true); + ".selection", bke::AttrDomain::Point, true); affected_curves.foreach_segment(GrainSize(512), [&](const IndexMaskSegment segment) { Vector closest_distances; for (const int curve_i : segment) { diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp index ba86244e89d..db2c2fa27dc 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp @@ -518,9 +518,9 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *mesh, int id) const bke::AttributeAccessor attributes = mesh->attributes(); const VArray material_indices = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_FACE, 0); + "material_index", bke::AttrDomain::Face, 0); const VArray sharp_faces = *attributes.lookup_or_default( - "sharp_face", ATTR_DOMAIN_FACE, false); + "sharp_face", bke::AttrDomain::Face, false); // We parse the vlak nodes again and import meshes while applying the clipping // by the near and far view planes. diff --git a/source/blender/geometry/GEO_mesh_copy_selection.hh b/source/blender/geometry/GEO_mesh_copy_selection.hh index 6ad71e66e59..00c8dbce382 100644 --- a/source/blender/geometry/GEO_mesh_copy_selection.hh +++ b/source/blender/geometry/GEO_mesh_copy_selection.hh @@ -25,19 +25,19 @@ namespace blender::geometry { std::optional mesh_copy_selection( const Mesh &src_mesh, const VArray &selection, - eAttrDomain selection_domain, + bke::AttrDomain selection_domain, const bke::AnonymousAttributePropagationInfo &propagation_info); std::optional mesh_copy_selection_keep_verts( const Mesh &src_mesh, const VArray &selection, - eAttrDomain selection_domain, + bke::AttrDomain selection_domain, const bke::AnonymousAttributePropagationInfo &propagation_info); std::optional mesh_copy_selection_keep_edges( const Mesh &mesh, const VArray &selection, - eAttrDomain selection_domain, + bke::AttrDomain selection_domain, const bke::AnonymousAttributePropagationInfo &propagation_info); } // namespace blender::geometry diff --git a/source/blender/geometry/intern/add_curves_on_mesh.cc b/source/blender/geometry/intern/add_curves_on_mesh.cc index 7b86d8d7291..203ff4e5244 100644 --- a/source/blender/geometry/intern/add_curves_on_mesh.cc +++ b/source/blender/geometry/intern/add_curves_on_mesh.cc @@ -398,9 +398,9 @@ AddCurvesOnMeshOutputs add_curves_on_mesh(CurvesGeometry &curves, /* Explicitly set all other attributes besides those processed above to default values. */ bke::fill_attribute_range_default( - attributes, ATTR_DOMAIN_POINT, {"position"}, outputs.new_points_range); + attributes, bke::AttrDomain::Point, {"position"}, outputs.new_points_range); bke::fill_attribute_range_default(attributes, - ATTR_DOMAIN_CURVE, + bke::AttrDomain::Curve, {"curve_type", "surface_uv_coordinate", "resolution"}, outputs.new_curves_range); diff --git a/source/blender/geometry/intern/fillet_curves.cc b/source/blender/geometry/intern/fillet_curves.cc index 50c30f42ef1..0066e57a6a4 100644 --- a/source/blender/geometry/intern/fillet_curves.cc +++ b/source/blender/geometry/intern/fillet_curves.cc @@ -505,7 +505,7 @@ static bke::CurvesGeometry fillet_curves( } bke::copy_attributes_group_to_group(src_attributes, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, propagation_info, {}, src_points_by_curve, diff --git a/source/blender/geometry/intern/join_geometries.cc b/source/blender/geometry/intern/join_geometries.cc index bda7ac936cc..3cc6175db0a 100644 --- a/source/blender/geometry/intern/join_geometries.cc +++ b/source/blender/geometry/intern/join_geometries.cc @@ -49,7 +49,7 @@ static Map get_final_attribute_info( static void fill_new_attribute(const Span src_components, const AttributeIDRef &attribute_id, const eCustomDataType data_type, - const eAttrDomain domain, + const bke::AttrDomain domain, GMutableSpan dst_span) { const CPPType *cpp_type = bke::custom_data_type_to_cpp_type(data_type); diff --git a/source/blender/geometry/intern/mesh_copy_selection.cc b/source/blender/geometry/intern/mesh_copy_selection.cc index 6d3364f7746..8e3f7d698b7 100644 --- a/source/blender/geometry/intern/mesh_copy_selection.cc +++ b/source/blender/geometry/intern/mesh_copy_selection.cc @@ -137,7 +137,7 @@ static void gather_vert_attributes(const Mesh &mesh_src, }, [&]() { bke::gather_attributes(mesh_src.attributes(), - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, propagation_info, vertex_group_names, vert_mask, @@ -148,7 +148,7 @@ static void gather_vert_attributes(const Mesh &mesh_src, std::optional mesh_copy_selection( const Mesh &src_mesh, const VArray &selection, - const eAttrDomain selection_domain, + const bke::AttrDomain selection_domain, const bke::AnonymousAttributePropagationInfo &propagation_info) { const Span src_edges = src_mesh.edges(); @@ -169,7 +169,7 @@ std::optional mesh_copy_selection( IndexMask edge_mask; IndexMask face_mask; switch (selection_domain) { - case ATTR_DOMAIN_POINT: { + case bke::AttrDomain::Point: { const VArraySpan span(selection); threading::parallel_invoke( src_mesh.verts_num > 1024, @@ -181,7 +181,7 @@ std::optional mesh_copy_selection( }); break; } - case ATTR_DOMAIN_EDGE: { + case bke::AttrDomain::Edge: { const VArraySpan span(selection); threading::parallel_invoke( src_edges.size() > 1024, @@ -196,7 +196,7 @@ std::optional mesh_copy_selection( }); break; } - case ATTR_DOMAIN_FACE: { + case bke::AttrDomain::Face: { const VArraySpan span(selection); face_mask = IndexMask::from_bools(span, memory.local()); threading::parallel_invoke( @@ -229,14 +229,14 @@ std::optional mesh_copy_selection( Mesh *dst_mesh = create_mesh_no_attributes( src_mesh, vert_mask.size(), edge_mask.size(), face_mask.size(), 0); bke::MutableAttributeAccessor dst_attributes = dst_mesh->attributes_for_write(); - dst_attributes.add(".edge_verts", ATTR_DOMAIN_EDGE, bke::AttributeInitConstruct()); + dst_attributes.add(".edge_verts", bke::AttrDomain::Edge, bke::AttributeInitConstruct()); MutableSpan dst_edges = dst_mesh->edges_for_write(); const OffsetIndices dst_faces = offset_indices::gather_selected_offsets( src_faces, face_mask, dst_mesh->face_offsets_for_write()); dst_mesh->corners_num = dst_faces.total_size(); - dst_attributes.add(".corner_vert", ATTR_DOMAIN_CORNER, bke::AttributeInitConstruct()); - dst_attributes.add(".corner_edge", ATTR_DOMAIN_CORNER, bke::AttributeInitConstruct()); + dst_attributes.add(".corner_vert", bke::AttrDomain::Corner, bke::AttributeInitConstruct()); + dst_attributes.add(".corner_edge", bke::AttrDomain::Corner, bke::AttributeInitConstruct()); MutableSpan dst_corner_verts = dst_mesh->corner_verts_for_write(); MutableSpan dst_corner_edges = dst_mesh->corner_edges_for_write(); @@ -266,15 +266,19 @@ std::optional mesh_copy_selection( [&]() { gather_vert_attributes(src_mesh, propagation_info, vert_mask, *dst_mesh); bke::gather_attributes(src_attributes, - ATTR_DOMAIN_EDGE, + bke::AttrDomain::Edge, propagation_info, {".edge_verts"}, edge_mask, dst_attributes); - bke::gather_attributes( - src_attributes, ATTR_DOMAIN_FACE, propagation_info, {}, face_mask, dst_attributes); + bke::gather_attributes(src_attributes, + bke::AttrDomain::Face, + propagation_info, + {}, + face_mask, + dst_attributes); bke::gather_attributes_group_to_group(src_attributes, - ATTR_DOMAIN_CORNER, + bke::AttrDomain::Corner, propagation_info, {".corner_edge", ".corner_vert"}, src_faces, @@ -283,10 +287,10 @@ std::optional mesh_copy_selection( dst_attributes); }); - if (selection_domain == ATTR_DOMAIN_EDGE) { + if (selection_domain == bke::AttrDomain::Edge) { copy_loose_vert_hint(src_mesh, *dst_mesh); } - else if (selection_domain == ATTR_DOMAIN_FACE) { + else if (selection_domain == bke::AttrDomain::Face) { copy_loose_vert_hint(src_mesh, *dst_mesh); copy_loose_edge_hint(src_mesh, *dst_mesh); } @@ -298,7 +302,7 @@ std::optional mesh_copy_selection( std::optional mesh_copy_selection_keep_verts( const Mesh &src_mesh, const VArray &selection, - const eAttrDomain selection_domain, + const bke::AttrDomain selection_domain, const bke::AnonymousAttributePropagationInfo &propagation_info) { const Span src_edges = src_mesh.edges(); @@ -315,7 +319,7 @@ std::optional mesh_copy_selection_keep_verts( IndexMask edge_mask; IndexMask face_mask; switch (selection_domain) { - case ATTR_DOMAIN_POINT: { + case bke::AttrDomain::Point: { const VArraySpan span(selection); threading::parallel_invoke( src_edges.size() > 1024, @@ -326,7 +330,7 @@ std::optional mesh_copy_selection_keep_verts( }); break; } - case ATTR_DOMAIN_EDGE: { + case bke::AttrDomain::Edge: { const VArraySpan span(selection); threading::parallel_invoke( src_edges.size() > 1024, @@ -337,7 +341,7 @@ std::optional mesh_copy_selection_keep_verts( }); break; } - case ATTR_DOMAIN_FACE: { + case bke::AttrDomain::Face: { const VArraySpan span(selection); face_mask = IndexMask::from_bools(span, memory.local()); edge_mask = edge_selection_from_face( @@ -362,7 +366,7 @@ std::optional mesh_copy_selection_keep_verts( const OffsetIndices dst_faces = offset_indices::gather_selected_offsets( src_faces, face_mask, dst_mesh->face_offsets_for_write()); dst_mesh->corners_num = dst_faces.total_size(); - dst_attributes.add(".corner_edge", ATTR_DOMAIN_CORNER, bke::AttributeInitConstruct()); + dst_attributes.add(".corner_edge", bke::AttrDomain::Corner, bke::AttributeInitConstruct()); MutableSpan dst_corner_edges = dst_mesh->corner_edges_for_write(); threading::parallel_invoke( @@ -377,13 +381,21 @@ std::optional mesh_copy_selection_keep_verts( }, [&]() { bke::copy_attributes( - src_attributes, ATTR_DOMAIN_POINT, propagation_info, {}, dst_attributes); - bke::gather_attributes( - src_attributes, ATTR_DOMAIN_EDGE, propagation_info, {}, edge_mask, dst_attributes); - bke::gather_attributes( - src_attributes, ATTR_DOMAIN_FACE, propagation_info, {}, face_mask, dst_attributes); + src_attributes, bke::AttrDomain::Point, propagation_info, {}, dst_attributes); + bke::gather_attributes(src_attributes, + bke::AttrDomain::Edge, + propagation_info, + {}, + edge_mask, + dst_attributes); + bke::gather_attributes(src_attributes, + bke::AttrDomain::Face, + propagation_info, + {}, + face_mask, + dst_attributes); bke::gather_attributes_group_to_group(src_attributes, - ATTR_DOMAIN_CORNER, + bke::AttrDomain::Corner, propagation_info, {".corner_edge"}, src_faces, @@ -394,7 +406,7 @@ std::optional mesh_copy_selection_keep_verts( /* Positions are not changed by the operation, so the bounds are the same. */ dst_mesh->runtime->bounds_cache = src_mesh.runtime->bounds_cache; - if (selection_domain == ATTR_DOMAIN_FACE) { + if (selection_domain == bke::AttrDomain::Face) { copy_loose_edge_hint(src_mesh, *dst_mesh); } copy_overlapping_hint(src_mesh, *dst_mesh); @@ -405,7 +417,7 @@ std::optional mesh_copy_selection_keep_verts( std::optional mesh_copy_selection_keep_edges( const Mesh &src_mesh, const VArray &selection, - const eAttrDomain selection_domain, + const bke::AttrDomain selection_domain, const bke::AnonymousAttributePropagationInfo &propagation_info) { const OffsetIndices src_faces = src_mesh.faces(); @@ -418,15 +430,15 @@ std::optional mesh_copy_selection_keep_edges( IndexMaskMemory memory; IndexMask face_mask; switch (selection_domain) { - case ATTR_DOMAIN_POINT: + case bke::AttrDomain::Point: face_mask = face_selection_from_vert( src_faces, src_mesh.corner_verts(), VArraySpan(selection), memory); break; - case ATTR_DOMAIN_EDGE: + case bke::AttrDomain::Edge: face_mask = face_selection_from_edge( src_faces, src_mesh.corner_edges(), VArraySpan(selection), memory); break; - case ATTR_DOMAIN_FACE: + case bke::AttrDomain::Face: face_mask = IndexMask::from_bools(selection, memory); break; default: @@ -446,15 +458,17 @@ std::optional mesh_copy_selection_keep_edges( const OffsetIndices dst_faces = offset_indices::gather_selected_offsets( src_faces, face_mask, dst_mesh->face_offsets_for_write()); dst_mesh->corners_num = dst_faces.total_size(); - dst_attributes.add(".corner_vert", ATTR_DOMAIN_CORNER, bke::AttributeInitConstruct()); - dst_attributes.add(".corner_edge", ATTR_DOMAIN_CORNER, bke::AttributeInitConstruct()); + dst_attributes.add(".corner_vert", bke::AttrDomain::Corner, bke::AttributeInitConstruct()); + dst_attributes.add(".corner_edge", bke::AttrDomain::Corner, bke::AttributeInitConstruct()); - bke::copy_attributes(src_attributes, ATTR_DOMAIN_POINT, propagation_info, {}, dst_attributes); - bke::copy_attributes(src_attributes, ATTR_DOMAIN_EDGE, propagation_info, {}, dst_attributes); + bke::copy_attributes( + src_attributes, bke::AttrDomain::Point, propagation_info, {}, dst_attributes); + bke::copy_attributes( + src_attributes, bke::AttrDomain::Edge, propagation_info, {}, dst_attributes); bke::gather_attributes( - src_attributes, ATTR_DOMAIN_FACE, propagation_info, {}, face_mask, dst_attributes); + src_attributes, bke::AttrDomain::Face, propagation_info, {}, face_mask, dst_attributes); bke::gather_attributes_group_to_group(src_attributes, - ATTR_DOMAIN_CORNER, + bke::AttrDomain::Corner, propagation_info, {}, src_faces, diff --git a/source/blender/geometry/intern/mesh_primitive_cuboid.cc b/source/blender/geometry/intern/mesh_primitive_cuboid.cc index 15cff45a796..c10cec8fcb1 100644 --- a/source/blender/geometry/intern/mesh_primitive_cuboid.cc +++ b/source/blender/geometry/intern/mesh_primitive_cuboid.cc @@ -293,7 +293,7 @@ static void calculate_uvs(const CuboidConfig &config, Mesh *mesh, const bke::Att { bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter uv_attribute = - attributes.lookup_or_add_for_write_only_span(uv_id, ATTR_DOMAIN_CORNER); + attributes.lookup_or_add_for_write_only_span(uv_id, bke::AttrDomain::Corner); MutableSpan uvs = uv_attribute.span; int loop_index = 0; diff --git a/source/blender/geometry/intern/mesh_primitive_cylinder_cone.cc b/source/blender/geometry/intern/mesh_primitive_cylinder_cone.cc index 8372f22fb3e..a70c7541d42 100644 --- a/source/blender/geometry/intern/mesh_primitive_cylinder_cone.cc +++ b/source/blender/geometry/intern/mesh_primitive_cylinder_cone.cc @@ -472,7 +472,7 @@ static void calculate_selection_outputs(const ConeConfig &config, if (attribute_outputs.top_id) { const bool face = !config.top_is_point && config.fill_type != ConeFillType::None; bke::SpanAttributeWriter selection = attributes.lookup_or_add_for_write_span( - attribute_outputs.top_id.get(), face ? ATTR_DOMAIN_FACE : ATTR_DOMAIN_POINT); + attribute_outputs.top_id.get(), face ? bke::AttrDomain::Face : bke::AttrDomain::Point); if (config.top_is_point) { selection.span[config.first_vert] = true; @@ -487,7 +487,7 @@ static void calculate_selection_outputs(const ConeConfig &config, if (attribute_outputs.bottom_id) { const bool face = !config.bottom_is_point && config.fill_type != ConeFillType::None; bke::SpanAttributeWriter selection = attributes.lookup_or_add_for_write_span( - attribute_outputs.bottom_id.get(), face ? ATTR_DOMAIN_FACE : ATTR_DOMAIN_POINT); + attribute_outputs.bottom_id.get(), face ? bke::AttrDomain::Face : bke::AttrDomain::Point); if (config.bottom_is_point) { selection.span[config.last_vert] = true; @@ -504,7 +504,7 @@ static void calculate_selection_outputs(const ConeConfig &config, /* Populate "Side" selection output. */ if (attribute_outputs.side_id) { bke::SpanAttributeWriter selection = attributes.lookup_or_add_for_write_span( - attribute_outputs.side_id.get(), ATTR_DOMAIN_FACE); + attribute_outputs.side_id.get(), bke::AttrDomain::Face); selection.span.slice(config.side_faces_start, config.side_faces_len).fill(true); selection.finish(); @@ -526,7 +526,7 @@ static void calculate_cone_uvs(const ConeConfig &config, bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter uv_attribute = - attributes.lookup_or_add_for_write_only_span(uv_map_id, ATTR_DOMAIN_CORNER); + attributes.lookup_or_add_for_write_only_span(uv_map_id, bke::AttrDomain::Corner); MutableSpan uvs = uv_attribute.span; Array circle(config.circle_segments); diff --git a/source/blender/geometry/intern/mesh_primitive_grid.cc b/source/blender/geometry/intern/mesh_primitive_grid.cc index 0050992ac75..c291f49e7cc 100644 --- a/source/blender/geometry/intern/mesh_primitive_grid.cc +++ b/source/blender/geometry/intern/mesh_primitive_grid.cc @@ -17,9 +17,8 @@ static void calculate_uvs(Mesh *mesh, const bke::AttributeIDRef &uv_map_id) { bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); - - bke::SpanAttributeWriter uv_attribute = - attributes.lookup_or_add_for_write_only_span(uv_map_id, ATTR_DOMAIN_CORNER); + bke::SpanAttributeWriter uv_attribute = attributes.lookup_or_add_for_write_only_span( + uv_map_id, bke::AttrDomain::Corner); const float dx = (size_x == 0.0f) ? 0.0f : 1.0f / size_x; const float dy = (size_y == 0.0f) ? 0.0f : 1.0f / size_y; diff --git a/source/blender/geometry/intern/mesh_primitive_uv_sphere.cc b/source/blender/geometry/intern/mesh_primitive_uv_sphere.cc index 677b695413d..edaaeb085d4 100644 --- a/source/blender/geometry/intern/mesh_primitive_uv_sphere.cc +++ b/source/blender/geometry/intern/mesh_primitive_uv_sphere.cc @@ -242,7 +242,7 @@ BLI_NOINLINE static void calculate_sphere_uvs(Mesh *mesh, bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter uv_attribute = - attributes.lookup_or_add_for_write_only_span(uv_map_id, ATTR_DOMAIN_CORNER); + attributes.lookup_or_add_for_write_only_span(uv_map_id, bke::AttrDomain::Corner); MutableSpan uvs = uv_attribute.span; const float dy = 1.0f / rings; diff --git a/source/blender/geometry/intern/mesh_split_edges.cc b/source/blender/geometry/intern/mesh_split_edges.cc index 62c48826e00..b16a2847eb0 100644 --- a/source/blender/geometry/intern/mesh_split_edges.cc +++ b/source/blender/geometry/intern/mesh_split_edges.cc @@ -28,7 +28,7 @@ static void propagate_vert_attributes(Mesh &mesh, const Span new_to_old_ver bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); for (const bke::AttributeIDRef &id : attributes.all_ids()) { - if (attributes.lookup_meta_data(id)->domain != ATTR_DOMAIN_POINT) { + if (attributes.lookup_meta_data(id)->domain != bke::AttrDomain::Point) { continue; } bke::GSpanAttributeWriter attribute = attributes.lookup_for_write_span(id); @@ -67,7 +67,7 @@ static void propagate_edge_attributes(Mesh &mesh, const Span new_to_old_edg bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); for (const bke::AttributeIDRef &id : attributes.all_ids()) { - if (attributes.lookup_meta_data(id)->domain != ATTR_DOMAIN_EDGE) { + if (attributes.lookup_meta_data(id)->domain != bke::AttrDomain::Edge) { continue; } if (id.name() == ".edge_verts") { diff --git a/source/blender/geometry/intern/mesh_to_curve_convert.cc b/source/blender/geometry/intern/mesh_to_curve_convert.cc index f5dde3dc8e1..fb92c44e62f 100644 --- a/source/blender/geometry/intern/mesh_to_curve_convert.cc +++ b/source/blender/geometry/intern/mesh_to_curve_convert.cc @@ -47,12 +47,16 @@ BLI_NOINLINE bke::CurvesGeometry create_curve_from_vert_indices( } } - bke::gather_attributes( - mesh_attributes, ATTR_DOMAIN_POINT, propagation_info, skip, vert_indices, curves_attributes); + bke::gather_attributes(mesh_attributes, + bke::AttrDomain::Point, + propagation_info, + skip, + vert_indices, + curves_attributes); mesh_attributes.for_all( [&](const bke::AttributeIDRef &id, const bke::AttributeMetaData meta_data) { - if (meta_data.domain == ATTR_DOMAIN_POINT) { + if (meta_data.domain == bke::AttrDomain::Point) { return true; } if (skip.contains(id.name())) { @@ -62,14 +66,14 @@ BLI_NOINLINE bke::CurvesGeometry create_curve_from_vert_indices( return true; } - const bke::GAttributeReader src = mesh_attributes.lookup(id, ATTR_DOMAIN_POINT); + const bke::GAttributeReader src = mesh_attributes.lookup(id, bke::AttrDomain::Point); /* Some attributes might not exist if they were builtin on domains that don't have * any elements, i.e. a face attribute on the output of the line primitive node. */ if (!src) { return true; } bke::GSpanAttributeWriter dst = curves_attributes.lookup_or_add_for_write_only_span( - id, ATTR_DOMAIN_POINT, meta_data.data_type); + id, bke::AttrDomain::Point, meta_data.data_type); bke::attribute_math::gather(*src, vert_indices, dst.span); dst.finish(); return true; diff --git a/source/blender/geometry/intern/point_merge_by_distance.cc b/source/blender/geometry/intern/point_merge_by_distance.cc index 02398142658..0cf1f2e8440 100644 --- a/source/blender/geometry/intern/point_merge_by_distance.cc +++ b/source/blender/geometry/intern/point_merge_by_distance.cc @@ -108,9 +108,9 @@ PointCloud *point_merge_by_distance(const PointCloud &src_points, /* Transfer the ID attribute if it exists, using the ID of the first merged point. */ if (attribute_ids.contains("id")) { - VArraySpan src = *src_attributes.lookup_or_default("id", ATTR_DOMAIN_POINT, 0); + VArraySpan src = *src_attributes.lookup_or_default("id", bke::AttrDomain::Point, 0); bke::SpanAttributeWriter dst = dst_attributes.lookup_or_add_for_write_only_span( - "id", ATTR_DOMAIN_POINT); + "id", bke::AttrDomain::Point); threading::parallel_for(IndexRange(dst_size), 1024, [&](IndexRange range) { for (const int i_dst : range) { @@ -133,7 +133,7 @@ PointCloud *point_merge_by_distance(const PointCloud &src_points, using T = decltype(dummy); if constexpr (!std::is_void_v>) { bke::SpanAttributeWriter dst_attribute = - dst_attributes.lookup_or_add_for_write_only_span(id, ATTR_DOMAIN_POINT); + dst_attributes.lookup_or_add_for_write_only_span(id, bke::AttrDomain::Point); VArraySpan src = src_attribute.varray.typed(); threading::parallel_for(IndexRange(dst_size), 1024, [&](IndexRange range) { diff --git a/source/blender/geometry/intern/realize_instances.cc b/source/blender/geometry/intern/realize_instances.cc index aea3e283aaf..4cbaa1b40f4 100644 --- a/source/blender/geometry/intern/realize_instances.cc +++ b/source/blender/geometry/intern/realize_instances.cc @@ -28,6 +28,7 @@ namespace blender::geometry { +using blender::bke::AttrDomain; using blender::bke::AttributeIDRef; using blender::bke::AttributeKind; using blender::bke::AttributeMetaData; @@ -314,13 +315,13 @@ static void copy_generic_attributes_to_result( const Span> src_attributes, const AttributeFallbacksArray &attribute_fallbacks, const OrderedAttributes &ordered_attributes, - const FunctionRef &range_fn, + const FunctionRef &range_fn, MutableSpan dst_attribute_writers) { threading::parallel_for( dst_attribute_writers.index_range(), 10, [&](const IndexRange attribute_range) { for (const int attribute_index : attribute_range) { - const eAttrDomain domain = ordered_attributes.kinds[attribute_index].domain; + const bke::AttrDomain domain = ordered_attributes.kinds[attribute_index].domain; const IndexRange element_slice = range_fn(domain); GMutableSpan dst_span = dst_attribute_writers[attribute_index].span.slice(element_slice); @@ -708,7 +709,7 @@ static AllPointCloudsInfo preprocess_pointclouds(const bke::GeometrySet &geometr for (const int attribute_index : info.attributes.index_range()) { const AttributeIDRef &attribute_id = info.attributes.ids[attribute_index]; const eCustomDataType data_type = info.attributes.kinds[attribute_index].data_type; - const eAttrDomain domain = info.attributes.kinds[attribute_index].domain; + const bke::AttrDomain domain = info.attributes.kinds[attribute_index].domain; if (attributes.contains(attribute_id)) { GVArray attribute = *attributes.lookup_or_default(attribute_id, domain, data_type); pointcloud_info.attributes[attribute_index].emplace(std::move(attribute)); @@ -721,10 +722,11 @@ static AllPointCloudsInfo preprocess_pointclouds(const bke::GeometrySet &geometr } } if (info.create_radius_attribute) { - pointcloud_info.radii = *attributes.lookup_or_default("radius", ATTR_DOMAIN_POINT, 0.01f); + pointcloud_info.radii = *attributes.lookup_or_default( + "radius", bke::AttrDomain::Point, 0.01f); } const VArray position_attribute = *attributes.lookup_or_default( - "position", ATTR_DOMAIN_POINT, float3(0)); + "position", bke::AttrDomain::Point, float3(0)); pointcloud_info.positions = position_attribute.get_internal_span(); } return info; @@ -759,8 +761,8 @@ static void execute_realize_pointcloud_task( pointcloud_info.attributes, task.attribute_fallbacks, ordered_attributes, - [&](const eAttrDomain domain) { - BLI_assert(domain == ATTR_DOMAIN_POINT); + [&](const bke::AttrDomain domain) { + BLI_assert(domain == bke::AttrDomain::Point); UNUSED_VARS_NDEBUG(domain); return point_slice; }, @@ -792,17 +794,18 @@ static void execute_realize_pointcloud_tasks(const RealizeInstancesOptions &opti dst_pointcloud->totcol = first_pointcloud.totcol; SpanAttributeWriter positions = dst_attributes.lookup_or_add_for_write_only_span( - "position", ATTR_DOMAIN_POINT); + "position", bke::AttrDomain::Point); /* Prepare id attribute. */ SpanAttributeWriter point_ids; if (all_pointclouds_info.create_id_attribute) { - point_ids = dst_attributes.lookup_or_add_for_write_only_span("id", ATTR_DOMAIN_POINT); + point_ids = dst_attributes.lookup_or_add_for_write_only_span("id", + bke::AttrDomain::Point); } SpanAttributeWriter point_radii; if (all_pointclouds_info.create_radius_attribute) { point_radii = dst_attributes.lookup_or_add_for_write_only_span("radius", - ATTR_DOMAIN_POINT); + bke::AttrDomain::Point); } /* Prepare generic output attributes. */ @@ -811,7 +814,7 @@ static void execute_realize_pointcloud_tasks(const RealizeInstancesOptions &opti const AttributeIDRef &attribute_id = ordered_attributes.ids[attribute_index]; const eCustomDataType data_type = ordered_attributes.kinds[attribute_index].data_type; dst_attribute_writers.append(dst_attributes.lookup_or_add_for_write_only_span( - attribute_id, ATTR_DOMAIN_POINT, data_type)); + attribute_id, bke::AttrDomain::Point, data_type)); } /* Actually execute all tasks. */ @@ -941,7 +944,7 @@ static AllMeshesInfo preprocess_meshes(const bke::GeometrySet &geometry_set, for (const int attribute_index : info.attributes.index_range()) { const AttributeIDRef &attribute_id = info.attributes.ids[attribute_index]; const eCustomDataType data_type = info.attributes.kinds[attribute_index].data_type; - const eAttrDomain domain = info.attributes.kinds[attribute_index].domain; + const bke::AttrDomain domain = info.attributes.kinds[attribute_index].domain; if (attributes.contains(attribute_id)) { GVArray attribute = *attributes.lookup_or_default(attribute_id, domain, data_type); mesh_info.attributes[attribute_index].emplace(std::move(attribute)); @@ -954,7 +957,7 @@ static AllMeshesInfo preprocess_meshes(const bke::GeometrySet &geometry_set, } } mesh_info.material_indices = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_FACE, 0); + "material_index", bke::AttrDomain::Face, 0); } info.no_loose_edges_hint = std::all_of( @@ -1067,15 +1070,15 @@ static void execute_realize_mesh_task(const RealizeInstancesOptions &options, mesh_info.attributes, task.attribute_fallbacks, ordered_attributes, - [&](const eAttrDomain domain) { + [&](const bke::AttrDomain domain) { switch (domain) { - case ATTR_DOMAIN_POINT: + case bke::AttrDomain::Point: return dst_vert_range; - case ATTR_DOMAIN_EDGE: + case bke::AttrDomain::Edge: return dst_edge_range; - case ATTR_DOMAIN_FACE: + case bke::AttrDomain::Face: return dst_face_range; - case ATTR_DOMAIN_CORNER: + case bke::AttrDomain::Corner: return dst_loop_range; default: BLI_assert_unreachable(); @@ -1129,20 +1132,21 @@ static void execute_realize_mesh_tasks(const RealizeInstancesOptions &options, /* Prepare id attribute. */ SpanAttributeWriter vertex_ids; if (all_meshes_info.create_id_attribute) { - vertex_ids = dst_attributes.lookup_or_add_for_write_only_span("id", ATTR_DOMAIN_POINT); + vertex_ids = dst_attributes.lookup_or_add_for_write_only_span("id", + bke::AttrDomain::Point); } /* Prepare material indices. */ SpanAttributeWriter material_indices; if (all_meshes_info.create_material_index_attribute) { - material_indices = dst_attributes.lookup_or_add_for_write_only_span("material_index", - ATTR_DOMAIN_FACE); + material_indices = dst_attributes.lookup_or_add_for_write_only_span( + "material_index", bke::AttrDomain::Face); } /* Prepare generic output attributes. */ Vector dst_attribute_writers; for (const int attribute_index : ordered_attributes.index_range()) { const AttributeIDRef &attribute_id = ordered_attributes.ids[attribute_index]; - const eAttrDomain domain = ordered_attributes.kinds[attribute_index].domain; + const bke::AttrDomain domain = ordered_attributes.kinds[attribute_index].domain; const eCustomDataType data_type = ordered_attributes.kinds[attribute_index].data_type; dst_attribute_writers.append( dst_attributes.lookup_or_add_for_write_only_span(attribute_id, domain, data_type)); @@ -1256,7 +1260,7 @@ static AllCurvesInfo preprocess_curves(const bke::GeometrySet &geometry_set, bke::AttributeAccessor attributes = curves.attributes(); curve_info.attributes.reinitialize(info.attributes.size()); for (const int attribute_index : info.attributes.index_range()) { - const eAttrDomain domain = info.attributes.kinds[attribute_index].domain; + const bke::AttrDomain domain = info.attributes.kinds[attribute_index].domain; const AttributeIDRef &attribute_id = info.attributes.ids[attribute_index]; const eCustomDataType data_type = info.attributes.kinds[attribute_index].data_type; if (attributes.contains(attribute_id)) { @@ -1273,12 +1277,12 @@ static AllCurvesInfo preprocess_curves(const bke::GeometrySet &geometry_set, if (attributes.contains("radius")) { curve_info.radius = - attributes.lookup("radius", ATTR_DOMAIN_POINT).varray.get_internal_span(); + attributes.lookup("radius", bke::AttrDomain::Point).varray.get_internal_span(); info.create_radius_attribute = true; } if (attributes.contains("nurbs_weight")) { - curve_info.nurbs_weight = - attributes.lookup("nurbs_weight", ATTR_DOMAIN_POINT).varray.get_internal_span(); + curve_info.nurbs_weight = attributes.lookup("nurbs_weight", bke::AttrDomain::Point) + .varray.get_internal_span(); info.create_nurbs_weight_attribute = true; } curve_info.resolution = curves.resolution(); @@ -1286,10 +1290,10 @@ static AllCurvesInfo preprocess_curves(const bke::GeometrySet &geometry_set, info.create_resolution_attribute = true; } if (attributes.contains("handle_right")) { - curve_info.handle_left = - attributes.lookup("handle_left", ATTR_DOMAIN_POINT).varray.get_internal_span(); - curve_info.handle_right = - attributes.lookup("handle_right", ATTR_DOMAIN_POINT).varray.get_internal_span(); + curve_info.handle_left = attributes.lookup("handle_left", bke::AttrDomain::Point) + .varray.get_internal_span(); + curve_info.handle_right = attributes.lookup("handle_right", bke::AttrDomain::Point) + .varray.get_internal_span(); info.create_handle_postion_attributes = true; } } @@ -1375,11 +1379,11 @@ static void execute_realize_curve_task(const RealizeInstancesOptions &options, curves_info.attributes, task.attribute_fallbacks, ordered_attributes, - [&](const eAttrDomain domain) { + [&](const bke::AttrDomain domain) { switch (domain) { - case ATTR_DOMAIN_POINT: + case bke::AttrDomain::Point: return IndexRange(task.start_indices.point, curves.points_num()); - case ATTR_DOMAIN_CURVE: + case bke::AttrDomain::Curve: return IndexRange(task.start_indices.curve, curves.curves_num()); default: BLI_assert_unreachable(); @@ -1419,14 +1423,15 @@ static void execute_realize_curve_tasks(const RealizeInstancesOptions &options, /* Prepare id attribute. */ SpanAttributeWriter point_ids; if (all_curves_info.create_id_attribute) { - point_ids = dst_attributes.lookup_or_add_for_write_only_span("id", ATTR_DOMAIN_POINT); + point_ids = dst_attributes.lookup_or_add_for_write_only_span("id", + bke::AttrDomain::Point); } /* Prepare generic output attributes. */ Vector dst_attribute_writers; for (const int attribute_index : ordered_attributes.index_range()) { const AttributeIDRef &attribute_id = ordered_attributes.ids[attribute_index]; - const eAttrDomain domain = ordered_attributes.kinds[attribute_index].domain; + const bke::AttrDomain domain = ordered_attributes.kinds[attribute_index].domain; const eCustomDataType data_type = ordered_attributes.kinds[attribute_index].data_type; dst_attribute_writers.append( dst_attributes.lookup_or_add_for_write_only_span(attribute_id, domain, data_type)); @@ -1437,24 +1442,25 @@ static void execute_realize_curve_tasks(const RealizeInstancesOptions &options, SpanAttributeWriter handle_right; if (all_curves_info.create_handle_postion_attributes) { handle_left = dst_attributes.lookup_or_add_for_write_only_span("handle_left", - ATTR_DOMAIN_POINT); - handle_right = dst_attributes.lookup_or_add_for_write_only_span("handle_right", - ATTR_DOMAIN_POINT); + bke::AttrDomain::Point); + handle_right = dst_attributes.lookup_or_add_for_write_only_span( + "handle_right", bke::AttrDomain::Point); } SpanAttributeWriter radius; if (all_curves_info.create_radius_attribute) { - radius = dst_attributes.lookup_or_add_for_write_only_span("radius", ATTR_DOMAIN_POINT); + radius = dst_attributes.lookup_or_add_for_write_only_span("radius", + bke::AttrDomain::Point); } SpanAttributeWriter nurbs_weight; if (all_curves_info.create_nurbs_weight_attribute) { nurbs_weight = dst_attributes.lookup_or_add_for_write_only_span("nurbs_weight", - ATTR_DOMAIN_POINT); + bke::AttrDomain::Point); } SpanAttributeWriter resolution; if (all_curves_info.create_resolution_attribute) { resolution = dst_attributes.lookup_or_add_for_write_only_span("resolution", - ATTR_DOMAIN_CURVE); + bke::AttrDomain::Curve); } /* Actually execute all tasks. */ diff --git a/source/blender/geometry/intern/resample_curves.cc b/source/blender/geometry/intern/resample_curves.cc index e17fbca6ec1..6c530fbab87 100644 --- a/source/blender/geometry/intern/resample_curves.cc +++ b/source/blender/geometry/intern/resample_curves.cc @@ -100,13 +100,13 @@ static void retrieve_attribute_spans(const Span ids, { const bke::AttributeAccessor src_attributes = src_curves.attributes(); for (const int i : ids.index_range()) { - const GVArray src_attribute = *src_attributes.lookup(ids[i], ATTR_DOMAIN_POINT); + const GVArray src_attribute = *src_attributes.lookup(ids[i], bke::AttrDomain::Point); src.append(src_attribute.get_internal_span()); const eCustomDataType data_type = bke::cpp_type_to_custom_data_type(src_attribute.type()); bke::GSpanAttributeWriter dst_attribute = dst_curves.attributes_for_write().lookup_or_add_for_write_only_span( - ids[i], ATTR_DOMAIN_POINT, data_type); + ids[i], bke::AttrDomain::Point, data_type); dst.append(dst_attribute.span); dst_attributes.append(std::move(dst_attribute)); } @@ -140,7 +140,7 @@ static void gather_point_attributes_to_interpolate( VectorSet ids_no_interpolation; src_curves.attributes().for_all( [&](const bke::AttributeIDRef &id, const bke::AttributeMetaData meta_data) { - if (meta_data.domain != ATTR_DOMAIN_POINT) { + if (meta_data.domain != bke::AttrDomain::Point) { return true; } if (meta_data.data_type == CD_PROP_STRING) { @@ -178,14 +178,14 @@ static void gather_point_attributes_to_interpolate( if (output_ids.tangent_id) { result.src_evaluated_tangents = src_curves.evaluated_tangents(); bke::GSpanAttributeWriter dst_attribute = dst_attributes.lookup_or_add_for_write_only_span( - output_ids.tangent_id, ATTR_DOMAIN_POINT, CD_PROP_FLOAT3); + output_ids.tangent_id, bke::AttrDomain::Point, CD_PROP_FLOAT3); result.dst_tangents = dst_attribute.span.typed(); result.dst_attributes.append(std::move(dst_attribute)); } if (output_ids.normal_id) { result.src_evaluated_normals = src_curves.evaluated_normals(); bke::GSpanAttributeWriter dst_attribute = dst_attributes.lookup_or_add_for_write_only_span( - output_ids.normal_id, ATTR_DOMAIN_POINT, CD_PROP_FLOAT3); + output_ids.normal_id, bke::AttrDomain::Point, CD_PROP_FLOAT3); result.dst_normals = dst_attribute.span.typed(); result.dst_attributes.append(std::move(dst_attribute)); } diff --git a/source/blender/geometry/intern/set_curve_type.cc b/source/blender/geometry/intern/set_curve_type.cc index 996545de5fa..499e66be2a8 100644 --- a/source/blender/geometry/intern/set_curve_type.cc +++ b/source/blender/geometry/intern/set_curve_type.cc @@ -454,7 +454,7 @@ static bke::CurvesGeometry convert_curves_to_bezier( } bke::copy_attributes_group_to_group(src_attributes, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, propagation_info, {}, src_points_by_curve, @@ -623,7 +623,7 @@ static bke::CurvesGeometry convert_curves_to_nurbs( } bke::copy_attributes_group_to_group(src_attributes, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, propagation_info, {}, src_points_by_curve, diff --git a/source/blender/geometry/intern/subdivide_curves.cc b/source/blender/geometry/intern/subdivide_curves.cc index a5cf22c9436..4d7854a94f6 100644 --- a/source/blender/geometry/intern/subdivide_curves.cc +++ b/source/blender/geometry/intern/subdivide_curves.cc @@ -411,7 +411,7 @@ bke::CurvesGeometry subdivide_curves( subdivide_nurbs); bke::copy_attributes_group_to_group(src_attributes, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, propagation_info, {}, src_points_by_curve, diff --git a/source/blender/geometry/intern/trim_curves.cc b/source/blender/geometry/intern/trim_curves.cc index 8b74f5f862c..5a08fcb472a 100644 --- a/source/blender/geometry/intern/trim_curves.cc +++ b/source/blender/geometry/intern/trim_curves.cc @@ -1060,7 +1060,7 @@ bke::CurvesGeometry trim_curves(const bke::CurvesGeometry &src_curves, } bke::copy_attributes_group_to_group(src_attributes, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, propagation_info, copy_point_skip, src_points_by_curve, diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc index 255b94dfb58..4a5cf740ca0 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc @@ -1964,7 +1964,8 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, /* Triangulate. */ const Span corner_tris = mesh->corner_tris(); const bke::AttributeAccessor attributes = mesh->attributes(); - const VArraySpan material_indices = *attributes.lookup("material_index", ATTR_DOMAIN_FACE); + const VArraySpan material_indices = *attributes.lookup("material_index", + bke::AttrDomain::Face); /* Check if we should look for custom data tags like Freestyle edges or faces. */ bool can_find_freestyle_edge = false; @@ -2094,9 +2095,9 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, edge_feat_settings.func_reduce = feat_data_sum_reduce; const VArray sharp_edges = *attributes.lookup_or_default( - "sharp_edge", ATTR_DOMAIN_EDGE, false); + "sharp_edge", bke::AttrDomain::Edge, false); const VArray sharp_faces = *attributes.lookup_or_default( - "sharp_face", ATTR_DOMAIN_FACE, false); + "sharp_face", bke::AttrDomain::Face, false); EdgeFeatData edge_feat_data = {nullptr}; edge_feat_data.ld = la_data; diff --git a/source/blender/gpu/intern/gpu_shader_builder_stubs.cc b/source/blender/gpu/intern/gpu_shader_builder_stubs.cc index b6d1feb9f87..a4e274d3032 100644 --- a/source/blender/gpu/intern/gpu_shader_builder_stubs.cc +++ b/source/blender/gpu/intern/gpu_shader_builder_stubs.cc @@ -106,18 +106,6 @@ void UI_GetThemeColorShadeAlpha4ubv(int /*colorid*/, /** \} */ -/* -------------------------------------------------------------------- */ -/** \name Stubs of BKE_attribute.h - * \{ */ - -extern "C" eAttrDomain BKE_id_attribute_domain(const struct ID * /*id*/, - const struct CustomDataLayer * /*layer*/) -{ - return ATTR_DOMAIN_AUTO; -} - -/** \} */ - /* -------------------------------------------------------------------- */ /** \name Stubs of BKE_paint.hh * \{ */ diff --git a/source/blender/io/alembic/exporter/abc_writer_mesh.cc b/source/blender/io/alembic/exporter/abc_writer_mesh.cc index d32179bd1a1..92131ed11a9 100644 --- a/source/blender/io/alembic/exporter/abc_writer_mesh.cc +++ b/source/blender/io/alembic/exporter/abc_writer_mesh.cc @@ -370,7 +370,7 @@ bool ABCGenericMeshWriter::get_velocities(Mesh *mesh, std::vector &v /* Export velocity attribute output by fluid sim, sequence cache modifier * and geometry nodes. */ const CustomDataLayer *velocity_layer = BKE_id_attribute_find( - &mesh->id, "velocity", CD_PROP_FLOAT3, ATTR_DOMAIN_POINT); + &mesh->id, "velocity", CD_PROP_FLOAT3, bke::AttrDomain::Point); if (velocity_layer == nullptr) { return false; @@ -395,7 +395,7 @@ void ABCGenericMeshWriter::get_geo_groups(Object *object, { const bke::AttributeAccessor attributes = mesh->attributes(); const VArraySpan material_indices = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_FACE, 0); + "material_index", bke::AttrDomain::Face, 0); for (const int i : material_indices.index_range()) { short mnr = material_indices[i]; @@ -478,7 +478,8 @@ static void get_edge_creases(Mesh *mesh, sharpnesses.clear(); const bke::AttributeAccessor attributes = mesh->attributes(); - const bke::AttributeReader attribute = attributes.lookup("crease_edge", ATTR_DOMAIN_EDGE); + const bke::AttributeReader attribute = attributes.lookup("crease_edge", + bke::AttrDomain::Edge); if (!attribute) { return; } @@ -506,7 +507,7 @@ static void get_vert_creases(Mesh *mesh, const bke::AttributeAccessor attributes = mesh->attributes(); const bke::AttributeReader attribute = attributes.lookup("crease_vert", - ATTR_DOMAIN_POINT); + bke::AttrDomain::Point); if (!attribute) { return; } diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc index 3abe6100ec4..a931573a5d1 100644 --- a/source/blender/io/alembic/intern/abc_reader_mesh.cc +++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc @@ -450,7 +450,7 @@ static void read_velocity(const V3fArraySamplePtr &velocities, } CustomDataLayer *velocity_layer = BKE_id_attribute_new( - &config.mesh->id, "velocity", CD_PROP_FLOAT3, ATTR_DOMAIN_POINT, nullptr); + &config.mesh->id, "velocity", CD_PROP_FLOAT3, bke::AttrDomain::Point, nullptr); float(*velocity)[3] = (float(*)[3])velocity_layer->data; for (int i = 0; i < num_velocity_vectors; i++) { @@ -834,7 +834,7 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh, std::map mat_map; bke::MutableAttributeAccessor attributes = new_mesh->attributes_for_write(); bke::SpanAttributeWriter material_indices = - attributes.lookup_or_add_for_write_span("material_index", ATTR_DOMAIN_FACE); + attributes.lookup_or_add_for_write_span("material_index", bke::AttrDomain::Face); assign_facesets_to_material_indices(sample_sel, material_indices.span, mat_map); material_indices.finish(); } @@ -895,7 +895,7 @@ void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, const ISampleSel std::map mat_map; bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter material_indices = attributes.lookup_or_add_for_write_span( - "material_index", ATTR_DOMAIN_FACE); + "material_index", bke::AttrDomain::Face); assign_facesets_to_material_indices(sample_sel, material_indices.span, mat_map); material_indices.finish(); utils::assign_materials(bmain, m_object, mat_map); diff --git a/source/blender/io/collada/GeometryExporter.cpp b/source/blender/io/collada/GeometryExporter.cpp index 650f6a5d9cd..308f5a02fa8 100644 --- a/source/blender/io/collada/GeometryExporter.cpp +++ b/source/blender/io/collada/GeometryExporter.cpp @@ -294,10 +294,11 @@ static bool collect_vertex_counts_per_poly(Mesh *mesh, int material_index, std::vector &vcount_list) { + using namespace blender; const blender::OffsetIndices faces = mesh->faces(); const blender::bke::AttributeAccessor attributes = mesh->attributes(); const blender::VArray material_indices = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_FACE, 0); + "material_index", bke::AttrDomain::Face, 0); bool is_triangulated = true; /* Expecting that the material index is always 0 if the mesh has no materials assigned */ @@ -328,6 +329,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index, std::string &geom_id, std::vector &norind) { + using namespace blender; const blender::OffsetIndices faces = mesh->faces(); const Span corner_verts = mesh->corner_verts(); @@ -407,7 +409,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index, const blender::bke::AttributeAccessor attributes = mesh->attributes(); const blender::VArray material_indices = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_FACE, 0); + "material_index", bke::AttrDomain::Face, 0); /*

*/ int texindex = 0; @@ -627,7 +629,7 @@ void GeometryExporter::create_normals(std::vector &normals, const bke::AttributeAccessor attributes = mesh->attributes(); const VArray sharp_faces = *attributes.lookup_or_default( - "sharp_face", ATTR_DOMAIN_FACE, false); + "sharp_face", bke::AttrDomain::Face, false); blender::Span corner_normals; if (mesh->normals_domain() == blender::bke::MeshNormalDomain::Corner) { diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp index 140f291fc6a..5316d2016dd 100644 --- a/source/blender/io/collada/MeshImporter.cpp +++ b/source/blender/io/collada/MeshImporter.cpp @@ -621,7 +621,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter material_indices = attributes.lookup_or_add_for_write_span( - "material_index", ATTR_DOMAIN_FACE); + "material_index", bke::AttrDomain::Face); bool *sharp_faces = static_cast(CustomData_get_layer_named_for_write( &mesh->face_data, CD_PROP_BOOL, "sharp_face", mesh->faces_num)); diff --git a/source/blender/io/ply/exporter/ply_export_load_plydata.cc b/source/blender/io/ply/exporter/ply_export_load_plydata.cc index 22c8e0a8fb1..ea5d68b5b8c 100644 --- a/source/blender/io/ply/exporter/ply_export_load_plydata.cc +++ b/source/blender/io/ply/exporter/ply_export_load_plydata.cc @@ -95,7 +95,7 @@ static void generate_vertex_map(const Mesh *mesh, const StringRef uv_name = CustomData_get_active_layer_name(&mesh->corner_data, CD_PROP_FLOAT2); if (!uv_name.is_empty()) { const bke::AttributeAccessor attributes = mesh->attributes(); - uv_map = *attributes.lookup(uv_name, ATTR_DOMAIN_CORNER); + uv_map = *attributes.lookup(uv_name, bke::AttrDomain::Corner); export_uv = !uv_map.is_empty(); } } @@ -179,7 +179,7 @@ static void load_custom_attributes(const Mesh *mesh, attributes.for_all([&](const bke::AttributeIDRef &attribute_id, const bke::AttributeMetaData &meta_data) { /* Skip internal, standard and non-vertex domain attributes. */ - if (meta_data.domain != ATTR_DOMAIN_POINT || attribute_id.name()[0] == '.' || + if (meta_data.domain != bke::AttrDomain::Point || attribute_id.name()[0] == '.' || attribute_id.is_anonymous() || ELEM(attribute_id.name(), "position", color_name, uv_name)) { return true; @@ -435,9 +435,8 @@ void load_plydata(PlyData &plyData, Depsgraph *depsgraph, const PLYExportParams const StringRef name = mesh->active_color_attribute; if (!name.is_empty()) { const bke::AttributeAccessor attributes = mesh->attributes(); - const VArray color_attribute = - *attributes.lookup_or_default( - name, ATTR_DOMAIN_POINT, {0.0f, 0.0f, 0.0f, 0.0f}); + const VArray color_attribute = *attributes.lookup_or_default( + name, bke::AttrDomain::Point, {0.0f, 0.0f, 0.0f, 0.0f}); if (!color_attribute.is_empty()) { if (plyData.vertex_colors.size() != vertex_offset) { plyData.vertex_colors.resize(vertex_offset, float4(0)); diff --git a/source/blender/io/ply/importer/ply_import_mesh.cc b/source/blender/io/ply/importer/ply_import_mesh.cc index bca9845c3c0..915567ac419 100644 --- a/source/blender/io/ply/importer/ply_import_mesh.cc +++ b/source/blender/io/ply/importer/ply_import_mesh.cc @@ -73,7 +73,7 @@ Mesh *convert_ply_to_mesh(PlyData &data, const PLYImportParams ¶ms) if (!data.vertex_colors.is_empty() && params.vertex_colors != PLY_VERTEX_COLOR_NONE) { /* Create a data layer for vertex colors and set them. */ bke::SpanAttributeWriter colors = - attributes.lookup_or_add_for_write_span("Col", ATTR_DOMAIN_POINT); + attributes.lookup_or_add_for_write_span("Col", bke::AttrDomain::Point); if (params.vertex_colors == PLY_VERTEX_COLOR_SRGB) { for (const int i : data.vertex_colors.index_range()) { @@ -93,7 +93,7 @@ Mesh *convert_ply_to_mesh(PlyData &data, const PLYImportParams ¶ms) /* Uvmap */ if (!data.uv_coordinates.is_empty()) { bke::SpanAttributeWriter uv_map = attributes.lookup_or_add_for_write_only_span( - "UVMap", ATTR_DOMAIN_CORNER); + "UVMap", bke::AttrDomain::Corner); for (const int i : data.face_vertices.index_range()) { uv_map.span[i] = data.uv_coordinates[data.face_vertices[i]]; } @@ -115,7 +115,7 @@ Mesh *convert_ply_to_mesh(PlyData &data, const PLYImportParams ¶ms) /* If we have no faces, add vertex normals as custom attribute. */ attributes.add( "normal", - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, bke::AttributeInitVArray(VArray::ForSpan(data.vertex_normals))); } } @@ -128,7 +128,7 @@ Mesh *convert_ply_to_mesh(PlyData &data, const PLYImportParams ¶ms) if (params.import_attributes && !data.vertex_custom_attr.is_empty()) { for (const PlyCustomAttribute &attr : data.vertex_custom_attr) { attributes.add(attr.name, - ATTR_DOMAIN_POINT, + bke::AttrDomain::Point, bke::AttributeInitVArray(VArray::ForSpan(attr.data))); } } diff --git a/source/blender/io/usd/hydra/curves.cc b/source/blender/io/usd/hydra/curves.cc index e12378309a2..2cd6398dac0 100644 --- a/source/blender/io/usd/hydra/curves.cc +++ b/source/blender/io/usd/hydra/curves.cc @@ -157,7 +157,7 @@ void CurvesData::write_curves(const Curves *curves_id) MutableSpan(vertices_.data(), vertices_.size()).copy_from(positions.cast()); const VArray radii = *curves.attributes().lookup_or_default( - "radius", ATTR_DOMAIN_POINT, 0.01f); + "radius", bke::AttrDomain::Point, 0.01f); widths_.resize(curves.points_num()); for (const int i : curves.points_range()) { widths_[i] = radii[i] * 2.0f; diff --git a/source/blender/io/usd/hydra/mesh.cc b/source/blender/io/usd/hydra/mesh.cc index 248595631c1..bf366c21e87 100644 --- a/source/blender/io/usd/hydra/mesh.cc +++ b/source/blender/io/usd/hydra/mesh.cc @@ -376,8 +376,8 @@ void MeshData::write_submeshes(const Mesh *mesh) const std::pair> normals = get_mesh_normals(*mesh); const bke::AttributeAccessor attributes = mesh->attributes(); const StringRef active_uv = CustomData_get_active_layer_name(&mesh->corner_data, CD_PROP_FLOAT2); - const VArraySpan uv_map = *attributes.lookup(active_uv, ATTR_DOMAIN_CORNER); - const VArraySpan material_indices = *attributes.lookup("material_index", ATTR_DOMAIN_FACE); + const VArraySpan uv_map = *attributes.lookup(active_uv, bke::AttrDomain::Corner); + const VArraySpan material_indices = *attributes.lookup("material_index", bke::AttrDomain::Face); if (material_indices.is_empty()) { copy_submesh(*mesh, diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index 523e6ea8cd2..cec1ce04925 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -213,24 +213,24 @@ static std::optional convert_usd_type_to_blender( return *value; } -static const std::optional convert_usd_varying_to_blender( +static const std::optional convert_usd_varying_to_blender( const pxr::TfToken usd_domain, ReportList *reports) { - static const blender::Map domain_map = []() { - blender::Map map; - map.add_new(pxr::UsdGeomTokens->faceVarying, ATTR_DOMAIN_CORNER); - map.add_new(pxr::UsdGeomTokens->vertex, ATTR_DOMAIN_POINT); - map.add_new(pxr::UsdGeomTokens->varying, ATTR_DOMAIN_POINT); - map.add_new(pxr::UsdGeomTokens->face, ATTR_DOMAIN_FACE); + static const blender::Map domain_map = []() { + blender::Map map; + map.add_new(pxr::UsdGeomTokens->faceVarying, bke::AttrDomain::Corner); + map.add_new(pxr::UsdGeomTokens->vertex, bke::AttrDomain::Point); + map.add_new(pxr::UsdGeomTokens->varying, bke::AttrDomain::Point); + map.add_new(pxr::UsdGeomTokens->face, bke::AttrDomain::Face); /* As there's no "constant" type in Blender, for now we're * translating into a point Attribute. */ - map.add_new(pxr::UsdGeomTokens->constant, ATTR_DOMAIN_POINT); - map.add_new(pxr::UsdGeomTokens->uniform, ATTR_DOMAIN_FACE); + map.add_new(pxr::UsdGeomTokens->constant, bke::AttrDomain::Point); + map.add_new(pxr::UsdGeomTokens->uniform, bke::AttrDomain::Face); /* Notice: Edge types are not supported! */ return map; }(); - const eAttrDomain *value = domain_map.lookup_ptr(usd_domain); + const bke::AttrDomain *value = domain_map.lookup_ptr(usd_domain); if (value == nullptr) { BKE_reportf( @@ -423,14 +423,14 @@ void USDMeshReader::read_color_data_primvar(Mesh *mesh, const StringRef primvar_name(primvar.GetBaseName().GetString()); bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); - eAttrDomain color_domain = ATTR_DOMAIN_POINT; + bke::AttrDomain color_domain = bke::AttrDomain::Point; if (ELEM(interp, pxr::UsdGeomTokens->varying, pxr::UsdGeomTokens->faceVarying, pxr::UsdGeomTokens->uniform)) { - color_domain = ATTR_DOMAIN_CORNER; + color_domain = bke::AttrDomain::Corner; } bke::SpanAttributeWriter color_data; @@ -540,7 +540,7 @@ void USDMeshReader::read_uv_data_primvar(Mesh *mesh, bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter uv_data = attributes.lookup_or_add_for_write_only_span( - primvar_name, ATTR_DOMAIN_CORNER); + primvar_name, bke::AttrDomain::Corner); if (!uv_data) { BKE_reportf(reports(), @@ -667,8 +667,8 @@ void USDMeshReader::read_generic_data_primvar(Mesh *mesh, const pxr::TfToken varying_type = primvar.GetInterpolation(); const pxr::TfToken name = pxr::UsdGeomPrimvar::StripPrimvarsName(primvar.GetPrimvarName()); - const std::optional domain = convert_usd_varying_to_blender(varying_type, - reports()); + const std::optional domain = convert_usd_varying_to_blender(varying_type, + reports()); const std::optional type = convert_usd_type_to_blender(sdf_type, reports()); if (!domain.has_value() || !type.has_value()) { @@ -740,7 +740,7 @@ void USDMeshReader::read_vertex_creases(Mesh *mesh, const double motionSampleTim bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter creases = attributes.lookup_or_add_for_write_span( - "crease_vert", ATTR_DOMAIN_POINT); + "crease_vert", bke::AttrDomain::Point); for (size_t i = 0; i < corner_indices.size(); i++) { creases.span[corner_indices[i]] = corner_sharpnesses[i]; @@ -1072,7 +1072,7 @@ void USDMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, const double mot bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter material_indices = attributes.lookup_or_add_for_write_span( - "material_index", ATTR_DOMAIN_FACE); + "material_index", bke::AttrDomain::Face); this->assign_facesets_to_material_indices(motionSampleTime, material_indices.span, &mat_map); material_indices.finish(); /* Build material name map if it's not built yet. */ @@ -1127,7 +1127,7 @@ Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh, std::map mat_map; bke::MutableAttributeAccessor attributes = active_mesh->attributes_for_write(); bke::SpanAttributeWriter material_indices = - attributes.lookup_or_add_for_write_span("material_index", ATTR_DOMAIN_FACE); + attributes.lookup_or_add_for_write_span("material_index", bke::AttrDomain::Face); assign_facesets_to_material_indices( params.motion_sample_time, material_indices.span, &mat_map); material_indices.finish(); diff --git a/source/blender/io/usd/intern/usd_writer_curves.cc b/source/blender/io/usd/intern/usd_writer_curves.cc index d4095788bdb..d1409584ae7 100644 --- a/source/blender/io/usd/intern/usd_writer_curves.cc +++ b/source/blender/io/usd/intern/usd_writer_curves.cc @@ -73,7 +73,7 @@ static void populate_curve_widths(const bke::CurvesGeometry &geometry, pxr::VtAr { const bke::AttributeAccessor curve_attributes = geometry.attributes(); const bke::AttributeReader radii = curve_attributes.lookup("radius", - ATTR_DOMAIN_POINT); + bke::AttrDomain::Point); widths.resize(radii.varray.size()); diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc index 3d6650b0ecf..5ef19c6980f 100644 --- a/source/blender/io/usd/intern/usd_writer_mesh.cc +++ b/source/blender/io/usd/intern/usd_writer_mesh.cc @@ -132,21 +132,21 @@ void USDGenericMeshWriter::write_custom_data(const Mesh *mesh, pxr::UsdGeomMesh * edge domain because USD doesn't have a good * conversion for them. */ if (attribute_id.name()[0] == '.' || attribute_id.is_anonymous() || - meta_data.domain == ATTR_DOMAIN_EDGE || + meta_data.domain == bke::AttrDomain::Edge || ELEM(attribute_id.name(), "position", "material_index")) { return true; } /* UV Data. */ - if (meta_data.domain == ATTR_DOMAIN_CORNER && meta_data.data_type == CD_PROP_FLOAT2) { + if (meta_data.domain == bke::AttrDomain::Corner && meta_data.data_type == CD_PROP_FLOAT2) { if (usd_export_context_.export_params.export_uvmaps) { write_uv_data(mesh, usd_mesh, attribute_id, active_set_name); } } /* Color data. */ - else if (ELEM(meta_data.domain, ATTR_DOMAIN_CORNER, ATTR_DOMAIN_POINT) && + else if (ELEM(meta_data.domain, bke::AttrDomain::Corner, bke::AttrDomain::Point) && ELEM(meta_data.data_type, CD_PROP_BYTE_COLOR, CD_PROP_COLOR)) { if (usd_export_context_.export_params.export_mesh_colors) { @@ -188,14 +188,14 @@ static std::optional convert_blender_type_to_usd( } static const std::optional convert_blender_domain_to_usd( - const eAttrDomain blender_domain, ReportList *reports) + const bke::AttrDomain blender_domain, ReportList *reports) { switch (blender_domain) { - case ATTR_DOMAIN_CORNER: + case bke::AttrDomain::Corner: return pxr::UsdGeomTokens->faceVarying; - case ATTR_DOMAIN_POINT: + case bke::AttrDomain::Point: return pxr::UsdGeomTokens->vertex; - case ATTR_DOMAIN_FACE: + case bke::AttrDomain::Face: return pxr::UsdGeomTokens->uniform; /* Notice: Edge types are not supported in USD! */ @@ -334,7 +334,7 @@ void USDGenericMeshWriter::write_uv_data(const Mesh *mesh, primvar_name, pxr::SdfValueTypeNames->TexCoord2fArray, pxr::UsdGeomTokens->faceVarying); const VArraySpan buffer = *mesh->attributes().lookup(attribute_id, - ATTR_DOMAIN_CORNER); + bke::AttrDomain::Corner); if (buffer.is_empty()) { return; } @@ -352,7 +352,7 @@ void USDGenericMeshWriter::write_color_data(const Mesh *mesh, const pxr::UsdGeomPrimvarsAPI pvApi = pxr::UsdGeomPrimvarsAPI(usd_mesh); /* Varying type depends on original domain. */ - const pxr::TfToken prim_varying = meta_data.domain == ATTR_DOMAIN_CORNER ? + const pxr::TfToken prim_varying = meta_data.domain == bke::AttrDomain::Corner ? pxr::UsdGeomTokens->faceVarying : pxr::UsdGeomTokens->vertex; @@ -366,8 +366,8 @@ void USDGenericMeshWriter::write_color_data(const Mesh *mesh, } switch (meta_data.domain) { - case ATTR_DOMAIN_CORNER: - case ATTR_DOMAIN_POINT: + case bke::AttrDomain::Corner: + case bke::AttrDomain::Point: copy_blender_buffer_to_prim(buffer, timecode, colors_pv); break; default: @@ -620,7 +620,7 @@ static void get_loops_polys(const Mesh *mesh, USDMeshData &usd_mesh_data) * assignments. */ const bke::AttributeAccessor attributes = mesh->attributes(); const VArray material_indices = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_FACE, 0); + "material_index", bke::AttrDomain::Face, 0); if (!material_indices.is_single() && mesh->totcol > 1) { const VArraySpan indices_span(material_indices); for (const int i : indices_span.index_range()) { @@ -642,7 +642,7 @@ static void get_loops_polys(const Mesh *mesh, USDMeshData &usd_mesh_data) static void get_edge_creases(const Mesh *mesh, USDMeshData &usd_mesh_data) { const bke::AttributeAccessor attributes = mesh->attributes(); - const bke::AttributeReader attribute = attributes.lookup("crease_edge", ATTR_DOMAIN_EDGE); + const bke::AttributeReader attribute = attributes.lookup("crease_edge", bke::AttrDomain::Edge); if (!attribute) { return; } @@ -667,7 +667,7 @@ static void get_vert_creases(const Mesh *mesh, USDMeshData &usd_mesh_data) { const bke::AttributeAccessor attributes = mesh->attributes(); const bke::AttributeReader attribute = attributes.lookup("crease_vert", - ATTR_DOMAIN_POINT); + bke::AttrDomain::Point); if (!attribute) { return; } @@ -804,7 +804,7 @@ void USDGenericMeshWriter::write_surface_velocity(const Mesh *mesh, pxr::UsdGeom /* Export velocity attribute output by fluid sim, sequence cache modifier * and geometry nodes. */ CustomDataLayer *velocity_layer = BKE_id_attribute_find( - &mesh->id, "velocity", CD_PROP_FLOAT3, ATTR_DOMAIN_POINT); + &mesh->id, "velocity", CD_PROP_FLOAT3, bke::AttrDomain::Point); if (velocity_layer == nullptr) { return; diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc index cd2e6d38c16..cb33443d3c3 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc @@ -262,7 +262,7 @@ void OBJWriter::write_vertex_coords(FormatHandler &fh, if (write_colors && !name.is_empty()) { const bke::AttributeAccessor attributes = mesh->attributes(); const VArray attribute = *attributes.lookup_or_default( - name, ATTR_DOMAIN_POINT, {0.0f, 0.0f, 0.0f, 0.0f}); + name, bke::AttrDomain::Point, {0.0f, 0.0f, 0.0f, 0.0f}); BLI_assert(tot_count == attribute.size()); obj_parallel_chunked_output(fh, tot_count, [&](FormatHandler &buf, int i) { @@ -346,7 +346,7 @@ void OBJWriter::write_poly_elements(FormatHandler &fh, threading::EnumerableThreadSpecific> group_weights; const bke::AttributeAccessor attributes = obj_mesh_data.get_mesh()->attributes(); const VArray material_indices = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_FACE, 0); + "material_index", bke::AttrDomain::Face, 0); obj_parallel_chunked_output(fh, tot_faces, [&](FormatHandler &buf, int idx) { /* Polygon order for writing into the file is not necessarily the same diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc index 3a022e77c32..be970bd5859 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc @@ -48,7 +48,7 @@ OBJMesh::OBJMesh(Depsgraph *depsgraph, const OBJExportParams &export_params, Obj mesh_faces_ = export_mesh_->faces(); mesh_corner_verts_ = export_mesh_->corner_verts(); sharp_faces_ = *export_mesh_->attributes().lookup_or_default( - "sharp_face", ATTR_DOMAIN_FACE, false); + "sharp_face", bke::AttrDomain::Face, false); } else { /* Curves and NURBS surfaces need a new mesh when they're @@ -88,7 +88,7 @@ void OBJMesh::set_mesh(Mesh *mesh) mesh_faces_ = mesh->faces(); mesh_corner_verts_ = mesh->corner_verts(); sharp_faces_ = *export_mesh_->attributes().lookup_or_default( - "sharp_face", ATTR_DOMAIN_FACE, false); + "sharp_face", bke::AttrDomain::Face, false); } void OBJMesh::clear() @@ -201,8 +201,8 @@ int OBJMesh::ith_smooth_group(const int face_index) const void OBJMesh::calc_smooth_groups(const bool use_bitflags) { const bke::AttributeAccessor attributes = export_mesh_->attributes(); - const VArraySpan sharp_edges = *attributes.lookup("sharp_edge", ATTR_DOMAIN_EDGE); - const VArraySpan sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + const VArraySpan sharp_edges = *attributes.lookup("sharp_edge", bke::AttrDomain::Edge); + const VArraySpan sharp_faces = *attributes.lookup("sharp_face", bke::AttrDomain::Face); poly_smooth_groups_ = BKE_mesh_calc_smoothgroups(mesh_edges_.size(), mesh_faces_, export_mesh_->corner_edges(), @@ -216,7 +216,7 @@ void OBJMesh::calc_poly_order() { const bke::AttributeAccessor attributes = export_mesh_->attributes(); const VArray material_indices = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_FACE, 0); + "material_index", bke::AttrDomain::Face, 0); if (material_indices.is_single() && material_indices.get_internal_single() == 0) { return; } @@ -275,7 +275,7 @@ void OBJMesh::store_uv_coords_and_indices() return; } const bke::AttributeAccessor attributes = export_mesh_->attributes(); - const VArraySpan uv_map = *attributes.lookup(active_uv_name, ATTR_DOMAIN_CORNER); + const VArraySpan uv_map = *attributes.lookup(active_uv_name, bke::AttrDomain::Corner); if (uv_map.is_empty()) { uv_coords_.clear(); return; diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc index 42251984202..9457f391f6d 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc @@ -192,9 +192,9 @@ void MeshFromGeometry::create_faces_loops(Mesh *mesh, bool use_vertex_groups) MutableSpan corner_verts = mesh->corner_verts_for_write(); bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter material_indices = - attributes.lookup_or_add_for_write_only_span("material_index", ATTR_DOMAIN_FACE); + attributes.lookup_or_add_for_write_only_span("material_index", bke::AttrDomain::Face); bke::SpanAttributeWriter sharp_faces = attributes.lookup_or_add_for_write_span( - "sharp_face", ATTR_DOMAIN_FACE); + "sharp_face", bke::AttrDomain::Face); const int64_t tot_face_elems{mesh->faces_num}; int tot_loop_idx = 0; @@ -279,7 +279,7 @@ void MeshFromGeometry::create_uv_verts(Mesh *mesh) bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter uv_map = attributes.lookup_or_add_for_write_only_span( - "UVMap", ATTR_DOMAIN_CORNER); + "UVMap", bke::AttrDomain::Corner); int tot_loop_idx = 0; bool added_uv = false; @@ -405,7 +405,7 @@ void MeshFromGeometry::create_colors(Mesh *mesh) { /* This block is suitable, use colors from it. */ CustomDataLayer *color_layer = BKE_id_attribute_new( - &mesh->id, "Color", CD_PROP_COLOR, ATTR_DOMAIN_POINT, nullptr); + &mesh->id, "Color", CD_PROP_COLOR, bke::AttrDomain::Point, nullptr); BKE_id_attributes_active_color_set(&mesh->id, color_layer->name); BKE_id_attributes_default_color_set(&mesh->id, color_layer->name); float4 *colors = (float4 *)color_layer->data; diff --git a/source/blender/makesdna/DNA_curves_types.h b/source/blender/makesdna/DNA_curves_types.h index 75c76962139..9fc3c9daca9 100644 --- a/source/blender/makesdna/DNA_curves_types.h +++ b/source/blender/makesdna/DNA_curves_types.h @@ -115,13 +115,13 @@ typedef struct CurvesGeometry { int *curve_offsets; /** - * All attributes stored on control points (#ATTR_DOMAIN_POINT). + * All attributes stored on control points (#AttrDomain::Point). * This might not contain a layer for positions if there are no points. */ CustomData point_data; /** - * All attributes stored on curves (#ATTR_DOMAIN_CURVE). + * All attributes stored on curves (#AttrDomain::Curve). */ CustomData curve_data; @@ -179,7 +179,7 @@ typedef struct Curves { */ char symmetry; /** - * #eAttrDomain. The active domain for edit/sculpt mode selection. Only one selection mode can + * #AttrDomain. The active domain for edit/sculpt mode selection. Only one selection mode can * be active at a time. */ char selection_domain; diff --git a/source/blender/makesdna/DNA_grease_pencil_types.h b/source/blender/makesdna/DNA_grease_pencil_types.h index 60b66e0cb2a..1aa564b34f1 100644 --- a/source/blender/makesdna/DNA_grease_pencil_types.h +++ b/source/blender/makesdna/DNA_grease_pencil_types.h @@ -408,7 +408,7 @@ typedef struct GreasePencil { GreasePencilLayerTreeGroup *root_group_ptr; /** - * All attributes stored on the grease pencil layers (#ATTR_DOMAIN_LAYER). + * All attributes stored on the grease pencil layers (#AttrDomain::Layer). */ CustomData layers_data; /** diff --git a/source/blender/makesdna/DNA_node_tree_interface_types.h b/source/blender/makesdna/DNA_node_tree_interface_types.h index 20e4d8a4a96..079cce91d7d 100644 --- a/source/blender/makesdna/DNA_node_tree_interface_types.h +++ b/source/blender/makesdna/DNA_node_tree_interface_types.h @@ -79,7 +79,7 @@ typedef struct bNodeTreeInterfaceSocket { /* NodeTreeInterfaceSocketFlag */ int flag; - /* eAttrDomain */ + /* AttrDomain */ int16_t attribute_domain; /** GeometryNodeDefaultInputType. */ int16_t default_input; diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index dd7cb169e39..383ba5a2c3c 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -149,7 +149,7 @@ typedef struct bNodeSocket { short stack_index; char display_shape; - /* #eAttrDomain used when the geometry nodes modifier creates an attribute for a group + /* #AttrDomain used when the geometry nodes modifier creates an attribute for a group * output. */ char attribute_domain; @@ -1515,7 +1515,7 @@ typedef struct NodeRandomValue { typedef struct NodeAccumulateField { /** #eCustomDataType. */ uint8_t data_type; - /** #eAttrDomain. */ + /** #AttrDomain. */ uint8_t domain; } NodeAccumulateField; @@ -1696,7 +1696,7 @@ typedef struct NodeGeometryCurveSample { typedef struct NodeGeometryTransferAttribute { /** #eCustomDataType. */ int8_t data_type; - /** #eAttrDomain. */ + /** #AttrDomain. */ int8_t domain; /** #GeometryNodeAttributeTransferMode. */ uint8_t mode; @@ -1706,7 +1706,7 @@ typedef struct NodeGeometryTransferAttribute { typedef struct NodeGeometrySampleIndex { /** #eCustomDataType. */ int8_t data_type; - /** #eAttrDomain. */ + /** #AttrDomain. */ int8_t domain; int8_t clamp; char _pad[1]; @@ -1732,14 +1732,14 @@ typedef struct NodeGeometryMeshToPoints { typedef struct NodeGeometryAttributeCapture { /** #eCustomDataType. */ int8_t data_type; - /** #eAttrDomain. */ + /** #AttrDomain. */ int8_t domain; } NodeGeometryAttributeCapture; typedef struct NodeGeometryStoreNamedAttribute { /** #eCustomDataType. */ int8_t data_type; - /** #eAttrDomain. */ + /** #AttrDomain. */ int8_t domain; } NodeGeometryStoreNamedAttribute; @@ -1760,19 +1760,19 @@ typedef struct NodeGeometryStringToCurves { } NodeGeometryStringToCurves; typedef struct NodeGeometryDeleteGeometry { - /** #eAttrDomain. */ + /** #AttrDomain. */ int8_t domain; /** #GeometryNodeDeleteGeometryMode. */ int8_t mode; } NodeGeometryDeleteGeometry; typedef struct NodeGeometryDuplicateElements { - /** #eAttrDomain. */ + /** #AttrDomain. */ int8_t domain; } NodeGeometryDuplicateElements; typedef struct NodeGeometrySeparateGeometry { - /** #eAttrDomain. */ + /** #AttrDomain. */ int8_t domain; } NodeGeometrySeparateGeometry; @@ -1784,7 +1784,7 @@ typedef struct NodeGeometryImageTexture { typedef struct NodeGeometryViewer { /** #eCustomDataType. */ int8_t data_type; - /** #eAttrDomain. */ + /** #AttrDomain. */ int8_t domain; } NodeGeometryViewer; @@ -1797,7 +1797,7 @@ typedef struct NodeSimulationItem { char *name; /** #eNodeSocketDatatype. */ short socket_type; - /** #eAttrDomain. */ + /** #AttrDomain. */ short attribute_domain; /** * Generates unique identifier for sockets which stays the same even when the item order or diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index f6f9677a157..6fc3eea2580 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -1983,7 +1983,7 @@ typedef struct SpaceSpreadsheet { /* #GeometryComponent::Type. */ uint8_t geometry_component_type; - /* #eAttrDomain. */ + /* #AttrDomain. */ uint8_t attribute_domain; /* eSpaceSpreadsheet_ObjectEvalState. */ uint8_t object_eval_state; diff --git a/source/blender/makesrna/intern/rna_attribute.cc b/source/blender/makesrna/intern/rna_attribute.cc index 4c0213c0acb..64cfeeb4075 100644 --- a/source/blender/makesrna/intern/rna_attribute.cc +++ b/source/blender/makesrna/intern/rna_attribute.cc @@ -22,13 +22,15 @@ #include "BLI_math_color.h" -#include "BKE_attribute.h" +#include "BKE_attribute.hh" #include "BKE_customdata.hh" #include "BLT_translation.h" #include "WM_types.hh" +using blender::bke::AttrDomain; + const EnumPropertyItem rna_enum_attribute_type_items[] = { {CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating-point value"}, {CD_PROP_INT32, "INT", 0, "Integer", "32-bit integer"}, @@ -80,84 +82,84 @@ const EnumPropertyItem rna_enum_attribute_type_with_auto_items[] = { const EnumPropertyItem rna_enum_attribute_domain_items[] = { /* Not implement yet */ // {ATTR_DOMAIN_GEOMETRY, "GEOMETRY", 0, "Geometry", "Attribute on (whole) geometry"}, - {ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"}, - {ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", "Attribute on mesh edge"}, - {ATTR_DOMAIN_FACE, "FACE", 0, "Face", "Attribute on mesh faces"}, - {ATTR_DOMAIN_CORNER, "CORNER", 0, "Face Corner", "Attribute on mesh face corner"}, + {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"}, + {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"}, + {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"}, + {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", "Attribute on mesh face corner"}, /* Not implement yet */ // {ATTR_DOMAIN_GRIDS, "GRIDS", 0, "Grids", "Attribute on mesh multires grids"}, - {ATTR_DOMAIN_CURVE, "CURVE", 0, "Spline", "Attribute on spline"}, - {ATTR_DOMAIN_INSTANCE, "INSTANCE", 0, "Instance", "Attribute on instance"}, - {ATTR_DOMAIN_LAYER, "LAYER", 0, "Layer", "Attribute on Grease Pencil layer"}, + {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"}, + {int(AttrDomain::Instance), "INSTANCE", 0, "Instance", "Attribute on instance"}, + {int(AttrDomain::Layer), "LAYER", 0, "Layer", "Attribute on Grease Pencil layer"}, {0, nullptr, 0, nullptr, nullptr}, }; const EnumPropertyItem rna_enum_attribute_domain_only_mesh_items[] = { - {ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"}, - {ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", "Attribute on mesh edge"}, - {ATTR_DOMAIN_FACE, "FACE", 0, "Face", "Attribute on mesh faces"}, - {ATTR_DOMAIN_CORNER, "CORNER", 0, "Face Corner", "Attribute on mesh face corner"}, + {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"}, + {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"}, + {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"}, + {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", "Attribute on mesh face corner"}, {0, nullptr, 0, nullptr, nullptr}, }; const EnumPropertyItem rna_enum_attribute_domain_only_mesh_no_edge_items[] = { - {ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"}, - {ATTR_DOMAIN_FACE, "FACE", 0, "Face", "Attribute on mesh faces"}, - {ATTR_DOMAIN_CORNER, "CORNER", 0, "Face Corner", "Attribute on mesh face corner"}, + {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"}, + {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"}, + {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", "Attribute on mesh face corner"}, {0, nullptr, 0, nullptr, nullptr}, }; const EnumPropertyItem rna_enum_attribute_domain_point_face_curve_items[] = { - {ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"}, - {ATTR_DOMAIN_FACE, "FACE", 0, "Face", "Attribute on mesh faces"}, - {ATTR_DOMAIN_CURVE, "CURVE", 0, "Spline", "Attribute on spline"}, + {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"}, + {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"}, + {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"}, {0, nullptr, 0, nullptr, nullptr}, }; const EnumPropertyItem rna_enum_attribute_domain_point_edge_face_curve_items[] = { - {ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"}, - {ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", "Attribute on mesh edge"}, - {ATTR_DOMAIN_FACE, "FACE", 0, "Face", "Attribute on mesh faces"}, - {ATTR_DOMAIN_CURVE, "CURVE", 0, "Spline", "Attribute on spline"}, + {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"}, + {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"}, + {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"}, + {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"}, {0, nullptr, 0, nullptr, nullptr}, }; const EnumPropertyItem rna_enum_attribute_domain_edge_face_items[] = { - {ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", "Attribute on mesh edge"}, - {ATTR_DOMAIN_FACE, "FACE", 0, "Face", "Attribute on mesh faces"}, + {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"}, + {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"}, {0, nullptr, 0, nullptr, nullptr}, }; const EnumPropertyItem rna_enum_attribute_domain_without_corner_items[] = { - {ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"}, - {ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", "Attribute on mesh edge"}, - {ATTR_DOMAIN_FACE, "FACE", 0, "Face", "Attribute on mesh faces"}, - {ATTR_DOMAIN_CURVE, "CURVE", 0, "Spline", "Attribute on spline"}, - {ATTR_DOMAIN_INSTANCE, "INSTANCE", 0, "Instance", "Attribute on instance"}, - {ATTR_DOMAIN_LAYER, "LAYER", 0, "Layer", "Attribute on Grease Pencil layer"}, + {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"}, + {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"}, + {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"}, + {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"}, + {int(AttrDomain::Instance), "INSTANCE", 0, "Instance", "Attribute on instance"}, + {int(AttrDomain::Layer), "LAYER", 0, "Layer", "Attribute on Grease Pencil layer"}, {0, nullptr, 0, nullptr, nullptr}, }; const EnumPropertyItem rna_enum_attribute_domain_with_auto_items[] = { - {ATTR_DOMAIN_AUTO, "AUTO", 0, "Auto", ""}, - {ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"}, - {ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", "Attribute on mesh edge"}, - {ATTR_DOMAIN_FACE, "FACE", 0, "Face", "Attribute on mesh faces"}, - {ATTR_DOMAIN_CORNER, "CORNER", 0, "Face Corner", "Attribute on mesh face corner"}, - {ATTR_DOMAIN_CURVE, "CURVE", 0, "Spline", "Attribute on spline"}, - {ATTR_DOMAIN_INSTANCE, "INSTANCE", 0, "Instance", "Attribute on instance"}, - {ATTR_DOMAIN_LAYER, "LAYER", 0, "Layer", "Attribute on Grease Pencil layer"}, + {int(AttrDomain::Auto), "AUTO", 0, "Auto", ""}, + {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"}, + {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"}, + {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"}, + {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", "Attribute on mesh face corner"}, + {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"}, + {int(AttrDomain::Instance), "INSTANCE", 0, "Instance", "Attribute on instance"}, + {int(AttrDomain::Layer), "LAYER", 0, "Layer", "Attribute on Grease Pencil layer"}, {0, nullptr, 0, nullptr, nullptr}, }; const EnumPropertyItem rna_enum_color_attribute_domain_items[] = { - {ATTR_DOMAIN_POINT, "POINT", 0, "Vertex", ""}, - {ATTR_DOMAIN_CORNER, "CORNER", 0, "Face Corner", ""}, + {int(AttrDomain::Point), "POINT", 0, "Vertex", ""}, + {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", ""}, {0, nullptr, 0, nullptr, nullptr}}; const EnumPropertyItem rna_enum_attribute_curves_domain_items[] = { - {ATTR_DOMAIN_POINT, "POINT", 0, "Control Point", ""}, - {ATTR_DOMAIN_CURVE, "CURVE", 0, "Curve", ""}, + {int(AttrDomain::Point), "POINT", 0, "Control Point", ""}, + {int(AttrDomain::Curve), "CURVE", 0, "Curve", ""}, {0, nullptr, 0, nullptr, nullptr}}; #ifdef RNA_RUNTIME @@ -247,28 +249,30 @@ const EnumPropertyItem *rna_enum_attribute_domain_itemf(ID *id, int totitem = 0, a; static EnumPropertyItem mesh_vertex_domain_item = { - ATTR_DOMAIN_POINT, "POINT", 0, N_("Vertex"), N_("Attribute per point/vertex")}; + int(AttrDomain::Point), "POINT", 0, N_("Vertex"), N_("Attribute per point/vertex")}; for (a = 0; rna_enum_attribute_domain_items[a].identifier; a++) { domain_item = &rna_enum_attribute_domain_items[a]; - if (id_type == ID_PT && !ELEM(domain_item->value, ATTR_DOMAIN_POINT)) { + if (id_type == ID_PT && !ELEM(domain_item->value, int(AttrDomain::Point))) { continue; } - if (id_type == ID_CV && !ELEM(domain_item->value, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) { + if (id_type == ID_CV && + !ELEM(domain_item->value, int(AttrDomain::Point), int(AttrDomain::Curve))) { continue; } - if (id_type == ID_ME && ELEM(domain_item->value, ATTR_DOMAIN_CURVE)) { + if (id_type == ID_ME && ELEM(domain_item->value, int(AttrDomain::Curve))) { continue; } - if (!include_instances && domain_item->value == ATTR_DOMAIN_INSTANCE) { + if (!include_instances && domain_item->value == int(AttrDomain::Instance)) { continue; } - if (!U.experimental.use_grease_pencil_version3 && domain_item->value == ATTR_DOMAIN_LAYER) { + if (!U.experimental.use_grease_pencil_version3 && domain_item->value == int(AttrDomain::Layer)) + { continue; } - if (domain_item->value == ATTR_DOMAIN_POINT && id_type == ID_ME) { + if (domain_item->value == int(AttrDomain::Point) && id_type == ID_ME) { RNA_enum_item_add(&item, &totitem, &mesh_vertex_domain_item); } else { @@ -291,7 +295,8 @@ static const EnumPropertyItem *rna_Attribute_domain_itemf(bContext * /*C*/, static int rna_Attribute_domain_get(PointerRNA *ptr) { - return BKE_id_attribute_domain(ptr->owner_id, static_cast(ptr->data)); + return int( + BKE_id_attribute_domain(ptr->owner_id, static_cast(ptr->data))); } static bool rna_Attribute_is_internal_get(PointerRNA *ptr) @@ -411,7 +416,7 @@ static PointerRNA rna_AttributeGroup_new( ID *id, ReportList *reports, const char *name, const int type, const int domain) { CustomDataLayer *layer = BKE_id_attribute_new( - id, name, eCustomDataType(type), eAttrDomain(domain), reports); + id, name, eCustomDataType(type), AttrDomain(domain), reports); if ((GS(id->name) == ID_ME) && ELEM(layer->type, CD_PROP_COLOR, CD_PROP_BYTE_COLOR)) { Mesh *mesh = (Mesh *)id; @@ -452,7 +457,7 @@ static int rna_Attributes_noncolor_layer_skip(CollectionPropertyIterator *iter, /* Check valid domain here, too, keep in line with rna_AttributeGroup_color_length(). */ ID *id = iter->parent.owner_id; - const eAttrDomain domain = BKE_id_attribute_domain(id, layer); + const AttrDomain domain = BKE_id_attribute_domain(id, layer); if (!(ATTR_DOMAIN_AS_MASK(domain) & ATTR_DOMAIN_MASK_COLOR)) { return 1; } @@ -1229,7 +1234,7 @@ static void rna_def_attribute_group(BlenderRNA *brna) parm = RNA_def_enum(func, "domain", rna_enum_attribute_domain_items, - ATTR_DOMAIN_POINT, + int(AttrDomain::Point), "Domain", "Type of element that attribute is stored on"); RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED); diff --git a/source/blender/makesrna/intern/rna_curves.cc b/source/blender/makesrna/intern/rna_curves.cc index d89142f0775..fa263dfba6a 100644 --- a/source/blender/makesrna/intern/rna_curves.cc +++ b/source/blender/makesrna/intern/rna_curves.cc @@ -186,7 +186,8 @@ static float rna_CurvePoint_radius_get(PointerRNA *ptr) using namespace blender; const Curves *curves = rna_curves(ptr); const bke::AttributeAccessor attributes = curves->geometry.wrap().attributes(); - const VArray radii = *attributes.lookup_or_default("radius", ATTR_DOMAIN_POINT, 0.0f); + const VArray radii = *attributes.lookup_or_default( + "radius", bke::AttrDomain::Point, 0.0f); return radii[rna_CurvePoint_index_get_const(ptr)]; } @@ -292,9 +293,9 @@ static void rna_Curves_add_curves(Curves *curves_id, /* Initialize new attribute values, since #CurvesGeometry::resize() doesn't do that. */ bke::MutableAttributeAccessor attributes = curves.attributes_for_write(); bke::fill_attribute_range_default( - attributes, ATTR_DOMAIN_POINT, {}, curves.points_range().drop_front(orig_points_num)); + attributes, bke::AttrDomain::Point, {}, curves.points_range().drop_front(orig_points_num)); bke::fill_attribute_range_default( - attributes, ATTR_DOMAIN_CURVE, {}, curves.curves_range().drop_front(orig_curves_num)); + attributes, bke::AttrDomain::Curve, {}, curves.curves_range().drop_front(orig_curves_num)); curves.update_curve_types(); diff --git a/source/blender/makesrna/intern/rna_mesh.cc b/source/blender/makesrna/intern/rna_mesh.cc index 302db25496a..916d85fca62 100644 --- a/source/blender/makesrna/intern/rna_mesh.cc +++ b/source/blender/makesrna/intern/rna_mesh.cc @@ -633,7 +633,7 @@ static int rna_MeshPolygon_material_index_get(PointerRNA *ptr) const Mesh *mesh = rna_mesh(ptr); const bke::AttributeAccessor attributes = mesh->attributes(); const VArray material_index = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_FACE, 0); + "material_index", bke::AttrDomain::Face, 0); return material_index[rna_MeshPolygon_index_get(ptr)]; } @@ -642,8 +642,8 @@ static void rna_MeshPolygon_material_index_set(PointerRNA *ptr, int value) using namespace blender; Mesh *mesh = rna_mesh(ptr); bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); - bke::AttributeWriter material_index = attributes.lookup_or_add_for_write("material_index", - ATTR_DOMAIN_FACE); + bke::AttributeWriter material_index = attributes.lookup_or_add_for_write( + "material_index", bke::AttrDomain::Face); material_index.varray.set(rna_MeshPolygon_index_get(ptr), max_ii(0, value)); material_index.finish(); } @@ -1394,7 +1394,7 @@ static int rna_MeshLoopTriangle_material_index_get(PointerRNA *ptr) const Mesh *mesh = rna_mesh(ptr); const bke::AttributeAccessor attributes = mesh->attributes(); const VArray material_indices = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_FACE, 0); + "material_index", bke::AttrDomain::Face, 0); return material_indices[rna_MeshLoopTriangle_polygon_index_get(ptr)]; } @@ -1891,7 +1891,8 @@ static PointerRNA rna_Mesh_uv_layers_new(Mesh *mesh, static void rna_Mesh_uv_layers_remove(Mesh *mesh, ReportList *reports, CustomDataLayer *layer) { - if (!BKE_id_attribute_find(&mesh->id, layer->name, CD_PROP_FLOAT2, ATTR_DOMAIN_CORNER)) { + using namespace blender; + if (!BKE_id_attribute_find(&mesh->id, layer->name, CD_PROP_FLOAT2, bke::AttrDomain::Corner)) { BKE_reportf(reports, RPT_ERROR, "UV map '%s' not found", layer->name); return; } diff --git a/source/blender/makesrna/intern/rna_mesh_api.cc b/source/blender/makesrna/intern/rna_mesh_api.cc index 43dd55c06d4..767f4021740 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.cc +++ b/source/blender/makesrna/intern/rna_mesh_api.cc @@ -93,8 +93,8 @@ static void rna_Mesh_calc_smooth_groups( using namespace blender; *r_poly_group_num = mesh->faces_num; const bke::AttributeAccessor attributes = mesh->attributes(); - const VArraySpan sharp_edges = *attributes.lookup("sharp_edge", ATTR_DOMAIN_EDGE); - const VArraySpan sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + const VArraySpan sharp_edges = *attributes.lookup("sharp_edge", bke::AttrDomain::Edge); + const VArraySpan sharp_faces = *attributes.lookup("sharp_face", bke::AttrDomain::Face); *r_poly_group = BKE_mesh_calc_smoothgroups(mesh->edges_num, mesh->faces(), mesh->corner_edges(), diff --git a/source/blender/makesrna/intern/rna_modifier.cc b/source/blender/makesrna/intern/rna_modifier.cc index 4d9c9b8ac08..16090396542 100644 --- a/source/blender/makesrna/intern/rna_modifier.cc +++ b/source/blender/makesrna/intern/rna_modifier.cc @@ -23,7 +23,7 @@ #include "BLT_translation.h" #include "BKE_animsys.h" -#include "BKE_attribute.h" +#include "BKE_attribute.hh" #include "BKE_curveprofile.h" #include "BKE_data_transfer.h" #include "BKE_dynamicpaint.h" @@ -1298,6 +1298,7 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf( PropertyRNA *prop, bool *r_free) { + using namespace blender; DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data; EnumPropertyItem *item = nullptr, tmp_item = {0}; int totitem = 0; @@ -1377,9 +1378,10 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf( Object *ob_src = dtmd->ob_source; if (ob_src) { - eAttrDomain domain = STREQ(RNA_property_identifier(prop), "layers_vcol_vert_select_src") ? - ATTR_DOMAIN_POINT : - ATTR_DOMAIN_CORNER; + bke::AttrDomain domain = STREQ(RNA_property_identifier(prop), + "layers_vcol_vert_select_src") ? + bke::AttrDomain::Point : + bke::AttrDomain::Corner; Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_src); @@ -1396,7 +1398,7 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf( } const CustomData *cdata; - if (domain == ATTR_DOMAIN_POINT) { + if (domain == bke::AttrDomain::Point) { cdata = &mesh_eval->vert_data; } else { diff --git a/source/blender/makesrna/intern/rna_node_tree_interface.cc b/source/blender/makesrna/intern/rna_node_tree_interface.cc index 77d75dd65cf..a8eeccda92f 100644 --- a/source/blender/makesrna/intern/rna_node_tree_interface.cc +++ b/source/blender/makesrna/intern/rna_node_tree_interface.cc @@ -28,7 +28,7 @@ static const EnumPropertyItem node_tree_interface_socket_in_out_items[] = { #ifdef RNA_RUNTIME -# include "BKE_attribute.h" +# include "BKE_attribute.hh" # include "BKE_node.h" # include "BKE_node_runtime.hh" # include "BKE_node_tree_interface.hh" @@ -446,13 +446,14 @@ static const EnumPropertyItem *rna_NodeTreeInterfaceSocket_default_input_itemf( static const EnumPropertyItem *rna_NodeTreeInterfaceSocket_attribute_domain_itemf( bContext * /*C*/, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free) { + using namespace blender; EnumPropertyItem *item_array = nullptr; int items_len = 0; for (const EnumPropertyItem *item = rna_enum_attribute_domain_items; item->identifier != nullptr; item++) { - if (!U.experimental.use_grease_pencil_version3 && item->value == ATTR_DOMAIN_LAYER) { + if (!U.experimental.use_grease_pencil_version3 && item->value == int(bke::AttrDomain::Layer)) { continue; } RNA_enum_item_add(&item_array, &items_len, item); diff --git a/source/blender/makesrna/intern/rna_nodetree.cc b/source/blender/makesrna/intern/rna_nodetree.cc index 4d986072a57..eca31996058 100644 --- a/source/blender/makesrna/intern/rna_nodetree.cc +++ b/source/blender/makesrna/intern/rna_nodetree.cc @@ -1897,13 +1897,14 @@ static const EnumPropertyItem *rna_GeometryNodeAttributeType_type_with_socket_it static const EnumPropertyItem *rna_GeometryNodeAttributeDomain_attribute_domain_itemf( bContext * /*C*/, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free) { + using namespace blender; EnumPropertyItem *item_array = nullptr; int items_len = 0; for (const EnumPropertyItem *item = rna_enum_attribute_domain_items; item->identifier != nullptr; item++) { - if (!U.experimental.use_grease_pencil_version3 && item->value == ATTR_DOMAIN_LAYER) { + if (!U.experimental.use_grease_pencil_version3 && item->value == int(bke::AttrDomain::Layer)) { continue; } RNA_enum_item_add(&item_array, &items_len, item); @@ -9265,6 +9266,7 @@ static void def_fn_rotate_euler(StructRNA *srna) static void def_geo_sample_index(StructRNA *srna) { + using namespace blender; PropertyRNA *prop; RNA_def_struct_sdna_from(srna, "NodeGeometrySampleIndex", "storage"); @@ -9281,7 +9283,7 @@ static void def_geo_sample_index(StructRNA *srna) RNA_def_property_enum_items(prop, rna_enum_attribute_domain_items); RNA_def_property_enum_funcs( prop, nullptr, nullptr, "rna_GeometryNodeAttributeDomain_attribute_domain_itemf"); - RNA_def_property_enum_default(prop, ATTR_DOMAIN_POINT); + RNA_def_property_enum_default(prop, int(bke::AttrDomain::Point)); RNA_def_property_ui_text(prop, "Domain", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); diff --git a/source/blender/makesrna/intern/rna_space.cc b/source/blender/makesrna/intern/rna_space.cc index 26bea566a95..9f3174eec82 100644 --- a/source/blender/makesrna/intern/rna_space.cc +++ b/source/blender/makesrna/intern/rna_space.cc @@ -13,7 +13,7 @@ #include "BLT_translation.h" -#include "BKE_attribute.h" +#include "BKE_attribute.hh" #include "BKE_context.hh" #include "BKE_geometry_set.hh" #include "BKE_image.h" @@ -3242,33 +3242,37 @@ static void rna_SpaceSpreadsheet_geometry_component_type_update(Main * /*bmain*/ Scene * /*scene*/, PointerRNA *ptr) { + using namespace blender; SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)ptr->data; switch (sspreadsheet->geometry_component_type) { - case int(blender::bke::GeometryComponent::Type::Mesh): { - if (!ELEM(sspreadsheet->attribute_domain, - ATTR_DOMAIN_POINT, - ATTR_DOMAIN_EDGE, - ATTR_DOMAIN_FACE, - ATTR_DOMAIN_CORNER)) + case int(bke::GeometryComponent::Type::Mesh): { + if (!ELEM(bke::AttrDomain(sspreadsheet->attribute_domain), + bke::AttrDomain::Point, + bke::AttrDomain::Edge, + bke::AttrDomain::Face, + bke::AttrDomain::Corner)) { - sspreadsheet->attribute_domain = ATTR_DOMAIN_POINT; + sspreadsheet->attribute_domain = uint8_t(bke::AttrDomain::Point); } break; } - case int(blender::bke::GeometryComponent::Type::PointCloud): { - sspreadsheet->attribute_domain = ATTR_DOMAIN_POINT; + case int(bke::GeometryComponent::Type::PointCloud): { + sspreadsheet->attribute_domain = uint8_t(bke::AttrDomain::Point); break; } - case int(blender::bke::GeometryComponent::Type::Instance): { - sspreadsheet->attribute_domain = ATTR_DOMAIN_INSTANCE; + case int(bke::GeometryComponent::Type::Instance): { + sspreadsheet->attribute_domain = uint8_t(bke::AttrDomain::Instance); break; } - case int(blender::bke::GeometryComponent::Type::Volume): { + case int(bke::GeometryComponent::Type::Volume): { break; } - case int(blender::bke::GeometryComponent::Type::Curve): { - if (!ELEM(sspreadsheet->attribute_domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) { - sspreadsheet->attribute_domain = ATTR_DOMAIN_POINT; + case int(bke::GeometryComponent::Type::Curve): { + if (!ELEM(bke::AttrDomain(sspreadsheet->attribute_domain), + bke::AttrDomain::Point, + bke::AttrDomain::Curve)) + { + sspreadsheet->attribute_domain = uint8_t(bke::AttrDomain::Point); } break; } @@ -3280,56 +3284,59 @@ const EnumPropertyItem *rna_SpaceSpreadsheet_attribute_domain_itemf(bContext * / PropertyRNA * /*prop*/, bool *r_free) { + using namespace blender; SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)ptr->data; - auto component_type = blender::bke::GeometryComponent::Type( - sspreadsheet->geometry_component_type); + auto component_type = bke::GeometryComponent::Type(sspreadsheet->geometry_component_type); if (sspreadsheet->object_eval_state == SPREADSHEET_OBJECT_EVAL_STATE_ORIGINAL) { ID *used_id = ED_spreadsheet_get_current_id(sspreadsheet); if (used_id != nullptr) { if (GS(used_id->name) == ID_OB) { Object *used_object = (Object *)used_id; if (used_object->type == OB_POINTCLOUD) { - component_type = blender::bke::GeometryComponent::Type::PointCloud; + component_type = bke::GeometryComponent::Type::PointCloud; } else { - component_type = blender::bke::GeometryComponent::Type::Mesh; + component_type = bke::GeometryComponent::Type::Mesh; } } } } static EnumPropertyItem mesh_vertex_domain_item = { - ATTR_DOMAIN_POINT, "POINT", 0, "Vertex", "Attribute per point/vertex"}; + int(bke::AttrDomain::Point), "POINT", 0, "Vertex", "Attribute per point/vertex"}; EnumPropertyItem *item_array = nullptr; int items_len = 0; for (const EnumPropertyItem *item = rna_enum_attribute_domain_items; item->identifier != nullptr; item++) { - if (component_type == blender::bke::GeometryComponent::Type::Mesh) { - if (!ELEM(item->value, - ATTR_DOMAIN_CORNER, - ATTR_DOMAIN_EDGE, - ATTR_DOMAIN_POINT, - ATTR_DOMAIN_FACE)) { + if (component_type == bke::GeometryComponent::Type::Mesh) { + if (!ELEM(bke::AttrDomain(item->value), + bke::AttrDomain::Corner, + bke::AttrDomain::Edge, + bke::AttrDomain::Point, + bke::AttrDomain::Face)) + { continue; } } - if (component_type == blender::bke::GeometryComponent::Type::PointCloud) { - if (item->value != ATTR_DOMAIN_POINT) { + if (component_type == bke::GeometryComponent::Type::PointCloud) { + if (bke::AttrDomain(item->value) != bke::AttrDomain::Point) { continue; } } - if (component_type == blender::bke::GeometryComponent::Type::Curve) { - if (!ELEM(item->value, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) { + if (component_type == bke::GeometryComponent::Type::Curve) { + if (!ELEM(bke::AttrDomain(item->value), bke::AttrDomain::Point, bke::AttrDomain::Curve)) { continue; } } - if (!U.experimental.use_grease_pencil_version3 && item->value == ATTR_DOMAIN_LAYER) { + if (!U.experimental.use_grease_pencil_version3 && + bke::AttrDomain(item->value) == bke::AttrDomain::Layer) + { continue; } - if (item->value == ATTR_DOMAIN_POINT && - component_type == blender::bke::GeometryComponent::Type::Mesh) + if (bke::AttrDomain(item->value) == bke::AttrDomain::Point && + component_type == bke::GeometryComponent::Type::Mesh) { RNA_enum_item_add(&item_array, &items_len, &mesh_vertex_domain_item); } diff --git a/source/blender/modifiers/intern/MOD_array.cc b/source/blender/modifiers/intern/MOD_array.cc index 308279305d0..c9685891e13 100644 --- a/source/blender/modifiers/intern/MOD_array.cc +++ b/source/blender/modifiers/intern/MOD_array.cc @@ -341,11 +341,12 @@ static void mesh_merge_transform(Mesh *result, const bke::AttributeAccessor cap_attributes = cap_mesh->attributes(); if (const VArray cap_material_indices = *cap_attributes.lookup("material_index", - ATTR_DOMAIN_FACE)) + bke::AttrDomain::Face)) { bke::MutableAttributeAccessor result_attributes = result->attributes_for_write(); bke::SpanAttributeWriter result_material_indices = - result_attributes.lookup_or_add_for_write_span("material_index", ATTR_DOMAIN_FACE); + result_attributes.lookup_or_add_for_write_span("material_index", + bke::AttrDomain::Face); cap_material_indices.materialize( result_material_indices.span.slice(cap_faces_index, cap_nfaces)); result_material_indices.finish(); diff --git a/source/blender/modifiers/intern/MOD_normal_edit.cc b/source/blender/modifiers/intern/MOD_normal_edit.cc index 3d92740855f..b867d041cfe 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.cc +++ b/source/blender/modifiers/intern/MOD_normal_edit.cc @@ -323,18 +323,18 @@ static void normalEditModifier_do_radial(NormalEditModifierData *enmd, faces_check_flip(*mesh, nos, mesh->face_normals()); } const bke::AttributeAccessor attributes = mesh->attributes(); - const VArraySpan sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); - blender::bke::mesh::normals_loop_custom_set(vert_positions, - edges, - faces, - corner_verts, - corner_edges, - mesh->vert_normals(), - mesh->face_normals(), - sharp_faces, - sharp_edges, - nos, - clnors); + const VArraySpan sharp_faces = *attributes.lookup("sharp_face", bke::AttrDomain::Face); + bke::mesh::normals_loop_custom_set(vert_positions, + edges, + faces, + corner_verts, + corner_edges, + mesh->vert_normals(), + mesh->face_normals(), + sharp_faces, + sharp_edges, + nos, + clnors); MEM_freeN(cos); MEM_freeN(done_verts); @@ -429,18 +429,18 @@ static void normalEditModifier_do_directional(NormalEditModifierData *enmd, faces_check_flip(*mesh, nos, mesh->face_normals()); } const bke::AttributeAccessor attributes = mesh->attributes(); - const VArraySpan sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); - blender::bke::mesh::normals_loop_custom_set(positions, - edges, - faces, - corner_verts, - corner_edges, - mesh->vert_normals(), - mesh->face_normals(), - sharp_faces, - sharp_edges, - nos, - clnors); + const VArraySpan sharp_faces = *attributes.lookup("sharp_face", bke::AttrDomain::Face); + bke::mesh::normals_loop_custom_set(positions, + edges, + faces, + corner_verts, + corner_edges, + mesh->vert_normals(), + mesh->face_normals(), + sharp_faces, + sharp_edges, + nos, + clnors); } static bool is_valid_target(NormalEditModifierData *enmd) @@ -505,7 +505,7 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, bke::MutableAttributeAccessor attributes = result->attributes_for_write(); bke::SpanAttributeWriter sharp_edges = attributes.lookup_or_add_for_write_span( - "sharp_edge", ATTR_DOMAIN_EDGE); + "sharp_edge", bke::AttrDomain::Edge); blender::short2 *clnors = static_cast( CustomData_get_layer_for_write(ldata, CD_CUSTOMLOOPNORMAL, corner_verts.size())); @@ -513,7 +513,7 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, clnors = static_cast( CustomData_get_layer_for_write(ldata, CD_CUSTOMLOOPNORMAL, corner_verts.size())); loop_normals.reinitialize(corner_verts.size()); - const VArraySpan sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + const VArraySpan sharp_faces = *attributes.lookup("sharp_face", bke::AttrDomain::Face); blender::bke::mesh::normals_calc_loop(positions, edges, faces, diff --git a/source/blender/modifiers/intern/MOD_screw.cc b/source/blender/modifiers/intern/MOD_screw.cc index 45bd0f7dc49..dffa213bd09 100644 --- a/source/blender/modifiers/intern/MOD_screw.cc +++ b/source/blender/modifiers/intern/MOD_screw.cc @@ -416,7 +416,7 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh blender::MutableSpan corner_edges_new = result->corner_edges_for_write(); bke::MutableAttributeAccessor attributes = result->attributes_for_write(); bke::SpanAttributeWriter sharp_faces = attributes.lookup_or_add_for_write_span( - "sharp_face", ATTR_DOMAIN_FACE); + "sharp_face", bke::AttrDomain::Face); if (!CustomData_has_layer(&result->face_data, CD_ORIGINDEX)) { CustomData_add_layer(&result->face_data, CD_ORIGINDEX, CD_SET_DEFAULT, int(maxPolys)); @@ -838,11 +838,11 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh const bke::AttributeAccessor src_attributes = mesh->attributes(); const VArraySpan src_material_index = *src_attributes.lookup("material_index", - ATTR_DOMAIN_FACE); + bke::AttrDomain::Face); bke::MutableAttributeAccessor dst_attributes = result->attributes_for_write(); bke::SpanAttributeWriter dst_material_index = dst_attributes.lookup_or_add_for_write_span( - "material_index", ATTR_DOMAIN_FACE); + "material_index", bke::AttrDomain::Face); for (uint i = 0; i < totedge; i++, med_new_firstloop++) { const uint step_last = step_tot - (close ? 1 : 2); diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.cc b/source/blender/modifiers/intern/MOD_solidify_extrude.cc index 84d3ada47c6..204c7daad74 100644 --- a/source/blender/modifiers/intern/MOD_solidify_extrude.cc +++ b/source/blender/modifiers/intern/MOD_solidify_extrude.cc @@ -422,7 +422,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex bke::MutableAttributeAccessor dst_attributes = result->attributes_for_write(); bke::SpanAttributeWriter dst_material_index = dst_attributes.lookup_or_add_for_write_span( - "material_index", ATTR_DOMAIN_FACE); + "material_index", bke::AttrDomain::Face); /* flip normals */ diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc index de9896ecf2e..5310df95c62 100644 --- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc +++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc @@ -2153,10 +2153,10 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, #endif const bke::AttributeAccessor src_attributes = mesh->attributes(); const VArraySpan src_material_index = *src_attributes.lookup("material_index", - ATTR_DOMAIN_FACE); + bke::AttrDomain::Face); bke::MutableAttributeAccessor dst_attributes = result->attributes_for_write(); bke::SpanAttributeWriter dst_material_index = dst_attributes.lookup_or_add_for_write_span( - "material_index", ATTR_DOMAIN_FACE); + "material_index", bke::AttrDomain::Face); /* Make boundary edges/faces. */ { diff --git a/source/blender/modifiers/intern/MOD_util.cc b/source/blender/modifiers/intern/MOD_util.cc index ae32e4dd7bb..8b6fdbeb481 100644 --- a/source/blender/modifiers/intern/MOD_util.cc +++ b/source/blender/modifiers/intern/MOD_util.cc @@ -104,7 +104,7 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd, &mesh->corner_data, CD_PROP_FLOAT2, dmd->uvlayer_name, uvname); const bke::AttributeAccessor attributes = mesh->attributes(); const VArraySpan uv_map = *attributes.lookup_or_default( - uvname, ATTR_DOMAIN_CORNER, float2(0)); + uvname, bke::AttrDomain::Corner, float2(0)); /* verts are given the UV from the first face that uses them */ for (const int i : faces.index_range()) { diff --git a/source/blender/modifiers/intern/MOD_uvproject.cc b/source/blender/modifiers/intern/MOD_uvproject.cc index 27f4b3ec4c8..6962a9cfe45 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.cc +++ b/source/blender/modifiers/intern/MOD_uvproject.cc @@ -120,7 +120,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, /* Create a new layer if no UV Maps are available * (e.g. if a preceding modifier could not preserve it). */ mesh->attributes_for_write().add( - umd->uvlayer_name, ATTR_DOMAIN_CORNER, bke::AttributeInitDefaultValue()); + umd->uvlayer_name, bke::AttrDomain::Corner, bke::AttributeInitDefaultValue()); /* make sure we're using an existing layer */ CustomData_validate_layer_name(&mesh->corner_data, CD_PROP_FLOAT2, umd->uvlayer_name, uvname); diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.cc b/source/blender/modifiers/intern/MOD_weighted_normal.cc index be41cc13424..4be2e906b20 100644 --- a/source/blender/modifiers/intern/MOD_weighted_normal.cc +++ b/source/blender/modifiers/intern/MOD_weighted_normal.cc @@ -523,7 +523,7 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh bke::MutableAttributeAccessor attributes = result->attributes_for_write(); bke::SpanAttributeWriter sharp_edges = attributes.lookup_or_add_for_write_span( - "sharp_edge", ATTR_DOMAIN_EDGE); + "sharp_edge", bke::AttrDomain::Edge); WeightedNormalData wn_data{}; wn_data.verts_num = verts_num; @@ -541,7 +541,7 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh wn_data.faces = faces; wn_data.face_normals = mesh->face_normals(); - wn_data.sharp_faces = *attributes.lookup("sharp_face", ATTR_DOMAIN_FACE); + wn_data.sharp_faces = *attributes.lookup("sharp_face", bke::AttrDomain::Face); wn_data.face_strength = static_cast(CustomData_get_layer_named( &result->face_data, CD_PROP_INT32, MOD_WEIGHTEDNORMALS_FACEWEIGHT_CDLAYER_ID)); diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh index 456dfb72f3e..d4e59c2a82b 100644 --- a/source/blender/nodes/NOD_geometry_exec.hh +++ b/source/blender/nodes/NOD_geometry_exec.hh @@ -31,6 +31,7 @@ using bke::AttributeAccessor; using bke::AttributeFieldInput; using bke::AttributeIDRef; using bke::AttributeKind; +using bke::AttrDomain; using bke::AttributeMetaData; using bke::AttributeReader; using bke::AttributeWriter; diff --git a/source/blender/nodes/NOD_geometry_nodes_log.hh b/source/blender/nodes/NOD_geometry_nodes_log.hh index dc54b95435d..d9918efd707 100644 --- a/source/blender/nodes/NOD_geometry_nodes_log.hh +++ b/source/blender/nodes/NOD_geometry_nodes_log.hh @@ -112,7 +112,7 @@ class FieldInfoLog : public ValueLog { struct GeometryAttributeInfo { std::string name; /** Can be empty when #name does not actually exist on a geometry yet. */ - std::optional domain; + std::optional domain; std::optional data_type; }; diff --git a/source/blender/nodes/geometry/node_geometry_util.cc b/source/blender/nodes/geometry/node_geometry_util.cc index 39b1a36c71e..f1e190674bd 100644 --- a/source/blender/nodes/geometry/node_geometry_util.cc +++ b/source/blender/nodes/geometry/node_geometry_util.cc @@ -75,8 +75,8 @@ const EnumPropertyItem *domain_experimental_grease_pencil_version3_fn(bContext * *r_free = true; return enum_items_filter( rna_enum_attribute_domain_items, [](const EnumPropertyItem &item) -> bool { - return (item.value == ATTR_DOMAIN_LAYER) ? U.experimental.use_grease_pencil_version3 : - true; + return (bke::AttrDomain(item.value) == bke::AttrDomain::Layer) ? U.experimental.use_grease_pencil_version3 : + true; }); } @@ -86,7 +86,7 @@ const EnumPropertyItem *domain_without_corner_experimental_grease_pencil_version *r_free = true; return enum_items_filter( rna_enum_attribute_domain_without_corner_items, [](const EnumPropertyItem &item) -> bool { - return (item.value == ATTR_DOMAIN_LAYER) ? U.experimental.use_grease_pencil_version3 : + return (bke::AttrDomain(item.value) == bke::AttrDomain::Layer) ? U.experimental.use_grease_pencil_version3 : true; }); } diff --git a/source/blender/nodes/geometry/node_geometry_util.hh b/source/blender/nodes/geometry/node_geometry_util.hh index 843c875c227..400d8aa125e 100644 --- a/source/blender/nodes/geometry/node_geometry_util.hh +++ b/source/blender/nodes/geometry/node_geometry_util.hh @@ -46,7 +46,7 @@ void transform_geometry_set(GeoNodeExecParams ¶ms, * component. If no component can work with the domain, then `error_message` is set to true. */ void separate_geometry(GeometrySet &geometry_set, - eAttrDomain domain, + AttrDomain domain, GeometryNodeDeleteGeometryMode mode, const Field &selection_field, const AnonymousAttributePropagationInfo &propagation_info, @@ -65,15 +65,15 @@ class EvaluateAtIndexInput final : public bke::GeometryFieldInput { private: Field index_field_; GField value_field_; - eAttrDomain value_field_domain_; + AttrDomain value_field_domain_; public: - EvaluateAtIndexInput(Field index_field, GField value_field, eAttrDomain value_field_domain); + EvaluateAtIndexInput(Field index_field, GField value_field, AttrDomain value_field_domain); GVArray get_varray_for_context(const bke::GeometryFieldContext &context, const IndexMask &mask) const final; - std::optional preferred_domain(const GeometryComponent & /*component*/) const final + std::optional preferred_domain(const GeometryComponent & /*component*/) const final { return value_field_domain_; } @@ -82,16 +82,16 @@ class EvaluateAtIndexInput final : public bke::GeometryFieldInput { class EvaluateOnDomainInput final : public bke::GeometryFieldInput { private: GField src_field_; - eAttrDomain src_domain_; + AttrDomain src_domain_; public: - EvaluateOnDomainInput(GField field, eAttrDomain domain); + EvaluateOnDomainInput(GField field, AttrDomain domain); GVArray get_varray_for_context(const bke::GeometryFieldContext &context, const IndexMask & /*mask*/) const final; void for_each_field_input_recursive(FunctionRef fn) const override; - std::optional preferred_domain( + std::optional preferred_domain( const GeometryComponent & /*component*/) const override; }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc index 6a9e6609605..9fe75cb1225 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc @@ -76,7 +76,7 @@ static void node_init(bNodeTree * /*tree*/, bNode *node) { NodeAccumulateField *data = MEM_cnew(__func__); data->data_type = CD_PROP_FLOAT; - data->domain = ATTR_DOMAIN_POINT; + data->domain = int16_t(AttrDomain::Point); node->storage = data; } @@ -149,11 +149,11 @@ class AccumulateFieldInput final : public bke::GeometryFieldInput { private: GField input_; Field group_index_; - eAttrDomain source_domain_; + AttrDomain source_domain_; AccumulationMode accumulation_mode_; public: - AccumulateFieldInput(const eAttrDomain source_domain, + AccumulateFieldInput(const AttrDomain source_domain, GField input, Field group_index, AccumulationMode accumulation_mode) @@ -248,7 +248,7 @@ class AccumulateFieldInput final : public bke::GeometryFieldInput { return false; } - std::optional preferred_domain( + std::optional preferred_domain( const GeometryComponent & /*component*/) const override { return source_domain_; @@ -259,10 +259,10 @@ class TotalFieldInput final : public bke::GeometryFieldInput { private: GField input_; Field group_index_; - eAttrDomain source_domain_; + AttrDomain source_domain_; public: - TotalFieldInput(const eAttrDomain source_domain, GField input, Field group_index) + TotalFieldInput(const AttrDomain source_domain, GField input, Field group_index) : bke::GeometryFieldInput(input.cpp_type(), "Total Value"), input_(input), group_index_(group_index), @@ -332,7 +332,7 @@ class TotalFieldInput final : public bke::GeometryFieldInput { return false; } - std::optional preferred_domain( + std::optional preferred_domain( const GeometryComponent & /*component*/) const override { return source_domain_; @@ -342,7 +342,7 @@ class TotalFieldInput final : public bke::GeometryFieldInput { static void node_geo_exec(GeoNodeExecParams params) { const NodeAccumulateField &storage = node_storage(params.node()); - const eAttrDomain source_domain = eAttrDomain(storage.domain); + const AttrDomain source_domain = AttrDomain(storage.domain); const Field group_index_field = params.extract_input>("Group Index"); const GField input_field = params.extract_input("Value"); @@ -388,7 +388,7 @@ static void node_rna(StructRNA *srna) "", rna_enum_attribute_domain_items, NOD_storage_enum_accessors(domain), - ATTR_DOMAIN_POINT, + int(AttrDomain::Point), enums::domain_experimental_grease_pencil_version3_fn); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc index 5d04ef96f98..1b9ec7f014b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc @@ -48,7 +48,7 @@ static void node_init(bNodeTree * /*tree*/, bNode *node) { NodeGeometryAttributeCapture *data = MEM_cnew(__func__); data->data_type = CD_PROP_FLOAT; - data->domain = ATTR_DOMAIN_POINT; + data->domain = int8_t(AttrDomain::Point); node->storage = data; } @@ -122,7 +122,7 @@ static void node_geo_exec(GeoNodeExecParams params) } const NodeGeometryAttributeCapture &storage = node_storage(params.node()); - const eAttrDomain domain = eAttrDomain(storage.domain); + const AttrDomain domain = AttrDomain(storage.domain); AnonymousAttributeIDPtr attribute_id = params.get_output_anonymous_attribute_id_if_needed( "Attribute"); @@ -143,7 +143,7 @@ static void node_geo_exec(GeoNodeExecParams params) }; /* Run on the instances component separately to only affect the top level of instances. */ - if (domain == ATTR_DOMAIN_INSTANCE) { + if (domain == AttrDomain::Instance) { if (geometry_set.has_instances()) { capture_on(geometry_set.get_component_for_write(GeometryComponent::Type::Instance)); } @@ -183,7 +183,7 @@ static void node_rna(StructRNA *srna) "Which domain to store the data in", rna_enum_attribute_domain_items, NOD_storage_enum_accessors(domain), - ATTR_DOMAIN_POINT, + int8_t(AttrDomain::Point), enums::domain_experimental_grease_pencil_version3_fn); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc index 75eaefd334f..fcce7f433bb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc @@ -88,10 +88,10 @@ static void node_geo_exec(GeoNodeExecParams params) case GeometryComponent::Type::Mesh: { if (const MeshComponent *component = geometry_set.get_component()) { const AttributeAccessor attributes = *component->attributes(); - params.set_output("Point Count", attributes.domain_size(ATTR_DOMAIN_POINT)); - params.set_output("Edge Count", attributes.domain_size(ATTR_DOMAIN_EDGE)); - params.set_output("Face Count", attributes.domain_size(ATTR_DOMAIN_FACE)); - params.set_output("Face Corner Count", attributes.domain_size(ATTR_DOMAIN_CORNER)); + params.set_output("Point Count", attributes.domain_size(AttrDomain::Point)); + params.set_output("Edge Count", attributes.domain_size(AttrDomain::Edge)); + params.set_output("Face Count", attributes.domain_size(AttrDomain::Face)); + params.set_output("Face Corner Count", attributes.domain_size(AttrDomain::Corner)); } else { params.set_default_remaining_outputs(); @@ -101,8 +101,8 @@ static void node_geo_exec(GeoNodeExecParams params) case GeometryComponent::Type::Curve: { if (const CurveComponent *component = geometry_set.get_component()) { const AttributeAccessor attributes = *component->attributes(); - params.set_output("Point Count", attributes.domain_size(ATTR_DOMAIN_POINT)); - params.set_output("Spline Count", attributes.domain_size(ATTR_DOMAIN_CURVE)); + params.set_output("Point Count", attributes.domain_size(AttrDomain::Point)); + params.set_output("Spline Count", attributes.domain_size(AttrDomain::Curve)); } else { params.set_default_remaining_outputs(); @@ -113,7 +113,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (const PointCloudComponent *component = geometry_set.get_component()) { const AttributeAccessor attributes = *component->attributes(); - params.set_output("Point Count", attributes.domain_size(ATTR_DOMAIN_POINT)); + params.set_output("Point Count", attributes.domain_size(AttrDomain::Point)); } else { params.set_default_remaining_outputs(); @@ -123,7 +123,7 @@ static void node_geo_exec(GeoNodeExecParams params) case GeometryComponent::Type::Instance: { if (const InstancesComponent *component = geometry_set.get_component()) { const AttributeAccessor attributes = *component->attributes(); - params.set_output("Instance Count", attributes.domain_size(ATTR_DOMAIN_INSTANCE)); + params.set_output("Instance Count", attributes.domain_size(AttrDomain::Instance)); } else { params.set_default_remaining_outputs(); @@ -134,7 +134,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (const GreasePencilComponent *component = geometry_set.get_component()) { const AttributeAccessor attributes = *component->attributes(); - params.set_output("Layer Count", attributes.domain_size(ATTR_DOMAIN_LAYER)); + params.set_output("Layer Count", attributes.domain_size(AttrDomain::Layer)); } else { params.set_default_remaining_outputs(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc index 3a92ded30c4..b0010e2955a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc @@ -52,7 +52,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { node->custom1 = CD_PROP_FLOAT; - node->custom2 = ATTR_DOMAIN_POINT; + node->custom2 = int16_t(AttrDomain::Point); } static std::optional node_type_from_other_socket(const bNodeSocket &socket) @@ -141,7 +141,7 @@ static void node_geo_exec(GeoNodeExecParams params) GeometrySet geometry_set = params.get_input("Geometry"); const bNode &node = params.node(); const eCustomDataType data_type = eCustomDataType(node.custom1); - const eAttrDomain domain = eAttrDomain(node.custom2); + const AttrDomain domain = AttrDomain(node.custom2); Vector components = geometry_set.get_components(); const Field selection_field = params.get_input>("Selection"); @@ -355,7 +355,7 @@ static void node_rna(StructRNA *srna) "Which domain to read the data from", rna_enum_attribute_domain_items, NOD_inline_enum_accessors(custom2), - ATTR_DOMAIN_POINT, + int(AttrDomain::Point), enums::domain_experimental_grease_pencil_version3_fn); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_bake.cc b/source/blender/nodes/geometry/nodes/node_geo_bake.cc index a1a4bf72ce4..48a06dbddeb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_bake.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_bake.cc @@ -75,7 +75,7 @@ static void node_init(bNodeTree * /*tree*/, bNode *node) NodeGeometryBakeItem &item = data->items[0]; item.name = BLI_strdup("Geometry"); item.identifier = data->next_identifier++; - item.attribute_domain = ATTR_DOMAIN_POINT; + item.attribute_domain = int16_t(AttrDomain::Point); item.socket_type = SOCK_GEOMETRY; node->storage = data; @@ -123,7 +123,7 @@ static bake::BakeSocketConfig make_bake_socket_config(const Span faces, } static GroupedSpan create_mesh_map(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, Array &r_offsets, Array &r_indices) { switch (domain) { - case ATTR_DOMAIN_POINT: + case AttrDomain::Point: build_vert_to_vert_by_edge_map(mesh.edges(), mesh.verts_num, r_offsets, r_indices); break; - case ATTR_DOMAIN_EDGE: + case AttrDomain::Edge: build_edge_to_edge_by_vert_map(mesh.edges(), mesh.verts_num, r_offsets, r_indices); break; - case ATTR_DOMAIN_FACE: + case AttrDomain::Face: build_face_to_face_by_edge_map( mesh.faces(), mesh.corner_edges(), mesh.edges_num, r_offsets, r_indices); break; @@ -256,7 +256,7 @@ static Span blur_on_mesh_exec(const Span neighbor_weights, } static GSpan blur_on_mesh(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const int iterations, const Span neighbor_weights, const GMutableSpan buffer_a, @@ -396,7 +396,7 @@ class BlurAttributeFieldInput final : public bke::GeometryFieldInput { GSpan result_buffer = buffer_a.as_span(); switch (context.type()) { case GeometryComponent::Type::Mesh: - if (ELEM(context.domain(), ATTR_DOMAIN_POINT, ATTR_DOMAIN_EDGE, ATTR_DOMAIN_FACE)) { + if (ELEM(context.domain(), AttrDomain::Point, AttrDomain::Edge, AttrDomain::Face)) { if (const Mesh *mesh = context.mesh()) { result_buffer = blur_on_mesh( *mesh, context.domain(), iterations_, neighbor_weights, buffer_a, buffer_b); @@ -405,7 +405,7 @@ class BlurAttributeFieldInput final : public bke::GeometryFieldInput { break; case GeometryComponent::Type::Curve: case GeometryComponent::Type::GreasePencil: - if (context.domain() == ATTR_DOMAIN_POINT) { + if (context.domain() == AttrDomain::Point) { if (const bke::CurvesGeometry *curves = context.curves_or_strokes()) { result_buffer = blur_on_curves( *curves, iterations_, neighbor_weights, buffer_a, buffer_b); @@ -445,12 +445,12 @@ class BlurAttributeFieldInput final : public bke::GeometryFieldInput { return false; } - std::optional preferred_domain(const GeometryComponent &component) const override + std::optional preferred_domain(const GeometryComponent &component) const override { - const std::optional domain = bke::try_detect_field_domain(component, + const std::optional domain = bke::try_detect_field_domain(component, value_field_); - if (domain.has_value() && *domain == ATTR_DOMAIN_CORNER) { - return ATTR_DOMAIN_POINT; + if (domain.has_value() && *domain == AttrDomain::Corner) { + return AttrDomain::Point; } return domain; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc index e6caa558e0d..60622c4bf77 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc @@ -181,7 +181,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (attribute_outputs.intersecting_edges_id) { MutableAttributeAccessor attributes = result->attributes_for_write(); SpanAttributeWriter selection = attributes.lookup_or_add_for_write_only_span( - attribute_outputs.intersecting_edges_id.get(), ATTR_DOMAIN_EDGE); + attribute_outputs.intersecting_edges_id.get(), AttrDomain::Edge); selection.span.fill(false); for (const int i : intersecting_edges) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc index 47661af3579..f3121eb85e4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc @@ -44,17 +44,17 @@ class EndpointFieldInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_POINT) { + if (domain != AttrDomain::Point) { return {}; } if (curves.points_num() == 0) { return {}; } - const bke::CurvesFieldContext size_context{curves, ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext size_context{curves, AttrDomain::Curve}; fn::FieldEvaluator evaluator{size_context, curves.curves_num()}; evaluator.add(start_size_); evaluator.add(end_size_); @@ -101,9 +101,9 @@ class EndpointFieldInput final : public bke::CurvesFieldInput { return false; } - std::optional preferred_domain(const CurvesGeometry & /*curves*/) const + std::optional preferred_domain(const CurvesGeometry & /*curves*/) const { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc index ddf80ae9611..03bf5745c9c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc @@ -125,7 +125,7 @@ static Array> do_group_aware_cdt( const CDT_output_type output_type, const Field &group_index_field) { - const bke::GeometryFieldContext field_context{curves, ATTR_DOMAIN_CURVE}; + const bke::GeometryFieldContext field_context{curves, AttrDomain::Curve}; fn::FieldEvaluator data_evaluator{field_context, curves.curves_num()}; data_evaluator.add(group_index_field); data_evaluator.evaluate(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc index 97564546e97..8ef0fb8b9bb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc @@ -108,7 +108,7 @@ static void fillet_grease_pencil(GreasePencil &grease_pencil, continue; } const bke::GreasePencilLayerFieldContext field_context( - grease_pencil, ATTR_DOMAIN_CURVE, layer_index); + grease_pencil, AttrDomain::Curve, layer_index); bke::CurvesGeometry dst_curves = fillet_curve(src_curves, mode, field_context, @@ -143,7 +143,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (geometry_set.has_curves()) { const Curves &curves_id = *geometry_set.get_curves(); const bke::CurvesGeometry &src_curves = curves_id.geometry.wrap(); - const bke::CurvesFieldContext field_context{src_curves, ATTR_DOMAIN_POINT}; + const bke::CurvesFieldContext field_context{src_curves, AttrDomain::Point}; bke::CurvesGeometry dst_curves = fillet_curve(src_curves, mode, field_context, diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc index 5628b9eba3c..86c8b81464d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc @@ -87,10 +87,10 @@ class HandleTypeFieldInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask &mask) const final { - if (domain != ATTR_DOMAIN_POINT) { + if (domain != AttrDomain::Point) { return {}; } Array selection(mask.min_array_size()); @@ -113,9 +113,9 @@ class HandleTypeFieldInput final : public bke::CurvesFieldInput { return false; } - std::optional preferred_domain(const CurvesGeometry & /*curves*/) const + std::optional preferred_domain(const CurvesGeometry & /*curves*/) const { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc index a0ccca61d89..b571ad42bef 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc @@ -65,7 +65,7 @@ static void create_selection_output(CurveComponent &component, { SpanAttributeWriter selection = component.attributes_for_write()->lookup_or_add_for_write_only_span(*r_attribute, - ATTR_DOMAIN_POINT); + AttrDomain::Point); for (int i : selection.span.index_range()) { selection.span[i] = i % 2 == 0; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc index 7806cb5c2d4..d94ce60ee34 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc @@ -74,7 +74,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry) { if (const Curves *src_curves_id = geometry.get_curves()) { const bke::CurvesGeometry &src_curves = src_curves_id->geometry.wrap(); - const bke::CurvesFieldContext field_context{src_curves, ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext field_context{src_curves, AttrDomain::Curve}; bke::CurvesGeometry dst_curves = geometry::resample_to_count( src_curves, field_context, selection, count); Curves *dst_curves_id = bke::curves_new_nomain(std::move(dst_curves)); @@ -92,7 +92,7 @@ static void node_geo_exec(GeoNodeExecParams params) } const bke::CurvesGeometry &src_curves = drawing->strokes(); const bke::GreasePencilLayerFieldContext field_context( - grease_pencil, ATTR_DOMAIN_CURVE, layer_index); + grease_pencil, AttrDomain::Curve, layer_index); bke::CurvesGeometry dst_curves = geometry::resample_to_count( src_curves, field_context, selection, count); drawing->strokes_for_write() = std::move(dst_curves); @@ -107,7 +107,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry) { if (const Curves *src_curves_id = geometry.get_curves()) { const bke::CurvesGeometry &src_curves = src_curves_id->geometry.wrap(); - const bke::CurvesFieldContext field_context{src_curves, ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext field_context{src_curves, AttrDomain::Curve}; bke::CurvesGeometry dst_curves = geometry::resample_to_length( src_curves, field_context, selection, length); Curves *dst_curves_id = bke::curves_new_nomain(std::move(dst_curves)); @@ -125,7 +125,7 @@ static void node_geo_exec(GeoNodeExecParams params) } const bke::CurvesGeometry &src_curves = drawing->strokes(); const bke::GreasePencilLayerFieldContext field_context( - grease_pencil, ATTR_DOMAIN_CURVE, layer_index); + grease_pencil, AttrDomain::Curve, layer_index); bke::CurvesGeometry dst_curves = geometry::resample_to_length( src_curves, field_context, selection, length); drawing->strokes_for_write() = std::move(dst_curves); @@ -139,7 +139,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry) { if (const Curves *src_curves_id = geometry.get_curves()) { const bke::CurvesGeometry &src_curves = src_curves_id->geometry.wrap(); - const bke::CurvesFieldContext field_context{src_curves, ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext field_context{src_curves, AttrDomain::Curve}; bke::CurvesGeometry dst_curves = geometry::resample_to_evaluated( src_curves, field_context, selection); Curves *dst_curves_id = bke::curves_new_nomain(std::move(dst_curves)); @@ -157,7 +157,7 @@ static void node_geo_exec(GeoNodeExecParams params) } const bke::CurvesGeometry &src_curves = drawing->strokes(); const bke::GreasePencilLayerFieldContext field_context( - grease_pencil, ATTR_DOMAIN_CURVE, layer_index); + grease_pencil, AttrDomain::Curve, layer_index); bke::CurvesGeometry dst_curves = geometry::resample_to_evaluated( src_curves, field_context, selection); drawing->strokes_for_write() = std::move(dst_curves); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc index b761c180ade..b4fb6866395 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc @@ -43,7 +43,7 @@ static void reverse_grease_pencil(GreasePencil &grease_pencil, const Field } bke::CurvesGeometry &curves = drawing->strokes_for_write(); const bke::GreasePencilLayerFieldContext field_context( - grease_pencil, ATTR_DOMAIN_CURVE, layer_index); + grease_pencil, AttrDomain::Curve, layer_index); reverse_curve(curves, field_context, selection_field); drawing->tag_topology_changed(); } @@ -59,7 +59,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (Curves *curves_id = geometry_set.get_curves_for_write()) { bke::CurvesGeometry &curves = curves_id->geometry.wrap(); - const bke::CurvesFieldContext field_context{curves, ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext field_context{curves, AttrDomain::Curve}; reverse_curve(curves, field_context, selection_field); } if (geometry_set.has_grease_pencil()) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc index 92d4f5115f5..2d3be09c1e7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc @@ -446,7 +446,7 @@ class SampleCurveFunction : public mf::MultiFunction { { const Curves &curves_id = *geometry_set_.get_curves(); const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); - source_context_.emplace(bke::CurvesFieldContext{curves, ATTR_DOMAIN_POINT}); + source_context_.emplace(bke::CurvesFieldContext{curves, AttrDomain::Point}); source_evaluator_ = std::make_unique(*source_context_, curves.points_num()); source_evaluator_->add(src_field_); source_evaluator_->evaluate(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc index 8c6852c6a26..bcb866c408e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc @@ -58,7 +58,7 @@ static void set_handle_type(bke::CurvesGeometry &curves, const HandleType new_handle_type, const Field &selection_field) { - const bke::CurvesFieldContext field_context{curves, ATTR_DOMAIN_POINT}; + const bke::CurvesFieldContext field_context{curves, AttrDomain::Point}; fn::FieldEvaluator evaluator{field_context, curves.points_num()}; evaluator.set_selection(selection_field); evaluator.evaluate(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc index 6e2ec4422d4..11b59bdae17 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc @@ -179,13 +179,13 @@ class CurveParameterFieldInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { switch (domain) { - case ATTR_DOMAIN_POINT: + case AttrDomain::Point: return VArray::ForContainer(calculate_point_parameters(curves)); - case ATTR_DOMAIN_CURVE: + case AttrDomain::Curve: return VArray::ForContainer(calculate_curve_parameters(curves)); default: BLI_assert_unreachable(); @@ -213,14 +213,14 @@ class CurveLengthParameterFieldInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { switch (domain) { - case ATTR_DOMAIN_POINT: + case AttrDomain::Point: return VArray::ForContainer(calculate_point_lengths( curves, [](MutableSpan /*lengths*/, const float /*total*/) {})); - case ATTR_DOMAIN_CURVE: + case AttrDomain::Curve: return VArray::ForContainer(accumulated_lengths_curve_domain(curves)); default: BLI_assert_unreachable(); @@ -247,10 +247,10 @@ class IndexOnSplineFieldInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_POINT) { + if (domain != AttrDomain::Point) { return {}; } Array result(curves.points_num()); @@ -274,9 +274,9 @@ class IndexOnSplineFieldInput final : public bke::CurvesFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const CurvesGeometry & /*curves*/) const + std::optional preferred_domain(const CurvesGeometry & /*curves*/) const { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc index 4b4ae437ce0..e1238035733 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc @@ -57,7 +57,7 @@ static void node_geo_exec(GeoNodeExecParams params) return; } - const bke::CurvesFieldContext field_context{src_curves, ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext field_context{src_curves, AttrDomain::Curve}; fn::FieldEvaluator evaluator{field_context, src_curves.curves_num()}; evaluator.set_selection(selection_field); evaluator.evaluate(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc index 9911ace9b72..13392b4e9df 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc @@ -29,7 +29,7 @@ static Curves *subdivide_curves(const Curves &src_curves_id, { const bke::CurvesGeometry &src_curves = src_curves_id.geometry.wrap(); - const bke::CurvesFieldContext field_context{src_curves, ATTR_DOMAIN_POINT}; + const bke::CurvesFieldContext field_context{src_curves, AttrDomain::Point}; fn::FieldEvaluator evaluator{field_context, src_curves.points_num()}; evaluator.add(cuts_field); evaluator.evaluate(); @@ -62,7 +62,7 @@ static void subdivide_grease_pencil_curves( const bke::CurvesGeometry &src_curves = drawing->strokes(); const bke::GreasePencilLayerFieldContext field_context{ - grease_pencil, ATTR_DOMAIN_POINT, layer_index}; + grease_pencil, AttrDomain::Point, layer_index}; fn::FieldEvaluator evaluator{field_context, src_curves.points_num()}; evaluator.add(cuts_field); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index 64fc5320276..daf96c73702 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -94,14 +94,14 @@ static void copy_curve_domain_attributes(const AttributeAccessor curve_attribute if (curve_attributes.is_builtin(id)) { return true; } - if (meta_data.domain != ATTR_DOMAIN_CURVE) { + if (meta_data.domain != AttrDomain::Curve) { return true; } point_attributes.add( id, - ATTR_DOMAIN_POINT, + AttrDomain::Point, meta_data.data_type, - bke::AttributeInitVArray(*curve_attributes.lookup(id, ATTR_DOMAIN_POINT))); + bke::AttributeInitVArray(*curve_attributes.lookup(id, AttrDomain::Point))); return true; }); } @@ -116,10 +116,10 @@ static PointCloud *pointcloud_from_curves(bke::CurvesGeometry curves, if (rotation_id) { MutableAttributeAccessor attributes = curves.attributes_for_write(); - const VArraySpan tangents = *attributes.lookup(tangent_id, ATTR_DOMAIN_POINT); - const VArraySpan normals = *attributes.lookup(normal_id, ATTR_DOMAIN_POINT); + const VArraySpan tangents = *attributes.lookup(tangent_id, AttrDomain::Point); + const VArraySpan normals = *attributes.lookup(normal_id, AttrDomain::Point); SpanAttributeWriter rotations = attributes.lookup_or_add_for_write_only_span( - rotation_id, ATTR_DOMAIN_POINT); + rotation_id, AttrDomain::Point); fill_rotation_attribute(tangents, normals, rotations.span); rotations.finish(); } @@ -146,7 +146,7 @@ static void curve_to_points(GeometrySet &geometry_set, geometry_set.modify_geometry_sets([&](GeometrySet &geometry) { if (const Curves *src_curves_id = geometry.get_curves()) { const bke::CurvesGeometry &src_curves = src_curves_id->geometry.wrap(); - const bke::CurvesFieldContext field_context{src_curves, ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext field_context{src_curves, AttrDomain::Curve}; bke::CurvesGeometry dst_curves = geometry::resample_to_count( src_curves, field_context, @@ -168,7 +168,7 @@ static void curve_to_points(GeometrySet &geometry_set, geometry_set.modify_geometry_sets([&](GeometrySet &geometry) { if (const Curves *src_curves_id = geometry.get_curves()) { const bke::CurvesGeometry &src_curves = src_curves_id->geometry.wrap(); - const bke::CurvesFieldContext field_context{src_curves, ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext field_context{src_curves, AttrDomain::Curve}; bke::CurvesGeometry dst_curves = geometry::resample_to_length( src_curves, field_context, @@ -189,7 +189,7 @@ static void curve_to_points(GeometrySet &geometry_set, geometry_set.modify_geometry_sets([&](GeometrySet &geometry) { if (const Curves *src_curves_id = geometry.get_curves()) { const bke::CurvesGeometry &src_curves = src_curves_id->geometry.wrap(); - const bke::CurvesFieldContext field_context{src_curves, ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext field_context{src_curves, AttrDomain::Curve}; bke::CurvesGeometry dst_curves = geometry::resample_to_evaluated( src_curves, field_context, fn::make_constant_field(true), resample_attributes); PointCloud *pointcloud = pointcloud_from_curves(std::move(dst_curves), @@ -238,7 +238,7 @@ static void grease_pencil_to_points(GeometrySet &geometry_set, } const bke::CurvesGeometry &src_curves = drawing->strokes(); bke::GreasePencilLayerFieldContext field_context( - grease_pencil, ATTR_DOMAIN_CURVE, layer_index); + grease_pencil, AttrDomain::Curve, layer_index); bke::CurvesGeometry dst_curves; switch (mode) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_topology_curve_of_point.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_topology_curve_of_point.cc index 49a27ee6603..c13d7518d67 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_topology_curve_of_point.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_topology_curve_of_point.cc @@ -29,10 +29,10 @@ class CurveOfPointInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_POINT) { + if (domain != AttrDomain::Point) { return {}; } return VArray::ForContainer(curves.point_to_curve_map()); @@ -48,9 +48,9 @@ class CurveOfPointInput final : public bke::CurvesFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final + std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; @@ -62,10 +62,10 @@ class PointIndexInCurveInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_POINT) { + if (domain != AttrDomain::Point) { return {}; } const Span offsets = curves.offsets(); @@ -88,9 +88,9 @@ class PointIndexInCurveInput final : public bke::CurvesFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) + std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; @@ -101,14 +101,14 @@ static void node_geo_exec(GeoNodeExecParams params) params.set_output( "Curve Index", Field(std::make_shared( - point_index, Field(std::make_shared()), ATTR_DOMAIN_POINT))); + point_index, Field(std::make_shared()), AttrDomain::Point))); } if (params.output_is_required("Index in Curve")) { params.set_output("Index in Curve", Field(std::make_shared( point_index, Field(std::make_shared()), - ATTR_DOMAIN_POINT))); + AttrDomain::Point))); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_topology_points_of_curve.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_topology_points_of_curve.cc index 8a4ecfb40e7..0665e505057 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_topology_points_of_curve.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_topology_points_of_curve.cc @@ -45,7 +45,7 @@ class PointsOfCurveInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask &mask) const final { const OffsetIndices points_by_curve = curves.points_by_curve(); @@ -58,7 +58,7 @@ class PointsOfCurveInput final : public bke::CurvesFieldInput { const VArray curve_indices = evaluator.get_evaluated(0); const VArray indices_in_sort = evaluator.get_evaluated(1); - const bke::CurvesFieldContext point_context{curves, ATTR_DOMAIN_POINT}; + const bke::CurvesFieldContext point_context{curves, AttrDomain::Point}; fn::FieldEvaluator point_evaluator{point_context, curves.points_num()}; point_evaluator.add(sort_weight_); point_evaluator.evaluate(); @@ -128,9 +128,9 @@ class PointsOfCurveInput final : public bke::CurvesFieldInput { return false; } - std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final + std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final { - return ATTR_DOMAIN_CURVE; + return AttrDomain::Curve; } }; @@ -142,10 +142,10 @@ class CurvePointCountInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_CURVE) { + if (domain != AttrDomain::Curve) { return {}; } const OffsetIndices points_by_curve = curves.points_by_curve(); @@ -164,9 +164,9 @@ class CurvePointCountInput final : public bke::CurvesFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final + std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final { - return ATTR_DOMAIN_CURVE; + return AttrDomain::Curve; } }; @@ -196,10 +196,10 @@ class CurveStartPointInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - return curves.adapt_domain(VArray::ForSpan(curves.offsets()), ATTR_DOMAIN_CURVE, domain); + return curves.adapt_domain(VArray::ForSpan(curves.offsets()), AttrDomain::Curve, domain); } uint64_t hash() const final @@ -212,9 +212,9 @@ class CurveStartPointInput final : public bke::CurvesFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final + std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final { - return ATTR_DOMAIN_CURVE; + return AttrDomain::Curve; } }; @@ -226,7 +226,7 @@ static void node_geo_exec(GeoNodeExecParams params) Field(std::make_shared( curve_index, Field(std::make_shared()), - ATTR_DOMAIN_CURVE))); + AttrDomain::Curve))); } if (params.output_is_required("Point Index")) { Field sort_index = params.extract_input>("Sort Index"); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc index 90463d9cc8f..929bad2fa4c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc @@ -155,7 +155,7 @@ static void geometry_set_curve_trim(GeometrySet &geometry_set, if (geometry_set.has_curves()) { const Curves &src_curves_id = *geometry_set.get_curves(); const bke::CurvesGeometry &src_curves = src_curves_id.geometry.wrap(); - const bke::CurvesFieldContext field_context{src_curves, ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext field_context{src_curves, AttrDomain::Curve}; bke::CurvesGeometry dst_curves; if (trim_curves(src_curves, mode, @@ -182,7 +182,7 @@ static void geometry_set_curve_trim(GeometrySet &geometry_set, } const bke::CurvesGeometry &src_curves = drawing->strokes(); const bke::GreasePencilLayerFieldContext field_context{ - grease_pencil, ATTR_DOMAIN_CURVE, layer_index}; + grease_pencil, AttrDomain::Curve, layer_index}; bke::CurvesGeometry dst_curves; if (trim_curves(src_curves, mode, diff --git a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc index a06745968c9..6d205f9171c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc @@ -301,13 +301,13 @@ static void node_geo_exec(GeoNodeExecParams params) return; } const VArraySpan uv_map_orig = *mesh_attributes_orig.lookup(uv_map_name, - ATTR_DOMAIN_CORNER); + AttrDomain::Corner); const VArraySpan uv_map_eval = *mesh_attributes_eval.lookup(uv_map_name, - ATTR_DOMAIN_CORNER); + AttrDomain::Corner); const VArraySpan rest_positions = *mesh_attributes_eval.lookup(rest_position_name, - ATTR_DOMAIN_POINT); + AttrDomain::Point); const VArraySpan surface_uv_coords = *curves.attributes().lookup_or_default( - "surface_uv_coordinate", ATTR_DOMAIN_CURVE, float2(0)); + "surface_uv_coordinate", AttrDomain::Curve, float2(0)); const Span corner_tris_orig = surface_mesh_orig->corner_tris(); const Span corner_tris_eval = surface_mesh_eval->corner_tris(); @@ -372,7 +372,7 @@ static void node_geo_exec(GeoNodeExecParams params) /* Then also deform edit curve information for use in sculpt mode. */ const CurvesGeometry &curves_orig = edit_hints->curves_id_orig.geometry.wrap(); const VArraySpan surface_uv_coords_orig = *curves_orig.attributes().lookup_or_default( - "surface_uv_coordinate", ATTR_DOMAIN_CURVE, float2(0)); + "surface_uv_coordinate", AttrDomain::Curve, float2(0)); if (!surface_uv_coords_orig.is_empty()) { deform_curves(curves_orig, *surface_mesh_orig, diff --git a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc index 5a199770660..64328a71870 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc @@ -29,7 +29,7 @@ static std::optional separate_curves_selection( const bke::CurvesGeometry &src_curves, const fn::FieldContext &field_context, const Field &selection_field, - const eAttrDomain domain, + const AttrDomain domain, const bke::AnonymousAttributePropagationInfo &propagation_info) { const int domain_size = src_curves.attributes().domain_size(domain); @@ -44,10 +44,10 @@ static std::optional separate_curves_selection( return bke::CurvesGeometry(); } - if (domain == ATTR_DOMAIN_POINT) { + if (domain == AttrDomain::Point) { return bke::curves_copy_point_selection(src_curves, selection, propagation_info); } - else if (domain == ATTR_DOMAIN_CURVE) { + else if (domain == AttrDomain::Curve) { return bke::curves_copy_curve_selection(src_curves, selection, propagation_info); } BLI_assert_unreachable(); @@ -74,7 +74,7 @@ static std::optional separate_point_cloud_selection( PointCloud *pointcloud = BKE_pointcloud_new_nomain(selection.size()); bke::gather_attributes(src_pointcloud.attributes(), - ATTR_DOMAIN_POINT, + AttrDomain::Point, propagation_info, {}, selection, @@ -104,7 +104,7 @@ static void delete_selected_instances(GeometrySet &geometry_set, static std::optional separate_mesh_selection( const Mesh &mesh, const Field &selection_field, - const eAttrDomain selection_domain, + const AttrDomain selection_domain, const GeometryNodeDeleteGeometryMode mode, const AnonymousAttributePropagationInfo &propagation_info) { @@ -136,12 +136,12 @@ static std::optional separate_grease_pencil_layer_selection( const bke::AttributeAccessor attributes = src_grease_pencil.attributes(); const bke::GeometryFieldContext context(src_grease_pencil); - fn::FieldEvaluator evaluator(context, attributes.domain_size(ATTR_DOMAIN_LAYER)); + fn::FieldEvaluator evaluator(context, attributes.domain_size(AttrDomain::Layer)); evaluator.set_selection(selection_field); evaluator.evaluate(); const IndexMask selection = evaluator.get_evaluated_selection_as_mask(); - if (selection.size() == attributes.domain_size(ATTR_DOMAIN_LAYER)) { + if (selection.size() == attributes.domain_size(AttrDomain::Layer)) { return std::nullopt; } if (selection.is_empty()) { @@ -157,7 +157,7 @@ static std::optional separate_grease_pencil_layer_selection( dst_grease_pencil->remove_drawings_with_no_users(); bke::gather_attributes(src_grease_pencil.attributes(), - ATTR_DOMAIN_LAYER, + AttrDomain::Layer, propagation_info, {}, selection, @@ -171,7 +171,7 @@ static std::optional separate_grease_pencil_layer_selection( namespace blender::nodes { void separate_geometry(GeometrySet &geometry_set, - const eAttrDomain domain, + const AttrDomain domain, const GeometryNodeDeleteGeometryMode mode, const Field &selection, const AnonymousAttributePropagationInfo &propagation_info, @@ -181,7 +181,7 @@ void separate_geometry(GeometrySet &geometry_set, bool some_valid_domain = false; if (const PointCloud *points = geometry_set.get_pointcloud()) { - if (domain == ATTR_DOMAIN_POINT) { + if (domain == AttrDomain::Point) { std::optional dst_points = file_ns::separate_point_cloud_selection( *points, selection, propagation_info); if (dst_points) { @@ -191,7 +191,7 @@ void separate_geometry(GeometrySet &geometry_set, } } if (const Mesh *mesh = geometry_set.get_mesh()) { - if (ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_EDGE, ATTR_DOMAIN_FACE, ATTR_DOMAIN_CORNER)) { + if (ELEM(domain, AttrDomain::Point, AttrDomain::Edge, AttrDomain::Face, AttrDomain::Corner)) { std::optional dst_mesh = file_ns::separate_mesh_selection( *mesh, selection, domain, mode, propagation_info); if (dst_mesh) { @@ -201,7 +201,7 @@ void separate_geometry(GeometrySet &geometry_set, } } if (const Curves *src_curves_id = geometry_set.get_curves()) { - if (ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) { + if (ELEM(domain, AttrDomain::Point, AttrDomain::Curve)) { const bke::CurvesGeometry &src_curves = src_curves_id->geometry.wrap(); const bke::CurvesFieldContext field_context{src_curves, domain}; std::optional dst_curves = file_ns::separate_curves_selection( @@ -221,7 +221,7 @@ void separate_geometry(GeometrySet &geometry_set, } if (geometry_set.get_grease_pencil()) { using namespace blender::bke::greasepencil; - if (domain == ATTR_DOMAIN_LAYER) { + if (domain == AttrDomain::Layer) { const GreasePencil &grease_pencil = *geometry_set.get_grease_pencil(); std::optional dst_grease_pencil = file_ns::separate_grease_pencil_layer_selection( @@ -231,7 +231,7 @@ void separate_geometry(GeometrySet &geometry_set, } some_valid_domain = true; } - else if (ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) { + else if (ELEM(domain, AttrDomain::Point, AttrDomain::Curve)) { GreasePencil &grease_pencil = *geometry_set.get_grease_pencil_for_write(); for (const int layer_index : grease_pencil.layers().index_range()) { Drawing *drawing = get_eval_grease_pencil_layer_drawing_for_write(grease_pencil, @@ -241,7 +241,7 @@ void separate_geometry(GeometrySet &geometry_set, } const bke::CurvesGeometry &src_curves = drawing->strokes(); const bke::GreasePencilLayerFieldContext field_context( - grease_pencil, ATTR_DOMAIN_CURVE, layer_index); + grease_pencil, AttrDomain::Curve, layer_index); std::optional dst_curves = file_ns::separate_curves_selection( src_curves, field_context, selection, domain, propagation_info); if (!dst_curves) { @@ -254,7 +254,7 @@ void separate_geometry(GeometrySet &geometry_set, } } if (geometry_set.has_instances()) { - if (domain == ATTR_DOMAIN_INSTANCE) { + if (domain == AttrDomain::Instance) { file_ns::delete_selected_instances(geometry_set, selection, propagation_info); some_valid_domain = true; } @@ -283,11 +283,11 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) { const bNode *node = static_cast(ptr->data); const NodeGeometryDeleteGeometry &storage = node_storage(*node); - const eAttrDomain domain = eAttrDomain(storage.domain); + const AttrDomain domain = AttrDomain(storage.domain); uiItemR(layout, ptr, "domain", UI_ITEM_NONE, "", ICON_NONE); /* Only show the mode when it is relevant. */ - if (ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_EDGE, ATTR_DOMAIN_FACE)) { + if (ELEM(domain, AttrDomain::Point, AttrDomain::Edge, AttrDomain::Face)) { uiItemR(layout, ptr, "mode", UI_ITEM_NONE, "", ICON_NONE); } } @@ -295,7 +295,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { NodeGeometryDeleteGeometry *data = MEM_cnew(__func__); - data->domain = ATTR_DOMAIN_POINT; + data->domain = int(AttrDomain::Point); data->mode = GEO_NODE_DELETE_GEOMETRY_MODE_ALL; node->storage = data; @@ -312,13 +312,13 @@ static void node_geo_exec(GeoNodeExecParams params) params.extract_input>("Selection")); const NodeGeometryDeleteGeometry &storage = node_storage(params.node()); - const eAttrDomain domain = eAttrDomain(storage.domain); + const AttrDomain domain = AttrDomain(storage.domain); const GeometryNodeDeleteGeometryMode mode = (GeometryNodeDeleteGeometryMode)storage.mode; const AnonymousAttributePropagationInfo &propagation_info = params.get_output_propagation_info( "Geometry"); - if (domain == ATTR_DOMAIN_INSTANCE) { + if (domain == AttrDomain::Instance) { bool is_error; separate_geometry(geometry_set, domain, mode, selection, propagation_info, is_error); } @@ -356,7 +356,7 @@ static void node_rna(StructRNA *srna) "Which domain to delete in", rna_enum_attribute_domain_without_corner_items, NOD_storage_enum_accessors(domain), - ATTR_DOMAIN_POINT, + int(AttrDomain::Point), enums::domain_experimental_grease_pencil_version3_fn); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc index 141cbc6953a..aebece7eb18 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc @@ -246,7 +246,7 @@ static void node_geo_exec(GeoNodeExecParams params) bke::MutableAttributeAccessor point_attributes = pointcloud->attributes_for_write(); pointcloud->positions_for_write().copy_from(positions); bke::SpanAttributeWriter point_radii = - point_attributes.lookup_or_add_for_write_only_span("radius", ATTR_DOMAIN_POINT); + point_attributes.lookup_or_add_for_write_only_span("radius", AttrDomain::Point); point_radii.span.fill(0.05f); point_radii.finish(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc index 47466ee56f7..f36259a702b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc @@ -250,12 +250,12 @@ BLI_NOINLINE static void eliminate_points_based_on_mask(const Span elimina BLI_NOINLINE static void interpolate_attribute(const Mesh &mesh, const Span bary_coords, const Span tri_indices, - const eAttrDomain source_domain, + const AttrDomain source_domain, const GVArray &source_data, GMutableSpan output_data) { switch (source_domain) { - case ATTR_DOMAIN_POINT: { + case AttrDomain::Point: { bke::mesh_surface_sample::sample_point_attribute(mesh.corner_verts(), mesh.corner_tris(), tri_indices, @@ -265,7 +265,7 @@ BLI_NOINLINE static void interpolate_attribute(const Mesh &mesh, output_data); break; } - case ATTR_DOMAIN_CORNER: { + case AttrDomain::Corner: { bke::mesh_surface_sample::sample_corner_attribute(mesh.corner_tris(), tri_indices, bary_coords, @@ -274,7 +274,7 @@ BLI_NOINLINE static void interpolate_attribute(const Mesh &mesh, output_data); break; } - case ATTR_DOMAIN_FACE: { + case AttrDomain::Face: { bke::mesh_surface_sample::sample_face_attribute(mesh.corner_tri_faces(), tri_indices, source_data, @@ -307,12 +307,12 @@ BLI_NOINLINE static void propagate_existing_attributes( if (!src) { continue; } - if (src.domain == ATTR_DOMAIN_EDGE) { + if (src.domain == AttrDomain::Edge) { continue; } GSpanAttributeWriter dst = point_attributes.lookup_or_add_for_write_only_span( - attribute_id, ATTR_DOMAIN_POINT, output_data_type); + attribute_id, AttrDomain::Point, output_data_type); if (!dst) { continue; } @@ -412,18 +412,18 @@ BLI_NOINLINE static void compute_attribute_outputs(const Mesh &mesh, MutableAttributeAccessor point_attributes = points.attributes_for_write(); SpanAttributeWriter ids = point_attributes.lookup_or_add_for_write_only_span( - "id", ATTR_DOMAIN_POINT); + "id", AttrDomain::Point); SpanAttributeWriter normals; SpanAttributeWriter rotations; if (attribute_outputs.normal_id) { normals = point_attributes.lookup_or_add_for_write_only_span( - attribute_outputs.normal_id.get(), ATTR_DOMAIN_POINT); + attribute_outputs.normal_id.get(), AttrDomain::Point); } if (attribute_outputs.rotation_id) { rotations = point_attributes.lookup_or_add_for_write_only_span( - attribute_outputs.rotation_id.get(), ATTR_DOMAIN_POINT); + attribute_outputs.rotation_id.get(), AttrDomain::Point); } threading::parallel_for(bary_coords.index_range(), 1024, [&](const IndexRange range) { @@ -456,7 +456,7 @@ static Array calc_full_density_factors_with_selection(const Mesh &mesh, const Field &density_field, const Field &selection_field) { - const eAttrDomain domain = ATTR_DOMAIN_CORNER; + const AttrDomain domain = AttrDomain::Corner; const int domain_size = mesh.attributes().domain_size(domain); Array densities(domain_size, 0.0f); @@ -553,7 +553,7 @@ static void point_distribution_calculate(GeometrySet &geometry_set, PointCloud *pointcloud = BKE_pointcloud_new_nomain(positions.size()); bke::MutableAttributeAccessor point_attributes = pointcloud->attributes_for_write(); bke::SpanAttributeWriter point_radii = - point_attributes.lookup_or_add_for_write_only_span("radius", ATTR_DOMAIN_POINT); + point_attributes.lookup_or_add_for_write_only_span("radius", AttrDomain::Point); pointcloud->positions_for_write().copy_from(positions); point_radii.span.fill(0.05f); point_radii.finish(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc index 1cca580e683..e87e036afc2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc @@ -155,12 +155,12 @@ static void transfer_attributes( for (const AttributeIDRef &id : attribute_ids) { GAttributeReader src = src_attributes.lookup(id); - eAttrDomain out_domain; - if (src.domain == ATTR_DOMAIN_FACE) { - out_domain = ATTR_DOMAIN_POINT; + AttrDomain out_domain; + if (src.domain == AttrDomain::Face) { + out_domain = AttrDomain::Point; } - else if (src.domain == ATTR_DOMAIN_POINT) { - out_domain = ATTR_DOMAIN_FACE; + else if (src.domain == AttrDomain::Point) { + out_domain = AttrDomain::Face; } else { /* Edges and Face Corners. */ @@ -174,7 +174,7 @@ static void transfer_attributes( } switch (src.domain) { - case ATTR_DOMAIN_POINT: { + case AttrDomain::Point: { const GVArraySpan src_span(*src); bke::attribute_math::convert_to_static_type(data_type, [&](auto dummy) { using T = decltype(dummy); @@ -183,10 +183,10 @@ static void transfer_attributes( }); break; } - case ATTR_DOMAIN_EDGE: + case AttrDomain::Edge: bke::attribute_math::gather(*src, new_to_old_edges_map, dst.span); break; - case ATTR_DOMAIN_FACE: { + case AttrDomain::Face: { const GVArraySpan src_span(*src); dst.span.take_front(src_span.size()).copy_from(src_span); bke::attribute_math::convert_to_static_type(data_type, [&](auto dummy) { @@ -198,7 +198,7 @@ static void transfer_attributes( }); break; } - case ATTR_DOMAIN_CORNER: + case AttrDomain::Corner: bke::attribute_math::gather(*src, new_to_old_face_corners_map, dst.span); break; default: diff --git a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc index 08443cada1c..1afe4bf74a3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc @@ -48,7 +48,7 @@ static void node_declare(NodeDeclarationBuilder &b) static void node_init(bNodeTree * /*tree*/, bNode *node) { NodeGeometryDuplicateElements *data = MEM_cnew(__func__); - data->domain = ATTR_DOMAIN_POINT; + data->domain = int8_t(AttrDomain::Point); node->storage = data; } @@ -108,7 +108,7 @@ static void threaded_id_offset_copy(const OffsetIndices offsets, /** Create the copy indices for the duplication domain. */ static void create_duplicate_index_attribute(bke::MutableAttributeAccessor attributes, - const eAttrDomain output_domain, + const AttrDomain output_domain, const IndexMask &selection, const IndexAttributes &attribute_outputs, const OffsetIndices offsets) @@ -137,7 +137,7 @@ static void copy_stable_id_point(const OffsetIndices offsets, return; } GSpanAttributeWriter dst_attribute = dst_attributes.lookup_or_add_for_write_only_span( - "id", ATTR_DOMAIN_POINT, CD_PROP_INT32); + "id", AttrDomain::Point, CD_PROP_INT32); if (!dst_attribute) { return; } @@ -175,11 +175,11 @@ static void copy_curve_attributes_without_id( {"id"})) { switch (attribute.meta_data.domain) { - case ATTR_DOMAIN_CURVE: + case AttrDomain::Curve: bke::attribute_math::gather_to_groups( curve_offsets, selection, attribute.src, attribute.dst.span); break; - case ATTR_DOMAIN_POINT: + case AttrDomain::Point: bke::attribute_math::convert_to_static_type(attribute.src.type(), [&](auto dummy) { using T = decltype(dummy); const Span src = attribute.src.typed(); @@ -218,7 +218,7 @@ static void copy_stable_id_curves(const bke::CurvesGeometry &src_curves, } GSpanAttributeWriter dst_attribute = dst_curves.attributes_for_write().lookup_or_add_for_write_only_span( - "id", ATTR_DOMAIN_POINT, CD_PROP_INT32); + "id", AttrDomain::Point, CD_PROP_INT32); if (!dst_attribute) { return; } @@ -258,7 +258,7 @@ static void duplicate_curves(GeometrySet &geometry_set, const Curves &curves_id = *geometry_set.get_curves(); const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); - const bke::CurvesFieldContext field_context{curves, ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext field_context{curves, AttrDomain::Curve}; FieldEvaluator evaluator{field_context, curves.curves_num()}; evaluator.add(count_field); evaluator.set_selection(selection_field); @@ -318,7 +318,7 @@ static void duplicate_curves(GeometrySet &geometry_set, if (attribute_outputs.duplicate_index) { create_duplicate_index_attribute(new_curves.attributes_for_write(), - ATTR_DOMAIN_CURVE, + AttrDomain::Curve, selection, attribute_outputs, curve_offsets); @@ -356,17 +356,17 @@ static void copy_face_attributes_without_id( {"id", ".corner_vert", ".corner_edge", ".edge_verts"})) { switch (attribute.meta_data.domain) { - case ATTR_DOMAIN_POINT: + case AttrDomain::Point: bke::attribute_math::gather(attribute.src, vert_mapping, attribute.dst.span); break; - case ATTR_DOMAIN_EDGE: + case AttrDomain::Edge: bke::attribute_math::gather(attribute.src, edge_mapping, attribute.dst.span); break; - case ATTR_DOMAIN_FACE: + case AttrDomain::Face: bke::attribute_math::gather_to_groups( offsets, selection, attribute.src, attribute.dst.span); break; - case ATTR_DOMAIN_CORNER: + case AttrDomain::Corner: bke::attribute_math::gather(attribute.src, loop_mapping, attribute.dst.span); break; default: @@ -396,7 +396,7 @@ static void copy_stable_id_faces(const Mesh &mesh, return; } GSpanAttributeWriter dst_attribute = dst_attributes.lookup_or_add_for_write_only_span( - "id", ATTR_DOMAIN_POINT, CD_PROP_INT32); + "id", AttrDomain::Point, CD_PROP_INT32); if (!dst_attribute) { return; } @@ -445,7 +445,7 @@ static void duplicate_faces(GeometrySet &geometry_set, const Span corner_verts = mesh.corner_verts(); const Span corner_edges = mesh.corner_edges(); - const bke::MeshFieldContext field_context{mesh, ATTR_DOMAIN_FACE}; + const bke::MeshFieldContext field_context{mesh, AttrDomain::Face}; FieldEvaluator evaluator(field_context, faces.size()); evaluator.add(count_field); evaluator.set_selection(selection_field); @@ -524,7 +524,7 @@ static void duplicate_faces(GeometrySet &geometry_set, if (attribute_outputs.duplicate_index) { create_duplicate_index_attribute(new_mesh->attributes_for_write(), - ATTR_DOMAIN_FACE, + AttrDomain::Face, selection, attribute_outputs, duplicates); @@ -559,11 +559,11 @@ static void copy_edge_attributes_without_id( {"id", ".edge_verts"})) { switch (attribute.meta_data.domain) { - case ATTR_DOMAIN_EDGE: + case AttrDomain::Edge: bke::attribute_math::gather_to_groups( offsets, selection, attribute.src, attribute.dst.span); break; - case ATTR_DOMAIN_POINT: + case AttrDomain::Point: bke::attribute_math::gather(attribute.src, point_mapping, attribute.dst.span); break; default: @@ -589,7 +589,7 @@ static void copy_stable_id_edges(const Mesh &mesh, return; } GSpanAttributeWriter dst_attribute = dst_attributes.lookup_or_add_for_write_only_span( - "id", ATTR_DOMAIN_POINT, CD_PROP_INT32); + "id", AttrDomain::Point, CD_PROP_INT32); if (!dst_attribute) { return; } @@ -629,7 +629,7 @@ static void duplicate_edges(GeometrySet &geometry_set, const Mesh &mesh = *geometry_set.get_mesh(); const Span edges = mesh.edges(); - const bke::MeshFieldContext field_context{mesh, ATTR_DOMAIN_EDGE}; + const bke::MeshFieldContext field_context{mesh, AttrDomain::Edge}; FieldEvaluator evaluator{field_context, edges.size()}; evaluator.add(count_field); evaluator.set_selection(selection_field); @@ -681,7 +681,7 @@ static void duplicate_edges(GeometrySet &geometry_set, if (attribute_outputs.duplicate_index) { create_duplicate_index_attribute(new_mesh->attributes_for_write(), - ATTR_DOMAIN_EDGE, + AttrDomain::Edge, selection, attribute_outputs, duplicates); @@ -710,7 +710,7 @@ static void duplicate_points_curve(GeometrySet &geometry_set, return; } - const bke::CurvesFieldContext field_context{src_curves, ATTR_DOMAIN_POINT}; + const bke::CurvesFieldContext field_context{src_curves, AttrDomain::Point}; FieldEvaluator evaluator{field_context, src_curves.points_num()}; evaluator.add(count_field); evaluator.set_selection(selection_field); @@ -731,7 +731,7 @@ static void duplicate_points_curve(GeometrySet &geometry_set, offset_indices::fill_constant_group_size(1, 0, new_curves.offsets_for_write()); bke::gather_attributes_to_groups(src_curves.attributes(), - ATTR_DOMAIN_POINT, + AttrDomain::Point, propagation_info, {}, duplicates, @@ -760,7 +760,7 @@ static void duplicate_points_curve(GeometrySet &geometry_set, if (attribute_outputs.duplicate_index) { create_duplicate_index_attribute(new_curves.attributes_for_write(), - ATTR_DOMAIN_POINT, + AttrDomain::Point, selection, attribute_outputs, duplicates); @@ -783,7 +783,7 @@ static void duplicate_points_mesh(GeometrySet &geometry_set, { const Mesh &mesh = *geometry_set.get_mesh(); - const bke::MeshFieldContext field_context{mesh, ATTR_DOMAIN_POINT}; + const bke::MeshFieldContext field_context{mesh, AttrDomain::Point}; FieldEvaluator evaluator{field_context, mesh.verts_num}; evaluator.add(count_field); evaluator.set_selection(selection_field); @@ -798,7 +798,7 @@ static void duplicate_points_mesh(GeometrySet &geometry_set, Mesh *new_mesh = BKE_mesh_new_nomain(duplicates.total_size(), 0, 0, 0); bke::gather_attributes_to_groups(mesh.attributes(), - ATTR_DOMAIN_POINT, + AttrDomain::Point, propagation_info, {"id"}, duplicates, @@ -809,7 +809,7 @@ static void duplicate_points_mesh(GeometrySet &geometry_set, if (attribute_outputs.duplicate_index) { create_duplicate_index_attribute(new_mesh->attributes_for_write(), - ATTR_DOMAIN_POINT, + AttrDomain::Point, selection, attribute_outputs, duplicates); @@ -849,7 +849,7 @@ static void duplicate_points_pointcloud(GeometrySet &geometry_set, PointCloud *pointcloud = BKE_pointcloud_new_nomain(duplicates.total_size()); bke::gather_attributes_to_groups(src_points.attributes(), - ATTR_DOMAIN_POINT, + AttrDomain::Point, propagation_info, {"id"}, duplicates, @@ -860,7 +860,7 @@ static void duplicate_points_pointcloud(GeometrySet &geometry_set, if (attribute_outputs.duplicate_index) { create_duplicate_index_attribute(pointcloud->attributes_for_write(), - ATTR_DOMAIN_POINT, + AttrDomain::Point, selection, attribute_outputs, duplicates); @@ -962,7 +962,7 @@ static void duplicate_instances(GeometrySet &geometry_set, } bke::gather_attributes_to_groups(src_instances.attributes(), - ATTR_DOMAIN_INSTANCE, + AttrDomain::Instance, propagation_info, {"id"}, duplicates, @@ -971,7 +971,7 @@ static void duplicate_instances(GeometrySet &geometry_set, if (attribute_outputs.duplicate_index) { create_duplicate_index_attribute(dst_instances->attributes_for_write(), - ATTR_DOMAIN_INSTANCE, + AttrDomain::Instance, selection, attribute_outputs, duplicates); @@ -991,7 +991,7 @@ static void node_geo_exec(GeoNodeExecParams params) GeometrySet geometry_set = params.extract_input("Geometry"); const NodeGeometryDuplicateElements &storage = node_storage(params.node()); - const eAttrDomain duplicate_domain = eAttrDomain(storage.domain); + const AttrDomain duplicate_domain = AttrDomain(storage.domain); static auto max_zero_fn = mf::build::SI1_SO( "max_zero", @@ -1008,26 +1008,26 @@ static void node_geo_exec(GeoNodeExecParams params) const AnonymousAttributePropagationInfo &propagation_info = params.get_output_propagation_info( "Geometry"); - if (duplicate_domain == ATTR_DOMAIN_INSTANCE) { + if (duplicate_domain == AttrDomain::Instance) { duplicate_instances( geometry_set, count_field, selection_field, attribute_outputs, propagation_info); } else { geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { switch (duplicate_domain) { - case ATTR_DOMAIN_CURVE: + case AttrDomain::Curve: duplicate_curves( geometry_set, count_field, selection_field, attribute_outputs, propagation_info); break; - case ATTR_DOMAIN_FACE: + case AttrDomain::Face: duplicate_faces( geometry_set, count_field, selection_field, attribute_outputs, propagation_info); break; - case ATTR_DOMAIN_EDGE: + case AttrDomain::Edge: duplicate_edges( geometry_set, count_field, selection_field, attribute_outputs, propagation_info); break; - case ATTR_DOMAIN_POINT: + case AttrDomain::Point: duplicate_points( geometry_set, count_field, selection_field, attribute_outputs, propagation_info); break; @@ -1051,11 +1051,11 @@ static void node_geo_exec(GeoNodeExecParams params) static void node_rna(StructRNA *srna) { static const EnumPropertyItem domain_items[] = { - {ATTR_DOMAIN_POINT, "POINT", 0, "Point", ""}, - {ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", ""}, - {ATTR_DOMAIN_FACE, "FACE", 0, "Face", ""}, - {ATTR_DOMAIN_CURVE, "SPLINE", 0, "Spline", ""}, - {ATTR_DOMAIN_INSTANCE, "INSTANCE", 0, "Instance", ""}, + {int(AttrDomain::Point), "POINT", 0, "Point", ""}, + {int(AttrDomain::Edge), "EDGE", 0, "Edge", ""}, + {int(AttrDomain::Face), "FACE", 0, "Face", ""}, + {int(AttrDomain::Curve), "SPLINE", 0, "Spline", ""}, + {int(AttrDomain::Instance), "INSTANCE", 0, "Instance", ""}, {0, nullptr, 0, nullptr, nullptr}, }; @@ -1065,7 +1065,7 @@ static void node_rna(StructRNA *srna) "Which domain to duplicate", domain_items, NOD_storage_enum_accessors(domain), - ATTR_DOMAIN_POINT); + int(AttrDomain::Point)); } static void node_register() diff --git a/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_curves.cc index f95d361519f..a41311ab1d6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_curves.cc @@ -78,7 +78,7 @@ static void node_geo_exec(GeoNodeExecParams params) return; } - const bke::MeshFieldContext context{*mesh, ATTR_DOMAIN_POINT}; + const bke::MeshFieldContext context{*mesh, AttrDomain::Point}; fn::FieldEvaluator evaluator{context, mesh->verts_num}; evaluator.add(params.get_input>("Next Vertex Index")); evaluator.add(params.get_input>("Start Vertices")); diff --git a/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc index 75c5dd9fd4e..1bf554b8e2d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc @@ -71,10 +71,10 @@ class PathToEdgeSelectionFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - const bke::MeshFieldContext context{mesh, ATTR_DOMAIN_POINT}; + const bke::MeshFieldContext context{mesh, AttrDomain::Point}; fn::FieldEvaluator evaluator{context, mesh.verts_num}; evaluator.add(next_vertex_); evaluator.add(start_vertices_); @@ -89,7 +89,7 @@ class PathToEdgeSelectionFieldInput final : public bke::MeshFieldInput { edge_paths_to_selection(mesh, start_verts, next_vert, selection); return mesh.attributes().adapt_domain( - VArray::ForContainer(std::move(selection)), ATTR_DOMAIN_EDGE, domain); + VArray::ForContainer(std::move(selection)), AttrDomain::Edge, domain); } void for_each_field_input_recursive(FunctionRef fn) const override @@ -114,9 +114,9 @@ class PathToEdgeSelectionFieldInput final : public bke::MeshFieldInput { return false; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_EDGE; + return AttrDomain::Edge; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_edge_split.cc b/source/blender/nodes/geometry/nodes/node_geo_edge_split.cc index f42cb35538d..1428fe2ecf5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_edge_split.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_edge_split.cc @@ -25,7 +25,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (const Mesh *mesh = geometry_set.get_mesh()) { - const bke::MeshFieldContext field_context{*mesh, ATTR_DOMAIN_EDGE}; + const bke::MeshFieldContext field_context{*mesh, AttrDomain::Edge}; fn::FieldEvaluator selection_evaluator{field_context, mesh->edges_num}; selection_evaluator.set_selection(selection_field); selection_evaluator.evaluate(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_edges_to_face_groups.cc b/source/blender/nodes/geometry/nodes/node_geo_edges_to_face_groups.cc index 7bac80739f1..dec93226c2a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_edges_to_face_groups.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_edges_to_face_groups.cc @@ -43,10 +43,10 @@ class FaceSetFromBoundariesInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - const bke::MeshFieldContext context{mesh, ATTR_DOMAIN_EDGE}; + const bke::MeshFieldContext context{mesh, AttrDomain::Edge}; fn::FieldEvaluator evaluator{context, mesh.edges_num}; evaluator.add(non_boundary_edge_field_); evaluator.evaluate(); @@ -67,7 +67,7 @@ class FaceSetFromBoundariesInput final : public bke::MeshFieldInput { islands.calc_reduced_ids(output); return mesh.attributes().adapt_domain( - VArray::ForContainer(std::move(output)), ATTR_DOMAIN_FACE, domain); + VArray::ForContainer(std::move(output)), AttrDomain::Face, domain); } uint64_t hash() const override @@ -83,9 +83,9 @@ class FaceSetFromBoundariesInput final : public bke::MeshFieldInput { return false; } - std::optional preferred_domain(const Mesh & /*mesh*/) const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { - return ATTR_DOMAIN_FACE; + return AttrDomain::Face; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc b/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc index 3fa3409b5c0..638635f7f1f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc @@ -21,7 +21,7 @@ namespace blender::nodes { EvaluateAtIndexInput::EvaluateAtIndexInput(Field index_field, GField value_field, - eAttrDomain value_field_domain) + AttrDomain value_field_domain) : bke::GeometryFieldInput(value_field.cpp_type(), "Evaluate at Index"), index_field_(std::move(index_field)), value_field_(std::move(value_field)), @@ -78,7 +78,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - node->custom1 = ATTR_DOMAIN_POINT; + node->custom1 = int(AttrDomain::Point); node->custom2 = CD_PROP_FLOAT; } @@ -107,7 +107,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) static void node_geo_exec(GeoNodeExecParams params) { const bNode &node = params.node(); - const eAttrDomain domain = eAttrDomain(node.custom1); + const AttrDomain domain = AttrDomain(node.custom1); GField output_field{std::make_shared( params.extract_input>("Index"), params.extract_input("Value"), domain)}; @@ -122,7 +122,7 @@ static void node_rna(StructRNA *srna) "Domain the field is evaluated in", rna_enum_attribute_domain_items, NOD_inline_enum_accessors(custom1), - ATTR_DOMAIN_POINT, + int(AttrDomain::Point), enums::domain_experimental_grease_pencil_version3_fn); RNA_def_node_enum(srna, diff --git a/source/blender/nodes/geometry/nodes/node_geo_evaluate_on_domain.cc b/source/blender/nodes/geometry/nodes/node_geo_evaluate_on_domain.cc index d080161ade3..5d131959f49 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_evaluate_on_domain.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_evaluate_on_domain.cc @@ -21,7 +21,7 @@ namespace blender::nodes { -EvaluateOnDomainInput::EvaluateOnDomainInput(GField field, eAttrDomain domain) +EvaluateOnDomainInput::EvaluateOnDomainInput(GField field, AttrDomain domain) : bke::GeometryFieldInput(field.cpp_type(), "Evaluate on Domain"), src_field_(std::move(field)), src_domain_(domain) @@ -31,16 +31,16 @@ EvaluateOnDomainInput::EvaluateOnDomainInput(GField field, eAttrDomain domain) GVArray EvaluateOnDomainInput::get_varray_for_context(const bke::GeometryFieldContext &context, const IndexMask & /*mask*/) const { - const eAttrDomain dst_domain = context.domain(); + const AttrDomain dst_domain = context.domain(); const int dst_domain_size = context.attributes()->domain_size(dst_domain); const CPPType &cpp_type = src_field_.cpp_type(); if (context.type() == GeometryComponent::Type::GreasePencil && - (src_domain_ == ATTR_DOMAIN_LAYER) != (dst_domain == ATTR_DOMAIN_LAYER)) + (src_domain_ == AttrDomain::Layer) != (dst_domain == AttrDomain::Layer)) { /* Evaluate field just for the current layer. */ - if (src_domain_ == ATTR_DOMAIN_LAYER) { - const bke::GeometryFieldContext src_domain_context{context, ATTR_DOMAIN_LAYER}; + if (src_domain_ == AttrDomain::Layer) { + const bke::GeometryFieldContext src_domain_context{context, AttrDomain::Layer}; const int layer_index = context.grease_pencil_layer_index(); const IndexMask single_layer_mask = IndexRange(layer_index, 1); @@ -76,7 +76,7 @@ void EvaluateOnDomainInput::for_each_field_input_recursive( src_field_.node().for_each_field_input_recursive(fn); } -std::optional EvaluateOnDomainInput::preferred_domain( +std::optional EvaluateOnDomainInput::preferred_domain( const GeometryComponent & /*component*/) const { return src_domain_; @@ -106,7 +106,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - node->custom1 = ATTR_DOMAIN_POINT; + node->custom1 = int(AttrDomain::Point); node->custom2 = CD_PROP_FLOAT; } @@ -127,7 +127,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) static void node_geo_exec(GeoNodeExecParams params) { const bNode &node = params.node(); - const eAttrDomain domain = eAttrDomain(node.custom1); + const AttrDomain domain = AttrDomain(node.custom1); GField src_field = params.extract_input("Value"); GField dst_field{std::make_shared(std::move(src_field), domain)}; @@ -142,7 +142,7 @@ static void node_rna(StructRNA *srna) "Domain the field is evaluated in", rna_enum_attribute_domain_items, NOD_inline_enum_accessors(custom1), - ATTR_DOMAIN_POINT, + int(AttrDomain::Point), enums::domain_experimental_grease_pencil_version3_fn); RNA_def_node_enum(srna, diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc index a45a36351d7..d3b79448124 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc @@ -77,7 +77,7 @@ struct AttributeOutputs { static void save_selection_as_attribute(MutableAttributeAccessor attributes, const AnonymousAttributeID *id, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask &selection) { BLI_assert(!attributes.contains(id)); @@ -150,7 +150,7 @@ static void expand_mesh(Mesh &mesh, if (edge_expand != 0) { if (mesh.edges_num == 0) { mesh.attributes_for_write().add( - ".edge_verts", ATTR_DOMAIN_EDGE, CD_PROP_INT32_2D, bke::AttributeInitConstruct()); + ".edge_verts", AttrDomain::Edge, CD_PROP_INT32_2D, bke::AttributeInitConstruct()); } const int old_edges_num = mesh.edges_num; mesh.edges_num += edge_expand; @@ -175,16 +175,16 @@ static void expand_mesh(Mesh &mesh, } } -static CustomData &mesh_custom_data_for_domain(Mesh &mesh, const eAttrDomain domain) +static CustomData &mesh_custom_data_for_domain(Mesh &mesh, const AttrDomain domain) { switch (domain) { - case ATTR_DOMAIN_POINT: + case AttrDomain::Point: return mesh.vert_data; - case ATTR_DOMAIN_EDGE: + case AttrDomain::Edge: return mesh.edge_data; - case ATTR_DOMAIN_FACE: + case AttrDomain::Face: return mesh.face_data; - case ATTR_DOMAIN_CORNER: + case AttrDomain::Corner: return mesh.corner_data; default: BLI_assert_unreachable(); @@ -192,7 +192,7 @@ static CustomData &mesh_custom_data_for_domain(Mesh &mesh, const eAttrDomain dom } } -static std::optional> get_orig_index_layer(Mesh &mesh, const eAttrDomain domain) +static std::optional> get_orig_index_layer(Mesh &mesh, const AttrDomain domain) { const bke::AttributeAccessor attributes = mesh.attributes(); CustomData &custom_data = mesh_custom_data_for_domain(mesh, domain); @@ -277,7 +277,7 @@ static IDsByDomain attribute_ids_by_domain(const AttributeAccessor attributes, if (skip.contains(id.name())) { return true; } - map[meta_data.domain].append(id); + map[int(meta_data.domain)].append(id); return true; }); return map; @@ -319,7 +319,7 @@ static void extrude_mesh_vertices(Mesh &mesh, /* Use an array for the result of the evaluation because the mesh is reallocated before * the vertices are moved, and the evaluated result might reference an attribute. */ Array offsets(orig_vert_size); - const bke::MeshFieldContext context{mesh, ATTR_DOMAIN_POINT}; + const bke::MeshFieldContext context{mesh, AttrDomain::Point}; FieldEvaluator evaluator{context, mesh.verts_num}; evaluator.add_with_destination(offset_field, offsets.as_mutable_span()); evaluator.set_selection(selection_field); @@ -338,7 +338,7 @@ static void extrude_mesh_vertices(Mesh &mesh, Array vert_to_edge_offsets; Array vert_to_edge_indices; GroupedSpan vert_to_edge_map; - if (!ids_by_domain[ATTR_DOMAIN_EDGE].is_empty()) { + if (!ids_by_domain[int(AttrDomain::Edge)].is_empty()) { vert_to_edge_map = bke::mesh::build_vert_to_edge_map( mesh.edges(), orig_vert_size, vert_to_edge_offsets, vert_to_edge_indices); } @@ -357,10 +357,10 @@ static void extrude_mesh_vertices(Mesh &mesh, }); /* New vertices copy the attribute values from their source vertex. */ - gather_attributes(attributes, ids_by_domain[ATTR_DOMAIN_POINT], selection, new_vert_range); + gather_attributes(attributes, ids_by_domain[int(AttrDomain::Point)], selection, new_vert_range); /* New edge values are mixed from of all the edges connected to the source vertex. */ - for (const AttributeIDRef &id : ids_by_domain[ATTR_DOMAIN_EDGE]) { + for (const AttributeIDRef &id : ids_by_domain[int(AttrDomain::Edge)]) { GSpanAttributeWriter attribute = attributes.lookup_for_write_span(id); copy_with_mixing( attribute.span, vert_to_edge_map, selection, attribute.span.slice(new_edge_range)); @@ -373,20 +373,20 @@ static void extrude_mesh_vertices(Mesh &mesh, new_positions[i] = positions[index] + offsets[index]; }); - if (std::optional> indices = get_orig_index_layer(mesh, ATTR_DOMAIN_POINT)) { + if (std::optional> indices = get_orig_index_layer(mesh, AttrDomain::Point)) { array_utils::gather(indices->as_span(), selection, indices->slice(new_vert_range)); } - if (std::optional> indices = get_orig_index_layer(mesh, ATTR_DOMAIN_EDGE)) { + if (std::optional> indices = get_orig_index_layer(mesh, AttrDomain::Edge)) { indices->slice(new_edge_range).fill(ORIGINDEX_NONE); } if (attribute_outputs.top_id) { save_selection_as_attribute( - attributes, attribute_outputs.top_id.get(), ATTR_DOMAIN_POINT, new_vert_range); + attributes, attribute_outputs.top_id.get(), AttrDomain::Point, new_vert_range); } if (attribute_outputs.side_id) { save_selection_as_attribute( - attributes, attribute_outputs.side_id.get(), ATTR_DOMAIN_EDGE, new_edge_range); + attributes, attribute_outputs.side_id.get(), AttrDomain::Edge, new_edge_range); } const bool no_loose_vert_hint = mesh.runtime->loose_verts_cache.is_cached() && @@ -499,7 +499,7 @@ static void extrude_mesh_edges(Mesh &mesh, const OffsetIndices orig_faces = mesh.faces(); const int orig_loop_size = mesh.corners_num; - const bke::MeshFieldContext edge_context{mesh, ATTR_DOMAIN_EDGE}; + const bke::MeshFieldContext edge_context{mesh, AttrDomain::Edge}; FieldEvaluator edge_evaluator{edge_context, mesh.edges_num}; edge_evaluator.set_selection(selection_field); edge_evaluator.add(offset_field); @@ -553,7 +553,7 @@ static void extrude_mesh_edges(Mesh &mesh, Array vert_to_edge_offsets; Array vert_to_edge_indices; GroupedSpan vert_to_selected_edge_map; - if (!ids_by_domain[ATTR_DOMAIN_EDGE].is_empty()) { + if (!ids_by_domain[int(AttrDomain::Edge)].is_empty()) { vert_to_selected_edge_map = build_vert_to_edge_map( orig_edges, edge_selection, orig_vert_size, vert_to_edge_offsets, vert_to_edge_indices); } @@ -631,14 +631,14 @@ static void extrude_mesh_edges(Mesh &mesh, }); /* New vertices copy the attribute values from their source vertex. */ - gather_attributes(attributes, ids_by_domain[ATTR_DOMAIN_POINT], new_verts, new_vert_range); + gather_attributes(attributes, ids_by_domain[int(AttrDomain::Point)], new_verts, new_vert_range); /* Edges parallel to original edges copy the edge attributes from the original edges. */ gather_attributes( - attributes, ids_by_domain[ATTR_DOMAIN_EDGE], edge_selection, duplicate_edge_range); + attributes, ids_by_domain[int(AttrDomain::Edge)], edge_selection, duplicate_edge_range); /* Edges connected to original vertices mix values of selected connected edges. */ - for (const AttributeIDRef &id : ids_by_domain[ATTR_DOMAIN_EDGE]) { + for (const AttributeIDRef &id : ids_by_domain[int(AttrDomain::Edge)]) { GSpanAttributeWriter attribute = attributes.lookup_for_write_span(id); copy_with_mixing(attribute.span, vert_to_selected_edge_map, @@ -648,7 +648,7 @@ static void extrude_mesh_edges(Mesh &mesh, } /* Attribute values for new faces are a mix of values connected to its original edge. */ - for (const AttributeIDRef &id : ids_by_domain[ATTR_DOMAIN_FACE]) { + for (const AttributeIDRef &id : ids_by_domain[int(AttrDomain::Face)]) { GSpanAttributeWriter attribute = attributes.lookup_for_write_span(id); copy_with_mixing( attribute.span, edge_to_face_map, edge_selection, attribute.span.slice(new_face_range)); @@ -657,7 +657,7 @@ static void extrude_mesh_edges(Mesh &mesh, /* New corners get the average value of all adjacent corners on original faces connected * to the original edge of their face. */ - for (const AttributeIDRef &id : ids_by_domain[ATTR_DOMAIN_CORNER]) { + for (const AttributeIDRef &id : ids_by_domain[int(AttrDomain::Corner)]) { GSpanAttributeWriter attribute = attributes.lookup_for_write_span(id); bke::attribute_math::convert_to_static_type(attribute.span.type(), [&](auto dummy) { using T = decltype(dummy); @@ -728,24 +728,24 @@ static void extrude_mesh_edges(Mesh &mesh, }); } - if (std::optional> indices = get_orig_index_layer(mesh, ATTR_DOMAIN_POINT)) { + if (std::optional> indices = get_orig_index_layer(mesh, AttrDomain::Point)) { array_utils::gather(indices->as_span(), new_verts, indices->slice(new_vert_range)); } - if (std::optional> indices = get_orig_index_layer(mesh, ATTR_DOMAIN_EDGE)) { + if (std::optional> indices = get_orig_index_layer(mesh, AttrDomain::Edge)) { indices->slice(connect_edge_range).fill(ORIGINDEX_NONE); array_utils::gather(indices->as_span(), edge_selection, indices->slice(duplicate_edge_range)); } - if (std::optional> indices = get_orig_index_layer(mesh, ATTR_DOMAIN_FACE)) { + if (std::optional> indices = get_orig_index_layer(mesh, AttrDomain::Face)) { indices->slice(new_face_range).fill(ORIGINDEX_NONE); } if (attribute_outputs.top_id) { save_selection_as_attribute( - attributes, attribute_outputs.top_id.get(), ATTR_DOMAIN_EDGE, duplicate_edge_range); + attributes, attribute_outputs.top_id.get(), AttrDomain::Edge, duplicate_edge_range); } if (attribute_outputs.side_id) { save_selection_as_attribute( - attributes, attribute_outputs.side_id.get(), ATTR_DOMAIN_FACE, new_face_range); + attributes, attribute_outputs.side_id.get(), AttrDomain::Face, new_face_range); } tag_mesh_added_faces(mesh); @@ -781,7 +781,7 @@ static void extrude_mesh_face_regions(Mesh &mesh, const Span orig_corner_verts = mesh.corner_verts(); const int orig_loop_size = orig_corner_verts.size(); - const bke::MeshFieldContext face_context{mesh, ATTR_DOMAIN_FACE}; + const bke::MeshFieldContext face_context{mesh, AttrDomain::Face}; FieldEvaluator face_evaluator{face_context, mesh.faces_num}; face_evaluator.set_selection(selection_field); face_evaluator.add(offset_field); @@ -1007,13 +1007,15 @@ static void extrude_mesh_face_regions(Mesh &mesh, /* New vertices copy the attributes from their original vertices. */ gather_attributes( - attributes, ids_by_domain[ATTR_DOMAIN_POINT], new_vert_indices, new_vert_range); + attributes, ids_by_domain[int(AttrDomain::Point)], new_vert_indices, new_vert_range); /* New faces on the side of extrusions get the values from the corresponding selected face. */ - gather_attributes( - attributes, ids_by_domain[ATTR_DOMAIN_FACE], edge_extruded_face_indices, side_face_range); + gather_attributes(attributes, + ids_by_domain[int(AttrDomain::Face)], + edge_extruded_face_indices, + side_face_range); - if (!ids_by_domain[ATTR_DOMAIN_EDGE].is_empty()) { + if (!ids_by_domain[int(AttrDomain::Edge)].is_empty()) { IndexMaskMemory memory; const IndexMask boundary_edge_mask = IndexMask::from_indices(boundary_edge_indices, memory); @@ -1023,7 +1025,7 @@ static void extrude_mesh_face_regions(Mesh &mesh, const GroupedSpan vert_to_boundary_edge_map = build_vert_to_edge_map( edges, boundary_edge_mask, mesh.verts_num, vert_to_edge_offsets, vert_to_edge_indices); - for (const AttributeIDRef &id : ids_by_domain[ATTR_DOMAIN_EDGE]) { + for (const AttributeIDRef &id : ids_by_domain[int(AttrDomain::Edge)]) { GSpanAttributeWriter attribute = attributes.lookup_for_write_span(id); /* Edges parallel to original edges copy the edge attributes from the original edges. */ @@ -1044,7 +1046,7 @@ static void extrude_mesh_face_regions(Mesh &mesh, } /* New corners get the values from the corresponding corner on the extruded face. */ - if (!ids_by_domain[ATTR_DOMAIN_CORNER].is_empty()) { + if (!ids_by_domain[int(AttrDomain::Corner)].is_empty()) { Array orig_corners(side_loop_range.size()); threading::parallel_for(boundary_edge_indices.index_range(), 256, [&](const IndexRange range) { for (const int i_boundary_edge : range) { @@ -1084,7 +1086,7 @@ static void extrude_mesh_face_regions(Mesh &mesh, } }); gather_attributes( - attributes, ids_by_domain[ATTR_DOMAIN_CORNER], orig_corners, side_loop_range); + attributes, ids_by_domain[int(AttrDomain::Corner)], orig_corners, side_loop_range); } /* Translate vertices based on the offset. If the vertex is used by a selected edge, it will @@ -1116,11 +1118,11 @@ static void extrude_mesh_face_regions(Mesh &mesh, }); } - if (std::optional> indices = get_orig_index_layer(mesh, ATTR_DOMAIN_POINT)) { + if (std::optional> indices = get_orig_index_layer(mesh, AttrDomain::Point)) { array_utils::gather( indices->as_span(), new_vert_indices.as_span(), indices->slice(new_vert_range)); } - if (std::optional> indices = get_orig_index_layer(mesh, ATTR_DOMAIN_EDGE)) { + if (std::optional> indices = get_orig_index_layer(mesh, AttrDomain::Edge)) { indices->slice(connect_edge_range).fill(ORIGINDEX_NONE); array_utils::gather(indices->as_span(), new_inner_edge_indices.as_span(), @@ -1128,18 +1130,18 @@ static void extrude_mesh_face_regions(Mesh &mesh, array_utils::gather( indices->as_span(), boundary_edge_indices.as_span(), indices->slice(boundary_edge_range)); } - if (std::optional> indices = get_orig_index_layer(mesh, ATTR_DOMAIN_FACE)) { + if (std::optional> indices = get_orig_index_layer(mesh, AttrDomain::Face)) { array_utils::gather( indices->as_span(), edge_extruded_face_indices.as_span(), indices->slice(side_face_range)); } if (attribute_outputs.top_id) { save_selection_as_attribute( - attributes, attribute_outputs.top_id.get(), ATTR_DOMAIN_FACE, face_selection); + attributes, attribute_outputs.top_id.get(), AttrDomain::Face, face_selection); } if (attribute_outputs.side_id) { save_selection_as_attribute( - attributes, attribute_outputs.side_id.get(), ATTR_DOMAIN_FACE, side_face_range); + attributes, attribute_outputs.side_id.get(), AttrDomain::Face, side_face_range); } tag_mesh_added_faces(mesh); @@ -1161,7 +1163,7 @@ static void extrude_individual_mesh_faces( /* Use an array for the result of the evaluation because the mesh is reallocated before * the vertices are moved, and the evaluated result might reference an attribute. */ Array face_offset(orig_faces.size()); - const bke::MeshFieldContext face_context{mesh, ATTR_DOMAIN_FACE}; + const bke::MeshFieldContext face_context{mesh, AttrDomain::Face}; FieldEvaluator face_evaluator{face_context, mesh.faces_num}; face_evaluator.set_selection(selection_field); face_evaluator.add_with_destination(offset_field, face_offset.as_mutable_span()); @@ -1275,14 +1277,16 @@ static void extrude_individual_mesh_faces( /* New vertices copy the attributes from their original vertices. */ gather_attributes( - attributes, ids_by_domain[ATTR_DOMAIN_POINT], new_vert_indices, new_vert_range); + attributes, ids_by_domain[int(AttrDomain::Point)], new_vert_indices, new_vert_range); /* The data for the duplicate edge is simply a copy of the original edge's data. */ - gather_attributes( - attributes, ids_by_domain[ATTR_DOMAIN_EDGE], duplicate_edge_indices, duplicate_edge_range); + gather_attributes(attributes, + ids_by_domain[int(AttrDomain::Edge)], + duplicate_edge_indices, + duplicate_edge_range); /* For extruded edges, mix the data from the two neighboring original edges of the face. */ - if (!ids_by_domain[ATTR_DOMAIN_EDGE].is_empty()) { + if (!ids_by_domain[int(AttrDomain::Edge)].is_empty()) { Array neighbor_edges(connect_edge_range.size()); face_selection.foreach_index( GrainSize(1024), [&](const int64_t index, const int64_t i_selection) { @@ -1298,7 +1302,7 @@ static void extrude_individual_mesh_faces( } }); - for (const AttributeIDRef &id : ids_by_domain[ATTR_DOMAIN_EDGE]) { + for (const AttributeIDRef &id : ids_by_domain[int(AttrDomain::Edge)]) { GSpanAttributeWriter attribute = attributes.lookup_for_write_span(id); bke::attribute_math::convert_to_static_type(attribute.span.type(), [&](auto dummy) { using T = decltype(dummy); @@ -1322,7 +1326,7 @@ static void extrude_individual_mesh_faces( } /* Each side face gets the values from the corresponding new face. */ - for (const AttributeIDRef &id : ids_by_domain[ATTR_DOMAIN_FACE]) { + for (const AttributeIDRef &id : ids_by_domain[int(AttrDomain::Face)]) { GSpanAttributeWriter attribute = attributes.lookup_for_write_span(id); bke::attribute_math::gather_to_groups( group_per_face, face_selection, attribute.span, attribute.span.slice(side_face_range)); @@ -1330,7 +1334,7 @@ static void extrude_individual_mesh_faces( } /* Each corner on a side face gets its value from the matching corner on an extruded face. */ - if (!ids_by_domain[ATTR_DOMAIN_CORNER].is_empty()) { + if (!ids_by_domain[int(AttrDomain::Corner)].is_empty()) { Array orig_corners(side_loop_range.size()); face_selection.foreach_index( GrainSize(256), [&](const int64_t index, const int64_t i_selection) { @@ -1351,7 +1355,7 @@ static void extrude_individual_mesh_faces( } }); gather_attributes( - attributes, ids_by_domain[ATTR_DOMAIN_CORNER], orig_corners, side_loop_range); + attributes, ids_by_domain[int(AttrDomain::Corner)], orig_corners, side_loop_range); } /* Offset the new vertices. */ @@ -1364,28 +1368,28 @@ static void extrude_individual_mesh_faces( } }); - if (std::optional> indices = get_orig_index_layer(mesh, ATTR_DOMAIN_POINT)) { + if (std::optional> indices = get_orig_index_layer(mesh, AttrDomain::Point)) { array_utils::gather( indices->as_span(), new_vert_indices.as_span(), indices->slice(new_vert_range)); } - if (std::optional> indices = get_orig_index_layer(mesh, ATTR_DOMAIN_EDGE)) { + if (std::optional> indices = get_orig_index_layer(mesh, AttrDomain::Edge)) { indices->slice(connect_edge_range).fill(ORIGINDEX_NONE); array_utils::gather(indices->as_span(), duplicate_edge_indices.as_span(), indices->slice(duplicate_edge_range)); } - if (std::optional> indices = get_orig_index_layer(mesh, ATTR_DOMAIN_FACE)) { + if (std::optional> indices = get_orig_index_layer(mesh, AttrDomain::Face)) { array_utils::gather_to_groups( group_per_face, face_selection, indices->as_span(), indices->slice(side_face_range)); } if (attribute_outputs.top_id) { save_selection_as_attribute( - attributes, attribute_outputs.top_id.get(), ATTR_DOMAIN_FACE, face_selection); + attributes, attribute_outputs.top_id.get(), AttrDomain::Face, face_selection); } if (attribute_outputs.side_id) { save_selection_as_attribute( - attributes, attribute_outputs.side_id.get(), ATTR_DOMAIN_FACE, side_face_range); + attributes, attribute_outputs.side_id.get(), AttrDomain::Face, side_face_range); } tag_mesh_added_faces(mesh); diff --git a/source/blender/nodes/geometry/nodes/node_geo_flip_faces.cc b/source/blender/nodes/geometry/nodes/node_geo_flip_faces.cc index 50cd3c79c1f..a03b262865d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_flip_faces.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_flip_faces.cc @@ -23,7 +23,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (Mesh *mesh = geometry_set.get_mesh_for_write()) { - const bke::MeshFieldContext field_context(*mesh, ATTR_DOMAIN_FACE); + const bke::MeshFieldContext field_context(*mesh, AttrDomain::Face); fn::FieldEvaluator evaluator(field_context, mesh->faces_num); evaluator.add(selection_field); evaluator.evaluate(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_index_of_nearest.cc b/source/blender/nodes/geometry/nodes/node_geo_index_of_nearest.cc index 49641053540..1df26c131bd 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_index_of_nearest.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_index_of_nearest.cc @@ -149,7 +149,7 @@ class IndexOfNearestFieldInput final : public bke::GeometryFieldInput { return false; } - std::optional preferred_domain(const GeometryComponent &component) const final + std::optional preferred_domain(const GeometryComponent &component) const final { return bke::try_detect_field_domain(component, positions_field_); } @@ -216,7 +216,7 @@ class HasNeighborFieldInput final : public bke::GeometryFieldInput { return false; } - std::optional preferred_domain(const GeometryComponent &component) const final + std::optional preferred_domain(const GeometryComponent &component) const final { return bke::try_detect_field_domain(component, group_field_); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc b/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc index 9e78c93f21c..de69e46f76a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc @@ -31,10 +31,10 @@ class HandlePositionFieldInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask &mask) const final { - const bke::CurvesFieldContext field_context{curves, ATTR_DOMAIN_POINT}; + const bke::CurvesFieldContext field_context{curves, AttrDomain::Point}; fn::FieldEvaluator evaluator(field_context, &mask); evaluator.add(relative_); evaluator.evaluate(); @@ -45,7 +45,7 @@ class HandlePositionFieldInput final : public bke::CurvesFieldInput { const AttributeAccessor attributes = curves.attributes(); StringRef side = left_ ? "handle_left" : "handle_right"; VArray handles = *attributes.lookup_or_default( - side, ATTR_DOMAIN_POINT, {0, 0, 0}); + side, AttrDomain::Point, {0, 0, 0}); if (relative.is_single()) { if (relative.get_internal_single()) { @@ -54,9 +54,9 @@ class HandlePositionFieldInput final : public bke::CurvesFieldInput { output[i] = handles[i] - positions[i]; } return attributes.adapt_domain( - VArray::ForContainer(std::move(output)), ATTR_DOMAIN_POINT, domain); + VArray::ForContainer(std::move(output)), AttrDomain::Point, domain); } - return attributes.adapt_domain(handles, ATTR_DOMAIN_POINT, domain); + return attributes.adapt_domain(handles, AttrDomain::Point, domain); } Array output(positions.size()); @@ -69,7 +69,7 @@ class HandlePositionFieldInput final : public bke::CurvesFieldInput { } } return attributes.adapt_domain( - VArray::ForContainer(std::move(output)), ATTR_DOMAIN_POINT, domain); + VArray::ForContainer(std::move(output)), AttrDomain::Point, domain); } void for_each_field_input_recursive(FunctionRef fn) const override @@ -92,9 +92,9 @@ class HandlePositionFieldInput final : public bke::CurvesFieldInput { return false; } - std::optional preferred_domain(const CurvesGeometry & /*curves*/) const + std::optional preferred_domain(const CurvesGeometry & /*curves*/) const { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc index e54e0adad59..2a8b53d0511 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_angle.cc @@ -65,7 +65,7 @@ class AngleFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { const Span positions = mesh.vert_positions(); @@ -87,7 +87,7 @@ class AngleFieldInput final : public bke::MeshFieldInput { }; VArray angles = VArray::ForFunc(mesh.edges_num, angle_fn); - return mesh.attributes().adapt_domain(std::move(angles), ATTR_DOMAIN_EDGE, domain); + return mesh.attributes().adapt_domain(std::move(angles), AttrDomain::Edge, domain); } uint64_t hash() const override @@ -101,9 +101,9 @@ class AngleFieldInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_EDGE; + return AttrDomain::Edge; } }; @@ -115,7 +115,7 @@ class SignedAngleFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { const Span positions = mesh.vert_positions(); @@ -159,7 +159,7 @@ class SignedAngleFieldInput final : public bke::MeshFieldInput { }; VArray angles = VArray::ForFunc(mesh.edges_num, angle_fn); - return mesh.attributes().adapt_domain(std::move(angles), ATTR_DOMAIN_EDGE, domain); + return mesh.attributes().adapt_domain(std::move(angles), AttrDomain::Edge, domain); } uint64_t hash() const override @@ -173,9 +173,9 @@ class SignedAngleFieldInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_EDGE; + return AttrDomain::Edge; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc index 847e953d914..14c90b483d0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc @@ -26,13 +26,13 @@ class EdgeNeighborCountFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { Array counts(mesh.edges_num, 0); array_utils::count_indices(mesh.corner_edges(), counts); return mesh.attributes().adapt_domain( - VArray::ForContainer(std::move(counts)), ATTR_DOMAIN_EDGE, domain); + VArray::ForContainer(std::move(counts)), AttrDomain::Edge, domain); } uint64_t hash() const override @@ -46,9 +46,9 @@ class EdgeNeighborCountFieldInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_EDGE; + return AttrDomain::Edge; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc index bbc98439428..6225fb1331d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc @@ -31,10 +31,10 @@ enum class VertNumber { V1, V2 }; static VArray construct_edge_verts_gvarray(const Mesh &mesh, const VertNumber vertex, - const eAttrDomain domain) + const AttrDomain domain) { const Span edges = mesh.edges(); - if (domain == ATTR_DOMAIN_EDGE) { + if (domain == AttrDomain::Edge) { if (vertex == VertNumber::V1) { return VArray::ForFunc(edges.size(), [edges](const int i) { return edges[i][0]; }); } @@ -55,7 +55,7 @@ class EdgeVertsInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { return construct_edge_verts_gvarray(mesh, vertex_, domain); @@ -74,15 +74,15 @@ class EdgeVertsInput final : public bke::MeshFieldInput { return false; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_EDGE; + return AttrDomain::Edge; } }; static VArray construct_edge_positions_gvarray(const Mesh &mesh, const VertNumber vertex, - const eAttrDomain domain) + const AttrDomain domain) { const Span positions = mesh.vert_positions(); const Span edges = mesh.edges(); @@ -91,13 +91,13 @@ static VArray construct_edge_positions_gvarray(const Mesh &mesh, return mesh.attributes().adapt_domain( VArray::ForFunc( edges.size(), [positions, edges](const int i) { return positions[edges[i][0]]; }), - ATTR_DOMAIN_EDGE, + AttrDomain::Edge, domain); } return mesh.attributes().adapt_domain( VArray::ForFunc(edges.size(), [positions, edges](const int i) { return positions[edges[i][1]]; }), - ATTR_DOMAIN_EDGE, + AttrDomain::Edge, domain); } @@ -113,7 +113,7 @@ class EdgePositionFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { return construct_edge_positions_gvarray(mesh, vertex_, domain); @@ -134,9 +134,9 @@ class EdgePositionFieldInput final : public bke::MeshFieldInput { return false; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_EDGE; + return AttrDomain::Edge; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc index 14b32c5addf..ed7d31475fb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc @@ -19,7 +19,7 @@ static void node_declare(NodeDeclarationBuilder &b) .description("The surface area of each of the mesh's faces"); } -static VArray construct_face_area_varray(const Mesh &mesh, const eAttrDomain domain) +static VArray construct_face_area_varray(const Mesh &mesh, const AttrDomain domain) { const Span positions = mesh.vert_positions(); const OffsetIndices faces = mesh.faces(); @@ -30,7 +30,7 @@ static VArray construct_face_area_varray(const Mesh &mesh, const eAttrDom }; return mesh.attributes().adapt_domain( - VArray::ForFunc(faces.size(), area_fn), ATTR_DOMAIN_FACE, domain); + VArray::ForFunc(faces.size(), area_fn), AttrDomain::Face, domain); } class FaceAreaFieldInput final : public bke::MeshFieldInput { @@ -41,7 +41,7 @@ class FaceAreaFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { return construct_face_area_varray(mesh, domain); @@ -58,9 +58,9 @@ class FaceAreaFieldInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_FACE; + return AttrDomain::Face; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc index 3e11b7e75af..4a7f1ee544f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc @@ -39,7 +39,7 @@ class PlanarFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { const Span positions = mesh.vert_positions(); @@ -47,7 +47,7 @@ class PlanarFieldInput final : public bke::MeshFieldInput { const Span corner_verts = mesh.corner_verts(); const Span face_normals = mesh.face_normals(); - const bke::MeshFieldContext context{mesh, ATTR_DOMAIN_FACE}; + const bke::MeshFieldContext context{mesh, AttrDomain::Face}; fn::FieldEvaluator evaluator{context, faces.size()}; evaluator.add(threshold_); evaluator.evaluate(); @@ -77,7 +77,7 @@ class PlanarFieldInput final : public bke::MeshFieldInput { }; return mesh.attributes().adapt_domain( - VArray::ForFunc(faces.size(), planar_fn), ATTR_DOMAIN_FACE, domain); + VArray::ForFunc(faces.size(), planar_fn), AttrDomain::Face, domain); } void for_each_field_input_recursive(FunctionRef fn) const override @@ -96,9 +96,9 @@ class PlanarFieldInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_FACE; + return AttrDomain::Face; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc index f01ae094494..487ed5041a3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc @@ -20,7 +20,7 @@ static void node_declare(NodeDeclarationBuilder &b) .description("Number of faces which share an edge with the face"); } -static VArray construct_neighbor_count_varray(const Mesh &mesh, const eAttrDomain domain) +static VArray construct_neighbor_count_varray(const Mesh &mesh, const AttrDomain domain) { const OffsetIndices faces = mesh.faces(); const Span corner_edges = mesh.corner_edges(); @@ -36,7 +36,7 @@ static VArray construct_neighbor_count_varray(const Mesh &mesh, const eAttr } return mesh.attributes().adapt_domain( - VArray::ForContainer(std::move(face_count)), ATTR_DOMAIN_FACE, domain); + VArray::ForContainer(std::move(face_count)), AttrDomain::Face, domain); } class FaceNeighborCountFieldInput final : public bke::MeshFieldInput { @@ -48,7 +48,7 @@ class FaceNeighborCountFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { return construct_neighbor_count_varray(mesh, domain); @@ -65,19 +65,19 @@ class FaceNeighborCountFieldInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_FACE; + return AttrDomain::Face; } }; -static VArray construct_vertex_count_varray(const Mesh &mesh, const eAttrDomain domain) +static VArray construct_vertex_count_varray(const Mesh &mesh, const AttrDomain domain) { const OffsetIndices faces = mesh.faces(); return mesh.attributes().adapt_domain( VArray::ForFunc(faces.size(), [faces](const int i) -> float { return faces[i].size(); }), - ATTR_DOMAIN_FACE, + AttrDomain::Face, domain); } @@ -89,7 +89,7 @@ class FaceVertexCountFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { return construct_vertex_count_varray(mesh, domain); @@ -106,9 +106,9 @@ class FaceVertexCountFieldInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_FACE; + return AttrDomain::Face; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc index 10c69b361b0..8ff8a3c379b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc @@ -34,7 +34,7 @@ class IslandFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { const Span edges = mesh.edges(); @@ -50,7 +50,7 @@ class IslandFieldInput final : public bke::MeshFieldInput { islands.calc_reduced_ids(output); return mesh.attributes().adapt_domain( - VArray::ForContainer(std::move(output)), ATTR_DOMAIN_POINT, domain); + VArray::ForContainer(std::move(output)), AttrDomain::Point, domain); } uint64_t hash() const override @@ -64,9 +64,9 @@ class IslandFieldInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; @@ -78,7 +78,7 @@ class IslandCountFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { const Span edges = mesh.edges(); @@ -105,9 +105,9 @@ class IslandCountFieldInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_vertex_neighbors.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_vertex_neighbors.cc index 9029a4aee51..392e90333f5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_vertex_neighbors.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_vertex_neighbors.cc @@ -30,10 +30,10 @@ class VertexCountFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_POINT) { + if (domain != AttrDomain::Point) { return {}; } Array counts(mesh.verts_num, 0); @@ -52,9 +52,9 @@ class VertexCountFieldInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; @@ -66,10 +66,10 @@ class VertexFaceCountFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_POINT) { + if (domain != AttrDomain::Point) { return {}; } Array counts(mesh.verts_num, 0); @@ -88,9 +88,9 @@ class VertexFaceCountFieldInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc b/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc index b2a8cada689..42f25acb537 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc @@ -96,16 +96,16 @@ class ShortestEdgePathsNextVertFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - const bke::MeshFieldContext edge_context{mesh, ATTR_DOMAIN_EDGE}; + const bke::MeshFieldContext edge_context{mesh, AttrDomain::Edge}; fn::FieldEvaluator edge_evaluator{edge_context, mesh.edges_num}; edge_evaluator.add(cost_); edge_evaluator.evaluate(); const VArray input_cost = edge_evaluator.get_evaluated(0); - const bke::MeshFieldContext point_context{mesh, ATTR_DOMAIN_POINT}; + const bke::MeshFieldContext point_context{mesh, AttrDomain::Point}; fn::FieldEvaluator point_evaluator{point_context, mesh.verts_num}; point_evaluator.add(end_selection_); point_evaluator.evaluate(); @@ -117,7 +117,7 @@ class ShortestEdgePathsNextVertFieldInput final : public bke::MeshFieldInput { if (end_selection.is_empty()) { array_utils::fill_index_range(next_index); return mesh.attributes().adapt_domain( - VArray::ForContainer(std::move(next_index)), ATTR_DOMAIN_POINT, domain); + VArray::ForContainer(std::move(next_index)), AttrDomain::Point, domain); } const Span edges = mesh.edges(); @@ -135,7 +135,7 @@ class ShortestEdgePathsNextVertFieldInput final : public bke::MeshFieldInput { } }); return mesh.attributes().adapt_domain( - VArray::ForContainer(std::move(next_index)), ATTR_DOMAIN_POINT, domain); + VArray::ForContainer(std::move(next_index)), AttrDomain::Point, domain); } void for_each_field_input_recursive(FunctionRef fn) const override @@ -160,9 +160,9 @@ class ShortestEdgePathsNextVertFieldInput final : public bke::MeshFieldInput { return false; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; @@ -181,16 +181,16 @@ class ShortestEdgePathsCostFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - const bke::MeshFieldContext edge_context{mesh, ATTR_DOMAIN_EDGE}; + const bke::MeshFieldContext edge_context{mesh, AttrDomain::Edge}; fn::FieldEvaluator edge_evaluator{edge_context, mesh.edges_num}; edge_evaluator.add(cost_); edge_evaluator.evaluate(); const VArray input_cost = edge_evaluator.get_evaluated(0); - const bke::MeshFieldContext point_context{mesh, ATTR_DOMAIN_POINT}; + const bke::MeshFieldContext point_context{mesh, AttrDomain::Point}; fn::FieldEvaluator point_evaluator{point_context, mesh.verts_num}; point_evaluator.add(end_selection_); point_evaluator.evaluate(); @@ -198,7 +198,7 @@ class ShortestEdgePathsCostFieldInput final : public bke::MeshFieldInput { if (end_selection.is_empty()) { return mesh.attributes().adapt_domain( - VArray::ForSingle(0.0f, mesh.verts_num), ATTR_DOMAIN_POINT, domain); + VArray::ForSingle(0.0f, mesh.verts_num), AttrDomain::Point, domain); } Array next_index(mesh.verts_num, -1); @@ -219,7 +219,7 @@ class ShortestEdgePathsCostFieldInput final : public bke::MeshFieldInput { } }); return mesh.attributes().adapt_domain( - VArray::ForContainer(std::move(cost)), ATTR_DOMAIN_POINT, domain); + VArray::ForContainer(std::move(cost)), AttrDomain::Point, domain); } void for_each_field_input_recursive(FunctionRef fn) const override @@ -243,9 +243,9 @@ class ShortestEdgePathsCostFieldInput final : public bke::MeshFieldInput { return false; } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc b/source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc index 585197119e9..ba091857dbd 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc @@ -19,17 +19,17 @@ static void node_declare(NodeDeclarationBuilder &b) */ static VArray construct_curve_point_count_gvarray(const bke::CurvesGeometry &curves, - const eAttrDomain domain) + const AttrDomain domain) { const OffsetIndices points_by_curve = curves.points_by_curve(); auto count_fn = [points_by_curve](int64_t i) { return points_by_curve[i].size(); }; - if (domain == ATTR_DOMAIN_CURVE) { + if (domain == AttrDomain::Curve) { return VArray::ForFunc(curves.curves_num(), count_fn); } - if (domain == ATTR_DOMAIN_POINT) { + if (domain == AttrDomain::Point) { VArray count = VArray::ForFunc(curves.curves_num(), count_fn); - return curves.adapt_domain(std::move(count), ATTR_DOMAIN_CURVE, ATTR_DOMAIN_POINT); + return curves.adapt_domain(std::move(count), AttrDomain::Curve, AttrDomain::Point); } return {}; @@ -43,7 +43,7 @@ class SplineCountFieldInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { return construct_curve_point_count_gvarray(curves, domain); @@ -60,9 +60,9 @@ class SplineCountFieldInput final : public bke::CurvesFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final + std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final { - return ATTR_DOMAIN_CURVE; + return AttrDomain::Curve; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_spline_resolution.cc b/source/blender/nodes/geometry/nodes/node_geo_input_spline_resolution.cc index f02082876db..1caeb69ed79 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_spline_resolution.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_spline_resolution.cc @@ -21,10 +21,10 @@ class ResolutionFieldInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - return curves.adapt_domain(curves.resolution(), ATTR_DOMAIN_CURVE, domain); + return curves.adapt_domain(curves.resolution(), AttrDomain::Curve, domain); } uint64_t hash() const final @@ -37,9 +37,9 @@ class ResolutionFieldInput final : public bke::CurvesFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final + std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final { - return ATTR_DOMAIN_CURVE; + return AttrDomain::Curve; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_tangent.cc b/source/blender/nodes/geometry/nodes/node_geo_input_tangent.cc index 9fac9297cdf..90d52b8b2ca 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_tangent.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_tangent.cc @@ -68,23 +68,23 @@ static Array curve_tangent_point_domain(const bke::CurvesGeometry &curve } static VArray construct_curve_tangent_gvarray(const bke::CurvesGeometry &curves, - const eAttrDomain domain) + const AttrDomain domain) { const VArray types = curves.curve_types(); if (curves.is_single_type(CURVE_TYPE_POLY)) { return curves.adapt_domain( - VArray::ForSpan(curves.evaluated_tangents()), ATTR_DOMAIN_POINT, domain); + VArray::ForSpan(curves.evaluated_tangents()), AttrDomain::Point, domain); } Array tangents = curve_tangent_point_domain(curves); - if (domain == ATTR_DOMAIN_POINT) { + if (domain == AttrDomain::Point) { return VArray::ForContainer(std::move(tangents)); } - if (domain == ATTR_DOMAIN_CURVE) { + if (domain == AttrDomain::Curve) { return curves.adapt_domain( - VArray::ForContainer(std::move(tangents)), ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE); + VArray::ForContainer(std::move(tangents)), AttrDomain::Point, AttrDomain::Curve); } return nullptr; @@ -98,7 +98,7 @@ class TangentFieldInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { return construct_curve_tangent_gvarray(curves, domain); @@ -115,9 +115,9 @@ class TangentFieldInput final : public bke::CurvesFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final + std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc index 83951573e21..3896ccca986 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc @@ -55,7 +55,7 @@ static void add_instances_from_component( const GeoNodeExecParams ¶ms, const Map &attributes_to_propagate) { - const eAttrDomain domain = ATTR_DOMAIN_POINT; + const AttrDomain domain = AttrDomain::Point; const int domain_num = src_attributes.domain_size(domain); VArray pick_instance; @@ -159,7 +159,7 @@ static void add_instances_from_component( for (const auto item : attributes_to_propagate.items()) { const AttributeIDRef &id = item.key; const eCustomDataType data_type = item.value.data_type; - const bke::GAttributeReader src = src_attributes.lookup(id, ATTR_DOMAIN_POINT, data_type); + const bke::GAttributeReader src = src_attributes.lookup(id, AttrDomain::Point, data_type); if (!src) { /* Domain interpolation can fail if the source domain is empty. */ continue; @@ -170,10 +170,10 @@ static void add_instances_from_component( src.varray.is_span()) { const bke::AttributeInitShared init(src.varray.get_internal_span().data(), *src.sharing_info); - dst_attributes.add(id, ATTR_DOMAIN_INSTANCE, data_type, init); + dst_attributes.add(id, AttrDomain::Instance, data_type, init); continue; } - dst_attributes.add(id, ATTR_DOMAIN_INSTANCE, data_type, bke::AttributeInitConstruct()); + dst_attributes.add(id, AttrDomain::Instance, data_type, bke::AttributeInitConstruct()); } GSpanAttributeWriter dst = dst_attributes.lookup_for_write_span(id); @@ -216,7 +216,7 @@ static void node_geo_exec(GeoNodeExecParams params) for (const GeometryComponent::Type type : types) { if (geometry_set.has(type)) { const GeometryComponent &component = *geometry_set.get_component(type); - const bke::GeometryFieldContext field_context{component, ATTR_DOMAIN_POINT}; + const bke::GeometryFieldContext field_context{component, AttrDomain::Point}; add_instances_from_component(*dst_instances, *component.attributes(), instance, @@ -245,7 +245,7 @@ static void node_geo_exec(GeoNodeExecParams params) /* TODO: Attributes are not propagating from the curves or the points. */ bke::Instances *instances = new bke::Instances(); const bke::GreasePencilLayerFieldContext field_context( - grease_pencil, ATTR_DOMAIN_POINT, layer_index); + grease_pencil, AttrDomain::Point, layer_index); add_instances_from_component(*instances, src_curves.attributes(), instance, diff --git a/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc index afa8f766843..d3e6b4a0a7e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc @@ -54,7 +54,7 @@ static void convert_instances_to_points(GeometrySet &geometry_set, bke::MutableAttributeAccessor dst_attributes = pointcloud->attributes_for_write(); bke::SpanAttributeWriter point_radii = - dst_attributes.lookup_or_add_for_write_only_span("radius", ATTR_DOMAIN_POINT); + dst_attributes.lookup_or_add_for_write_only_span("radius", AttrDomain::Point); array_utils::gather(radii, selection, point_radii.span); point_radii.finish(); @@ -78,11 +78,11 @@ static void convert_instances_to_points(GeometrySet &geometry_set, { const bke::AttributeInitShared init(src.varray.get_internal_span().data(), *src.sharing_info); - dst_attributes.add(id, ATTR_DOMAIN_POINT, type, init); + dst_attributes.add(id, AttrDomain::Point, type, init); } else { GSpanAttributeWriter dst = dst_attributes.lookup_or_add_for_write_only_span( - id, ATTR_DOMAIN_POINT, type); + id, AttrDomain::Point, type); array_utils::gather(src.varray, selection, dst.span); dst.finish(); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc index 33c8914be46..1b2269e1841 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc @@ -478,11 +478,11 @@ static void interpolate_curve_attributes(bke::CurvesGeometry &child_curves, return true; } - if (meta_data.domain == ATTR_DOMAIN_CURVE) { - const GVArraySpan src_generic = *guide_curve_attributes.lookup(id, ATTR_DOMAIN_CURVE, type); + if (meta_data.domain == AttrDomain::Curve) { + const GVArraySpan src_generic = *guide_curve_attributes.lookup(id, AttrDomain::Curve, type); GSpanAttributeWriter dst_generic = children_attributes.lookup_or_add_for_write_only_span( - id, ATTR_DOMAIN_CURVE, type); + id, AttrDomain::Curve, type); if (!dst_generic) { return true; } @@ -512,10 +512,10 @@ static void interpolate_curve_attributes(bke::CurvesGeometry &child_curves, dst_generic.finish(); } else { - BLI_assert(meta_data.domain == ATTR_DOMAIN_POINT); - const GVArraySpan src_generic = *guide_curve_attributes.lookup(id, ATTR_DOMAIN_POINT, type); + BLI_assert(meta_data.domain == AttrDomain::Point); + const GVArraySpan src_generic = *guide_curve_attributes.lookup(id, AttrDomain::Point, type); GSpanAttributeWriter dst_generic = children_attributes.lookup_or_add_for_write_only_span( - id, ATTR_DOMAIN_POINT, type); + id, AttrDomain::Point, type); if (!dst_generic) { return true; } @@ -615,11 +615,11 @@ static void interpolate_curve_attributes(bke::CurvesGeometry &child_curves, if (src.sharing_info && src.varray.is_span()) { const bke::AttributeInitShared init(src.varray.get_internal_span().data(), *src.sharing_info); - children_attributes.add(id, ATTR_DOMAIN_CURVE, meta_data.data_type, init); + children_attributes.add(id, AttrDomain::Curve, meta_data.data_type, init); } else { children_attributes.add( - id, ATTR_DOMAIN_CURVE, meta_data.data_type, bke::AttributeInitVArray(src.varray)); + id, AttrDomain::Curve, meta_data.data_type, bke::AttributeInitVArray(src.varray)); } return true; }); @@ -640,12 +640,12 @@ static void store_output_attributes(bke::CurvesGeometry &child_curves, if (weight_attribute_id) { weight_attribute = child_curves.attributes_for_write().lookup_or_add_for_write_only_span( - *weight_attribute_id, ATTR_DOMAIN_CURVE); + *weight_attribute_id, AttrDomain::Curve); } SpanAttributeWriter index_attribute; if (index_attribute_id) { index_attribute = child_curves.attributes_for_write().lookup_or_add_for_write_only_span( - *index_attribute_id, ATTR_DOMAIN_CURVE); + *index_attribute_id, AttrDomain::Curve); } threading::parallel_for(child_curves.curves_range(), 512, [&](const IndexRange range) { for (const int child_curve_i : range) { @@ -708,7 +708,7 @@ static GeometrySet generate_interpolated_curves( }); const VArraySpan point_positions = *point_attributes.lookup("position"); - const int num_child_curves = point_attributes.domain_size(ATTR_DOMAIN_POINT); + const int num_child_curves = point_attributes.domain_size(AttrDomain::Point); /* The set of guides per child are stored in a flattened array to allow fast access, reduce * memory consumption and reduce number of allocations. */ @@ -829,7 +829,7 @@ static void node_geo_exec(GeoNodeExecParams params) const Curves &guide_curves_id = *guide_curves_geometry.get_curves(); - const bke::CurvesFieldContext curves_context{guide_curves_id.geometry.wrap(), ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext curves_context{guide_curves_id.geometry.wrap(), AttrDomain::Curve}; fn::FieldEvaluator curves_evaluator{curves_context, guide_curves_id.geometry.curve_num}; curves_evaluator.add(guides_up_field); curves_evaluator.add(guide_group_field); @@ -837,9 +837,9 @@ static void node_geo_exec(GeoNodeExecParams params) const VArray guides_up = curves_evaluator.get_evaluated(0); const VArray guide_group_ids = curves_evaluator.get_evaluated(1); - const bke::GeometryFieldContext points_context(*points_component, ATTR_DOMAIN_POINT); + const bke::GeometryFieldContext points_context(*points_component, AttrDomain::Point); fn::FieldEvaluator points_evaluator{points_context, - points_component->attribute_domain_size(ATTR_DOMAIN_POINT)}; + points_component->attribute_domain_size(AttrDomain::Point)}; points_evaluator.add(points_up_field); points_evaluator.add(point_group_field); points_evaluator.evaluate(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc index 699dcfec988..3c07c521320 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc @@ -27,7 +27,7 @@ static void node_declare(NodeDeclarationBuilder &b) static VArray select_by_material(const Span materials, const Material *material, const AttributeAccessor &attributes, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask &domain_mask) { const int domain_size = attributes.domain_size(domain); @@ -76,34 +76,34 @@ class MaterialSelectionFieldInput final : public bke::GeometryFieldInput { if (!mesh) { return {}; } - const eAttrDomain domain = context.domain(); - const IndexMask domain_mask = (domain == ATTR_DOMAIN_FACE) ? mask : + const AttrDomain domain = context.domain(); + const IndexMask domain_mask = (domain == AttrDomain::Face) ? mask : IndexMask(mesh->faces_num); const AttributeAccessor attributes = mesh->attributes(); VArray selection = select_by_material( - {mesh->mat, mesh->totcol}, material_, attributes, ATTR_DOMAIN_FACE, domain_mask); - return attributes.adapt_domain(std::move(selection), ATTR_DOMAIN_FACE, domain); + {mesh->mat, mesh->totcol}, material_, attributes, AttrDomain::Face, domain_mask); + return attributes.adapt_domain(std::move(selection), AttrDomain::Face, domain); } case GeometryComponent::Type::GreasePencil: { const bke::CurvesGeometry *curves = context.curves_or_strokes(); if (!curves) { return {}; } - const eAttrDomain domain = context.domain(); - const IndexMask domain_mask = (domain == ATTR_DOMAIN_CURVE) ? + const AttrDomain domain = context.domain(); + const IndexMask domain_mask = (domain == AttrDomain::Curve) ? mask : IndexMask(curves->curves_num()); const AttributeAccessor attributes = curves->attributes(); const VArray material_indices = *attributes.lookup_or_default( - "material_index", ATTR_DOMAIN_CURVE, 0); + "material_index", AttrDomain::Curve, 0); const GreasePencil &grease_pencil = *context.grease_pencil(); VArray selection = select_by_material( {grease_pencil.material_array, grease_pencil.material_array_num}, material_, attributes, - ATTR_DOMAIN_CURVE, + AttrDomain::Curve, domain_mask); - return attributes.adapt_domain(std::move(selection), ATTR_DOMAIN_CURVE, domain); + return attributes.adapt_domain(std::move(selection), AttrDomain::Curve, domain); } default: return {}; @@ -125,10 +125,10 @@ class MaterialSelectionFieldInput final : public bke::GeometryFieldInput { return false; } - std::optional preferred_domain( + std::optional preferred_domain( const GeometryComponent & /*component*/) const override { - return ATTR_DOMAIN_FACE; + return AttrDomain::Face; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc b/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc index 1e7b3f4b1c3..945ae3cebf5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc @@ -67,7 +67,7 @@ static std::optional mesh_merge_by_distance_connected(const Mesh &mesh, const Field &selection_field) { Array selection(mesh.verts_num); - const bke::MeshFieldContext context{mesh, ATTR_DOMAIN_POINT}; + const bke::MeshFieldContext context{mesh, AttrDomain::Point}; FieldEvaluator evaluator{context, mesh.verts_num}; evaluator.add_with_destination(selection_field, selection.as_mutable_span()); evaluator.evaluate(); @@ -79,7 +79,7 @@ static std::optional mesh_merge_by_distance_all(const Mesh &mesh, const float merge_distance, const Field &selection_field) { - const bke::MeshFieldContext context{mesh, ATTR_DOMAIN_POINT}; + const bke::MeshFieldContext context{mesh, AttrDomain::Point}; FieldEvaluator evaluator{context, mesh.verts_num}; evaluator.add(selection_field); evaluator.evaluate(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_face_group_boundaries.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_face_group_boundaries.cc index 59cddf554d1..11fe98d6fc5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_face_group_boundaries.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_face_group_boundaries.cc @@ -39,10 +39,10 @@ class BoundaryFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - const bke::MeshFieldContext face_context{mesh, ATTR_DOMAIN_FACE}; + const bke::MeshFieldContext face_context{mesh, AttrDomain::Face}; FieldEvaluator face_evaluator{face_context, mesh.faces_num}; face_evaluator.add(face_set_); face_evaluator.evaluate(); @@ -103,7 +103,7 @@ class BoundaryFieldInput final : public bke::MeshFieldInput { } }); return mesh.attributes().adapt_domain( - VArray::ForContainer(std::move(boundary)), ATTR_DOMAIN_EDGE, domain); + VArray::ForContainer(std::move(boundary)), AttrDomain::Edge, domain); } void for_each_field_input_recursive(FunctionRef fn) const override @@ -111,9 +111,9 @@ class BoundaryFieldInput final : public bke::MeshFieldInput { face_set_.node().for_each_field_input_recursive(fn); } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_EDGE; + return AttrDomain::Edge; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc index c7de5af0db3..1344dcc55fe 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc @@ -105,7 +105,7 @@ static Mesh *create_ico_sphere_mesh(const int subdivisions, if (create_uv_map) { const VArraySpan orig_uv_map = *attributes.lookup("UVMap"); SpanAttributeWriter uv_map = attributes.lookup_or_add_for_write_only_span( - uv_map_id, ATTR_DOMAIN_CORNER); + uv_map_id, AttrDomain::Corner); uv_map.span.copy_from(orig_uv_map); uv_map.finish(); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc index 91349570148..9be85fb311d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc @@ -28,7 +28,7 @@ static void node_geo_exec(GeoNodeExecParams params) return; } - const bke::MeshFieldContext context{*mesh, ATTR_DOMAIN_EDGE}; + const bke::MeshFieldContext context{*mesh, AttrDomain::Edge}; fn::FieldEvaluator evaluator{context, mesh->edges_num}; evaluator.add(params.get_input>("Selection")); evaluator.evaluate(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc index 3383e5bd281..80070e298d8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc @@ -52,7 +52,7 @@ static void geometry_set_mesh_to_points(GeometrySet &geometry_set, const Field &position_field, const Field &radius_field, const Field &selection_field, - const eAttrDomain domain, + const AttrDomain domain, const AnonymousAttributePropagationInfo &propagation_info) { const Mesh *mesh = geometry_set.get_mesh(); @@ -92,7 +92,7 @@ static void geometry_set_mesh_to_points(GeometrySet &geometry_set, pointcloud->totpoint = mesh->verts_num; const bke::AttributeReader src = src_attributes.lookup("position"); const bke::AttributeInitShared init(src.varray.get_internal_span().data(), *src.sharing_info); - pointcloud->attributes_for_write().add("position", ATTR_DOMAIN_POINT, init); + pointcloud->attributes_for_write().add("position", AttrDomain::Point, init); } else { pointcloud = BKE_pointcloud_new_nomain(selection.size()); @@ -101,7 +101,7 @@ static void geometry_set_mesh_to_points(GeometrySet &geometry_set, MutableAttributeAccessor dst_attributes = pointcloud->attributes_for_write(); GSpanAttributeWriter radius = dst_attributes.lookup_or_add_for_write_only_span( - "radius", ATTR_DOMAIN_POINT, CD_PROP_FLOAT); + "radius", AttrDomain::Point, CD_PROP_FLOAT); array_utils::gather(evaluator.get_evaluated(1), selection, radius.span); radius.finish(); @@ -126,11 +126,11 @@ static void geometry_set_mesh_to_points(GeometrySet &geometry_set, if (share_arrays && src.domain == domain && src.sharing_info && src.varray.is_span()) { const bke::AttributeInitShared init(src.varray.get_internal_span().data(), *src.sharing_info); - dst_attributes.add(attribute_id, ATTR_DOMAIN_POINT, data_type, init); + dst_attributes.add(attribute_id, AttrDomain::Point, data_type, init); } else { GSpanAttributeWriter dst = dst_attributes.lookup_or_add_for_write_only_span( - attribute_id, ATTR_DOMAIN_POINT, data_type); + attribute_id, AttrDomain::Point, data_type); array_utils::gather(src.varray, selection, dst.span); dst.finish(); } @@ -168,7 +168,7 @@ static void node_geo_exec(GeoNodeExecParams params) position, positive_radius, selection, - ATTR_DOMAIN_POINT, + AttrDomain::Point, propagation_info); break; case GEO_NODE_MESH_TO_POINTS_EDGES: @@ -176,7 +176,7 @@ static void node_geo_exec(GeoNodeExecParams params) position, positive_radius, selection, - ATTR_DOMAIN_EDGE, + AttrDomain::Edge, propagation_info); break; case GEO_NODE_MESH_TO_POINTS_FACES: @@ -184,7 +184,7 @@ static void node_geo_exec(GeoNodeExecParams params) position, positive_radius, selection, - ATTR_DOMAIN_FACE, + AttrDomain::Face, propagation_info); break; case GEO_NODE_MESH_TO_POINTS_CORNERS: @@ -192,7 +192,7 @@ static void node_geo_exec(GeoNodeExecParams params) position, positive_radius, selection, - ATTR_DOMAIN_CORNER, + AttrDomain::Corner, propagation_info); break; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_edge.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_edge.cc index 61fe9212819..89a5251eb19 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_edge.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_edge.cc @@ -46,7 +46,7 @@ class CornersOfEdgeInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask &mask) const final { const IndexRange edge_range(mesh.edges_num); @@ -64,7 +64,7 @@ class CornersOfEdgeInput final : public bke::MeshFieldInput { const VArray edge_indices = evaluator.get_evaluated(0); const VArray indices_in_sort = evaluator.get_evaluated(1); - const bke::MeshFieldContext corner_context{mesh, ATTR_DOMAIN_CORNER}; + const bke::MeshFieldContext corner_context{mesh, AttrDomain::Corner}; fn::FieldEvaluator corner_evaluator{corner_context, corner_edges.size()}; corner_evaluator.add(sort_weight_); corner_evaluator.evaluate(); @@ -127,9 +127,9 @@ class CornersOfEdgeInput final : public bke::MeshFieldInput { sort_weight_.node().for_each_field_input_recursive(fn); } - std::optional preferred_domain(const Mesh & /*mesh*/) const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { - return ATTR_DOMAIN_EDGE; + return AttrDomain::Edge; } }; @@ -141,10 +141,10 @@ class CornersOfEdgeCountInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_EDGE) { + if (domain != AttrDomain::Edge) { return {}; } Array counts(mesh.edges_num, 0); @@ -162,9 +162,9 @@ class CornersOfEdgeCountInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { - return ATTR_DOMAIN_EDGE; + return AttrDomain::Edge; } }; @@ -176,7 +176,7 @@ static void node_geo_exec(GeoNodeExecParams params) Field(std::make_shared( edge_index, Field(std::make_shared()), - ATTR_DOMAIN_EDGE))); + AttrDomain::Edge))); } if (params.output_is_required("Corner Index")) { params.set_output("Corner Index", diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_face.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_face.cc index 371f1de2117..eca2e777a0c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_face.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_face.cc @@ -45,7 +45,7 @@ class CornersOfFaceInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask &mask) const final { const OffsetIndices faces = mesh.faces(); @@ -58,7 +58,7 @@ class CornersOfFaceInput final : public bke::MeshFieldInput { const VArray face_indices = evaluator.get_evaluated(0); const VArray indices_in_sort = evaluator.get_evaluated(1); - const bke::MeshFieldContext corner_context{mesh, ATTR_DOMAIN_CORNER}; + const bke::MeshFieldContext corner_context{mesh, AttrDomain::Corner}; fn::FieldEvaluator corner_evaluator{corner_context, mesh.corners_num}; corner_evaluator.add(sort_weight_); corner_evaluator.evaluate(); @@ -129,9 +129,9 @@ class CornersOfFaceInput final : public bke::MeshFieldInput { return false; } - std::optional preferred_domain(const Mesh & /*mesh*/) const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { - return ATTR_DOMAIN_FACE; + return AttrDomain::Face; } }; @@ -143,10 +143,10 @@ class CornersOfFaceCountInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_FACE) { + if (domain != AttrDomain::Face) { return {}; } const OffsetIndices faces = mesh.faces(); @@ -164,9 +164,9 @@ class CornersOfFaceCountInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { - return ATTR_DOMAIN_FACE; + return AttrDomain::Face; } }; @@ -178,7 +178,7 @@ static void node_geo_exec(GeoNodeExecParams params) Field(std::make_shared( face_index, Field(std::make_shared()), - ATTR_DOMAIN_FACE))); + AttrDomain::Face))); } if (params.output_is_required("Corner Index")) { params.set_output("Corner Index", diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc index d3ed0e060a7..e69623738e9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc @@ -45,7 +45,7 @@ class CornersOfVertInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask &mask) const final { const IndexRange vert_range(mesh.verts_num); @@ -59,7 +59,7 @@ class CornersOfVertInput final : public bke::MeshFieldInput { const VArray vert_indices = evaluator.get_evaluated(0); const VArray indices_in_sort = evaluator.get_evaluated(1); - const bke::MeshFieldContext corner_context{mesh, ATTR_DOMAIN_CORNER}; + const bke::MeshFieldContext corner_context{mesh, AttrDomain::Corner}; fn::FieldEvaluator corner_evaluator{corner_context, mesh.corners_num}; corner_evaluator.add(sort_weight_); corner_evaluator.evaluate(); @@ -135,9 +135,9 @@ class CornersOfVertInput final : public bke::MeshFieldInput { return false; } - std::optional preferred_domain(const Mesh & /*mesh*/) const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; @@ -149,10 +149,10 @@ class CornersOfVertCountInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_POINT) { + if (domain != AttrDomain::Point) { return {}; } Array counts(mesh.verts_num, 0); @@ -170,9 +170,9 @@ class CornersOfVertCountInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; @@ -184,7 +184,7 @@ static void node_geo_exec(GeoNodeExecParams params) Field(std::make_shared( vert_index, Field(std::make_shared()), - ATTR_DOMAIN_POINT))); + AttrDomain::Point))); } if (params.output_is_required("Corner Index")) { params.set_output("Corner Index", diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_corner.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_corner.cc index ed1d82edf32..a11b3183c37 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_corner.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_corner.cc @@ -34,10 +34,10 @@ class CornerNextEdgeFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_CORNER) { + if (domain != AttrDomain::Corner) { return {}; } return VArray::ForSpan(mesh.corner_edges()); @@ -53,9 +53,9 @@ class CornerNextEdgeFieldInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { - return ATTR_DOMAIN_CORNER; + return AttrDomain::Corner; } }; @@ -67,10 +67,10 @@ class CornerPreviousEdgeFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_CORNER) { + if (domain != AttrDomain::Corner) { return {}; } const OffsetIndices faces = mesh.faces(); @@ -92,9 +92,9 @@ class CornerPreviousEdgeFieldInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { - return ATTR_DOMAIN_CORNER; + return AttrDomain::Corner; } }; @@ -106,14 +106,14 @@ static void node_geo_exec(GeoNodeExecParams params) Field(std::make_shared( corner_index, Field(std::make_shared()), - ATTR_DOMAIN_CORNER))); + AttrDomain::Corner))); } if (params.output_is_required("Previous Edge Index")) { params.set_output("Previous Edge Index", Field(std::make_shared( corner_index, Field(std::make_shared()), - ATTR_DOMAIN_CORNER))); + AttrDomain::Corner))); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_vertex.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_vertex.cc index 761b7193844..3408332ffcd 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_vertex.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_vertex.cc @@ -45,7 +45,7 @@ class EdgesOfVertInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask &mask) const final { const IndexRange vert_range(mesh.verts_num); @@ -63,7 +63,7 @@ class EdgesOfVertInput final : public bke::MeshFieldInput { const VArray vert_indices = evaluator.get_evaluated(0); const VArray indices_in_sort = evaluator.get_evaluated(1); - const bke::MeshFieldContext edge_context{mesh, ATTR_DOMAIN_EDGE}; + const bke::MeshFieldContext edge_context{mesh, AttrDomain::Edge}; fn::FieldEvaluator edge_evaluator{edge_context, mesh.edges_num}; edge_evaluator.add(sort_weight_); edge_evaluator.evaluate(); @@ -140,9 +140,9 @@ class EdgesOfVertInput final : public bke::MeshFieldInput { return false; } - std::optional preferred_domain(const Mesh & /*mesh*/) const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; @@ -154,10 +154,10 @@ class EdgesOfVertCountInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_POINT) { + if (domain != AttrDomain::Point) { return {}; } Array counts(mesh.verts_num, 0); @@ -175,9 +175,9 @@ class EdgesOfVertCountInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { - return ATTR_DOMAIN_POINT; + return AttrDomain::Point; } }; @@ -189,7 +189,7 @@ static void node_geo_exec(GeoNodeExecParams params) Field(std::make_shared( vert_index, Field(std::make_shared()), - ATTR_DOMAIN_POINT))); + AttrDomain::Point))); } if (params.output_is_required("Edge Index")) { params.set_output("Edge Index", diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_face_of_corner.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_face_of_corner.cc index bd9e700a744..1023d435c90 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_face_of_corner.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_face_of_corner.cc @@ -30,10 +30,10 @@ class CornerFaceIndexInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_CORNER) { + if (domain != AttrDomain::Corner) { return {}; } return VArray::ForSpan(mesh.corner_to_face_map()); @@ -58,10 +58,10 @@ class CornerIndexInFaceInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_CORNER) { + if (domain != AttrDomain::Corner) { return {}; } const OffsetIndices faces = mesh.faces(); @@ -82,9 +82,9 @@ class CornerIndexInFaceInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { - return ATTR_DOMAIN_CORNER; + return AttrDomain::Corner; } }; @@ -96,14 +96,14 @@ static void node_geo_exec(GeoNodeExecParams params) Field(std::make_shared( corner_index, Field(std::make_shared()), - ATTR_DOMAIN_CORNER))); + AttrDomain::Corner))); } if (params.output_is_required("Index in Face")) { params.set_output("Index in Face", Field(std::make_shared( corner_index, Field(std::make_shared()), - ATTR_DOMAIN_CORNER))); + AttrDomain::Corner))); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_offset_corner_in_face.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_offset_corner_in_face.cc index 61330954734..f985febe525 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_offset_corner_in_face.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_offset_corner_in_face.cc @@ -38,7 +38,7 @@ class OffsetCornerInFaceFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask &mask) const final { const IndexRange corner_range(mesh.corners_num); @@ -91,9 +91,9 @@ class OffsetCornerInFaceFieldInput final : public bke::MeshFieldInput { return false; } - std::optional preferred_domain(const Mesh & /*mesh*/) const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { - return ATTR_DOMAIN_CORNER; + return AttrDomain::Corner; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_vertex_of_corner.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_vertex_of_corner.cc index 29d53bd4131..4194c7d5673 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_vertex_of_corner.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_vertex_of_corner.cc @@ -28,10 +28,10 @@ class CornerVertFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { - if (domain != ATTR_DOMAIN_CORNER) { + if (domain != AttrDomain::Corner) { return {}; } return VArray::ForSpan(mesh.corner_verts()); @@ -47,9 +47,9 @@ class CornerVertFieldInput final : public bke::MeshFieldInput { return dynamic_cast(&other) != nullptr; } - std::optional preferred_domain(const Mesh & /*mesh*/) const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { - return ATTR_DOMAIN_CORNER; + return AttrDomain::Corner; } }; @@ -59,7 +59,7 @@ static void node_geo_exec(GeoNodeExecParams params) Field(std::make_shared( params.extract_input>("Corner Index"), Field(std::make_shared()), - ATTR_DOMAIN_CORNER))); + AttrDomain::Corner))); } static void node_register() diff --git a/source/blender/nodes/geometry/nodes/node_geo_offset_point_in_curve.cc b/source/blender/nodes/geometry/nodes/node_geo_offset_point_in_curve.cc index 79390c47788..21481cc3421 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_offset_point_in_curve.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_offset_point_in_curve.cc @@ -60,7 +60,7 @@ class ControlPointNeighborFieldInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask &mask) const final { const OffsetIndices points_by_curve = curves.points_by_curve(); @@ -115,7 +115,7 @@ class OffsetValidFieldInput final : public bke::CurvesFieldInput { } GVArray get_varray_for_context(const bke::CurvesGeometry &curves, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask &mask) const final { const VArray cyclic = curves.cyclic(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_points.cc b/source/blender/nodes/geometry/nodes/node_geo_points.cc index e8950c64d4a..73e0a943124 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points.cc @@ -72,7 +72,7 @@ static void node_geo_exec(GeoNodeExecParams params) PointCloud *points = BKE_pointcloud_new_nomain(count); MutableAttributeAccessor attributes = points->attributes_for_write(); AttributeWriter output_radii = attributes.lookup_or_add_for_write( - "radius", ATTR_DOMAIN_POINT); + "radius", AttrDomain::Point); PointsFieldContext context{count}; fn::FieldEvaluator evaluator{context, count}; diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_curves.cc index 97fe596f92b..9354666eadb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_curves.cc @@ -95,7 +95,7 @@ static Curves *curve_from_points(const AttributeAccessor attributes, bke::CurvesGeometry &curves = curves_id->geometry.wrap(); if (weights_varray.is_single()) { bke::copy_attributes( - attributes, ATTR_DOMAIN_POINT, propagation_info, {}, curves.attributes_for_write()); + attributes, AttrDomain::Point, propagation_info, {}, curves.attributes_for_write()); return curves_id; } Array indices(domain_size); @@ -103,7 +103,7 @@ static Curves *curve_from_points(const AttributeAccessor attributes, const VArraySpan weights(weights_varray); grouped_sort(OffsetIndices({0, domain_size}), weights, indices); bke::gather_attributes( - attributes, ATTR_DOMAIN_POINT, propagation_info, {}, indices, curves.attributes_for_write()); + attributes, AttrDomain::Point, propagation_info, {}, indices, curves.attributes_for_write()); return curves_id; } @@ -148,7 +148,7 @@ static Curves *curves_from_points(const PointCloud &points, grouped_sort(OffsetIndices(offset), weights, indices); } bke::gather_attributes(points.attributes(), - ATTR_DOMAIN_POINT, + AttrDomain::Point, propagation_info, {}, indices, diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc index f3d4a68298b..3a215ec7519 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc @@ -70,11 +70,11 @@ static void geometry_set_points_to_vertices( if (selection.size() == points->totpoint && src.sharing_info && src.varray.is_span()) { const bke::AttributeInitShared init(src.varray.get_internal_span().data(), *src.sharing_info); - dst_attributes.add(id, ATTR_DOMAIN_POINT, data_type, init); + dst_attributes.add(id, AttrDomain::Point, data_type, init); } else { GSpanAttributeWriter dst = dst_attributes.lookup_or_add_for_write_only_span( - id, ATTR_DOMAIN_POINT, data_type); + id, AttrDomain::Point, data_type); array_utils::gather(src.varray, selection, dst.span); dst.finish(); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc index ac6fb747344..d36a0a8272e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc @@ -36,8 +36,8 @@ static void gather_point_data_from_component(Field radius_field, } const VArray positions = *component.attributes()->lookup("position"); - const bke::GeometryFieldContext field_context{component, ATTR_DOMAIN_POINT}; - const int domain_num = component.attribute_domain_size(ATTR_DOMAIN_POINT); + const bke::GeometryFieldContext field_context{component, AttrDomain::Point}; + const int domain_num = component.attribute_domain_size(AttrDomain::Point); r_positions.resize(r_positions.size() + domain_num); positions.materialize(r_positions.as_mutable_span().take_back(domain_num)); diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc index d84558d2075..8a88910c779 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc @@ -84,7 +84,7 @@ static void node_init(bNodeTree * /*tree*/, bNode *node) { NodeGeometrySampleIndex *data = MEM_cnew(__func__); data->data_type = CD_PROP_FLOAT; - data->domain = ATTR_DOMAIN_POINT; + data->domain = int8_t(AttrDomain::Point); data->clamp = 0; node->storage = data; } @@ -108,7 +108,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) static bool component_is_available(const GeometrySet &geometry, const GeometryComponent::Type type, - const eAttrDomain domain) + const AttrDomain domain) { if (!geometry.has(type)) { return false; @@ -118,7 +118,7 @@ static bool component_is_available(const GeometrySet &geometry, } static const GeometryComponent *find_source_component(const GeometrySet &geometry, - const eAttrDomain domain) + const AttrDomain domain) { /* Choose the other component based on a consistent order, rather than some more complicated * heuristic. This is the same order visible in the spreadsheet and used in the ray-cast node. */ @@ -159,7 +159,7 @@ void copy_with_clamped_indices(const VArray &src, class SampleIndexFunction : public mf::MultiFunction { GeometrySet src_geometry_; GField src_field_; - eAttrDomain domain_; + AttrDomain domain_; bool clamp_; mf::Signature signature_; @@ -171,7 +171,7 @@ class SampleIndexFunction : public mf::MultiFunction { public: SampleIndexFunction(GeometrySet geometry, GField src_field, - const eAttrDomain domain, + const AttrDomain domain, const bool clamp) : src_geometry_(std::move(geometry)), src_field_(std::move(src_field)), @@ -229,7 +229,7 @@ static void node_geo_exec(GeoNodeExecParams params) { GeometrySet geometry = params.extract_input("Geometry"); const NodeGeometrySampleIndex &storage = node_storage(params.node()); - const eAttrDomain domain = eAttrDomain(storage.domain); + const AttrDomain domain = AttrDomain(storage.domain); const bool use_clamp = bool(storage.clamp); GField value_field = params.extract_input("Value"); diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc index 2b32c032e3c..ecfda215b04 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc @@ -70,7 +70,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { node->custom1 = CD_PROP_FLOAT; - node->custom2 = ATTR_DOMAIN_POINT; + node->custom2 = int(AttrDomain::Point); } static void get_closest_pointcloud_points(const PointCloud &pointcloud, @@ -211,7 +211,7 @@ static void get_closest_mesh_corners(const Mesh &mesh, static bool component_is_available(const GeometrySet &geometry, const GeometryComponent::Type type, - const eAttrDomain domain) + const AttrDomain domain) { if (!geometry.has(type)) { return false; @@ -221,7 +221,7 @@ static bool component_is_available(const GeometrySet &geometry, } static const GeometryComponent *find_source_component(const GeometrySet &geometry, - const eAttrDomain domain) + const AttrDomain domain) { /* Choose the other component based on a consistent order, rather than some more complicated * heuristic. This is the same order visible in the spreadsheet and used in the ray-cast node. */ @@ -238,14 +238,14 @@ static const GeometryComponent *find_source_component(const GeometrySet &geometr class SampleNearestFunction : public mf::MultiFunction { GeometrySet source_; - eAttrDomain domain_; + AttrDomain domain_; const GeometryComponent *src_component_; mf::Signature signature_; public: - SampleNearestFunction(GeometrySet geometry, eAttrDomain domain) + SampleNearestFunction(GeometrySet geometry, AttrDomain domain) : source_(std::move(geometry)), domain_(domain) { source_.ensure_owns_direct_data(); @@ -271,16 +271,16 @@ class SampleNearestFunction : public mf::MultiFunction { const MeshComponent &component = *static_cast(src_component_); const Mesh &mesh = *component.get(); switch (domain_) { - case ATTR_DOMAIN_POINT: + case AttrDomain::Point: get_closest_mesh_points(mesh, positions, mask, indices, {}, {}); break; - case ATTR_DOMAIN_EDGE: + case AttrDomain::Edge: get_closest_mesh_edges(mesh, positions, mask, indices, {}, {}); break; - case ATTR_DOMAIN_FACE: + case AttrDomain::Face: get_closest_mesh_faces(mesh, positions, mask, indices, {}, {}); break; - case ATTR_DOMAIN_CORNER: + case AttrDomain::Corner: get_closest_mesh_corners(mesh, positions, mask, indices, {}, {}); break; default: @@ -304,7 +304,7 @@ class SampleNearestFunction : public mf::MultiFunction { static void node_geo_exec(GeoNodeExecParams params) { GeometrySet geometry = params.extract_input("Geometry"); - const eAttrDomain domain = eAttrDomain(params.node().custom2); + const AttrDomain domain = AttrDomain(params.node().custom2); if (geometry.has_curves() && !geometry.has_mesh() && !geometry.has_pointcloud()) { params.error_message_add(NodeWarningType::Error, TIP_("The source geometry must contain a mesh or a point cloud")); @@ -326,7 +326,7 @@ static void node_rna(StructRNA *srna) "", rna_enum_attribute_domain_only_mesh_items, NOD_inline_enum_accessors(custom2), - ATTR_DOMAIN_POINT); + int(AttrDomain::Point)); } static void node_register() diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_uv_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_uv_surface.cc index d3e35691bb3..c50ca37f29d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_uv_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_uv_surface.cc @@ -134,7 +134,7 @@ class ReverseUVSampleFunction : public mf::MultiFunction { void evaluate_source() { const Mesh &mesh = *source_.get_mesh(); - source_context_.emplace(bke::MeshFieldContext{mesh, ATTR_DOMAIN_CORNER}); + source_context_.emplace(bke::MeshFieldContext{mesh, AttrDomain::Corner}); source_evaluator_ = std::make_unique(*source_context_, mesh.corners_num); source_evaluator_->add(src_uv_map_field_); source_evaluator_->evaluate(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc index 8f5b99d4082..836fae4ed9e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc @@ -50,7 +50,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - node->custom1 = ATTR_DOMAIN_FACE; + node->custom1 = int16_t(AttrDomain::Face); node->custom2 = GEO_NODE_SCALE_ELEMENTS_UNIFORM; } @@ -304,7 +304,7 @@ static AxisScaleParams evaluate_axis_scale_fields(FieldEvaluator &evaluator, static void scale_faces_on_axis(Mesh &mesh, const AxisScaleFields &fields) { - const bke::MeshFieldContext field_context{mesh, ATTR_DOMAIN_FACE}; + const bke::MeshFieldContext field_context{mesh, AttrDomain::Face}; FieldEvaluator evaluator{field_context, mesh.faces_num}; AxisScaleParams params = evaluate_axis_scale_fields(evaluator, fields); @@ -326,7 +326,7 @@ static UniformScaleParams evaluate_uniform_scale_fields(FieldEvaluator &evaluato static void scale_faces_uniformly(Mesh &mesh, const UniformScaleFields &fields) { - const bke::MeshFieldContext field_context{mesh, ATTR_DOMAIN_FACE}; + const bke::MeshFieldContext field_context{mesh, AttrDomain::Face}; FieldEvaluator evaluator{field_context, mesh.faces_num}; UniformScaleParams params = evaluate_uniform_scale_fields(evaluator, fields); @@ -379,7 +379,7 @@ static void get_edge_verts(const Span edges, static void scale_edges_uniformly(Mesh &mesh, const UniformScaleFields &fields) { - const bke::MeshFieldContext field_context{mesh, ATTR_DOMAIN_EDGE}; + const bke::MeshFieldContext field_context{mesh, AttrDomain::Edge}; FieldEvaluator evaluator{field_context, mesh.edges_num}; UniformScaleParams params = evaluate_uniform_scale_fields(evaluator, fields); @@ -389,7 +389,7 @@ static void scale_edges_uniformly(Mesh &mesh, const UniformScaleFields &fields) static void scale_edges_on_axis(Mesh &mesh, const AxisScaleFields &fields) { - const bke::MeshFieldContext field_context{mesh, ATTR_DOMAIN_EDGE}; + const bke::MeshFieldContext field_context{mesh, AttrDomain::Edge}; FieldEvaluator evaluator{field_context, mesh.edges_num}; AxisScaleParams params = evaluate_axis_scale_fields(evaluator, fields); @@ -400,7 +400,7 @@ static void scale_edges_on_axis(Mesh &mesh, const AxisScaleFields &fields) static void node_geo_exec(GeoNodeExecParams params) { const bNode &node = params.node(); - const eAttrDomain domain = eAttrDomain(node.custom1); + const AttrDomain domain = AttrDomain(node.custom1); const GeometryNodeScaleElementsMode scale_mode = GeometryNodeScaleElementsMode(node.custom2); GeometrySet geometry = params.extract_input("Geometry"); @@ -416,7 +416,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry.modify_geometry_sets([&](GeometrySet &geometry) { if (Mesh *mesh = geometry.get_mesh_for_write()) { switch (domain) { - case ATTR_DOMAIN_FACE: { + case AttrDomain::Face: { switch (scale_mode) { case GEO_NODE_SCALE_ELEMENTS_UNIFORM: { scale_faces_uniformly(*mesh, {selection_field, scale_field, center_field}); @@ -429,7 +429,7 @@ static void node_geo_exec(GeoNodeExecParams params) } break; } - case ATTR_DOMAIN_EDGE: { + case AttrDomain::Edge: { switch (scale_mode) { case GEO_NODE_SCALE_ELEMENTS_UNIFORM: { scale_edges_uniformly(*mesh, {selection_field, scale_field, center_field}); @@ -455,12 +455,12 @@ static void node_geo_exec(GeoNodeExecParams params) static void node_rna(StructRNA *srna) { static const EnumPropertyItem domain_items[] = { - {ATTR_DOMAIN_FACE, + {int(AttrDomain::Face), "FACE", ICON_NONE, "Face", "Scale individual faces or neighboring face islands"}, - {ATTR_DOMAIN_EDGE, + {int(AttrDomain::Edge), "EDGE", ICON_NONE, "Edge", @@ -488,7 +488,7 @@ static void node_rna(StructRNA *srna) "Element type to transform", domain_items, NOD_inline_enum_accessors(custom1), - ATTR_DOMAIN_FACE); + int(AttrDomain::Face)); RNA_def_node_enum( srna, "scale_mode", "Scale Mode", "", scale_mode_items, NOD_inline_enum_accessors(custom2)); diff --git a/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc index fc4b8865db3..ff649dba834 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc @@ -39,8 +39,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { NodeGeometrySeparateGeometry *data = MEM_cnew(__func__); - data->domain = ATTR_DOMAIN_POINT; - + data->domain = int8_t(AttrDomain::Point); node->storage = data; } @@ -51,14 +50,14 @@ static void node_geo_exec(GeoNodeExecParams params) const Field selection_field = params.extract_input>("Selection"); const NodeGeometrySeparateGeometry &storage = node_storage(params.node()); - const eAttrDomain domain = eAttrDomain(storage.domain); + const AttrDomain domain = AttrDomain(storage.domain); auto separate_geometry_maybe_recursively = [&](GeometrySet &geometry_set, const Field &selection, const AnonymousAttributePropagationInfo &propagation_info) { bool is_error; - if (domain == ATTR_DOMAIN_INSTANCE) { + if (domain == AttrDomain::Instance) { /* Only delete top level instances. */ separate_geometry(geometry_set, domain, @@ -101,7 +100,7 @@ static void node_rna(StructRNA *srna) "Which domain to separate on", rna_enum_attribute_domain_without_corner_items, NOD_storage_enum_accessors(domain), - ATTR_DOMAIN_POINT); + int(AttrDomain::Point)); } static void node_register() diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc b/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc index f0ad0e2ac5a..bc3a25e972f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc @@ -92,7 +92,7 @@ static void set_position_in_component(bke::CurvesGeometry &curves, return; } - const bke::CurvesFieldContext field_context{curves, ATTR_DOMAIN_POINT}; + const bke::CurvesFieldContext field_context{curves, AttrDomain::Point}; fn::FieldEvaluator evaluator{field_context, curves.points_num()}; evaluator.set_selection(selection_field); evaluator.add(position_field); diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_curve_normal.cc b/source/blender/nodes/geometry/nodes/node_geo_set_curve_normal.cc index b2a5e9ab0bc..a50bdedcfe1 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_curve_normal.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_curve_normal.cc @@ -59,7 +59,7 @@ static void set_grease_pencil_normal(GreasePencil &grease_pencil, } bke::CurvesGeometry &curves = drawing->strokes_for_write(); const bke::GreasePencilLayerFieldContext field_context( - grease_pencil, ATTR_DOMAIN_CURVE, layer_index); + grease_pencil, AttrDomain::Curve, layer_index); set_curve_normal(curves, mode, field_context, selection_field); } } @@ -74,7 +74,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (Curves *curves_id = geometry_set.get_curves_for_write()) { bke::CurvesGeometry &curves = curves_id->geometry.wrap(); - const bke::CurvesFieldContext field_context{curves, ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext field_context{curves, AttrDomain::Curve}; set_curve_normal(curves, mode, field_context, selection_field); } if (geometry_set.has_grease_pencil()) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_curve_radius.cc b/source/blender/nodes/geometry/nodes/node_geo_set_curve_radius.cc index 0f89b6f7de9..ddd6a9c3378 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_curve_radius.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_curve_radius.cc @@ -32,7 +32,7 @@ static void set_radius(bke::CurvesGeometry &curves, } MutableAttributeAccessor attributes = curves.attributes_for_write(); AttributeWriter radii = attributes.lookup_or_add_for_write("radius", - ATTR_DOMAIN_POINT); + AttrDomain::Point); fn::FieldEvaluator evaluator{field_context, curves.points_num()}; evaluator.set_selection(selection_field); evaluator.add_with_destination(radius_field, radii.varray); @@ -50,7 +50,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (Curves *curves_id = geometry_set.get_curves_for_write()) { bke::CurvesGeometry &curves = curves_id->geometry.wrap(); - const bke::CurvesFieldContext field_context{curves, ATTR_DOMAIN_POINT}; + const bke::CurvesFieldContext field_context{curves, AttrDomain::Point}; set_radius(curves, field_context, selection_field, radii_field); } @@ -65,7 +65,7 @@ static void node_geo_exec(GeoNodeExecParams params) } bke::CurvesGeometry &curves = drawing->strokes_for_write(); const bke::GreasePencilLayerFieldContext field_context( - *grease_pencil, ATTR_DOMAIN_POINT, layer_index); + *grease_pencil, AttrDomain::Point, layer_index); set_radius(curves, field_context, selection_field, radii_field); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_curve_tilt.cc b/source/blender/nodes/geometry/nodes/node_geo_set_curve_tilt.cc index 10857cedae0..d18af3246d5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_curve_tilt.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_curve_tilt.cc @@ -28,7 +28,7 @@ static void set_curve_tilt(bke::CurvesGeometry &curves, } MutableAttributeAccessor attributes = curves.attributes_for_write(); AttributeWriter tilts = attributes.lookup_or_add_for_write("tilt", - ATTR_DOMAIN_POINT); + AttrDomain::Point); fn::FieldEvaluator evaluator{field_context, curves.points_num()}; evaluator.set_selection(selection_field); evaluator.add_with_destination(tilt_field, tilts.varray); @@ -49,7 +49,7 @@ static void set_grease_pencil_tilt(GreasePencil &grease_pencil, } bke::CurvesGeometry &curves = drawing->strokes_for_write(); const bke::GreasePencilLayerFieldContext field_context( - grease_pencil, ATTR_DOMAIN_POINT, layer_index); + grease_pencil, AttrDomain::Point, layer_index); set_curve_tilt(curves, field_context, selection_field, tilt_field); } } @@ -63,7 +63,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (Curves *curves_id = geometry_set.get_curves_for_write()) { bke::CurvesGeometry &curves = curves_id->geometry.wrap(); - const bke::CurvesFieldContext field_context{curves, ATTR_DOMAIN_POINT}; + const bke::CurvesFieldContext field_context{curves, AttrDomain::Point}; set_curve_tilt(curves, field_context, selection_field, tilt_field); } if (geometry_set.has_grease_pencil()) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_id.cc b/source/blender/nodes/geometry/nodes/node_geo_set_id.cc index c1b2d6f6c5b..bf2346b4ea8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_id.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_id.cc @@ -18,9 +18,9 @@ static void set_id_in_component(GeometryComponent &component, const Field &selection_field, const Field &id_field) { - const eAttrDomain domain = (component.type() == GeometryComponent::Type::Instance) ? - ATTR_DOMAIN_INSTANCE : - ATTR_DOMAIN_POINT; + const AttrDomain domain = (component.type() == GeometryComponent::Type::Instance) ? + AttrDomain::Instance : + AttrDomain::Point; const int domain_size = component.attribute_domain_size(domain); if (domain_size == 0) { return; diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_material.cc b/source/blender/nodes/geometry/nodes/node_geo_set_material.cc index adcbb1a8fb1..fcf4418b980 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_material.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_material.cc @@ -37,7 +37,7 @@ static void assign_material_to_id_geometry(ID *id, const fn::FieldContext &field_context, const Field &selection_field, MutableAttributeAccessor &attributes, - const eAttrDomain domain, + const AttrDomain domain, Material *material) { const int domain_size = attributes.domain_size(domain); @@ -91,10 +91,10 @@ static void node_geo_exec(GeoNodeExecParams params) } } else { - const bke::MeshFieldContext field_context{*mesh, ATTR_DOMAIN_FACE}; + const bke::MeshFieldContext field_context{*mesh, AttrDomain::Face}; MutableAttributeAccessor attributes = mesh->attributes_for_write(); assign_material_to_id_geometry( - &mesh->id, field_context, selection_field, attributes, ATTR_DOMAIN_FACE, material); + &mesh->id, field_context, selection_field, attributes, AttrDomain::Face, material); } } if (Volume *volume = geometry_set.get_volume_for_write()) { @@ -130,13 +130,13 @@ static void node_geo_exec(GeoNodeExecParams params) } const bke::GreasePencilLayerFieldContext field_context{ - *grease_pencil, ATTR_DOMAIN_CURVE, layer_index}; + *grease_pencil, AttrDomain::Curve, layer_index}; MutableAttributeAccessor attributes = curves.attributes_for_write(); assign_material_to_id_geometry(&grease_pencil->id, field_context, selection_field, attributes, - ATTR_DOMAIN_CURVE, + AttrDomain::Curve, material); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_material_index.cc b/source/blender/nodes/geometry/nodes/node_geo_set_material_index.cc index fdb0998abc1..090abb307b0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_material_index.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_material_index.cc @@ -24,7 +24,7 @@ static void set_material_index_in_geometry(const fn::FieldContext &field_context const Field &selection_field, const Field &index_field, MutableAttributeAccessor &attributes, - const eAttrDomain domain) + const AttrDomain domain) { const int domain_size = attributes.domain_size(domain); if (domain_size == 0) { @@ -59,9 +59,9 @@ static void set_material_index_in_grease_pencil(GreasePencil &grease_pencil, MutableAttributeAccessor attributes = curves.attributes_for_write(); const bke::GreasePencilLayerFieldContext field_context{ - grease_pencil, ATTR_DOMAIN_CURVE, layer_index}; + grease_pencil, AttrDomain::Curve, layer_index}; set_material_index_in_geometry( - field_context, selection_field, index_field, attributes, ATTR_DOMAIN_CURVE); + field_context, selection_field, index_field, attributes, AttrDomain::Curve); } } @@ -75,10 +75,10 @@ static void node_geo_exec(GeoNodeExecParams params) if (geometry_set.has_mesh()) { GeometryComponent &component = geometry_set.get_component_for_write(); const bke::GeometryFieldContext field_context{ - geometry_set.get_component_for_write(), ATTR_DOMAIN_FACE}; + geometry_set.get_component_for_write(), AttrDomain::Face}; MutableAttributeAccessor attributes = *component.attributes_for_write(); set_material_index_in_geometry( - field_context, selection_field, index_field, attributes, ATTR_DOMAIN_FACE); + field_context, selection_field, index_field, attributes, AttrDomain::Face); } if (GreasePencil *grease_pencil = geometry_set.get_grease_pencil_for_write()) { set_material_index_in_grease_pencil(*grease_pencil, selection_field, index_field); diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_point_radius.cc b/source/blender/nodes/geometry/nodes/node_geo_set_point_radius.cc index d86509b1eb9..4128d8cec6d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_point_radius.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_point_radius.cc @@ -29,7 +29,7 @@ static void set_radius_in_component(PointCloud &pointcloud, } MutableAttributeAccessor attributes = pointcloud.attributes_for_write(); AttributeWriter radii = attributes.lookup_or_add_for_write("radius", - ATTR_DOMAIN_POINT); + AttrDomain::Point); const bke::PointCloudFieldContext field_context{pointcloud}; fn::FieldEvaluator evaluator{field_context, pointcloud.totpoint}; diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc index 10f3dc579a6..647fe756715 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc @@ -56,9 +56,9 @@ static void set_computed_position_and_offset(GeometryComponent &component, Curves &curves_id = *curve_component.get_for_write(); bke::CurvesGeometry &curves = curves_id.geometry.wrap(); SpanAttributeWriter handle_right_attribute = - attributes.lookup_or_add_for_write_span("handle_right", ATTR_DOMAIN_POINT); + attributes.lookup_or_add_for_write_span("handle_right", AttrDomain::Point); SpanAttributeWriter handle_left_attribute = - attributes.lookup_or_add_for_write_span("handle_left", ATTR_DOMAIN_POINT); + attributes.lookup_or_add_for_write_span("handle_left", AttrDomain::Point); AttributeWriter positions = attributes.lookup_for_write("position"); MutableVArraySpan out_positions_span = positions.varray; @@ -123,7 +123,7 @@ static void set_position_in_grease_pencil(GreasePencilComponent &grease_pencil_c continue; } bke::GreasePencilLayerFieldContext field_context( - grease_pencil, ATTR_DOMAIN_POINT, layer_index); + grease_pencil, AttrDomain::Point, layer_index); fn::FieldEvaluator evaluator{field_context, drawing->strokes().points_num()}; evaluator.set_selection(selection_field); evaluator.add(position_field); @@ -151,9 +151,9 @@ static void set_position_in_component(GeometrySet &geometry, const Field &offset_field) { const GeometryComponent &component = *geometry.get_component(component_type); - const eAttrDomain domain = component.type() == GeometryComponent::Type::Instance ? - ATTR_DOMAIN_INSTANCE : - ATTR_DOMAIN_POINT; + const AttrDomain domain = component.type() == GeometryComponent::Type::Instance ? + AttrDomain::Instance : + AttrDomain::Point; const int domain_size = component.attribute_domain_size(domain); if (domain_size == 0) { return; diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_shade_smooth.cc b/source/blender/nodes/geometry/nodes/node_geo_set_shade_smooth.cc index 61ced20706f..d0befb084ab 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_shade_smooth.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_shade_smooth.cc @@ -30,7 +30,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - node->custom1 = ATTR_DOMAIN_FACE; + node->custom1 = int16_t(AttrDomain::Face); } /** @@ -59,7 +59,7 @@ static bool try_removing_sharp_attribute(Mesh &mesh, } static void set_sharp(Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const StringRef name, const Field &selection_field, const Field &sharp_field) @@ -87,7 +87,7 @@ static void set_sharp(Mesh &mesh, static void node_geo_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input("Geometry"); - const eAttrDomain domain = eAttrDomain(params.node().custom1); + const AttrDomain domain = AttrDomain(params.node().custom1); Field selection_field = params.extract_input>("Selection"); Field smooth_field = params.extract_input>("Shade Smooth"); @@ -95,7 +95,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (Mesh *mesh = geometry_set.get_mesh_for_write()) { set_sharp(*mesh, domain, - domain == ATTR_DOMAIN_FACE ? "sharp_face" : "sharp_edge", + domain == AttrDomain::Face ? "sharp_face" : "sharp_edge", selection_field, fn::invert_boolean_field(smooth_field)); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_spline_cyclic.cc b/source/blender/nodes/geometry/nodes/node_geo_set_spline_cyclic.cc index da6b32046f4..948eddf8525 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_spline_cyclic.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_spline_cyclic.cc @@ -28,7 +28,7 @@ static void set_curve_cyclic(bke::CurvesGeometry &curves, } MutableAttributeAccessor attributes = curves.attributes_for_write(); AttributeWriter cyclics = attributes.lookup_or_add_for_write("cyclic", - ATTR_DOMAIN_CURVE); + AttrDomain::Curve); fn::FieldEvaluator evaluator{field_context, curves.curves_num()}; evaluator.set_selection(selection_field); evaluator.add_with_destination(cyclic_field, cyclics.varray); @@ -49,7 +49,7 @@ static void set_grease_pencil_cyclic(GreasePencil &grease_pencil, } bke::CurvesGeometry &curves = drawing->strokes_for_write(); const bke::GreasePencilLayerFieldContext field_context( - grease_pencil, ATTR_DOMAIN_CURVE, layer_index); + grease_pencil, AttrDomain::Curve, layer_index); set_curve_cyclic(curves, field_context, selection_field, cyclic_field); } } @@ -63,7 +63,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (Curves *curves_id = geometry_set.get_curves_for_write()) { bke::CurvesGeometry &curves = curves_id->geometry.wrap(); - const bke::CurvesFieldContext field_context{curves, ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext field_context{curves, AttrDomain::Curve}; set_curve_cyclic(curves_id->geometry.wrap(), field_context, selection_field, cyclic_field); } if (geometry_set.has_grease_pencil()) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_spline_resolution.cc b/source/blender/nodes/geometry/nodes/node_geo_set_spline_resolution.cc index 81c22382b43..30dbeb8d2fa 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_spline_resolution.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_spline_resolution.cc @@ -28,7 +28,7 @@ static void set_curve_resolution(bke::CurvesGeometry &curves, } MutableAttributeAccessor attributes = curves.attributes_for_write(); AttributeWriter resolutions = attributes.lookup_or_add_for_write("resolution", - ATTR_DOMAIN_CURVE); + AttrDomain::Curve); bke::AttributeValidator validator = attributes.lookup_validator("resolution"); fn::FieldEvaluator evaluator{field_context, curves.curves_num()}; @@ -52,7 +52,7 @@ static void set_grease_pencil_resolution(GreasePencil &grease_pencil, } bke::CurvesGeometry &curves = drawing->strokes_for_write(); const bke::GreasePencilLayerFieldContext field_context( - grease_pencil, ATTR_DOMAIN_CURVE, layer_index); + grease_pencil, AttrDomain::Curve, layer_index); set_curve_resolution(curves, field_context, selection_field, resolution_field); } } @@ -66,7 +66,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (Curves *curves_id = geometry_set.get_curves_for_write()) { bke::CurvesGeometry &curves = curves_id->geometry.wrap(); - const bke::CurvesFieldContext field_context{curves, ATTR_DOMAIN_CURVE}; + const bke::CurvesFieldContext field_context{curves, AttrDomain::Curve}; set_curve_resolution(curves_id->geometry.wrap(), field_context, selection, resolution); } if (geometry_set.has_grease_pencil()) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc b/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc index e3ca87ff887..e085bfd5324 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc @@ -76,7 +76,7 @@ static bke::bake::BakeSocketConfig make_bake_socket_config( for (const int item_i : node_simulation_items.index_range()) { const NodeSimulationItem &item = node_simulation_items[item_i]; config.types[item_i] = eNodeSocketDatatype(item.socket_type); - config.domains[item_i] = eAttrDomain(item.attribute_domain); + config.domains[item_i] = AttrDomain(item.attribute_domain); if (item.socket_type == SOCK_GEOMETRY) { last_geometry_index = item_i; } @@ -251,7 +251,7 @@ static void mix_with_indices(MutableSpan prev, static void mix_attributes(MutableAttributeAccessor prev_attributes, const AttributeAccessor next_attributes, const Span index_map, - const eAttrDomain mix_domain, + const AttrDomain mix_domain, const float factor, const Set &names_to_skip = {}) { @@ -263,7 +263,7 @@ static void mix_attributes(MutableAttributeAccessor prev_attributes, for (const AttributeIDRef &id : ids) { const GAttributeReader prev = prev_attributes.lookup(id); - const eAttrDomain domain = prev.domain; + const AttrDomain domain = prev.domain; if (domain != mix_domain) { continue; } @@ -334,7 +334,7 @@ static void mix_geometries(GeometrySet &prev, const GeometrySet &next, const flo mix_attributes(mesh_prev->attributes_for_write(), mesh_next->attributes(), vert_map, - ATTR_DOMAIN_POINT, + AttrDomain::Point, factor, {}); } @@ -346,7 +346,7 @@ static void mix_geometries(GeometrySet &prev, const GeometrySet &next, const flo mix_attributes(points_prev->attributes_for_write(), points_next->attributes(), index_map, - ATTR_DOMAIN_POINT, + AttrDomain::Point, factor); } } @@ -358,7 +358,7 @@ static void mix_geometries(GeometrySet &prev, const GeometrySet &next, const flo mix_attributes(prev, next, index_map, - ATTR_DOMAIN_POINT, + AttrDomain::Point, factor, {"handle_type_left", "handle_type_right"}); } @@ -370,7 +370,7 @@ static void mix_geometries(GeometrySet &prev, const GeometrySet &next, const flo mix_attributes(instances_prev->attributes_for_write(), instances_next->attributes(), index_map, - ATTR_DOMAIN_INSTANCE, + AttrDomain::Instance, factor, {"position"}); if (index_map.is_empty()) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_split_to_instances.cc b/source/blender/nodes/geometry/nodes/node_geo_split_to_instances.cc index 101c1a817f0..7a4f6f389fa 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_split_to_instances.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_split_to_instances.cc @@ -71,7 +71,7 @@ struct SplitGroups { */ [[nodiscard]] static bool do_common_split( const GeometryComponent &src_component, - const eAttrDomain domain, + const AttrDomain domain, const Field &selection_field, const Field &group_id_field, Map> &geometry_by_group_id, @@ -115,7 +115,7 @@ struct SplitGroups { } static void split_mesh_groups(const MeshComponent &component, - const eAttrDomain domain, + const AttrDomain domain, const Field &selection_field, const Field &group_id_field, const AnonymousAttributePropagationInfo &propagation_info, @@ -174,7 +174,7 @@ static void split_pointcloud_groups(const PointCloudComponent &component, { SplitGroups split_groups; if (do_common_split(component, - ATTR_DOMAIN_POINT, + AttrDomain::Point, selection_field, group_id_field, geometry_by_group_id, @@ -193,7 +193,7 @@ static void split_pointcloud_groups(const PointCloudComponent &component, const AttributeAccessor src_attributes = src_pointcloud.attributes(); MutableAttributeAccessor dst_attributes = group_pointcloud->attributes_for_write(); bke::gather_attributes( - src_attributes, ATTR_DOMAIN_POINT, propagation_info, {}, mask, dst_attributes); + src_attributes, AttrDomain::Point, propagation_info, {}, mask, dst_attributes); GeometrySet &group_geometry = *geometry_by_group_id.lookup(group_id); group_geometry.replace_pointcloud(group_pointcloud); @@ -202,7 +202,7 @@ static void split_pointcloud_groups(const PointCloudComponent &component, } static void split_curve_groups(const bke::CurveComponent &component, - const eAttrDomain domain, + const AttrDomain domain, const Field &selection_field, const Field &group_id_field, const AnonymousAttributePropagationInfo &propagation_info, @@ -221,7 +221,7 @@ static void split_curve_groups(const bke::CurveComponent &component, const int group_id = split_groups.group_ids[group_index]; bke::CurvesGeometry group_curves; - if (domain == ATTR_DOMAIN_POINT) { + if (domain == AttrDomain::Point) { group_curves = bke::curves_copy_point_selection(src_curves, mask, propagation_info); } else { @@ -242,7 +242,7 @@ static void split_instance_groups(const InstancesComponent &component, { SplitGroups split_groups; if (do_common_split(component, - ATTR_DOMAIN_INSTANCE, + AttrDomain::Instance, selection_field, group_id_field, geometry_by_group_id, @@ -267,7 +267,7 @@ static void split_instance_groups(const InstancesComponent &component, array_utils::gather( src_instances.reference_handles(), mask, group_instances->reference_handles()); bke::gather_attributes(src_instances.attributes(), - ATTR_DOMAIN_INSTANCE, + AttrDomain::Instance, propagation_info, {}, mask, @@ -283,7 +283,7 @@ static void split_instance_groups(const InstancesComponent &component, static void node_geo_exec(GeoNodeExecParams params) { const bNode &node = params.node(); - const eAttrDomain domain = eAttrDomain(node.custom1); + const AttrDomain domain = AttrDomain(node.custom1); GeometrySet src_geometry = params.extract_input("Geometry"); const Field selection_field = params.extract_input>("Selection"); @@ -295,7 +295,7 @@ static void node_geo_exec(GeoNodeExecParams params) Map> geometry_by_group_id; if (src_geometry.has_mesh() && - ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_EDGE, ATTR_DOMAIN_FACE)) { + ELEM(domain, AttrDomain::Point, AttrDomain::Edge, AttrDomain::Face)) { const auto &component = *src_geometry.get_component(); split_mesh_groups(component, domain, @@ -304,12 +304,12 @@ static void node_geo_exec(GeoNodeExecParams params) propagation_info, geometry_by_group_id); } - if (src_geometry.has_pointcloud() && domain == ATTR_DOMAIN_POINT) { + if (src_geometry.has_pointcloud() && domain == AttrDomain::Point) { const auto &component = *src_geometry.get_component(); split_pointcloud_groups( component, selection_field, group_id_field, propagation_info, geometry_by_group_id); } - if (src_geometry.has_curves() && ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) { + if (src_geometry.has_curves() && ELEM(domain, AttrDomain::Point, AttrDomain::Curve)) { const auto &component = *src_geometry.get_component(); split_curve_groups(component, domain, @@ -318,7 +318,7 @@ static void node_geo_exec(GeoNodeExecParams params) propagation_info, geometry_by_group_id); } - if (src_geometry.has_instances() && domain == ATTR_DOMAIN_INSTANCE) { + if (src_geometry.has_instances() && domain == AttrDomain::Instance) { const auto &component = *src_geometry.get_component(); split_instance_groups( component, selection_field, group_id_field, propagation_info, geometry_by_group_id); @@ -334,7 +334,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (dst_group_id_attribute_id) { SpanAttributeWriter dst_group_id = dst_instances->attributes_for_write().lookup_or_add_for_write_span( - *dst_group_id_attribute_id, ATTR_DOMAIN_INSTANCE); + *dst_group_id_attribute_id, AttrDomain::Instance); std::copy(geometry_by_group_id.keys().begin(), geometry_by_group_id.keys().end(), dst_group_id.span.begin()); @@ -362,7 +362,7 @@ static void node_rna(StructRNA *srna) "Attribute domain for the Selection and Group ID inputs", rna_enum_attribute_domain_without_corner_items, NOD_inline_enum_accessors(custom1), - ATTR_DOMAIN_POINT, + int(AttrDomain::Point), enums::domain_without_corner_experimental_grease_pencil_version3_fn); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc index 1d9a4355a9f..b7a27497715 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc @@ -54,7 +54,7 @@ static void node_init(bNodeTree * /*tree*/, bNode *node) { NodeGeometryStoreNamedAttribute *data = MEM_cnew(__func__); data->data_type = CD_PROP_FLOAT; - data->domain = ATTR_DOMAIN_POINT; + data->domain = int8_t(AttrDomain::Point); node->storage = data; } @@ -97,7 +97,7 @@ static void node_geo_exec(GeoNodeExecParams params) const NodeGeometryStoreNamedAttribute &storage = node_storage(params.node()); const eCustomDataType data_type = eCustomDataType(storage.data_type); - const eAttrDomain domain = eAttrDomain(storage.domain); + const AttrDomain domain = AttrDomain(storage.domain); const Field selection = params.extract_input>("Selection"); @@ -114,7 +114,7 @@ static void node_geo_exec(GeoNodeExecParams params) std::atomic failure = false; /* Run on the instances component separately to only affect the top level of instances. */ - if (domain == ATTR_DOMAIN_INSTANCE) { + if (domain == AttrDomain::Instance) { if (geometry_set.has_instances()) { GeometryComponent &component = geometry_set.get_component_for_write( GeometryComponent::Type::Instance); @@ -146,7 +146,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (failure) { const char *domain_name = nullptr; - RNA_enum_name_from_value(rna_enum_attribute_domain_items, domain, &domain_name); + RNA_enum_name_from_value(rna_enum_attribute_domain_items, int(domain), &domain_name); const char *type_name = nullptr; RNA_enum_name_from_value(rna_enum_attribute_type_items, data_type, &type_name); const std::string message = fmt::format( @@ -182,7 +182,7 @@ static void node_rna(StructRNA *srna) "Which domain to store the data in", rna_enum_attribute_domain_items, NOD_storage_enum_accessors(domain), - ATTR_DOMAIN_POINT, + int(AttrDomain::Point), enums::domain_experimental_grease_pencil_version3_fn); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc index 86ad17fca82..36229517354 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc @@ -340,7 +340,7 @@ static void create_attributes(GeoNodeExecParams ¶ms, if (AnonymousAttributeIDPtr line_id = params.get_output_anonymous_attribute_id_if_needed("Line")) { SpanAttributeWriter line_attribute = attributes.lookup_or_add_for_write_only_span( - *line_id, ATTR_DOMAIN_INSTANCE); + *line_id, AttrDomain::Instance); line_attribute.span.copy_from(layout.line_numbers); line_attribute.finish(); } @@ -349,7 +349,7 @@ static void create_attributes(GeoNodeExecParams ¶ms, "Pivot Point")) { SpanAttributeWriter pivot_attribute = - attributes.lookup_or_add_for_write_only_span(*pivot_id, ATTR_DOMAIN_INSTANCE); + attributes.lookup_or_add_for_write_only_span(*pivot_id, AttrDomain::Instance); for (const int i : layout.char_codes.index_range()) { pivot_attribute.span[i] = layout.pivot_points.lookup(layout.char_codes[i]); diff --git a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc index dac07d95ab9..5c1d9482ec0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc @@ -67,14 +67,14 @@ static void write_vert_creases(Mesh &mesh, const VArray &creases) { bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); attributes.remove("crease_vert"); - attributes.add("crease_vert", ATTR_DOMAIN_POINT, bke::AttributeInitVArray(creases)); + attributes.add("crease_vert", AttrDomain::Point, bke::AttributeInitVArray(creases)); } static void write_edge_creases(Mesh &mesh, const VArray &creases) { bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); attributes.remove("crease_edge"); - attributes.add("crease_edge", ATTR_DOMAIN_EDGE, bke::AttributeInitVArray(creases)); + attributes.add("crease_edge", AttrDomain::Edge, bke::AttributeInitVArray(creases)); } static bool varray_is_single_zero(const VArray &varray) @@ -101,12 +101,12 @@ static Mesh *mesh_subsurf_calc(const Mesh *mesh, const int boundary_smooth, const int uv_smooth) { - const bke::MeshFieldContext point_context{*mesh, ATTR_DOMAIN_POINT}; + const bke::MeshFieldContext point_context{*mesh, AttrDomain::Point}; FieldEvaluator point_evaluator(point_context, mesh->verts_num); point_evaluator.add(clamp_crease(vert_crease_field)); point_evaluator.evaluate(); - const bke::MeshFieldContext edge_context{*mesh, ATTR_DOMAIN_EDGE}; + const bke::MeshFieldContext edge_context{*mesh, AttrDomain::Edge}; FieldEvaluator edge_evaluator(edge_context, mesh->edges_num); edge_evaluator.add(clamp_crease(edge_crease_field)); edge_evaluator.evaluate(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_tool_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_tool_selection.cc index e3306f1c548..8d3dbaa3aad 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_tool_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_tool_selection.cc @@ -23,7 +23,7 @@ class ToolSelectionFieldInput final : public bke::GeometryFieldInput { GVArray get_varray_for_context(const bke::GeometryFieldContext &context, const IndexMask & /*mask*/) const final { - const eAttrDomain domain = context.domain(); + const AttrDomain domain = context.domain(); const AttributeAccessor attributes = *context.attributes(); switch (context.type()) { case GeometryComponent::Type::Curve: @@ -31,12 +31,12 @@ class ToolSelectionFieldInput final : public bke::GeometryFieldInput { return *attributes.lookup_or_default(".selection", domain, true); case GeometryComponent::Type::Mesh: switch (domain) { - case ATTR_DOMAIN_POINT: + case AttrDomain::Point: return *attributes.lookup_or_default(".select_vert", domain, false); - case ATTR_DOMAIN_EDGE: + case AttrDomain::Edge: return *attributes.lookup_or_default(".select_edge", domain, false); - case ATTR_DOMAIN_FACE: - case ATTR_DOMAIN_CORNER: + case AttrDomain::Face: + case AttrDomain::Corner: return *attributes.lookup_or_default(".select_poly", domain, false); default: BLI_assert_unreachable(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_tool_set_face_set.cc b/source/blender/nodes/geometry/nodes/node_geo_tool_set_face_set.cc index 6dd0f0f46b5..c390af09eef 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_tool_set_face_set.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_tool_set_face_set.cc @@ -45,7 +45,7 @@ static void node_geo_exec(GeoNodeExecParams params) else { bke::try_capture_field_on_geometry(geometry.get_component_for_write(), ".sculpt_face_set", - ATTR_DOMAIN_FACE, + AttrDomain::Face, selection, face_set); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_tool_set_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_tool_set_selection.cc index df523e65645..0565b6845f7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_tool_set_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_tool_set_selection.cc @@ -29,7 +29,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_init(bNodeTree * /*tree*/, bNode *node) { - node->custom1 = ATTR_DOMAIN_POINT; + node->custom1 = int16_t(AttrDomain::Point); } static void node_geo_exec(GeoNodeExecParams params) @@ -45,36 +45,36 @@ static void node_geo_exec(GeoNodeExecParams params) return; } const Field selection = params.extract_input>("Selection"); - const eAttrDomain domain = eAttrDomain(params.node().custom1); + const AttrDomain domain = AttrDomain(params.node().custom1); geometry.modify_geometry_sets([&](GeometrySet &geometry) { if (Mesh *mesh = geometry.get_mesh_for_write()) { switch (domain) { - case ATTR_DOMAIN_POINT: + case AttrDomain::Point: /* Remove attributes in case they are on the wrong domain, which can happen after * conversion to and from other geometry types. */ mesh->attributes_for_write().remove(".select_edge"); mesh->attributes_for_write().remove(".select_poly"); bke::try_capture_field_on_geometry(geometry.get_component_for_write(), ".select_vert", - ATTR_DOMAIN_POINT, + AttrDomain::Point, selection); bke::mesh_select_vert_flush(*mesh); break; - case ATTR_DOMAIN_EDGE: + case AttrDomain::Edge: bke::try_capture_field_on_geometry(geometry.get_component_for_write(), ".select_edge", - ATTR_DOMAIN_EDGE, + AttrDomain::Edge, selection); bke::mesh_select_edge_flush(*mesh); break; - case ATTR_DOMAIN_FACE: + case AttrDomain::Face: /* Remove attributes in case they are on the wrong domain, which can happen after * conversion to and from other geometry types. */ mesh->attributes_for_write().remove(".select_vert"); mesh->attributes_for_write().remove(".select_edge"); bke::try_capture_field_on_geometry(geometry.get_component_for_write(), ".select_poly", - ATTR_DOMAIN_FACE, + AttrDomain::Face, selection); bke::mesh_select_face_flush(*mesh); break; @@ -83,13 +83,13 @@ static void node_geo_exec(GeoNodeExecParams params) } } if (geometry.has_curves()) { - if (ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) { + if (ELEM(domain, AttrDomain::Point, AttrDomain::Curve)) { bke::try_capture_field_on_geometry( geometry.get_component_for_write(), ".selection", domain, selection); } } if (geometry.has_pointcloud()) { - if (domain == ATTR_DOMAIN_POINT) { + if (domain == AttrDomain::Point) { bke::try_capture_field_on_geometry(geometry.get_component_for_write(), ".selection", domain, @@ -108,7 +108,7 @@ static void node_rna(StructRNA *srna) "", rna_enum_attribute_domain_point_edge_face_curve_items, NOD_inline_enum_accessors(custom1), - ATTR_DOMAIN_POINT); + int(AttrDomain::Point)); } static void node_register() diff --git a/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc index 53f2b3b44f6..33871ccf88f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc @@ -78,7 +78,7 @@ static void translate_pointcloud(PointCloud &pointcloud, const float3 translatio MutableAttributeAccessor attributes = pointcloud.attributes_for_write(); SpanAttributeWriter position = attributes.lookup_or_add_for_write_span( - "position", ATTR_DOMAIN_POINT); + "position", AttrDomain::Point); translate_positions(position.span, translation); position.finish(); @@ -93,7 +93,7 @@ static void transform_pointcloud(PointCloud &pointcloud, const float4x4 &transfo { MutableAttributeAccessor attributes = pointcloud.attributes_for_write(); SpanAttributeWriter position = attributes.lookup_or_add_for_write_span( - "position", ATTR_DOMAIN_POINT); + "position", AttrDomain::Point); transform_positions(position.span, transform); position.finish(); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc b/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc index 6d4c1689a58..e67469b41a0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc @@ -91,7 +91,7 @@ static void node_geo_exec(GeoNodeExecParams params) } const Mesh &mesh_in = *geometry_set.get_mesh(); - const bke::MeshFieldContext context{mesh_in, ATTR_DOMAIN_FACE}; + const bke::MeshFieldContext context{mesh_in, AttrDomain::Face}; FieldEvaluator evaluator{context, mesh_in.faces_num}; evaluator.add(selection_field); evaluator.evaluate(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc b/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc index a63203e66ed..3361cdcf098 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_uv_pack_islands.cc @@ -32,13 +32,13 @@ static VArray construct_uv_gvarray(const Mesh &mesh, const Field uv_field, const bool rotate, const float margin, - const eAttrDomain domain) + const AttrDomain domain) { const Span positions = mesh.vert_positions(); const OffsetIndices faces = mesh.faces(); const Span corner_verts = mesh.corner_verts(); - const bke::MeshFieldContext face_context{mesh, ATTR_DOMAIN_FACE}; + const bke::MeshFieldContext face_context{mesh, AttrDomain::Face}; FieldEvaluator face_evaluator{face_context, faces.size()}; face_evaluator.add(selection_field); face_evaluator.evaluate(); @@ -47,7 +47,7 @@ static VArray construct_uv_gvarray(const Mesh &mesh, return {}; } - const bke::MeshFieldContext corner_context{mesh, ATTR_DOMAIN_CORNER}; + const bke::MeshFieldContext corner_context{mesh, AttrDomain::Corner}; FieldEvaluator evaluator{corner_context, mesh.corners_num}; Array uv(mesh.corners_num); evaluator.add_with_destination(uv_field, uv.as_mutable_span()); @@ -86,7 +86,7 @@ static VArray construct_uv_gvarray(const Mesh &mesh, delete (handle); return mesh.attributes().adapt_domain( - VArray::ForContainer(std::move(uv)), ATTR_DOMAIN_CORNER, domain); + VArray::ForContainer(std::move(uv)), AttrDomain::Corner, domain); } class PackIslandsFieldInput final : public bke::MeshFieldInput { @@ -111,7 +111,7 @@ class PackIslandsFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { return construct_uv_gvarray(mesh, selection_field_, uv_field_, rotate_, margin_, domain); @@ -123,9 +123,9 @@ class PackIslandsFieldInput final : public bke::MeshFieldInput { uv_field_.node().for_each_field_input_recursive(fn); } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_CORNER; + return AttrDomain::Corner; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc b/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc index d1c3bf35e7a..ed20fe03563 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc @@ -60,14 +60,14 @@ static VArray construct_uv_gvarray(const Mesh &mesh, const bool fill_holes, const float margin, const GeometryNodeUVUnwrapMethod method, - const eAttrDomain domain) + const AttrDomain domain) { const Span positions = mesh.vert_positions(); const Span edges = mesh.edges(); const OffsetIndices faces = mesh.faces(); const Span corner_verts = mesh.corner_verts(); - const bke::MeshFieldContext face_context{mesh, ATTR_DOMAIN_FACE}; + const bke::MeshFieldContext face_context{mesh, AttrDomain::Face}; FieldEvaluator face_evaluator{face_context, faces.size()}; face_evaluator.add(selection_field); face_evaluator.evaluate(); @@ -76,7 +76,7 @@ static VArray construct_uv_gvarray(const Mesh &mesh, return {}; } - const bke::MeshFieldContext edge_context{mesh, ATTR_DOMAIN_EDGE}; + const bke::MeshFieldContext edge_context{mesh, AttrDomain::Edge}; FieldEvaluator edge_evaluator{edge_context, edges.size()}; edge_evaluator.add(seam_field); edge_evaluator.evaluate(); @@ -130,7 +130,7 @@ static VArray construct_uv_gvarray(const Mesh &mesh, delete (handle); return mesh.attributes().adapt_domain( - VArray::ForContainer(std::move(uv)), ATTR_DOMAIN_CORNER, domain); + VArray::ForContainer(std::move(uv)), AttrDomain::Corner, domain); } class UnwrapFieldInput final : public bke::MeshFieldInput { @@ -158,7 +158,7 @@ class UnwrapFieldInput final : public bke::MeshFieldInput { } GVArray get_varray_for_context(const Mesh &mesh, - const eAttrDomain domain, + const AttrDomain domain, const IndexMask & /*mask*/) const final { return construct_uv_gvarray(mesh, selection_, seam_, fill_holes_, margin_, method_, domain); @@ -170,9 +170,9 @@ class UnwrapFieldInput final : public bke::MeshFieldInput { seam_.node().for_each_field_input_recursive(fn); } - std::optional preferred_domain(const Mesh & /*mesh*/) const override + std::optional preferred_domain(const Mesh & /*mesh*/) const override { - return ATTR_DOMAIN_CORNER; + return AttrDomain::Corner; } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_viewer.cc b/source/blender/nodes/geometry/nodes/node_geo_viewer.cc index d07de4a8d71..cf00e0fc3b5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_viewer.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_viewer.cc @@ -36,8 +36,7 @@ static void node_init(bNodeTree * /*tree*/, bNode *node) { NodeGeometryViewer *data = MEM_cnew(__func__); data->data_type = CD_PROP_FLOAT; - data->domain = ATTR_DOMAIN_AUTO; - + data->domain = int8_t(AttrDomain::Auto); node->storage = data; } @@ -120,7 +119,7 @@ static void node_rna(StructRNA *srna) "Domain to evaluate the field on", rna_enum_attribute_domain_with_auto_items, NOD_storage_enum_accessors(domain), - ATTR_DOMAIN_POINT); + int(AttrDomain::Point)); } static void node_register() diff --git a/source/blender/nodes/intern/geometry_nodes_execute.cc b/source/blender/nodes/intern/geometry_nodes_execute.cc index b0ae01412ea..d53dd9150d8 100644 --- a/source/blender/nodes/intern/geometry_nodes_execute.cc +++ b/source/blender/nodes/intern/geometry_nodes_execute.cc @@ -531,7 +531,7 @@ struct OutputAttributeInfo { struct OutputAttributeToStore { bke::GeometryComponent::Type component_type; - eAttrDomain domain; + bke::AttrDomain domain; StringRefNull name; GMutableSpan data; }; @@ -540,11 +540,11 @@ struct OutputAttributeToStore { * The output attributes are organized based on their domain, because attributes on the same domain * can be evaluated together. */ -static MultiValueMap find_output_attributes_to_store( +static MultiValueMap find_output_attributes_to_store( const bNodeTree &tree, const IDProperty *properties, Span output_values) { const bNode &output_node = *tree.group_output_node(); - MultiValueMap outputs_by_domain; + MultiValueMap outputs_by_domain; for (const bNodeSocket *socket : output_node.input_sockets().drop_front(1).drop_back(1)) { if (!socket_type_has_attribute_toggle(eNodeSocketDatatype(socket->type))) { continue; @@ -568,7 +568,7 @@ static MultiValueMap find_output_attributes_to const fn::GField field = value_variant.extract(); const bNodeTreeInterfaceSocket *interface_socket = tree.interface_outputs()[index]; - const eAttrDomain domain = (eAttrDomain)interface_socket->attribute_domain; + const bke::AttrDomain domain = bke::AttrDomain(interface_socket->attribute_domain); OutputAttributeInfo output_info; output_info.field = std::move(field); output_info.name = attribute_name; @@ -583,7 +583,7 @@ static MultiValueMap find_output_attributes_to */ static Vector compute_attributes_to_store( const bke::GeometrySet &geometry, - const MultiValueMap &outputs_by_domain) + const MultiValueMap &outputs_by_domain) { Vector attributes_to_store; for (const auto component_type : {bke::GeometryComponent::Type::Mesh, @@ -597,7 +597,7 @@ static Vector compute_attributes_to_store( const bke::GeometryComponent &component = *geometry.get_component(component_type); const bke::AttributeAccessor attributes = *component.attributes(); for (const auto item : outputs_by_domain.items()) { - const eAttrDomain domain = item.key; + const bke::AttrDomain domain = item.key; const Span outputs_info = item.value; if (!attributes.domain_supported(domain)) { continue; @@ -673,7 +673,7 @@ static void store_output_attributes(bke::GeometrySet &geometry, { /* All new attribute values have to be computed before the geometry is actually changed. This is * necessary because some fields might depend on attributes that are overwritten. */ - MultiValueMap outputs_by_domain = + MultiValueMap outputs_by_domain = find_output_attributes_to_store(tree, properties, output_values); Vector attributes_to_store = compute_attributes_to_store( geometry, outputs_by_domain); diff --git a/source/blender/nodes/intern/geometry_nodes_lazy_function.cc b/source/blender/nodes/intern/geometry_nodes_lazy_function.cc index a5a2486fd2b..c4194464af9 100644 --- a/source/blender/nodes/intern/geometry_nodes_lazy_function.cc +++ b/source/blender/nodes/intern/geometry_nodes_lazy_function.cc @@ -799,14 +799,14 @@ class LazyFunctionForViewerNode : public LazyFunction { SocketValueVariant *value_variant = params.try_get_input_data_ptr(1); BLI_assert(value_variant != nullptr); GField field = value_variant->extract(); - const eAttrDomain domain = eAttrDomain(storage->domain); + const AttrDomain domain = AttrDomain(storage->domain); const StringRefNull viewer_attribute_name = ".viewer"; - if (domain == ATTR_DOMAIN_INSTANCE) { + if (domain == AttrDomain::Instance) { if (geometry.has_instances()) { GeometryComponent &component = geometry.get_component_for_write( bke::GeometryComponent::Type::Instance); bke::try_capture_field_on_geometry( - component, viewer_attribute_name, ATTR_DOMAIN_INSTANCE, field); + component, viewer_attribute_name, AttrDomain::Instance, field); } } else { @@ -817,15 +817,15 @@ class LazyFunctionForViewerNode : public LazyFunction { { if (geometry.has(type)) { GeometryComponent &component = geometry.get_component_for_write(type); - eAttrDomain used_domain = domain; - if (used_domain == ATTR_DOMAIN_AUTO) { - if (const std::optional detected_domain = + AttrDomain used_domain = domain; + if (used_domain == AttrDomain::Auto) { + if (const std::optional detected_domain = bke::try_detect_field_domain(component, field)) { used_domain = *detected_domain; } else { - used_domain = ATTR_DOMAIN_POINT; + used_domain = AttrDomain::Point; } } bke::try_capture_field_on_geometry( diff --git a/source/blender/nodes/intern/geometry_nodes_log.cc b/source/blender/nodes/intern/geometry_nodes_log.cc index 5107c7daf47..3fbd68faf6a 100644 --- a/source/blender/nodes/intern/geometry_nodes_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_log.cc @@ -88,29 +88,29 @@ GeometryInfoLog::GeometryInfoLog(const bke::GeometrySet &geometry_set) case bke::GeometryComponent::Type::Mesh: { const auto &mesh_component = *static_cast(component); MeshInfo &info = this->mesh_info.emplace(); - info.verts_num = mesh_component.attribute_domain_size(ATTR_DOMAIN_POINT); - info.edges_num = mesh_component.attribute_domain_size(ATTR_DOMAIN_EDGE); - info.faces_num = mesh_component.attribute_domain_size(ATTR_DOMAIN_FACE); + info.verts_num = mesh_component.attribute_domain_size(bke::AttrDomain::Point); + info.edges_num = mesh_component.attribute_domain_size(bke::AttrDomain::Edge); + info.faces_num = mesh_component.attribute_domain_size(bke::AttrDomain::Face); break; } case bke::GeometryComponent::Type::Curve: { const auto &curve_component = *static_cast(component); CurveInfo &info = this->curve_info.emplace(); - info.points_num = curve_component.attribute_domain_size(ATTR_DOMAIN_POINT); - info.splines_num = curve_component.attribute_domain_size(ATTR_DOMAIN_CURVE); + info.points_num = curve_component.attribute_domain_size(bke::AttrDomain::Point); + info.splines_num = curve_component.attribute_domain_size(bke::AttrDomain::Curve); break; } case bke::GeometryComponent::Type::PointCloud: { const auto &pointcloud_component = *static_cast( component); PointCloudInfo &info = this->pointcloud_info.emplace(); - info.points_num = pointcloud_component.attribute_domain_size(ATTR_DOMAIN_POINT); + info.points_num = pointcloud_component.attribute_domain_size(bke::AttrDomain::Point); break; } case bke::GeometryComponent::Type::Instance: { const auto &instances_component = *static_cast(component); InstancesInfo &info = this->instances_info.emplace(); - info.instances_num = instances_component.attribute_domain_size(ATTR_DOMAIN_INSTANCE); + info.instances_num = instances_component.attribute_domain_size(bke::AttrDomain::Instance); break; } case bke::GeometryComponent::Type::Edit: { @@ -131,7 +131,7 @@ GeometryInfoLog::GeometryInfoLog(const bke::GeometrySet &geometry_set) const auto &grease_pencil_component = *static_cast( component); GreasePencilInfo &info = this->grease_pencil_info.emplace(); - info.layers_num = grease_pencil_component.attribute_domain_size(ATTR_DOMAIN_LAYER); + info.layers_num = grease_pencil_component.attribute_domain_size(bke::AttrDomain::Layer); break; } } diff --git a/source/blender/render/intern/bake.cc b/source/blender/render/intern/bake.cc index 70313202d88..f68b750849b 100644 --- a/source/blender/render/intern/bake.cc +++ b/source/blender/render/intern/bake.cc @@ -470,7 +470,7 @@ static TriTessFace *mesh_calc_tri_tessface(Mesh *mesh, bool tangent, Mesh *me_ev const blender::Span corner_verts = mesh->corner_verts(); const bke::AttributeAccessor attributes = mesh->attributes(); const VArray sharp_faces = - attributes.lookup_or_default("sharp_face", ATTR_DOMAIN_FACE, false).varray; + attributes.lookup_or_default("sharp_face", bke::AttrDomain::Face, false).varray; blender::int3 *corner_tris = static_cast( MEM_mallocN(sizeof(*corner_tris) * tottri, __func__)); @@ -759,7 +759,8 @@ void RE_bake_pixels_populate(Mesh *mesh, const blender::Span tri_faces = mesh->corner_tri_faces(); const bke::AttributeAccessor attributes = mesh->attributes(); - const VArraySpan material_indices = *attributes.lookup("material_index", ATTR_DOMAIN_FACE); + const VArraySpan material_indices = *attributes.lookup("material_index", + bke::AttrDomain::Face); const int materials_num = targets->materials_num; diff --git a/source/blender/render/intern/texture_margin.cc b/source/blender/render/intern/texture_margin.cc index 81ca5d64643..339da52cc41 100644 --- a/source/blender/render/intern/texture_margin.cc +++ b/source/blender/render/intern/texture_margin.cc @@ -568,13 +568,14 @@ void RE_generate_texturemargin_adjacentfaces(ImBuf *ibuf, char const *uv_layer, const float uv_offset[2]) { + using namespace blender; const blender::StringRef uv_map_name = (uv_layer && uv_layer[0]) ? uv_layer : CustomData_get_active_layer_name(&mesh->corner_data, CD_PROP_FLOAT2); const blender::bke::AttributeAccessor attributes = mesh->attributes(); - const blender::VArraySpan uv_map = *attributes.lookup( - uv_map_name, ATTR_DOMAIN_CORNER); + const VArraySpan uv_map = *attributes.lookup(uv_map_name, + bke::AttrDomain::Corner); blender::render::texturemargin::generate_margin(ibuf, mask,