diff options
author | Campbell Barton <campbell@blender.org> | 2022-06-01 07:38:06 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-06-01 08:38:48 +0300 |
commit | 44bac4c8ccf19cb5941435115b8f89a9d14e9c23 (patch) | |
tree | 2bd7698ca3e1e382b078e274566dbad0ae82214c /source/blender/blenkernel | |
parent | ca346d2176737b6aa296617452a8a6cacb7a970a (diff) |
Cleanup: use 'e' prefix for enum types
- CustomDataType -> eCustomDataType
- CustomDataMask -> eCustomDataMask
- AttributeDomain -> eAttrDomain
- NamedAttributeUsage -> eNamedAttrUsage
Diffstat (limited to 'source/blender/blenkernel')
31 files changed, 309 insertions, 314 deletions
diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h index 050cfe1ed85..2985e7cd0b2 100644 --- a/source/blender/blenkernel/BKE_attribute.h +++ b/source/blender/blenkernel/BKE_attribute.h @@ -22,7 +22,7 @@ struct ID; struct ReportList; /** #Attribute.domain */ -typedef enum AttributeDomain { +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 */ @@ -30,23 +30,23 @@ typedef enum AttributeDomain { ATTR_DOMAIN_CORNER = 3, /* Mesh Corner */ ATTR_DOMAIN_CURVE = 4, /* A single curve in a larger curve data-block */ ATTR_DOMAIN_INSTANCE = 5, /* Instance */ -} AttributeDomain; +} eAttrDomain; #define ATTR_DOMAIN_NUM 6 -typedef enum AttributeDomainMask { +typedef enum eAttrDomainMask { ATTR_DOMAIN_MASK_POINT = (1 << 0), ATTR_DOMAIN_MASK_EDGE = (1 << 1), ATTR_DOMAIN_MASK_FACE = (1 << 2), ATTR_DOMAIN_MASK_CORNER = (1 << 3), ATTR_DOMAIN_MASK_CURVE = (1 << 4), ATTR_DOMAIN_MASK_ALL = (1 << 5) - 1 -} AttributeDomainMask; +} eAttrDomainMask; -#define ATTR_DOMAIN_AS_MASK(domain) ((AttributeDomainMask)((1 << (int)(domain)))) +#define ATTR_DOMAIN_AS_MASK(domain) ((eAttrDomainMask)((1 << (int)(domain)))) /* All domains that support color attributes. */ #define ATTR_DOMAIN_MASK_COLOR \ - ((AttributeDomainMask)((ATTR_DOMAIN_MASK_POINT | ATTR_DOMAIN_MASK_CORNER))) + ((eAttrDomainMask)((ATTR_DOMAIN_MASK_POINT | ATTR_DOMAIN_MASK_CORNER))) /* Attributes. */ @@ -57,7 +57,7 @@ bool BKE_attribute_allow_procedural_access(const char *attribute_name); * Create a new attribute layer. */ struct CustomDataLayer *BKE_id_attribute_new( - struct ID *id, const char *name, int type, AttributeDomain domain, struct ReportList *reports); + struct ID *id, const char *name, int type, eAttrDomain domain, struct ReportList *reports); bool BKE_id_attribute_remove(struct ID *id, struct CustomDataLayer *layer, struct ReportList *reports); @@ -65,14 +65,14 @@ bool BKE_id_attribute_remove(struct ID *id, struct CustomDataLayer *BKE_id_attribute_find(const struct ID *id, const char *name, const int type, - const AttributeDomain domain); + const eAttrDomain domain); struct CustomDataLayer *BKE_id_attribute_search(const struct ID *id, const char *name, - const CustomDataMask type, - const AttributeDomainMask domain_mask); + const eCustomDataMask type, + const eAttrDomainMask domain_mask); -AttributeDomain BKE_id_attribute_domain(const struct ID *id, const struct CustomDataLayer *layer); +eAttrDomain 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(struct ID *id, struct CustomDataLayer *layer); bool BKE_id_attribute_rename(struct ID *id, @@ -81,8 +81,8 @@ bool BKE_id_attribute_rename(struct ID *id, struct ReportList *reports); int BKE_id_attributes_length(const struct ID *id, - AttributeDomainMask domain_mask, - CustomDataMask mask); + eAttrDomainMask domain_mask, + eCustomDataMask mask); struct CustomDataLayer *BKE_id_attributes_active_get(struct ID *id); void BKE_id_attributes_active_set(struct ID *id, struct CustomDataLayer *layer); @@ -91,24 +91,24 @@ 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, - AttributeDomainMask domain_mask, - CustomDataMask layer_mask); + eAttrDomainMask 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, - AttributeDomainMask domain_mask, - CustomDataMask layer_mask); + eAttrDomainMask domain_mask, + eCustomDataMask layer_mask); struct CustomDataLayer *BKE_id_attribute_subset_active_get(const struct ID *id, int active_flag, - AttributeDomainMask domain_mask, - CustomDataMask mask); + eAttrDomainMask domain_mask, + eCustomDataMask mask); void BKE_id_attribute_subset_active_set(struct ID *id, struct CustomDataLayer *layer, int active_flag, - AttributeDomainMask domain_mask, - CustomDataMask mask); + eAttrDomainMask domain_mask, + eCustomDataMask mask); /** * Sets up a temporary ID with arbitrary CustomData domains. `r_id` will diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh index c8c7c4c6808..d7826a0e17a 100644 --- a/source/blender/blenkernel/BKE_attribute_access.hh +++ b/source/blender/blenkernel/BKE_attribute_access.hh @@ -32,7 +32,7 @@ * extremely important for writing coherent bug-free code. When an attribute is retrieved with * write access, via #WriteAttributeLookup or #OutputAttribute, the geometry component must be * tagged to clear caches that depend on the changed data. - * 2. Domain interpolation: When retrieving an attribute, a domain (#AttributeDomain) can be + * 2. Domain interpolation: When retrieving an attribute, a domain (#eAttrDomain) can be * provided. If the attribute is stored on a different domain and conversion is possible, a * version of the data interpolated to the requested domain will be provided. These conversions * are implemented in each #GeometryComponent by `attribute_try_adapt_domain_impl`. @@ -88,8 +88,8 @@ extern const char *no_procedural_access_message; * stored (uv map, vertex group, ...). */ struct AttributeMetaData { - AttributeDomain domain; - CustomDataType data_type; + eAttrDomain domain; + eCustomDataType data_type; constexpr friend bool operator==(AttributeMetaData a, AttributeMetaData b) { @@ -98,8 +98,8 @@ struct AttributeMetaData { }; struct AttributeKind { - AttributeDomain domain; - CustomDataType data_type; + eAttrDomain domain; + eCustomDataType data_type; }; /** @@ -167,12 +167,12 @@ using AttributeForeachCallback = blender::FunctionRef<bool( namespace blender::bke { -CustomDataType attribute_data_type_highest_complexity(Span<CustomDataType> data_types); +eCustomDataType attribute_data_type_highest_complexity(Span<eCustomDataType> data_types); /** * Domains with a higher "information density" have a higher priority, * in order to choose a domain that will not lose data through domain conversion. */ -AttributeDomain attribute_domain_highest_priority(Span<AttributeDomain> domains); +eAttrDomain attribute_domain_highest_priority(Span<eAttrDomain> domains); /** * Used when looking up a "plain attribute" based on a name for reading from it. @@ -181,7 +181,7 @@ struct ReadAttributeLookup { /* The virtual array that is used to read from this attribute. */ GVArray varray; /* Domain the attribute lives on in the geometry. */ - AttributeDomain domain; + eAttrDomain domain; /* Convenience function to check if the attribute has been found. */ operator bool() const @@ -197,7 +197,7 @@ struct WriteAttributeLookup { /** The virtual array that is used to read from and write to the attribute. */ GVMutableArray varray; /** Domain the attributes lives on in the geometry component. */ - AttributeDomain domain; + eAttrDomain domain; /** * Call this after changing the attribute to invalidate caches that depend on this attribute. * \note Do not call this after the component the attribute is from has been destructed. @@ -232,7 +232,7 @@ class OutputAttribute { private: GVMutableArray varray_; - AttributeDomain domain_ = ATTR_DOMAIN_AUTO; + eAttrDomain domain_ = ATTR_DOMAIN_AUTO; SaveFn save_; std::unique_ptr<GVMutableArray_GSpan> optional_span_varray_; bool ignore_old_values_ = false; @@ -241,10 +241,7 @@ class OutputAttribute { public: OutputAttribute(); OutputAttribute(OutputAttribute &&other); - OutputAttribute(GVMutableArray varray, - AttributeDomain domain, - SaveFn save, - bool ignore_old_values); + OutputAttribute(GVMutableArray varray, eAttrDomain domain, SaveFn save, bool ignore_old_values); ~OutputAttribute(); @@ -253,9 +250,9 @@ class OutputAttribute { GVMutableArray &operator*(); GVMutableArray *operator->(); GVMutableArray &varray(); - AttributeDomain domain() const; + eAttrDomain domain() const; const CPPType &cpp_type() const; - CustomDataType custom_data_type() const; + eCustomDataType custom_data_type() const; GMutableSpan as_span(); template<typename T> MutableSpan<T> as_span(); @@ -313,7 +310,7 @@ template<typename T> class OutputAttribute_Typed { return varray_; } - AttributeDomain domain() const + eAttrDomain domain() const { return attribute_.domain(); } @@ -323,7 +320,7 @@ template<typename T> class OutputAttribute_Typed { return CPPType::get<T>(); } - CustomDataType custom_data_type() const + eCustomDataType custom_data_type() const { return cpp_type_to_custom_data_type(this->cpp_type()); } @@ -379,22 +376,22 @@ class CustomDataAttributes { * value for the type will be used. */ blender::GVArray get_for_read(const AttributeIDRef &attribute_id, - const CustomDataType data_type, + const eCustomDataType data_type, const void *default_value) const; template<typename T> blender::VArray<T> get_for_read(const AttributeIDRef &attribute_id, const T &default_value) const { const blender::CPPType &cpp_type = blender::CPPType::get<T>(); - const CustomDataType type = blender::bke::cpp_type_to_custom_data_type(cpp_type); + const eCustomDataType type = blender::bke::cpp_type_to_custom_data_type(cpp_type); GVArray varray = this->get_for_read(attribute_id, type, &default_value); return varray.typed<T>(); } std::optional<blender::GMutableSpan> get_for_write(const AttributeIDRef &attribute_id); - bool create(const AttributeIDRef &attribute_id, const CustomDataType data_type); + bool create(const AttributeIDRef &attribute_id, const eCustomDataType data_type); bool create_by_move(const AttributeIDRef &attribute_id, - const CustomDataType data_type, + const eCustomDataType data_type, void *buffer); bool remove(const AttributeIDRef &attribute_id); @@ -403,7 +400,7 @@ class CustomDataAttributes { */ void reorder(Span<AttributeIDRef> new_order); - bool foreach_attribute(const AttributeForeachCallback callback, AttributeDomain domain) const; + bool foreach_attribute(const AttributeForeachCallback callback, eAttrDomain domain) const; }; /* -------------------------------------------------------------------- */ @@ -491,7 +488,7 @@ inline OutputAttribute::OutputAttribute() = default; inline OutputAttribute::OutputAttribute(OutputAttribute &&other) = default; inline OutputAttribute::OutputAttribute(GVMutableArray varray, - AttributeDomain domain, + eAttrDomain domain, SaveFn save, const bool ignore_old_values) : varray_(std::move(varray)), @@ -521,7 +518,7 @@ inline GVMutableArray &OutputAttribute::varray() return varray_; } -inline AttributeDomain OutputAttribute::domain() const +inline eAttrDomain OutputAttribute::domain() const { return domain_; } @@ -531,7 +528,7 @@ inline const CPPType &OutputAttribute::cpp_type() const return varray_.type(); } -inline CustomDataType OutputAttribute::custom_data_type() const +inline eCustomDataType OutputAttribute::custom_data_type() const { return cpp_type_to_custom_data_type(this->cpp_type()); } diff --git a/source/blender/blenkernel/BKE_attribute_math.hh b/source/blender/blenkernel/BKE_attribute_math.hh index 3d194ba77dc..01c2ef988f2 100644 --- a/source/blender/blenkernel/BKE_attribute_math.hh +++ b/source/blender/blenkernel/BKE_attribute_math.hh @@ -39,7 +39,7 @@ inline void convert_to_static_type(const CPPType &cpp_type, const Func &func) } template<typename Func> -inline void convert_to_static_type(const CustomDataType data_type, const Func &func) +inline void convert_to_static_type(const eCustomDataType data_type, const Func &func) { const CPPType &cpp_type = *bke::custom_data_type_to_cpp_type(data_type); convert_to_static_type(cpp_type, func); diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h index b7aa1c09e04..40df7acd066 100644 --- a/source/blender/blenkernel/BKE_camera.h +++ b/source/blender/blenkernel/BKE_camera.h @@ -171,7 +171,7 @@ struct CameraBGImage *BKE_camera_background_image_new(struct Camera *cam); * `BKE_lib_id.h`. */ struct CameraBGImage *BKE_camera_background_image_copy(struct CameraBGImage *bgpic_src, - const int copy_flag); + const int copy_flag); void BKE_camera_background_image_remove(struct Camera *cam, struct CameraBGImage *bgpic); void BKE_camera_background_image_clear(struct Camera *cam); diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh index 445f8d46f2d..168b17bad30 100644 --- a/source/blender/blenkernel/BKE_curves.hh +++ b/source/blender/blenkernel/BKE_curves.hh @@ -410,9 +410,9 @@ class CurvesGeometry : public ::CurvesGeometry { * Attributes. */ - GVArray adapt_domain(const GVArray &varray, AttributeDomain from, AttributeDomain to) const; + GVArray adapt_domain(const GVArray &varray, eAttrDomain from, eAttrDomain to) const; template<typename T> - VArray<T> adapt_domain(const VArray<T> &varray, AttributeDomain from, AttributeDomain to) const + VArray<T> adapt_domain(const VArray<T> &varray, eAttrDomain from, eAttrDomain to) const { return this->adapt_domain(GVArray(varray), from, to).typed<T>(); } diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 64c49830dc5..0e3e427d7ab 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -28,7 +28,7 @@ struct BlendWriter; struct CustomData; struct CustomData_MeshMasks; struct ID; -typedef uint64_t CustomDataMask; +typedef uint64_t eCustomDataMask; /* A data type large enough to hold 1 element from any custom-data layer type. */ typedef struct { @@ -63,7 +63,7 @@ typedef enum eCDAllocType { CD_DUPLICATE = 4, } eCDAllocType; -#define CD_TYPE_AS_MASK(_type) (CustomDataMask)((CustomDataMask)1 << (CustomDataMask)(_type)) +#define CD_TYPE_AS_MASK(_type) (eCustomDataMask)((eCustomDataMask)1 << (eCustomDataMask)(_type)) void customData_mask_layers__print(const struct CustomData_MeshMasks *mask); @@ -137,7 +137,7 @@ void CustomData_data_add(int type, void *data1, const void *data2); */ void CustomData_copy(const struct CustomData *source, struct CustomData *dest, - CustomDataMask mask, + eCustomDataMask mask, eCDAllocType alloctype, int totelem); @@ -150,7 +150,7 @@ void CustomData_update_typemap(struct CustomData *data); */ bool CustomData_merge(const struct CustomData *source, struct CustomData *dest, - CustomDataMask mask, + eCustomDataMask mask, eCDAllocType alloctype, int totelem); @@ -170,7 +170,7 @@ void CustomData_realloc(struct CustomData *data, int totelem); */ bool CustomData_bmesh_merge(const struct CustomData *source, struct CustomData *dest, - CustomDataMask mask, + eCustomDataMask mask, eCDAllocType alloctype, struct BMesh *bm, char htype); @@ -188,7 +188,7 @@ void CustomData_free(struct CustomData *data, int totelem); /** * Same as above, but only frees layers which matches the given mask. */ -void CustomData_free_typemask(struct CustomData *data, int totelem, CustomDataMask mask); +void CustomData_free_typemask(struct CustomData *data, int totelem, eCustomDataMask mask); /** * Frees all layers with #CD_FLAG_TEMPORARY. @@ -248,7 +248,7 @@ bool CustomData_has_layer(const struct CustomData *data, int type); * Returns the number of layers with this type. */ int CustomData_number_of_layers(const struct CustomData *data, int type); -int CustomData_number_of_layers_typemask(const struct CustomData *data, CustomDataMask mask); +int CustomData_number_of_layers_typemask(const struct CustomData *data, eCustomDataMask mask); /** * Duplicate data of a layer with flag NOFREE, and remove that flag. @@ -276,7 +276,7 @@ void CustomData_duplicate_referenced_layers(CustomData *data, int totelem); * Set the #CD_FLAG_NOCOPY flag in custom data layers where the mask is * zero for the layer type, so only layer types specified by the mask will be copied */ -void CustomData_set_only_copy(const struct CustomData *data, CustomDataMask mask); +void CustomData_set_only_copy(const struct CustomData *data, eCustomDataMask mask); /** * Copies data from one CustomData object to another @@ -309,7 +309,7 @@ void CustomData_bmesh_copy_data_exclude_by_type(const struct CustomData *source, struct CustomData *dest, void *src_block, void **dest_block, - CustomDataMask mask_exclude); + eCustomDataMask mask_exclude); /** * Copies data of a single layer of a given type. @@ -488,7 +488,7 @@ void CustomData_bmesh_free_block_data(struct CustomData *data, void *block); */ void CustomData_bmesh_free_block_data_exclude_by_type(struct CustomData *data, void *block, - CustomDataMask mask_exclude); + eCustomDataMask mask_exclude); /** * Copy custom data to/from layers as in mesh/derived-mesh, to edit-mesh @@ -593,14 +593,14 @@ void CustomData_external_remove(struct CustomData *data, struct ID *id, int type bool CustomData_external_test(struct CustomData *data, int type); void CustomData_external_write( - struct CustomData *data, struct ID *id, CustomDataMask mask, int totelem, int free); + struct CustomData *data, struct ID *id, eCustomDataMask mask, int totelem, int free); void CustomData_external_read(struct CustomData *data, struct ID *id, - CustomDataMask mask, + eCustomDataMask mask, int totelem); void CustomData_external_reload(struct CustomData *data, struct ID *id, - CustomDataMask mask, + eCustomDataMask mask, int totelem); /* Mesh-to-mesh transfer data. */ @@ -726,7 +726,7 @@ void CustomData_blend_write(BlendWriter *writer, CustomData *data, blender::Span<CustomDataLayer> layers_to_write, int count, - CustomDataMask cddata_mask, + eCustomDataMask cddata_mask, ID *id); #endif @@ -749,7 +749,7 @@ void CustomData_debug_info_from_layers(const struct CustomData *data, # include "BLI_cpp_type.hh" namespace blender::bke { -const CPPType *custom_data_type_to_cpp_type(const CustomDataType type); -CustomDataType cpp_type_to_custom_data_type(const CPPType &type); +const CPPType *custom_data_type_to_cpp_type(const eCustomDataType type); +eCustomDataType cpp_type_to_custom_data_type(const CPPType &type); } // namespace blender::bke #endif diff --git a/source/blender/blenkernel/BKE_geometry_fields.hh b/source/blender/blenkernel/BKE_geometry_fields.hh index 9c86ab262ef..8478a9d7464 100644 --- a/source/blender/blenkernel/BKE_geometry_fields.hh +++ b/source/blender/blenkernel/BKE_geometry_fields.hh @@ -17,10 +17,10 @@ namespace blender::bke { class GeometryComponentFieldContext : public fn::FieldContext { private: const GeometryComponent &component_; - const AttributeDomain domain_; + const eAttrDomain domain_; public: - GeometryComponentFieldContext(const GeometryComponent &component, const AttributeDomain domain) + GeometryComponentFieldContext(const GeometryComponent &component, const eAttrDomain domain) : component_(component), domain_(domain) { } @@ -30,7 +30,7 @@ class GeometryComponentFieldContext : public fn::FieldContext { return component_; } - AttributeDomain domain() const + eAttrDomain domain() const { return domain_; } @@ -45,7 +45,7 @@ class GeometryFieldInput : public fn::FieldInput { ResourceScope &scope) const override; virtual GVArray get_varray_for_context(const GeometryComponent &component, - AttributeDomain domain, + eAttrDomain domain, IndexMask mask) const = 0; }; @@ -73,7 +73,7 @@ class AttributeFieldInput : public GeometryFieldInput { } GVArray get_varray_for_context(const GeometryComponent &component, - AttributeDomain domain, + eAttrDomain domain, IndexMask mask) const override; std::string socket_inspection_name() const override; @@ -90,7 +90,7 @@ class IDAttributeFieldInput : public GeometryFieldInput { } GVArray get_varray_for_context(const GeometryComponent &component, - AttributeDomain domain, + eAttrDomain domain, IndexMask mask) const override; std::string socket_inspection_name() const override; @@ -99,12 +99,12 @@ class IDAttributeFieldInput : public GeometryFieldInput { bool is_equal_to(const fn::FieldNode &other) const override; }; -VArray<float3> curve_normals_varray(const CurveComponent &component, const AttributeDomain domain); +VArray<float3> curve_normals_varray(const CurveComponent &component, const eAttrDomain domain); VArray<float3> mesh_normals_varray(const MeshComponent &mesh_component, const Mesh &mesh, const IndexMask mask, - const AttributeDomain domain); + const eAttrDomain domain); class NormalFieldInput : public GeometryFieldInput { public: @@ -114,7 +114,7 @@ class NormalFieldInput : public GeometryFieldInput { } GVArray get_varray_for_context(const GeometryComponent &component, - const AttributeDomain domain, + const eAttrDomain domain, IndexMask mask) const override; std::string socket_inspection_name() const override; @@ -153,7 +153,7 @@ class AnonymousAttributeFieldInput : public GeometryFieldInput { } GVArray get_varray_for_context(const GeometryComponent &component, - AttributeDomain domain, + eAttrDomain domain, IndexMask mask) const override; std::string socket_inspection_name() const override; @@ -166,7 +166,7 @@ class CurveLengthFieldInput final : public GeometryFieldInput { public: CurveLengthFieldInput(); GVArray get_varray_for_context(const GeometryComponent &component, - AttributeDomain domain, + eAttrDomain domain, IndexMask mask) const final; uint64_t hash() const override; bool is_equal_to(const fn::FieldNode &other) const override; diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index c58420efceb..04e467b2ff1 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -94,11 +94,11 @@ class GeometryComponent { * \note Conceptually this function is static, the result is always the same for different * instances of the same geometry component type. */ - bool attribute_domain_supported(AttributeDomain domain) const; + bool attribute_domain_supported(eAttrDomain domain) const; /** * Return the length of a specific domain, or 0 if the domain is not supported. */ - virtual int attribute_domain_num(AttributeDomain domain) const; + virtual int attribute_domain_num(eAttrDomain domain) const; /** * Return true if the attribute name corresponds to a built-in attribute with a hardcoded domain @@ -130,16 +130,16 @@ class GeometryComponent { * \return null if the interpolation is not implemented. */ blender::GVArray attribute_try_adapt_domain(const blender::GVArray &varray, - const AttributeDomain from_domain, - const AttributeDomain to_domain) const + const eAttrDomain from_domain, + const eAttrDomain to_domain) const { return this->attribute_try_adapt_domain_impl(varray, from_domain, to_domain); } /* Use instead of the method above when the type is known at compile time for type safety. */ template<typename T> blender::VArray<T> attribute_try_adapt_domain(const blender::VArray<T> &varray, - const AttributeDomain from_domain, - const AttributeDomain to_domain) const + const eAttrDomain from_domain, + const eAttrDomain to_domain) const { return this->attribute_try_adapt_domain_impl(varray, from_domain, to_domain) .template typed<T>(); @@ -156,8 +156,8 @@ class GeometryComponent { /** Returns true when the attribute has been created. */ bool attribute_try_create(const blender::bke::AttributeIDRef &attribute_id, - AttributeDomain domain, - const CustomDataType data_type, + eAttrDomain domain, + const eCustomDataType data_type, const AttributeInit &initializer); /** @@ -182,8 +182,8 @@ class GeometryComponent { * interpolated or converted. */ blender::GVArray attribute_try_get_for_read(const blender::bke::AttributeIDRef &attribute_id, - AttributeDomain domain, - const CustomDataType data_type) const; + eAttrDomain domain, + const eCustomDataType data_type) const; /** * Get a virtual array that refers to the data of an attribute, interpolated to the given domain. @@ -191,7 +191,7 @@ class GeometryComponent { * interpolated. */ blender::GVArray attribute_try_get_for_read(const blender::bke::AttributeIDRef &attribute_id, - AttributeDomain domain) const; + eAttrDomain domain) const; /** * Get a virtual array that refers to the data of an attribute converted to the given data type. @@ -199,7 +199,7 @@ class GeometryComponent { * cannot be converted. */ blender::bke::ReadAttributeLookup attribute_try_get_for_read( - const blender::bke::AttributeIDRef &attribute_id, const CustomDataType data_type) const; + const blender::bke::AttributeIDRef &attribute_id, const eCustomDataType data_type) const; /** * Get a virtual array that refers to the data of an attribute, interpolated to the given domain @@ -207,17 +207,17 @@ class GeometryComponent { * contain a default value. This never returns null. */ blender::GVArray attribute_get_for_read(const blender::bke::AttributeIDRef &attribute_id, - AttributeDomain domain, - const CustomDataType data_type, + eAttrDomain domain, + const eCustomDataType data_type, const void *default_value = nullptr) const; /* Use instead of the method above when the type is known at compile time for type safety. */ template<typename T> blender::VArray<T> attribute_get_for_read(const blender::bke::AttributeIDRef &attribute_id, - const AttributeDomain domain, + const eAttrDomain domain, const T &default_value) const { const blender::CPPType &cpp_type = blender::CPPType::get<T>(); - const CustomDataType type = blender::bke::cpp_type_to_custom_data_type(cpp_type); + const eCustomDataType type = blender::bke::cpp_type_to_custom_data_type(cpp_type); return this->attribute_get_for_read(attribute_id, domain, type, &default_value) .template typed<T>(); } @@ -234,18 +234,18 @@ class GeometryComponent { */ blender::bke::OutputAttribute attribute_try_get_for_output( const blender::bke::AttributeIDRef &attribute_id, - AttributeDomain domain, - const CustomDataType data_type, + eAttrDomain domain, + const eCustomDataType data_type, const void *default_value = nullptr); /* Use instead of the method above when the type is known at compile time for type safety. */ template<typename T> blender::bke::OutputAttribute_Typed<T> attribute_try_get_for_output( const blender::bke::AttributeIDRef &attribute_id, - const AttributeDomain domain, + const eAttrDomain domain, const T default_value) { const blender::CPPType &cpp_type = blender::CPPType::get<T>(); - const CustomDataType data_type = blender::bke::cpp_type_to_custom_data_type(cpp_type); + const eCustomDataType data_type = blender::bke::cpp_type_to_custom_data_type(cpp_type); return this->attribute_try_get_for_output(attribute_id, domain, data_type, &default_value); } @@ -257,15 +257,15 @@ class GeometryComponent { */ blender::bke::OutputAttribute attribute_try_get_for_output_only( const blender::bke::AttributeIDRef &attribute_id, - AttributeDomain domain, - const CustomDataType data_type); + eAttrDomain domain, + const eCustomDataType data_type); /* Use instead of the method above when the type is known at compile time for type safety. */ template<typename T> blender::bke::OutputAttribute_Typed<T> attribute_try_get_for_output_only( - const blender::bke::AttributeIDRef &attribute_id, const AttributeDomain domain) + const blender::bke::AttributeIDRef &attribute_id, const eAttrDomain domain) { const blender::CPPType &cpp_type = blender::CPPType::get<T>(); - const CustomDataType data_type = blender::bke::cpp_type_to_custom_data_type(cpp_type); + const eCustomDataType data_type = blender::bke::cpp_type_to_custom_data_type(cpp_type); return this->attribute_try_get_for_output_only(attribute_id, domain, data_type); } @@ -273,8 +273,8 @@ class GeometryComponent { virtual const blender::bke::ComponentAttributeProviders *get_attribute_providers() const; virtual blender::GVArray attribute_try_adapt_domain_impl(const blender::GVArray &varray, - AttributeDomain from_domain, - AttributeDomain to_domain) const; + eAttrDomain from_domain, + eAttrDomain to_domain) const; }; template<typename T> @@ -560,7 +560,7 @@ class MeshComponent : public GeometryComponent { */ Mesh *get_for_write(); - int attribute_domain_num(AttributeDomain domain) const final; + int attribute_domain_num(eAttrDomain domain) const final; bool is_empty() const final; @@ -573,8 +573,8 @@ class MeshComponent : public GeometryComponent { const blender::bke::ComponentAttributeProviders *get_attribute_providers() const final; blender::GVArray attribute_try_adapt_domain_impl(const blender::GVArray &varray, - AttributeDomain from_domain, - AttributeDomain to_domain) const final; + eAttrDomain from_domain, + eAttrDomain to_domain) const final; }; /** @@ -623,7 +623,7 @@ class PointCloudComponent : public GeometryComponent { */ PointCloud *get_for_write(); - int attribute_domain_num(AttributeDomain domain) const final; + int attribute_domain_num(eAttrDomain domain) const final; bool is_empty() const final; @@ -664,7 +664,7 @@ class CurveComponentLegacy : public GeometryComponent { const CurveEval *get_for_read() const; CurveEval *get_for_write(); - int attribute_domain_num(AttributeDomain domain) const final; + int attribute_domain_num(eAttrDomain domain) const final; bool is_empty() const final; @@ -677,8 +677,8 @@ class CurveComponentLegacy : public GeometryComponent { const blender::bke::ComponentAttributeProviders *get_attribute_providers() const final; blender::GVArray attribute_try_adapt_domain_impl(const blender::GVArray &varray, - AttributeDomain from_domain, - AttributeDomain to_domain) const final; + eAttrDomain from_domain, + eAttrDomain to_domain) const final; }; /** @@ -716,7 +716,7 @@ class CurveComponent : public GeometryComponent { const Curves *get_for_read() const; Curves *get_for_write(); - int attribute_domain_num(AttributeDomain domain) const final; + int attribute_domain_num(eAttrDomain domain) const final; bool is_empty() const final; @@ -735,8 +735,8 @@ class CurveComponent : public GeometryComponent { const blender::bke::ComponentAttributeProviders *get_attribute_providers() const final; blender::GVArray attribute_try_adapt_domain_impl(const blender::GVArray &varray, - AttributeDomain from_domain, - AttributeDomain to_domain) const final; + eAttrDomain from_domain, + eAttrDomain to_domain) const final; }; /** @@ -964,7 +964,7 @@ class InstancesComponent : public GeometryComponent { blender::bke::CustomDataAttributes &attributes(); const blender::bke::CustomDataAttributes &attributes() const; - int attribute_domain_num(AttributeDomain domain) const final; + int attribute_domain_num(eAttrDomain domain) const final; void foreach_referenced_geometry( blender::FunctionRef<void(const GeometrySet &geometry_set)> callback) const; diff --git a/source/blender/blenkernel/BKE_mesh_runtime.h b/source/blender/blenkernel/BKE_mesh_runtime.h index 0e78f9d7e15..dfefe125a51 100644 --- a/source/blender/blenkernel/BKE_mesh_runtime.h +++ b/source/blender/blenkernel/BKE_mesh_runtime.h @@ -8,7 +8,7 @@ * This file contains access functions for the Mesh.runtime struct. */ -//#include "BKE_customdata.h" /* for CustomDataMask */ +//#include "BKE_customdata.h" /* for eCustomDataMask */ #ifdef __cplusplus extern "C" { diff --git a/source/blender/blenkernel/BKE_mesh_sample.hh b/source/blender/blenkernel/BKE_mesh_sample.hh index a942f3bb7ed..37c2ad7d3cb 100644 --- a/source/blender/blenkernel/BKE_mesh_sample.hh +++ b/source/blender/blenkernel/BKE_mesh_sample.hh @@ -69,7 +69,7 @@ class MeshAttributeInterpolator { const Span<int> looptri_indices); void sample_data(const GVArray &src, - AttributeDomain domain, + eAttrDomain domain, eAttributeMapMode mode, const GMutableSpan dst); diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index c39ab22ce3a..9e0ea5e13d5 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -501,8 +501,8 @@ typedef struct SculptSession { struct MPropCol *vcol; struct MLoopCol *mcol; - AttributeDomain vcol_domain; - CustomDataType vcol_type; + eAttrDomain vcol_domain; + eCustomDataType vcol_type; float *vmask; diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 291b9b6b778..7a89dee4148 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -549,7 +549,7 @@ PBVHColorBufferNode *BKE_pbvh_node_color_buffer_get(PBVHNode *node); void BKE_pbvh_node_color_buffer_free(PBVH *pbvh); bool BKE_pbvh_get_color_layer(const struct Mesh *me, CustomDataLayer **r_layer, - AttributeDomain *r_attr); + eAttrDomain *r_attr); /* Swaps colors at each element in indices (of domain pbvh->vcol_domain) * with values in colors. */ diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index 584035ddb85..fedcfc5c721 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -183,7 +183,7 @@ bool BKE_id_attribute_calc_unique_name(ID *id, const char *name, char *outname) } CustomDataLayer *BKE_id_attribute_new( - ID *id, const char *name, const int type, const AttributeDomain domain, ReportList *reports) + ID *id, const char *name, const int type, const eAttrDomain domain, ReportList *reports) { DomainInfo info[ATTR_DOMAIN_NUM]; get_domains(id, info); @@ -264,7 +264,7 @@ bool BKE_id_attribute_remove(ID *id, CustomDataLayer *layer, ReportList *reports CustomDataLayer *BKE_id_attribute_find(const ID *id, const char *name, const int type, - const AttributeDomain domain) + const eAttrDomain domain) { DomainInfo info[ATTR_DOMAIN_NUM]; get_domains(id, info); @@ -286,14 +286,14 @@ CustomDataLayer *BKE_id_attribute_find(const ID *id, CustomDataLayer *BKE_id_attribute_search(const ID *id, const char *name, - const CustomDataMask type_mask, - const AttributeDomainMask domain_mask) + const eCustomDataMask type_mask, + const eAttrDomainMask domain_mask) { DomainInfo info[ATTR_DOMAIN_NUM]; get_domains(id, info); - for (AttributeDomain domain = ATTR_DOMAIN_POINT; domain < ATTR_DOMAIN_NUM; - domain = static_cast<AttributeDomain>((static_cast<int>(domain)) + 1)) { + for (eAttrDomain domain = ATTR_DOMAIN_POINT; domain < ATTR_DOMAIN_NUM; + domain = static_cast<eAttrDomain>((static_cast<int>(domain)) + 1)) { if (!(domain_mask & ATTR_DOMAIN_AS_MASK(domain))) { continue; } @@ -314,7 +314,7 @@ CustomDataLayer *BKE_id_attribute_search(const ID *id, return NULL; } -int BKE_id_attributes_length(const ID *id, AttributeDomainMask domain_mask, CustomDataMask mask) +int BKE_id_attributes_length(const ID *id, eAttrDomainMask domain_mask, eCustomDataMask mask) { DomainInfo info[ATTR_DOMAIN_NUM]; get_domains(id, info); @@ -332,7 +332,7 @@ int BKE_id_attributes_length(const ID *id, AttributeDomainMask domain_mask, Cust return length; } -AttributeDomain BKE_id_attribute_domain(const ID *id, const CustomDataLayer *layer) +eAttrDomain BKE_id_attribute_domain(const ID *id, const CustomDataLayer *layer) { DomainInfo info[ATTR_DOMAIN_NUM]; get_domains(id, info); @@ -341,12 +341,12 @@ AttributeDomain BKE_id_attribute_domain(const ID *id, const CustomDataLayer *lay CustomData *customdata = info[domain].customdata; if (customdata && ARRAY_HAS_ITEM((CustomDataLayer *)layer, customdata->layers, customdata->totlayer)) { - return static_cast<AttributeDomain>(domain); + return static_cast<eAttrDomain>(domain); } } BLI_assert_msg(0, "Custom data layer not found in geometry"); - return static_cast<AttributeDomain>(ATTR_DOMAIN_POINT); + return static_cast<eAttrDomain>(ATTR_DOMAIN_POINT); } int BKE_id_attribute_data_length(ID *id, CustomDataLayer *layer) @@ -489,8 +489,8 @@ CustomData *BKE_id_attributes_iterator_next_domain(ID *id, CustomDataLayer *laye CustomDataLayer *BKE_id_attribute_from_index(ID *id, int lookup_index, - AttributeDomainMask domain_mask, - CustomDataMask layer_mask) + eAttrDomainMask domain_mask, + eCustomDataMask layer_mask) { DomainInfo info[ATTR_DOMAIN_NUM]; get_domains(id, info); @@ -523,27 +523,27 @@ CustomDataLayer *BKE_id_attribute_from_index(ID *id, /** Get list of domain types but with ATTR_DOMAIN_FACE and * ATTR_DOMAIN_CORNER swapped. */ -static void get_domains_types(AttributeDomain domains[ATTR_DOMAIN_NUM]) +static void get_domains_types(eAttrDomain domains[ATTR_DOMAIN_NUM]) { for (const int i : IndexRange(ATTR_DOMAIN_NUM)) { - domains[i] = static_cast<AttributeDomain>(i); + domains[i] = static_cast<eAttrDomain>(i); } /* Swap corner and face. */ - SWAP(AttributeDomain, domains[ATTR_DOMAIN_FACE], domains[ATTR_DOMAIN_CORNER]); + SWAP(eAttrDomain, domains[ATTR_DOMAIN_FACE], domains[ATTR_DOMAIN_CORNER]); } int BKE_id_attribute_to_index(const ID *id, const CustomDataLayer *layer, - AttributeDomainMask domain_mask, - CustomDataMask layer_mask) + eAttrDomainMask domain_mask, + eCustomDataMask layer_mask) { if (!layer) { return -1; } DomainInfo info[ATTR_DOMAIN_NUM]; - AttributeDomain domains[ATTR_DOMAIN_NUM]; + eAttrDomain domains[ATTR_DOMAIN_NUM]; get_domains_types(domains); get_domains(id, info); @@ -575,11 +575,11 @@ int BKE_id_attribute_to_index(const ID *id, CustomDataLayer *BKE_id_attribute_subset_active_get(const ID *id, int active_flag, - AttributeDomainMask domain_mask, - CustomDataMask mask) + eAttrDomainMask domain_mask, + eCustomDataMask mask) { DomainInfo info[ATTR_DOMAIN_NUM]; - AttributeDomain domains[ATTR_DOMAIN_NUM]; + eAttrDomain domains[ATTR_DOMAIN_NUM]; get_domains_types(domains); get_domains(id, info); @@ -613,17 +613,17 @@ CustomDataLayer *BKE_id_attribute_subset_active_get(const ID *id, void BKE_id_attribute_subset_active_set(ID *id, CustomDataLayer *layer, int active_flag, - AttributeDomainMask domain_mask, - CustomDataMask mask) + eAttrDomainMask domain_mask, + eCustomDataMask mask) { DomainInfo info[ATTR_DOMAIN_NUM]; - AttributeDomain domains[ATTR_DOMAIN_NUM]; + eAttrDomain domains[ATTR_DOMAIN_NUM]; get_domains_types(domains); get_domains(id, info); for (int i = 0; i < ATTR_DOMAIN_NUM; i++) { - AttributeDomainMask domain_mask2 = (AttributeDomainMask)(1 << domains[i]); + eAttrDomainMask domain_mask2 = (eAttrDomainMask)(1 << domains[i]); if (!(domain_mask2 & domain_mask) || !info[domains[i]].customdata) { continue; diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index e487bf4acf6..bc146d87e4c 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -63,7 +63,7 @@ bool allow_procedural_attribute_access(StringRef attribute_name) return !attribute_name.startswith(".selection"); } -static int attribute_data_type_complexity(const CustomDataType data_type) +static int attribute_data_type_complexity(const eCustomDataType data_type) { switch (data_type) { case CD_PROP_BOOL: @@ -93,12 +93,12 @@ static int attribute_data_type_complexity(const CustomDataType data_type) } } -CustomDataType attribute_data_type_highest_complexity(Span<CustomDataType> data_types) +eCustomDataType attribute_data_type_highest_complexity(Span<eCustomDataType> data_types) { int highest_complexity = INT_MIN; - CustomDataType most_complex_type = CD_PROP_COLOR; + eCustomDataType most_complex_type = CD_PROP_COLOR; - for (const CustomDataType data_type : data_types) { + for (const eCustomDataType data_type : data_types) { const int complexity = attribute_data_type_complexity(data_type); if (complexity > highest_complexity) { highest_complexity = complexity; @@ -113,7 +113,7 @@ CustomDataType attribute_data_type_highest_complexity(Span<CustomDataType> data_ * \note Generally the order should mirror the order of the domains * established in each component's ComponentAttributeProviders. */ -static int attribute_domain_priority(const AttributeDomain domain) +static int attribute_domain_priority(const eAttrDomain domain) { switch (domain) { case ATTR_DOMAIN_INSTANCE: @@ -135,12 +135,12 @@ static int attribute_domain_priority(const AttributeDomain domain) } } -AttributeDomain attribute_domain_highest_priority(Span<AttributeDomain> domains) +eAttrDomain attribute_domain_highest_priority(Span<eAttrDomain> domains) { int highest_priority = INT_MIN; - AttributeDomain highest_priority_domain = ATTR_DOMAIN_CORNER; + eAttrDomain highest_priority_domain = ATTR_DOMAIN_CORNER; - for (const AttributeDomain domain : domains) { + for (const eAttrDomain domain : domains) { const int priority = attribute_domain_priority(domain); if (priority > highest_priority) { highest_priority = priority; @@ -191,7 +191,7 @@ static AttributeIDRef attribute_id_from_custom_data_layer(const CustomDataLayer } static bool add_builtin_type_custom_data_layer_from_init(CustomData &custom_data, - const CustomDataType data_type, + const eCustomDataType data_type, const int domain_num, const AttributeInit &initializer) { @@ -226,7 +226,7 @@ static bool add_builtin_type_custom_data_layer_from_init(CustomData &custom_data } static void *add_generic_custom_data_layer(CustomData &custom_data, - const CustomDataType data_type, + const eCustomDataType data_type, const eCDAllocType alloctype, void *layer_data, const int domain_num, @@ -245,7 +245,7 @@ static void *add_generic_custom_data_layer(CustomData &custom_data, static bool add_custom_data_layer_from_attribute_init(const AttributeIDRef &attribute_id, CustomData &custom_data, - const CustomDataType data_type, + const eCustomDataType data_type, const int domain_num, const AttributeInit &initializer) { @@ -459,7 +459,7 @@ ReadAttributeLookup CustomDataAttributeProvider::try_get_for_read( if (!custom_data_layer_matches_attribute_id(layer, attribute_id)) { continue; } - const CPPType *type = custom_data_type_to_cpp_type((CustomDataType)layer.type); + const CPPType *type = custom_data_type_to_cpp_type((eCustomDataType)layer.type); if (type == nullptr) { continue; } @@ -488,7 +488,7 @@ WriteAttributeLookup CustomDataAttributeProvider::try_get_for_write( CustomData_duplicate_referenced_layer_anonymous( custom_data, layer.type, &attribute_id.anonymous_id(), domain_num); } - const CPPType *type = custom_data_type_to_cpp_type((CustomDataType)layer.type); + const CPPType *type = custom_data_type_to_cpp_type((eCustomDataType)layer.type); if (type == nullptr) { continue; } @@ -508,7 +508,7 @@ bool CustomDataAttributeProvider::try_delete(GeometryComponent &component, const int domain_num = component.attribute_domain_num(domain_); for (const int i : IndexRange(custom_data->totlayer)) { const CustomDataLayer &layer = custom_data->layers[i]; - if (this->type_is_supported((CustomDataType)layer.type) && + if (this->type_is_supported((eCustomDataType)layer.type) && custom_data_layer_matches_attribute_id(layer, attribute_id)) { CustomData_free_layer(custom_data, layer.type, domain_num, i); return true; @@ -519,8 +519,8 @@ bool CustomDataAttributeProvider::try_delete(GeometryComponent &component, bool CustomDataAttributeProvider::try_create(GeometryComponent &component, const AttributeIDRef &attribute_id, - const AttributeDomain domain, - const CustomDataType data_type, + const eAttrDomain domain, + const eCustomDataType data_type, const AttributeInit &initializer) const { if (domain_ != domain) { @@ -552,7 +552,7 @@ bool CustomDataAttributeProvider::foreach_attribute(const GeometryComponent &com return true; } for (const CustomDataLayer &layer : Span(custom_data->layers, custom_data->totlayer)) { - const CustomDataType data_type = (CustomDataType)layer.type; + const eCustomDataType data_type = (eCustomDataType)layer.type; if (this->type_is_supported(data_type)) { AttributeMetaData meta_data{domain_, data_type}; const AttributeIDRef attribute_id = attribute_id_from_custom_data_layer(layer); @@ -650,7 +650,7 @@ bool NamedLegacyCustomDataProvider::foreach_attribute( } void NamedLegacyCustomDataProvider::foreach_domain( - const FunctionRef<void(AttributeDomain)> callback) const + const FunctionRef<void(eAttrDomain)> callback) const { callback(domain_); } @@ -693,7 +693,7 @@ std::optional<GSpan> CustomDataAttributes::get_for_read(const AttributeIDRef &at { for (const CustomDataLayer &layer : Span(data.layers, data.totlayer)) { if (custom_data_layer_matches_attribute_id(layer, attribute_id)) { - const CPPType *cpp_type = custom_data_type_to_cpp_type((CustomDataType)layer.type); + const CPPType *cpp_type = custom_data_type_to_cpp_type((eCustomDataType)layer.type); BLI_assert(cpp_type != nullptr); return GSpan(*cpp_type, layer.data, size_); } @@ -702,7 +702,7 @@ std::optional<GSpan> CustomDataAttributes::get_for_read(const AttributeIDRef &at } GVArray CustomDataAttributes::get_for_read(const AttributeIDRef &attribute_id, - const CustomDataType data_type, + const eCustomDataType data_type, const void *default_value) const { const CPPType *type = blender::bke::custom_data_type_to_cpp_type(data_type); @@ -726,7 +726,7 @@ std::optional<GMutableSpan> CustomDataAttributes::get_for_write(const AttributeI { for (CustomDataLayer &layer : MutableSpan(data.layers, data.totlayer)) { if (custom_data_layer_matches_attribute_id(layer, attribute_id)) { - const CPPType *cpp_type = custom_data_type_to_cpp_type((CustomDataType)layer.type); + const CPPType *cpp_type = custom_data_type_to_cpp_type((eCustomDataType)layer.type); BLI_assert(cpp_type != nullptr); return GMutableSpan(*cpp_type, layer.data, size_); } @@ -735,7 +735,7 @@ std::optional<GMutableSpan> CustomDataAttributes::get_for_write(const AttributeI } bool CustomDataAttributes::create(const AttributeIDRef &attribute_id, - const CustomDataType data_type) + const eCustomDataType data_type) { void *result = add_generic_custom_data_layer( data, data_type, CD_DEFAULT, nullptr, size_, attribute_id); @@ -743,7 +743,7 @@ bool CustomDataAttributes::create(const AttributeIDRef &attribute_id, } bool CustomDataAttributes::create_by_move(const AttributeIDRef &attribute_id, - const CustomDataType data_type, + const eCustomDataType data_type, void *buffer) { void *result = add_generic_custom_data_layer( @@ -776,10 +776,10 @@ void CustomDataAttributes::clear() } bool CustomDataAttributes::foreach_attribute(const AttributeForeachCallback callback, - const AttributeDomain domain) const + const eAttrDomain domain) const { for (const CustomDataLayer &layer : Span(data.layers, data.totlayer)) { - AttributeMetaData meta_data{domain, (CustomDataType)layer.type}; + AttributeMetaData meta_data{domain, (eCustomDataType)layer.type}; const AttributeIDRef attribute_id = attribute_id_from_custom_data_layer(layer); if (!callback(attribute_id, meta_data)) { return false; @@ -819,7 +819,7 @@ const blender::bke::ComponentAttributeProviders *GeometryComponent::get_attribut return nullptr; } -bool GeometryComponent::attribute_domain_supported(const AttributeDomain domain) const +bool GeometryComponent::attribute_domain_supported(const eAttrDomain domain) const { using namespace blender::bke; const ComponentAttributeProviders *providers = this->get_attribute_providers(); @@ -829,7 +829,7 @@ bool GeometryComponent::attribute_domain_supported(const AttributeDomain domain) return providers->supported_domains().contains(domain); } -int GeometryComponent::attribute_domain_num(const AttributeDomain UNUSED(domain)) const +int GeometryComponent::attribute_domain_num(const eAttrDomain UNUSED(domain)) const { return 0; } @@ -877,8 +877,8 @@ blender::bke::ReadAttributeLookup GeometryComponent::attribute_try_get_for_read( blender::GVArray GeometryComponent::attribute_try_adapt_domain_impl( const blender::GVArray &varray, - const AttributeDomain from_domain, - const AttributeDomain to_domain) const + const eAttrDomain from_domain, + const eAttrDomain to_domain) const { if (from_domain == to_domain) { return varray; @@ -949,8 +949,8 @@ void GeometryComponent::attributes_remove_anonymous() } bool GeometryComponent::attribute_try_create(const AttributeIDRef &attribute_id, - const AttributeDomain domain, - const CustomDataType data_type, + const eAttrDomain domain, + const eCustomDataType data_type, const AttributeInit &initializer) { using namespace blender::bke; @@ -1087,8 +1087,8 @@ static blender::GVArray try_adapt_data_type(blender::GVArray varray, blender::GVArray GeometryComponent::attribute_try_get_for_read( const AttributeIDRef &attribute_id, - const AttributeDomain domain, - const CustomDataType data_type) const + const eAttrDomain domain, + const eCustomDataType data_type) const { blender::bke::ReadAttributeLookup attribute = this->attribute_try_get_for_read(attribute_id); if (!attribute) { @@ -1116,7 +1116,7 @@ blender::GVArray GeometryComponent::attribute_try_get_for_read( } blender::GVArray GeometryComponent::attribute_try_get_for_read(const AttributeIDRef &attribute_id, - const AttributeDomain domain) const + const eAttrDomain domain) const { if (!this->attribute_domain_supported(domain)) { return {}; @@ -1135,7 +1135,7 @@ blender::GVArray GeometryComponent::attribute_try_get_for_read(const AttributeID } blender::bke::ReadAttributeLookup GeometryComponent::attribute_try_get_for_read( - const AttributeIDRef &attribute_id, const CustomDataType data_type) const + const AttributeIDRef &attribute_id, const eCustomDataType data_type) const { blender::bke::ReadAttributeLookup attribute = this->attribute_try_get_for_read(attribute_id); if (!attribute) { @@ -1152,8 +1152,8 @@ blender::bke::ReadAttributeLookup GeometryComponent::attribute_try_get_for_read( } blender::GVArray GeometryComponent::attribute_get_for_read(const AttributeIDRef &attribute_id, - const AttributeDomain domain, - const CustomDataType data_type, + const eAttrDomain domain, + const eCustomDataType data_type, const void *default_value) const { blender::GVArray varray = this->attribute_try_get_for_read(attribute_id, domain, data_type); @@ -1214,8 +1214,8 @@ static void save_output_attribute(OutputAttribute &output_attribute) else { attribute_id = varray.anonymous_attribute_id.extract(); } - const AttributeDomain domain = output_attribute.domain(); - const CustomDataType data_type = output_attribute.custom_data_type(); + const eAttrDomain domain = output_attribute.domain(); + const eCustomDataType data_type = output_attribute.custom_data_type(); const CPPType &cpp_type = output_attribute.cpp_type(); component.attribute_try_delete(attribute_id); @@ -1252,8 +1252,8 @@ static std::function<void(OutputAttribute &)> get_simple_output_attribute_save_m static OutputAttribute create_output_attribute(GeometryComponent &component, const AttributeIDRef &attribute_id, - const AttributeDomain domain, - const CustomDataType data_type, + const eAttrDomain domain, + const eCustomDataType data_type, const bool ignore_old_values, const void *default_value) { @@ -1358,17 +1358,15 @@ static OutputAttribute create_output_attribute(GeometryComponent &component, } OutputAttribute GeometryComponent::attribute_try_get_for_output(const AttributeIDRef &attribute_id, - const AttributeDomain domain, - const CustomDataType data_type, + const eAttrDomain domain, + const eCustomDataType data_type, const void *default_value) { return create_output_attribute(*this, attribute_id, domain, data_type, false, default_value); } OutputAttribute GeometryComponent::attribute_try_get_for_output_only( - const AttributeIDRef &attribute_id, - const AttributeDomain domain, - const CustomDataType data_type) + const AttributeIDRef &attribute_id, const eAttrDomain domain, const eCustomDataType data_type) { return create_output_attribute(*this, attribute_id, domain, data_type, true, nullptr); } @@ -1382,17 +1380,17 @@ GVArray GeometryFieldInput::get_varray_for_context(const fn::FieldContext &conte if (const GeometryComponentFieldContext *geometry_context = dynamic_cast<const GeometryComponentFieldContext *>(&context)) { const GeometryComponent &component = geometry_context->geometry_component(); - const AttributeDomain domain = geometry_context->domain(); + const eAttrDomain domain = geometry_context->domain(); return this->get_varray_for_context(component, domain, mask); } return {}; } GVArray AttributeFieldInput::get_varray_for_context(const GeometryComponent &component, - const AttributeDomain domain, + const eAttrDomain domain, IndexMask UNUSED(mask)) const { - const CustomDataType data_type = cpp_type_to_custom_data_type(*type_); + const eCustomDataType data_type = cpp_type_to_custom_data_type(*type_); return component.attribute_try_get_for_read(name_, domain, data_type); } @@ -1416,7 +1414,7 @@ bool AttributeFieldInput::is_equal_to(const fn::FieldNode &other) const return false; } -static StringRef get_random_id_attribute_name(const AttributeDomain domain) +static StringRef get_random_id_attribute_name(const eAttrDomain domain) { switch (domain) { case ATTR_DOMAIN_POINT: @@ -1428,7 +1426,7 @@ static StringRef get_random_id_attribute_name(const AttributeDomain domain) } GVArray IDAttributeFieldInput::get_varray_for_context(const GeometryComponent &component, - const AttributeDomain domain, + const eAttrDomain domain, IndexMask mask) const { @@ -1461,10 +1459,10 @@ bool IDAttributeFieldInput::is_equal_to(const fn::FieldNode &other) const } GVArray AnonymousAttributeFieldInput::get_varray_for_context(const GeometryComponent &component, - const AttributeDomain domain, + const eAttrDomain domain, IndexMask UNUSED(mask)) const { - const CustomDataType data_type = cpp_type_to_custom_data_type(*type_); + const eCustomDataType data_type = cpp_type_to_custom_data_type(*type_); return component.attribute_try_get_for_read(anonymous_id_.get(), domain, data_type); } diff --git a/source/blender/blenkernel/intern/attribute_access_intern.hh b/source/blender/blenkernel/intern/attribute_access_intern.hh index f0f47cb7a11..ac43754dd1a 100644 --- a/source/blender/blenkernel/intern/attribute_access_intern.hh +++ b/source/blender/blenkernel/intern/attribute_access_intern.hh @@ -47,16 +47,16 @@ class BuiltinAttributeProvider { protected: const std::string name_; - const AttributeDomain domain_; - const CustomDataType data_type_; + const eAttrDomain domain_; + const eCustomDataType data_type_; const CreatableEnum createable_; const WritableEnum writable_; const DeletableEnum deletable_; public: BuiltinAttributeProvider(std::string name, - const AttributeDomain domain, - const CustomDataType data_type, + const eAttrDomain domain, + const eCustomDataType data_type, const CreatableEnum createable, const WritableEnum writable, const DeletableEnum deletable) @@ -81,12 +81,12 @@ class BuiltinAttributeProvider { return name_; } - AttributeDomain domain() const + eAttrDomain domain() const { return domain_; } - CustomDataType data_type() const + eCustomDataType data_type() const { return data_type_; } @@ -106,8 +106,8 @@ class DynamicAttributesProvider { const AttributeIDRef &attribute_id) const = 0; virtual bool try_create(GeometryComponent &UNUSED(component), const AttributeIDRef &UNUSED(attribute_id), - const AttributeDomain UNUSED(domain), - const CustomDataType UNUSED(data_type), + const eAttrDomain UNUSED(domain), + const eCustomDataType UNUSED(data_type), const AttributeInit &UNUSED(initializer)) const { /* Some providers should not create new attributes. */ @@ -116,7 +116,7 @@ class DynamicAttributesProvider { virtual bool foreach_attribute(const GeometryComponent &component, const AttributeForeachCallback callback) const = 0; - virtual void foreach_domain(const FunctionRef<void(AttributeDomain)> callback) const = 0; + virtual void foreach_domain(const FunctionRef<void(eAttrDomain)> callback) const = 0; }; /** @@ -128,11 +128,11 @@ class CustomDataAttributeProvider final : public DynamicAttributesProvider { CD_MASK_PROP_FLOAT3 | CD_MASK_PROP_INT32 | CD_MASK_PROP_COLOR | CD_MASK_PROP_BOOL | CD_MASK_PROP_INT8 | CD_MASK_PROP_BYTE_COLOR; - const AttributeDomain domain_; + const eAttrDomain domain_; const CustomDataAccessInfo custom_data_access_; public: - CustomDataAttributeProvider(const AttributeDomain domain, + CustomDataAttributeProvider(const eAttrDomain domain, const CustomDataAccessInfo custom_data_access) : domain_(domain), custom_data_access_(custom_data_access) { @@ -148,20 +148,20 @@ class CustomDataAttributeProvider final : public DynamicAttributesProvider { bool try_create(GeometryComponent &component, const AttributeIDRef &attribute_id, - AttributeDomain domain, - const CustomDataType data_type, + eAttrDomain domain, + const eCustomDataType data_type, const AttributeInit &initializer) const final; bool foreach_attribute(const GeometryComponent &component, const AttributeForeachCallback callback) const final; - void foreach_domain(const FunctionRef<void(AttributeDomain)> callback) const final + void foreach_domain(const FunctionRef<void(eAttrDomain)> callback) const final { callback(domain_); } private: - bool type_is_supported(CustomDataType data_type) const + bool type_is_supported(eCustomDataType data_type) const { return ((1ULL << data_type) & supported_types_mask) != 0; } @@ -174,17 +174,17 @@ class NamedLegacyCustomDataProvider final : public DynamicAttributesProvider { private: using AsReadAttribute = GVArray (*)(const void *data, int domain_num); using AsWriteAttribute = GVMutableArray (*)(void *data, int domain_num); - const AttributeDomain domain_; - const CustomDataType attribute_type_; - const CustomDataType stored_type_; + const eAttrDomain domain_; + const eCustomDataType attribute_type_; + const eCustomDataType stored_type_; const CustomDataAccessInfo custom_data_access_; const AsReadAttribute as_read_attribute_; const AsWriteAttribute as_write_attribute_; public: - NamedLegacyCustomDataProvider(const AttributeDomain domain, - const CustomDataType attribute_type, - const CustomDataType stored_type, + NamedLegacyCustomDataProvider(const eAttrDomain domain, + const eCustomDataType attribute_type, + const eCustomDataType stored_type, const CustomDataAccessInfo custom_data_access, const AsReadAttribute as_read_attribute, const AsWriteAttribute as_write_attribute) @@ -204,7 +204,7 @@ class NamedLegacyCustomDataProvider final : public DynamicAttributesProvider { bool try_delete(GeometryComponent &component, const AttributeIDRef &attribute_id) const final; bool foreach_attribute(const GeometryComponent &component, const AttributeForeachCallback callback) const final; - void foreach_domain(const FunctionRef<void(AttributeDomain)> callback) const final; + void foreach_domain(const FunctionRef<void(eAttrDomain)> callback) const final; }; template<typename T> GVArray make_array_read_attribute(const void *data, const int domain_num) @@ -230,7 +230,7 @@ class BuiltinCustomDataLayerProvider final : public BuiltinAttributeProvider { using AsWriteAttribute = GVMutableArray (*)(void *data, int domain_num); using UpdateOnRead = void (*)(const GeometryComponent &component); using UpdateOnWrite = void (*)(GeometryComponent &component); - const CustomDataType stored_type_; + const eCustomDataType stored_type_; const CustomDataAccessInfo custom_data_access_; const AsReadAttribute as_read_attribute_; const AsWriteAttribute as_write_attribute_; @@ -239,9 +239,9 @@ class BuiltinCustomDataLayerProvider final : public BuiltinAttributeProvider { public: BuiltinCustomDataLayerProvider(std::string attribute_name, - const AttributeDomain domain, - const CustomDataType attribute_type, - const CustomDataType stored_type, + const eAttrDomain domain, + const eCustomDataType attribute_type, + const eCustomDataType stored_type, const CreatableEnum creatable, const WritableEnum writable, const DeletableEnum deletable, @@ -288,7 +288,7 @@ class ComponentAttributeProviders { /** * All the domains that are supported by at least one of the providers above. */ - VectorSet<AttributeDomain> supported_domains_; + VectorSet<eAttrDomain> supported_domains_; public: ComponentAttributeProviders(Span<const BuiltinAttributeProvider *> builtin_attribute_providers, @@ -301,7 +301,7 @@ class ComponentAttributeProviders { supported_domains_.add(provider->domain()); } for (const DynamicAttributesProvider *provider : dynamic_attribute_providers) { - provider->foreach_domain([&](AttributeDomain domain) { supported_domains_.add(domain); }); + provider->foreach_domain([&](eAttrDomain domain) { supported_domains_.add(domain); }); } } @@ -315,7 +315,7 @@ class ComponentAttributeProviders { return dynamic_attribute_providers_; } - Span<AttributeDomain> supported_domains() const + Span<eAttrDomain> supported_domains() const { return supported_domains_; } diff --git a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc index 0cd324cfe2c..58380a1a35f 100644 --- a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc +++ b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc @@ -315,8 +315,8 @@ static ResultOffsets calculate_result_offsets(const CurvesInfo &info, const bool return result; } -static AttributeDomain get_attribute_domain_for_mesh(const MeshComponent &mesh, - const AttributeIDRef &attribute_id) +static eAttrDomain get_attribute_domain_for_mesh(const MeshComponent &mesh, + const AttributeIDRef &attribute_id) { /* Only use a different domain if it is builtin and must only exist on one domain. */ if (!mesh.attribute_is_builtin(attribute_id)) { @@ -456,7 +456,7 @@ static void copy_main_point_data_to_mesh_faces(const Span<T> src, static void copy_main_point_domain_attribute_to_mesh(const CurvesInfo &curves_info, const ResultOffsets &offsets, - const AttributeDomain dst_domain, + const eAttrDomain dst_domain, const GSpan src_all, GMutableSpan dst_all) { @@ -538,7 +538,7 @@ static void copy_profile_point_data_to_mesh_faces(const Span<T> src, static void copy_profile_point_domain_attribute_to_mesh(const CurvesInfo &curves_info, const ResultOffsets &offsets, - const AttributeDomain dst_domain, + const eAttrDomain dst_domain, const GSpan src_all, GMutableSpan dst_all) { @@ -597,7 +597,7 @@ static void copy_indices_to_offset_ranges(const VArray<T> &src, static void copy_curve_domain_attribute_to_mesh(const ResultOffsets &mesh_offsets, const Span<int> curve_indices, - const AttributeDomain dst_domain, + const eAttrDomain dst_domain, const GVArray &src, GMutableSpan dst) { @@ -728,11 +728,11 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main, } main_attributes.add_new(id); - const AttributeDomain src_domain = meta_data.domain; - const CustomDataType type = meta_data.data_type; + const eAttrDomain src_domain = meta_data.domain; + const eCustomDataType type = meta_data.data_type; GVArray src = main_component.attribute_try_get_for_read(id, src_domain, type); - const AttributeDomain dst_domain = get_attribute_domain_for_mesh(mesh_component, id); + const eAttrDomain dst_domain = get_attribute_domain_for_mesh(mesh_component, id); OutputAttribute dst = mesh_component.attribute_try_get_for_output_only(id, dst_domain, type); if (!dst) { return true; @@ -763,11 +763,11 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main, if (!should_add_attribute_to_mesh(profile_component, mesh_component, id)) { return true; } - const AttributeDomain src_domain = meta_data.domain; - const CustomDataType type = meta_data.data_type; + const eAttrDomain src_domain = meta_data.domain; + const eCustomDataType type = meta_data.data_type; GVArray src = profile_component.attribute_try_get_for_read(id, src_domain, type); - const AttributeDomain dst_domain = get_attribute_domain_for_mesh(mesh_component, id); + const eAttrDomain dst_domain = get_attribute_domain_for_mesh(mesh_component, id); OutputAttribute dst = mesh_component.attribute_try_get_for_output_only(id, dst_domain, type); if (!dst) { return true; diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc index 07e50eea88c..c2e67d853c9 100644 --- a/source/blender/blenkernel/intern/curves_geometry.cc +++ b/source/blender/blenkernel/intern/curves_geometry.cc @@ -160,30 +160,29 @@ CurvesGeometry::~CurvesGeometry() /** \name Accessors * \{ */ -static int domain_num(const CurvesGeometry &curves, const AttributeDomain domain) +static int domain_num(const CurvesGeometry &curves, const eAttrDomain domain) { return domain == ATTR_DOMAIN_POINT ? curves.points_num() : curves.curves_num(); } -static CustomData &domain_custom_data(CurvesGeometry &curves, const AttributeDomain domain) +static CustomData &domain_custom_data(CurvesGeometry &curves, const eAttrDomain domain) { return domain == ATTR_DOMAIN_POINT ? curves.point_data : curves.curve_data; } -static const CustomData &domain_custom_data(const CurvesGeometry &curves, - const AttributeDomain domain) +static const CustomData &domain_custom_data(const CurvesGeometry &curves, const eAttrDomain domain) { return domain == ATTR_DOMAIN_POINT ? curves.point_data : curves.curve_data; } template<typename T> static VArray<T> get_varray_attribute(const CurvesGeometry &curves, - const AttributeDomain domain, + const eAttrDomain domain, const StringRefNull name, const T default_value) { const int num = domain_num(curves, domain); - const CustomDataType type = cpp_type_to_custom_data_type(CPPType::get<T>()); + const eCustomDataType type = cpp_type_to_custom_data_type(CPPType::get<T>()); const CustomData &custom_data = domain_custom_data(curves, domain); const T *data = (const T *)CustomData_get_layer_named(&custom_data, type, name.c_str()); @@ -195,12 +194,12 @@ static VArray<T> get_varray_attribute(const CurvesGeometry &curves, template<typename T> static Span<T> get_span_attribute(const CurvesGeometry &curves, - const AttributeDomain domain, + const eAttrDomain domain, const StringRefNull name) { const int num = domain_num(curves, domain); const CustomData &custom_data = domain_custom_data(curves, domain); - const CustomDataType type = cpp_type_to_custom_data_type(CPPType::get<T>()); + const eCustomDataType type = cpp_type_to_custom_data_type(CPPType::get<T>()); T *data = (T *)CustomData_get_layer_named(&custom_data, type, name.c_str()); if (data == nullptr) { @@ -211,12 +210,12 @@ static Span<T> get_span_attribute(const CurvesGeometry &curves, template<typename T> static MutableSpan<T> get_mutable_attribute(CurvesGeometry &curves, - const AttributeDomain domain, + const eAttrDomain domain, const StringRefNull name, const T default_value = T()) { const int num = domain_num(curves, domain); - const CustomDataType type = cpp_type_to_custom_data_type(CPPType::get<T>()); + const eCustomDataType type = cpp_type_to_custom_data_type(CPPType::get<T>()); CustomData &custom_data = domain_custom_data(curves, domain); T *data = (T *)CustomData_duplicate_referenced_layer_named( @@ -1106,7 +1105,7 @@ void CurvesGeometry::update_customdata_pointers() static void *ensure_customdata_layer(CustomData &custom_data, const StringRefNull name, - const CustomDataType data_type, + const eCustomDataType data_type, const int tot_elements) { for (const int other_layer_i : IndexRange(custom_data.totlayer)) { @@ -1175,7 +1174,7 @@ static CurvesGeometry copy_with_removed_curves(const CurvesGeometry &curves, CustomData &new_point_data = new_curves.point_data; for (const int layer_i : IndexRange(old_point_data.totlayer)) { const CustomDataLayer &old_layer = old_point_data.layers[layer_i]; - const CustomDataType data_type = static_cast<CustomDataType>(old_layer.type); + const eCustomDataType data_type = static_cast<eCustomDataType>(old_layer.type); const CPPType &type = *bke::custom_data_type_to_cpp_type(data_type); const void *src_buffer = old_layer.data; @@ -1202,7 +1201,7 @@ static CurvesGeometry copy_with_removed_curves(const CurvesGeometry &curves, CustomData &new_curve_data = new_curves.curve_data; for (const int layer_i : IndexRange(old_curve_data.totlayer)) { const CustomDataLayer &old_layer = old_curve_data.layers[layer_i]; - const CustomDataType data_type = static_cast<CustomDataType>(old_layer.type); + const eCustomDataType data_type = static_cast<eCustomDataType>(old_layer.type); const CPPType &type = *bke::custom_data_type_to_cpp_type(data_type); const void *src_buffer = old_layer.data; @@ -1268,7 +1267,7 @@ static void reverse_swap_curve_point_data(const CurvesGeometry &curves, static bool layer_matches_name_and_type(const CustomDataLayer &layer, const StringRef name, - const CustomDataType type) + const eCustomDataType type) { if (layer.type != type) { return false; @@ -1311,7 +1310,7 @@ void CurvesGeometry::reverse_curves(const IndexMask curves_to_reverse) continue; } - const CustomDataType data_type = static_cast<CustomDataType>(layer.type); + const eCustomDataType data_type = static_cast<eCustomDataType>(layer.type); attribute_math::convert_to_static_type(data_type, [&](auto dummy) { using T = decltype(dummy); reverse_curve_point_data<T>( @@ -1430,8 +1429,8 @@ static GVArray adapt_curve_domain_curve_to_point(const CurvesGeometry &curves, } GVArray CurvesGeometry::adapt_domain(const GVArray &varray, - const AttributeDomain from, - const AttributeDomain to) const + const eAttrDomain from, + const eAttrDomain to) const { if (!varray) { return {}; diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index 058230745e7..a63528835ee 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -2239,7 +2239,7 @@ static bool customdata_typemap_is_valid(const CustomData *data) bool CustomData_merge(const struct CustomData *source, struct CustomData *dest, - CustomDataMask mask, + eCustomDataMask mask, eCDAllocType alloctype, int totelem) { @@ -2341,7 +2341,7 @@ void CustomData_realloc(CustomData *data, int totelem) void CustomData_copy(const struct CustomData *source, struct CustomData *dest, - CustomDataMask mask, + eCustomDataMask mask, eCDAllocType alloctype, int totelem) { @@ -2403,7 +2403,7 @@ void CustomData_free(CustomData *data, int totelem) CustomData_reset(data); } -void CustomData_free_typemask(struct CustomData *data, int totelem, CustomDataMask mask) +void CustomData_free_typemask(struct CustomData *data, int totelem, eCustomDataMask mask) { for (int i = 0; i < data->totlayer; i++) { CustomDataLayer *layer = &data->layers[i]; @@ -2934,7 +2934,7 @@ int CustomData_number_of_layers(const CustomData *data, int type) return number; } -int CustomData_number_of_layers_typemask(const CustomData *data, CustomDataMask mask) +int CustomData_number_of_layers_typemask(const CustomData *data, eCustomDataMask mask) { int number = 0; @@ -3077,7 +3077,7 @@ void CustomData_free_temporary(CustomData *data, int totelem) } } -void CustomData_set_only_copy(const struct CustomData *data, CustomDataMask mask) +void CustomData_set_only_copy(const struct CustomData *data, eCustomDataMask mask) { for (int i = 0; i < data->totlayer; i++) { if (!(mask & CD_TYPE_AS_MASK(data->layers[i].type))) { @@ -3692,7 +3692,7 @@ void CustomData_bmesh_init_pool(CustomData *data, int totelem, const char htype) bool CustomData_bmesh_merge(const CustomData *source, CustomData *dest, - CustomDataMask mask, + eCustomDataMask mask, eCDAllocType alloctype, BMesh *bm, const char htype) @@ -3841,7 +3841,7 @@ static void CustomData_bmesh_alloc_block(CustomData *data, void **block) void CustomData_bmesh_free_block_data_exclude_by_type(CustomData *data, void *block, - const CustomDataMask mask_exclude) + const eCustomDataMask mask_exclude) { if (block == nullptr) { return; @@ -3888,7 +3888,7 @@ void CustomData_bmesh_copy_data_exclude_by_type(const CustomData *source, CustomData *dest, void *src_block, void **dest_block, - const CustomDataMask mask_exclude) + const eCustomDataMask mask_exclude) { /* Note that having a version of this function without a 'mask_exclude' * would cause too much duplicate code, so add a check instead. */ @@ -4600,7 +4600,10 @@ static void customdata_external_filename(char filepath[FILE_MAX], BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(id)); } -void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask mask, int totelem) +void CustomData_external_reload(CustomData *data, + ID *UNUSED(id), + eCustomDataMask mask, + int totelem) { for (int i = 0; i < data->totlayer; i++) { CustomDataLayer *layer = &data->layers[i]; @@ -4618,7 +4621,7 @@ void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask } } -void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int totelem) +void CustomData_external_read(CustomData *data, ID *id, eCustomDataMask mask, int totelem) { CustomDataExternal *external = data->external; CustomDataLayer *layer; @@ -4692,7 +4695,7 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int } void CustomData_external_write( - CustomData *data, ID *id, CustomDataMask mask, int totelem, int free) + CustomData *data, ID *id, eCustomDataMask mask, int totelem, int free) { CustomDataExternal *external = data->external; int update = 0; @@ -5183,7 +5186,7 @@ void CustomData_blend_write(BlendWriter *writer, CustomData *data, Span<CustomDataLayer> layers_to_write, int count, - CustomDataMask cddata_mask, + eCustomDataMask cddata_mask, ID *id) { /* write external customdata (not for undo) */ @@ -5384,7 +5387,7 @@ namespace blender::bke { /** \name Custom Data C++ API * \{ */ -const blender::CPPType *custom_data_type_to_cpp_type(const CustomDataType type) +const blender::CPPType *custom_data_type_to_cpp_type(const eCustomDataType type) { switch (type) { case CD_PROP_FLOAT: @@ -5409,7 +5412,7 @@ const blender::CPPType *custom_data_type_to_cpp_type(const CustomDataType type) return nullptr; } -CustomDataType cpp_type_to_custom_data_type(const blender::CPPType &type) +eCustomDataType cpp_type_to_custom_data_type(const blender::CPPType &type) { if (type.is<float>()) { return CD_PROP_FLOAT; @@ -5435,7 +5438,7 @@ CustomDataType cpp_type_to_custom_data_type(const blender::CPPType &type) if (type.is<ColorGeometry4b>()) { return CD_PROP_BYTE_COLOR; } - return static_cast<CustomDataType>(-1); + return static_cast<eCustomDataType>(-1); } /** \} */ diff --git a/source/blender/blenkernel/intern/geometry_component_curve.cc b/source/blender/blenkernel/intern/geometry_component_curve.cc index a28afc8ddca..898869c3c44 100644 --- a/source/blender/blenkernel/intern/geometry_component_curve.cc +++ b/source/blender/blenkernel/intern/geometry_component_curve.cc @@ -114,7 +114,7 @@ void CurveComponentLegacy::ensure_owns_direct_data() /** \name Attribute Access Helper Functions * \{ */ -int CurveComponentLegacy::attribute_domain_num(const AttributeDomain domain) const +int CurveComponentLegacy::attribute_domain_num(const eAttrDomain domain) const { if (curve_ == nullptr) { return 0; @@ -308,10 +308,9 @@ static GVArray adapt_curve_domain_spline_to_point(const CurveEval &curve, GVArra } // namespace blender::bke -GVArray CurveComponentLegacy::attribute_try_adapt_domain_impl( - const GVArray &varray, - const AttributeDomain from_domain, - const AttributeDomain to_domain) const +GVArray CurveComponentLegacy::attribute_try_adapt_domain_impl(const GVArray &varray, + const eAttrDomain from_domain, + const eAttrDomain to_domain) const { if (!varray) { return {}; @@ -366,7 +365,7 @@ class BuiltinSplineAttributeProvider final : public BuiltinAttributeProvider { public: BuiltinSplineAttributeProvider(std::string attribute_name, - const CustomDataType attribute_type, + const eCustomDataType attribute_type, const WritableEnum writable, const AsReadAttribute as_read_attribute, const AsWriteAttribute as_write_attribute) @@ -577,7 +576,7 @@ static void point_attribute_materialize_to_uninitialized(Span<Span<T>> data, } static GVArray varray_from_initializer(const AttributeInit &initializer, - const CustomDataType data_type, + const eCustomDataType data_type, const Span<SplinePtr> splines) { switch (initializer.type) { @@ -604,7 +603,7 @@ static GVArray varray_from_initializer(const AttributeInit &initializer, static bool create_point_attribute(GeometryComponent &component, const AttributeIDRef &attribute_id, const AttributeInit &initializer, - const CustomDataType data_type) + const eCustomDataType data_type) { CurveEval *curve = get_curve_from_component_for_write(component); if (curve == nullptr || curve->splines().size() == 0) { @@ -1306,8 +1305,8 @@ class DynamicPointAttributeProvider final : public DynamicAttributesProvider { bool try_create(GeometryComponent &component, const AttributeIDRef &attribute_id, - const AttributeDomain domain, - const CustomDataType data_type, + const eAttrDomain domain, + const eCustomDataType data_type, const AttributeInit &initializer) const final { BLI_assert(this->type_is_supported(data_type)); @@ -1336,12 +1335,12 @@ class DynamicPointAttributeProvider final : public DynamicAttributesProvider { return true; } - void foreach_domain(const FunctionRef<void(AttributeDomain)> callback) const final + void foreach_domain(const FunctionRef<void(eAttrDomain)> callback) const final { callback(ATTR_DOMAIN_POINT); } - bool type_is_supported(CustomDataType data_type) const + bool type_is_supported(eCustomDataType data_type) const { return ((1ULL << data_type) & supported_types_mask) != 0; } diff --git a/source/blender/blenkernel/intern/geometry_component_curves.cc b/source/blender/blenkernel/intern/geometry_component_curves.cc index 9b023d12a7d..0003961c033 100644 --- a/source/blender/blenkernel/intern/geometry_component_curves.cc +++ b/source/blender/blenkernel/intern/geometry_component_curves.cc @@ -208,7 +208,7 @@ static Array<float3> curve_normal_point_domain(const bke::CurvesGeometry &curves return results; } -VArray<float3> curve_normals_varray(const CurveComponent &component, const AttributeDomain domain) +VArray<float3> curve_normals_varray(const CurveComponent &component, const eAttrDomain domain) { if (!component.has_curves()) { return {}; @@ -244,7 +244,7 @@ VArray<float3> curve_normals_varray(const CurveComponent &component, const Attri * \{ */ static VArray<float> construct_curve_length_gvarray(const CurveComponent &component, - const AttributeDomain domain) + const eAttrDomain domain) { if (!component.has_curves()) { return {}; @@ -279,7 +279,7 @@ CurveLengthFieldInput::CurveLengthFieldInput() } GVArray CurveLengthFieldInput::get_varray_for_context(const GeometryComponent &component, - const AttributeDomain domain, + const eAttrDomain domain, IndexMask UNUSED(mask)) const { if (component.type() == GEO_COMPONENT_TYPE_CURVE) { @@ -308,7 +308,7 @@ bool CurveLengthFieldInput::is_equal_to(const fn::FieldNode &other) const /** \name Attribute Access Helper Functions * \{ */ -int CurveComponent::attribute_domain_num(const AttributeDomain domain) const +int CurveComponent::attribute_domain_num(const eAttrDomain domain) const { if (curves_ == nullptr) { return 0; @@ -325,8 +325,8 @@ int CurveComponent::attribute_domain_num(const AttributeDomain domain) const } GVArray CurveComponent::attribute_try_adapt_domain_impl(const GVArray &varray, - const AttributeDomain from_domain, - const AttributeDomain to_domain) const + const eAttrDomain from_domain, + const eAttrDomain to_domain) const { return blender::bke::CurvesGeometry::wrap(curves_->geometry) .adapt_domain(varray, from_domain, to_domain); diff --git a/source/blender/blenkernel/intern/geometry_component_instances.cc b/source/blender/blenkernel/intern/geometry_component_instances.cc index e56a7ca4dd8..653be03b991 100644 --- a/source/blender/blenkernel/intern/geometry_component_instances.cc +++ b/source/blender/blenkernel/intern/geometry_component_instances.cc @@ -366,7 +366,7 @@ blender::Span<int> InstancesComponent::almost_unique_ids() const return almost_unique_ids_; } -int InstancesComponent::attribute_domain_num(const AttributeDomain domain) const +int InstancesComponent::attribute_domain_num(const eAttrDomain domain) const { if (domain != ATTR_DOMAIN_INSTANCE) { return 0; diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc index 5ac9a03f43c..8a021e596bd 100644 --- a/source/blender/blenkernel/intern/geometry_component_mesh.cc +++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc @@ -119,7 +119,7 @@ namespace blender::bke { VArray<float3> mesh_normals_varray(const MeshComponent &mesh_component, const Mesh &mesh, const IndexMask mask, - const AttributeDomain domain) + const eAttrDomain domain) { switch (domain) { case ATTR_DOMAIN_FACE: { @@ -169,7 +169,7 @@ VArray<float3> mesh_normals_varray(const MeshComponent &mesh_component, /** \name Attribute Access * \{ */ -int MeshComponent::attribute_domain_num(const AttributeDomain domain) const +int MeshComponent::attribute_domain_num(const eAttrDomain domain) const { if (mesh_ == nullptr) { return 0; @@ -747,10 +747,9 @@ static GVArray adapt_mesh_domain_edge_to_face(const Mesh &mesh, const GVArray &v } // namespace blender::bke -blender::GVArray MeshComponent::attribute_try_adapt_domain_impl( - const blender::GVArray &varray, - const AttributeDomain from_domain, - const AttributeDomain to_domain) const +blender::GVArray MeshComponent::attribute_try_adapt_domain_impl(const blender::GVArray &varray, + const eAttrDomain from_domain, + const eAttrDomain to_domain) const { if (!varray) { return {}; @@ -1115,7 +1114,7 @@ class VertexGroupsAttributeProvider final : public DynamicAttributesProvider { return true; } - void foreach_domain(const FunctionRef<void(AttributeDomain)> callback) const final + void foreach_domain(const FunctionRef<void(eAttrDomain)> callback) const final { callback(ATTR_DOMAIN_POINT); } diff --git a/source/blender/blenkernel/intern/geometry_component_pointcloud.cc b/source/blender/blenkernel/intern/geometry_component_pointcloud.cc index 6de123c7cb9..facdbed265d 100644 --- a/source/blender/blenkernel/intern/geometry_component_pointcloud.cc +++ b/source/blender/blenkernel/intern/geometry_component_pointcloud.cc @@ -104,7 +104,7 @@ void PointCloudComponent::ensure_owns_direct_data() /** \name Attribute Access * \{ */ -int PointCloudComponent::attribute_domain_num(const AttributeDomain domain) const +int PointCloudComponent::attribute_domain_num(const eAttrDomain domain) const { if (pointcloud_ == nullptr) { return 0; diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 40e36ced199..10226bc6990 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -470,7 +470,7 @@ void GeometrySet::gather_attributes_for_propagation( return; } - AttributeDomain domain = meta_data.domain; + eAttrDomain domain = meta_data.domain; if (dst_component_type != GEO_COMPONENT_TYPE_INSTANCES && domain == ATTR_DOMAIN_INSTANCE) { domain = ATTR_DOMAIN_POINT; } @@ -567,7 +567,7 @@ void GeometrySet::modify_geometry_sets(ForeachSubGeometryCallback callback) namespace blender::bke { GVArray NormalFieldInput::get_varray_for_context(const GeometryComponent &component, - const AttributeDomain domain, + const eAttrDomain domain, IndexMask mask) const { if (component.type() == GEO_COMPONENT_TYPE_MESH) { diff --git a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc index c960a7f35f1..85aed01ce52 100644 --- a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc +++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc @@ -375,7 +375,7 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source) while ((layer = BKE_id_attribute_from_index( const_cast<ID *>(&source->id), i++, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL))) { - AttributeDomain domain = BKE_id_attribute_domain(&source->id, layer); + eAttrDomain domain = BKE_id_attribute_domain(&source->id, layer); CustomData *target_cdata = domain == ATTR_DOMAIN_POINT ? &target->vdata : &target->ldata; const CustomData *source_cdata = domain == ATTR_DOMAIN_POINT ? &source->vdata : &source->ldata; diff --git a/source/blender/blenkernel/intern/mesh_sample.cc b/source/blender/blenkernel/intern/mesh_sample.cc index 33b051c792c..7595c08a208 100644 --- a/source/blender/blenkernel/intern/mesh_sample.cc +++ b/source/blender/blenkernel/intern/mesh_sample.cc @@ -204,7 +204,7 @@ Span<float3> MeshAttributeInterpolator::ensure_nearest_weights() } void MeshAttributeInterpolator::sample_data(const GVArray &src, - const AttributeDomain domain, + const eAttrDomain domain, const eAttributeMapMode mode, const GMutableSpan dst) { diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_validate.cc index d16f7eaf588..9b2697ecc84 100644 --- a/source/blender/blenkernel/intern/mesh_validate.cc +++ b/source/blender/blenkernel/intern/mesh_validate.cc @@ -926,7 +926,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh, } static bool mesh_validate_customdata(CustomData *data, - CustomDataMask mask, + eCustomDataMask mask, const uint totitems, const bool do_verbose, const bool do_fixes, @@ -953,7 +953,7 @@ static bool mesh_validate_customdata(CustomData *data, } if (mask != 0) { - CustomDataMask layer_typemask = CD_TYPE_AS_MASK(layer->type); + eCustomDataMask layer_typemask = CD_TYPE_AS_MASK(layer->type); if ((layer_typemask & mask) == 0) { PRINT_ERR("\tCustomDataLayer type %d which isn't in the mask\n", layer->type); ok = false; diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index cff7eb20b05..bb499f24c07 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -1674,7 +1674,7 @@ static void sculpt_update_object(Depsgraph *depsgraph, ss->vmask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK); CustomDataLayer *layer; - AttributeDomain domain; + eAttrDomain domain; if (BKE_pbvh_get_color_layer(me, &layer, &domain)) { if (layer->type == CD_PROP_COLOR) { diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 1d4fbb92fa0..2b049222073 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -1264,7 +1264,7 @@ static int pbvh_get_buffers_update_flags(PBVH *UNUSED(pbvh)) return update_flags; } -bool BKE_pbvh_get_color_layer(const Mesh *me, CustomDataLayer **r_layer, AttributeDomain *r_attr) +bool BKE_pbvh_get_color_layer(const Mesh *me, CustomDataLayer **r_layer, eAttrDomain *r_attr) { CustomDataLayer *layer = BKE_id_attributes_active_color_get((ID *)me); @@ -1274,7 +1274,7 @@ bool BKE_pbvh_get_color_layer(const Mesh *me, CustomDataLayer **r_layer, Attribu return false; } - AttributeDomain domain = BKE_id_attribute_domain((ID *)me, layer); + eAttrDomain domain = BKE_id_attribute_domain((ID *)me, layer); if (!ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CORNER)) { *r_layer = NULL; @@ -1340,7 +1340,7 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata, break; case PBVH_FACES: { CustomDataLayer *layer = NULL; - AttributeDomain domain; + eAttrDomain domain; BKE_pbvh_get_color_layer(pbvh->mesh, &layer, &domain); diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index be6e95426c2..dec93826b9b 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -44,7 +44,7 @@ using blender::IndexRange; namespace blender::bke { template<typename Func> -inline void to_static_color_type(const CustomDataType type, const Func &func) +inline void to_static_color_type(const eCustomDataType type, const Func &func) { switch (type) { case CD_PROP_COLOR: @@ -146,7 +146,7 @@ static void pbvh_vertex_color_set(PBVH &pbvh, int vertex, const float color[4]) extern "C" { void BKE_pbvh_vertex_color_get(const PBVH *pbvh, int vertex, float r_color[4]) { - blender::bke::to_static_color_type(CustomDataType(pbvh->color_layer->type), [&](auto dummy) { + blender::bke::to_static_color_type(eCustomDataType(pbvh->color_layer->type), [&](auto dummy) { using T = decltype(dummy); blender::bke::pbvh_vertex_color_get<T>(*pbvh, vertex, r_color); }); @@ -154,7 +154,7 @@ void BKE_pbvh_vertex_color_get(const PBVH *pbvh, int vertex, float r_color[4]) void BKE_pbvh_vertex_color_set(PBVH *pbvh, int vertex, const float color[4]) { - blender::bke::to_static_color_type(CustomDataType(pbvh->color_layer->type), [&](auto dummy) { + blender::bke::to_static_color_type(eCustomDataType(pbvh->color_layer->type), [&](auto dummy) { using T = decltype(dummy); blender::bke::pbvh_vertex_color_set<T>(*pbvh, vertex, color); }); @@ -165,7 +165,7 @@ void BKE_pbvh_swap_colors(PBVH *pbvh, const int indices_num, float (*r_colors)[4]) { - blender::bke::to_static_color_type(CustomDataType(pbvh->color_layer->type), [&](auto dummy) { + blender::bke::to_static_color_type(eCustomDataType(pbvh->color_layer->type), [&](auto dummy) { using T = decltype(dummy); T *pbvh_colors = static_cast<T *>(pbvh->color_layer->data); for (const int i : IndexRange(indices_num)) { @@ -181,7 +181,7 @@ void BKE_pbvh_store_colors(PBVH *pbvh, const int indices_num, float (*r_colors)[4]) { - blender::bke::to_static_color_type(CustomDataType(pbvh->color_layer->type), [&](auto dummy) { + blender::bke::to_static_color_type(eCustomDataType(pbvh->color_layer->type), [&](auto dummy) { using T = decltype(dummy); T *pbvh_colors = static_cast<T *>(pbvh->color_layer->data); for (const int i : IndexRange(indices_num)) { @@ -199,7 +199,7 @@ void BKE_pbvh_store_colors_vertex(PBVH *pbvh, BKE_pbvh_store_colors(pbvh, indices, indices_num, r_colors); } else { - blender::bke::to_static_color_type(CustomDataType(pbvh->color_layer->type), [&](auto dummy) { + blender::bke::to_static_color_type(eCustomDataType(pbvh->color_layer->type), [&](auto dummy) { using T = decltype(dummy); for (const int i : IndexRange(indices_num)) { blender::bke::pbvh_vertex_color_get<T>(*pbvh, indices[i], r_colors[i]); diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h index a86663a9c74..98b490b28dd 100644 --- a/source/blender/blenkernel/intern/pbvh_intern.h +++ b/source/blender/blenkernel/intern/pbvh_intern.h @@ -198,7 +198,7 @@ struct PBVH { const struct MeshElemMap *pmap; CustomDataLayer *color_layer; - AttributeDomain color_domain; + eAttrDomain color_domain; bool is_drawing; |