diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 9fd07c304ad..a9a34318cbe 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -146,10 +146,10 @@ struct DerivedMesh { * from the derived mesh (this gives a pointer to the actual data, not * a copy) */ - void *(*getVertDataArray)(DerivedMesh *dm, int type); - void *(*getEdgeDataArray)(DerivedMesh *dm, int type); - void *(*getLoopDataArray)(DerivedMesh *dm, int type); - void *(*getPolyDataArray)(DerivedMesh *dm, int type); + void *(*getVertDataArray)(DerivedMesh *dm, eCustomDataType type); + void *(*getEdgeDataArray)(DerivedMesh *dm, eCustomDataType type); + void *(*getLoopDataArray)(DerivedMesh *dm, eCustomDataType type); + void *(*getPolyDataArray)(DerivedMesh *dm, eCustomDataType type); /** Optional grid access for subsurf */ int (*getNumGrids)(DerivedMesh *dm); @@ -228,10 +228,10 @@ void DM_set_only_copy(DerivedMesh *dm, const struct CustomData_MeshMasks *mask); * \note these return pointers - any change modifies the internals of the mesh. * \{ */ -void *DM_get_vert_data_layer(struct DerivedMesh *dm, int type); -void *DM_get_edge_data_layer(struct DerivedMesh *dm, int type); -void *DM_get_poly_data_layer(struct DerivedMesh *dm, int type); -void *DM_get_loop_data_layer(struct DerivedMesh *dm, int type); +void *DM_get_vert_data_layer(struct DerivedMesh *dm, eCustomDataType type); +void *DM_get_edge_data_layer(struct DerivedMesh *dm, eCustomDataType type); +void *DM_get_poly_data_layer(struct DerivedMesh *dm, eCustomDataType type); +void *DM_get_loop_data_layer(struct DerivedMesh *dm, eCustomDataType type); /** \} */ diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h index 096c89098bb..da3f68a46c6 100644 --- a/source/blender/blenkernel/BKE_attribute.h +++ b/source/blender/blenkernel/BKE_attribute.h @@ -57,8 +57,11 @@ 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, eAttrDomain domain, struct ReportList *reports); +struct CustomDataLayer *BKE_id_attribute_new(struct ID *id, + const char *name, + eCustomDataType type, + eAttrDomain domain, + struct ReportList *reports); bool BKE_id_attribute_remove(struct ID *id, const char *name, struct ReportList *reports); /** @@ -70,7 +73,7 @@ struct CustomDataLayer *BKE_id_attribute_duplicate(struct ID *id, struct CustomDataLayer *BKE_id_attribute_find(const struct ID *id, const char *name, - int type, + eCustomDataType type, eAttrDomain domain); struct CustomDataLayer *BKE_id_attribute_search(struct ID *id, diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 53e21f3c660..1a2a6770d13 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -136,26 +136,26 @@ bool CustomData_has_referenced(const struct CustomData *data); * another, while not overwriting anything else (e.g. flags). probably only * implemented for `mloopuv/mloopcol`, for now. */ -void CustomData_data_copy_value(int type, const void *source, void *dest); -void CustomData_data_set_default_value(int type, void *elem); +void CustomData_data_copy_value(eCustomDataType type, const void *source, void *dest); +void CustomData_data_set_default_value(eCustomDataType type, void *elem); /** * Mixes the "value" (e.g. `mloopuv` UV or `mloopcol` colors) from one block into * another, while not overwriting anything else (e.g. flags). */ void CustomData_data_mix_value( - int type, const void *source, void *dest, int mixmode, float mixfactor); + eCustomDataType type, const void *source, void *dest, int mixmode, float mixfactor); /** * Compares if data1 is equal to data2. type is a valid #CustomData type * enum (e.g. #CD_PROP_FLOAT). the layer type's equal function is used to compare * the data, if it exists, otherwise #memcmp is used. */ -bool CustomData_data_equals(int type, const void *data1, const void *data2); -void CustomData_data_initminmax(int type, void *min, void *max); -void CustomData_data_dominmax(int type, const void *data, void *min, void *max); -void CustomData_data_multiply(int type, void *data, float fac); -void CustomData_data_add(int type, void *data1, const void *data2); +bool CustomData_data_equals(eCustomDataType type, const void *data1, const void *data2); +void CustomData_data_initminmax(eCustomDataType type, void *min, void *max); +void CustomData_data_dominmax(eCustomDataType type, const void *data, void *min, void *max); +void CustomData_data_multiply(eCustomDataType type, void *data, float fac); +void CustomData_data_add(eCustomDataType type, void *data1, const void *data2); /** * Initializes a CustomData object with the same layer setup as source. @@ -256,7 +256,7 @@ const void *CustomData_add_layer_named_with_data(struct CustomData *data, int totelem, const char *name); void *CustomData_add_layer_anonymous(struct CustomData *data, - int type, + eCustomDataType type, eCDAllocType alloctype, void *layer, int totelem, @@ -268,7 +268,7 @@ void *CustomData_add_layer_anonymous(struct CustomData *data, * * In edit-mode, use #EDBM_data_layer_free instead of this function. */ -bool CustomData_free_layer(struct CustomData *data, int type, int totelem, int index); +bool CustomData_free_layer(struct CustomData *data, eCustomDataType type, int totelem, int index); bool CustomData_free_layer_named(struct CustomData *data, const char *name, const int totelem); /** @@ -277,23 +277,23 @@ bool CustomData_free_layer_named(struct CustomData *data, const char *name, cons * * In edit-mode, use #EDBM_data_layer_free instead of this function. */ -bool CustomData_free_layer_active(struct CustomData *data, int type, int totelem); +bool CustomData_free_layer_active(struct CustomData *data, eCustomDataType type, int totelem); /** * Same as above, but free all layers with type. */ -void CustomData_free_layers(struct CustomData *data, int type, int totelem); +void CustomData_free_layers(struct CustomData *data, eCustomDataType type, int totelem); /** * Returns true if a layer with the specified type exists. */ -bool CustomData_has_layer(const struct CustomData *data, int type); +bool CustomData_has_layer(const struct CustomData *data, eCustomDataType type); /** * Returns the number of layers with this type. */ -int CustomData_number_of_layers(const struct CustomData *data, int type); -int CustomData_number_of_anonymous_layers(const struct CustomData *data, int type); +int CustomData_number_of_layers(const struct CustomData *data, eCustomDataType type); +int CustomData_number_of_anonymous_layers(const struct CustomData *data, eCustomDataType type); int CustomData_number_of_layers_typemask(const struct CustomData *data, eCustomDataMask mask); /** @@ -329,7 +329,10 @@ void CustomData_copy_data_named(const struct CustomData *source, int source_index, int dest_index, int count); -void CustomData_copy_elements(int type, void *src_data_ofs, void *dst_data_ofs, int count); +void CustomData_copy_elements(eCustomDataType type, + void *src_data_ofs, + void *dst_data_ofs, + int count); void CustomData_bmesh_copy_data(const struct CustomData *source, struct CustomData *dest, void *src_block, @@ -345,7 +348,7 @@ void CustomData_bmesh_copy_data_exclude_by_type(const struct CustomData *source, */ void CustomData_copy_layer_type_data(const struct CustomData *source, struct CustomData *destination, - int type, + eCustomDataType type, int source_index, int destination_index, int count); @@ -410,18 +413,25 @@ void CustomData_swap(struct CustomData *data, int index_a, int index_b); * Retrieve a pointer to an element of the active layer of the given \a type, chosen by the * \a index, if it exists. */ -void *CustomData_get_for_write(struct CustomData *data, int index, int type, int totelem); +void *CustomData_get_for_write(struct CustomData *data, + int index, + eCustomDataType type, + int totelem); /** * Retrieve a pointer to an element of the \a nth layer of the given \a type, chosen by the * \a index, if it exists. */ -void *CustomData_get_n_for_write(struct CustomData *data, int type, int index, int n, int totelem); +void *CustomData_get_n_for_write( + struct CustomData *data, eCustomDataType type, int index, int n, int totelem); /* BMesh Custom Data Functions. * Should replace edit-mesh ones with these as well, due to more efficient memory alloc. */ -void *CustomData_bmesh_get(const struct CustomData *data, void *block, int type); -void *CustomData_bmesh_get_n(const struct CustomData *data, void *block, int type, int n); +void *CustomData_bmesh_get(const struct CustomData *data, void *block, eCustomDataType type); +void *CustomData_bmesh_get_n(const struct CustomData *data, + void *block, + eCustomDataType type, + int n); /** * Gets from the layer at physical index `n`, @@ -429,95 +439,109 @@ void *CustomData_bmesh_get_n(const struct CustomData *data, void *block, int typ */ void *CustomData_bmesh_get_layer_n(const struct CustomData *data, void *block, int n); -bool CustomData_set_layer_name(struct CustomData *data, int type, int n, const char *name); -const char *CustomData_get_layer_name(const struct CustomData *data, int type, int n); +bool CustomData_set_layer_name(struct CustomData *data, + eCustomDataType type, + int n, + const char *name); +const char *CustomData_get_layer_name(const struct CustomData *data, eCustomDataType type, int n); /** * Retrieve the data array of the active layer of the given \a type, if it exists. Return null * otherwise. */ -const void *CustomData_get_layer(const struct CustomData *data, int type); -void *CustomData_get_layer_for_write(struct CustomData *data, int type, int totelem); +const void *CustomData_get_layer(const struct CustomData *data, eCustomDataType type); +void *CustomData_get_layer_for_write(struct CustomData *data, eCustomDataType type, int totelem); /** * Retrieve the data array of the \a nth layer of the given \a type, if it exists. Return null * otherwise. */ -const void *CustomData_get_layer_n(const struct CustomData *data, int type, int n); -void *CustomData_get_layer_n_for_write(struct CustomData *data, int type, int n, int totelem); +const void *CustomData_get_layer_n(const struct CustomData *data, eCustomDataType type, int n); +void *CustomData_get_layer_n_for_write(struct CustomData *data, + eCustomDataType type, + int n, + int totelem); /** * Retrieve the data array of the layer with the given \a name and \a type, if it exists. Return * null otherwise. */ -const void *CustomData_get_layer_named(const struct CustomData *data, int type, const char *name); +const void *CustomData_get_layer_named(const struct CustomData *data, + eCustomDataType type, + const char *name); void *CustomData_get_layer_named_for_write(CustomData *data, - int type, + eCustomDataType type, const char *name, int totelem); -int CustomData_get_offset(const struct CustomData *data, int type); -int CustomData_get_offset_named(const struct CustomData *data, int type, const char *name); -int CustomData_get_n_offset(const struct CustomData *data, int type, int n); +int CustomData_get_offset(const struct CustomData *data, eCustomDataType type); +int CustomData_get_offset_named(const struct CustomData *data, + eCustomDataType type, + const char *name); +int CustomData_get_n_offset(const struct CustomData *data, eCustomDataType type, int n); -int CustomData_get_layer_index(const struct CustomData *data, int type); -int CustomData_get_layer_index_n(const struct CustomData *data, int type, int n); -int CustomData_get_named_layer_index(const struct CustomData *data, int type, const char *name); +int CustomData_get_layer_index(const struct CustomData *data, eCustomDataType type); +int CustomData_get_layer_index_n(const struct CustomData *data, eCustomDataType type, int n); +int CustomData_get_named_layer_index(const struct CustomData *data, + eCustomDataType type, + const char *name); int CustomData_get_named_layer_index_notype(const struct CustomData *data, const char *name); -int CustomData_get_active_layer_index(const struct CustomData *data, int type); -int CustomData_get_render_layer_index(const struct CustomData *data, int type); -int CustomData_get_clone_layer_index(const struct CustomData *data, int type); -int CustomData_get_stencil_layer_index(const struct CustomData *data, int type); -int CustomData_get_named_layer(const struct CustomData *data, int type, const char *name); -int CustomData_get_active_layer(const struct CustomData *data, int type); -int CustomData_get_render_layer(const struct CustomData *data, int type); -int CustomData_get_clone_layer(const struct CustomData *data, int type); -int CustomData_get_stencil_layer(const struct CustomData *data, int type); +int CustomData_get_active_layer_index(const struct CustomData *data, eCustomDataType type); +int CustomData_get_render_layer_index(const struct CustomData *data, eCustomDataType type); +int CustomData_get_clone_layer_index(const struct CustomData *data, eCustomDataType type); +int CustomData_get_stencil_layer_index(const struct CustomData *data, eCustomDataType type); +int CustomData_get_named_layer(const struct CustomData *data, + eCustomDataType type, + const char *name); +int CustomData_get_active_layer(const struct CustomData *data, eCustomDataType type); +int CustomData_get_render_layer(const struct CustomData *data, eCustomDataType type); +int CustomData_get_clone_layer(const struct CustomData *data, eCustomDataType type); +int CustomData_get_stencil_layer(const struct CustomData *data, eCustomDataType type); /** * Returns name of the active layer of the given type or NULL * if no such active layer is defined. */ -const char *CustomData_get_active_layer_name(const struct CustomData *data, int type); +const char *CustomData_get_active_layer_name(const struct CustomData *data, eCustomDataType type); /** * Returns name of the default layer of the given type or NULL * if no such active layer is defined. */ -const char *CustomData_get_render_layer_name(const struct CustomData *data, int type); +const char *CustomData_get_render_layer_name(const struct CustomData *data, eCustomDataType type); -bool CustomData_layer_is_anonymous(const struct CustomData *data, int type, int n); +bool CustomData_layer_is_anonymous(const struct CustomData *data, eCustomDataType type, int n); void CustomData_bmesh_set(const struct CustomData *data, void *block, - int type, + eCustomDataType type, const void *source); void CustomData_bmesh_set_n( - struct CustomData *data, void *block, int type, int n, const void *source); + struct CustomData *data, void *block, eCustomDataType type, int n, const void *source); /** * Sets the nth layer of type as active. */ -void CustomData_set_layer_active(struct CustomData *data, int type, int n); -void CustomData_set_layer_render(struct CustomData *data, int type, int n); -void CustomData_set_layer_clone(struct CustomData *data, int type, int n); -void CustomData_set_layer_stencil(struct CustomData *data, int type, int n); +void CustomData_set_layer_active(struct CustomData *data, eCustomDataType type, int n); +void CustomData_set_layer_render(struct CustomData *data, eCustomDataType type, int n); +void CustomData_set_layer_clone(struct CustomData *data, eCustomDataType type, int n); +void CustomData_set_layer_stencil(struct CustomData *data, eCustomDataType type, int n); /** * For using with an index from #CustomData_get_active_layer_index and * #CustomData_get_render_layer_index. */ -void CustomData_set_layer_active_index(struct CustomData *data, int type, int n); -void CustomData_set_layer_render_index(struct CustomData *data, int type, int n); -void CustomData_set_layer_clone_index(struct CustomData *data, int type, int n); -void CustomData_set_layer_stencil_index(struct CustomData *data, int type, int n); +void CustomData_set_layer_active_index(struct CustomData *data, eCustomDataType type, int n); +void CustomData_set_layer_render_index(struct CustomData *data, eCustomDataType type, int n); +void CustomData_set_layer_clone_index(struct CustomData *data, eCustomDataType type, int n); +void CustomData_set_layer_stencil_index(struct CustomData *data, eCustomDataType type, int n); /** * Adds flag to the layer flags. */ -void CustomData_set_layer_flag(struct CustomData *data, int type, int flag); -void CustomData_clear_layer_flag(struct CustomData *data, int type, int flag); +void CustomData_set_layer_flag(struct CustomData *data, eCustomDataType type, int flag); +void CustomData_clear_layer_flag(struct CustomData *data, eCustomDataType type, int flag); void CustomData_bmesh_set_default(struct CustomData *data, void **block); void CustomData_bmesh_free_block(struct CustomData *data, void **block); @@ -537,27 +561,29 @@ void CustomData_bmesh_free_block_data_exclude_by_type(struct CustomData *data, /** * Query info over types. */ -void CustomData_file_write_info(int type, const char **r_struct_name, int *r_struct_num); -int CustomData_sizeof(int type); +void CustomData_file_write_info(eCustomDataType type, + const char **r_struct_name, + int *r_struct_num); +int CustomData_sizeof(eCustomDataType type); /** * Get the name of a layer type. */ -const char *CustomData_layertype_name(int type); +const char *CustomData_layertype_name(eCustomDataType type); /** * Can only ever be one of these. */ -bool CustomData_layertype_is_singleton(int type); +bool CustomData_layertype_is_singleton(eCustomDataType type); /** * Has dynamically allocated members. * This is useful to know if operations such as #memcmp are * valid when comparing data from two layers. */ -bool CustomData_layertype_is_dynamic(int type); +bool CustomData_layertype_is_dynamic(eCustomDataType type); /** * \return Maximum number of layers of given \a type, -1 means 'no limit'. */ -int CustomData_layertype_layers_max(int type); +int CustomData_layertype_layers_max(eCustomDataType type); #ifdef __cplusplus @@ -572,7 +598,7 @@ int CustomData_name_max_length_calc(blender::StringRef name); void CustomData_set_layer_unique_name(struct CustomData *data, int index); void CustomData_validate_layer_name(const struct CustomData *data, - int type, + eCustomDataType type, const char *name, char *outname); @@ -596,10 +622,16 @@ bool CustomData_layer_validate(struct CustomDataLayer *layer, uint totitems, boo /* External file storage */ -void CustomData_external_add( - struct CustomData *data, struct ID *id, int type, int totelem, const char *filepath); -void CustomData_external_remove(struct CustomData *data, struct ID *id, int type, int totelem); -bool CustomData_external_test(struct CustomData *data, int type); +void CustomData_external_add(struct CustomData *data, + struct ID *id, + eCustomDataType type, + int totelem, + const char *filepath); +void CustomData_external_remove(struct CustomData *data, + struct ID *id, + eCustomDataType type, + int totelem); +bool CustomData_external_test(struct CustomData *data, eCustomDataType type); void CustomData_external_write( struct CustomData *data, struct ID *id, eCustomDataMask mask, int totelem, int free); @@ -674,7 +706,7 @@ enum { typedef struct CustomDataTransferLayerMap { struct CustomDataTransferLayerMap *next, *prev; - int data_type; + eCustomDataType data_type; int mix_mode; float mix_factor; /** If non-NULL, array of weights, one for each dest item, replaces mix_factor. */ diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc index f6fcd4278a0..f036c4918c9 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.cc +++ b/source/blender/blenkernel/intern/DerivedMesh.cc @@ -366,12 +366,12 @@ static void mesh_set_only_copy(Mesh *mesh, const CustomData_MeshMasks *mask) #endif } -void *DM_get_vert_data_layer(DerivedMesh *dm, int type) +void *DM_get_vert_data_layer(DerivedMesh *dm, const eCustomDataType type) { return CustomData_get_layer_for_write(&dm->vertData, type, dm->getNumVerts(dm)); } -void *DM_get_edge_data_layer(DerivedMesh *dm, int type) +void *DM_get_edge_data_layer(DerivedMesh *dm, const eCustomDataType type) { if (type == CD_MEDGE) { return dm->getEdgeArray(dm); @@ -380,12 +380,12 @@ void *DM_get_edge_data_layer(DerivedMesh *dm, int type) return CustomData_get_layer_for_write(&dm->edgeData, type, dm->getNumEdges(dm)); } -void *DM_get_poly_data_layer(DerivedMesh *dm, int type) +void *DM_get_poly_data_layer(DerivedMesh *dm, const eCustomDataType type) { return CustomData_get_layer_for_write(&dm->polyData, type, dm->getNumPolys(dm)); } -void *DM_get_loop_data_layer(DerivedMesh *dm, int type) +void *DM_get_loop_data_layer(DerivedMesh *dm, const eCustomDataType type) { return CustomData_get_layer_for_write(&dm->loopData, type, dm->getNumLoops(dm)); } @@ -488,7 +488,8 @@ static Mesh *create_orco_mesh(Object *ob, Mesh *me, BMEditMesh *em, int layer) return mesh; } -static void add_orco_mesh(Object *ob, BMEditMesh *em, Mesh *mesh, Mesh *mesh_orco, int layer) +static void add_orco_mesh( + Object *ob, BMEditMesh *em, Mesh *mesh, Mesh *mesh_orco, const eCustomDataType layer) { float(*orco)[3], (*layerorco)[3]; int totvert, free; diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index bb993156eae..4fbcbfc2047 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -268,8 +268,11 @@ bool BKE_id_attribute_calc_unique_name(ID *id, const char *name, char *outname) return BLI_uniquename_cb(unique_name_cb, &data, nullptr, '.', outname, maxlength); } -CustomDataLayer *BKE_id_attribute_new( - ID *id, const char *name, const int type, const eAttrDomain domain, ReportList *reports) +CustomDataLayer *BKE_id_attribute_new(ID *id, + const char *name, + const eCustomDataType type, + const eAttrDomain domain, + ReportList *reports) { using namespace blender::bke; DomainInfo info[ATTR_DOMAIN_NUM]; @@ -500,7 +503,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 int type, + const eCustomDataType type, const eAttrDomain domain) { if (!name) { diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index 564918ec245..210869fda33 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -478,9 +478,10 @@ GAttributeWriter CustomDataAttributeProvider::try_get_for_write( if (!custom_data_layer_matches_attribute_id(layer, attribute_id)) { continue; } - CustomData_get_layer_named_for_write(custom_data, layer.type, layer.name, element_num); + CustomData_get_layer_named_for_write( + custom_data, eCustomDataType(layer.type), layer.name, element_num); - const CPPType *type = custom_data_type_to_cpp_type((eCustomDataType)layer.type); + const CPPType *type = custom_data_type_to_cpp_type(eCustomDataType(layer.type)); if (type == nullptr) { continue; } @@ -502,7 +503,7 @@ bool CustomDataAttributeProvider::try_delete(void *owner, const AttributeIDRef & const CustomDataLayer &layer = custom_data->layers[i]; if (this->type_is_supported((eCustomDataType)layer.type) && custom_data_layer_matches_attribute_id(layer, attribute_id)) { - CustomData_free_layer(custom_data, layer.type, element_num, i); + CustomData_free_layer(custom_data, eCustomDataType(layer.type), element_num, i); return true; } } @@ -668,7 +669,7 @@ bool CustomDataAttributes::remove(const AttributeIDRef &attribute_id) for (const int i : IndexRange(data.totlayer)) { const CustomDataLayer &layer = data.layers[i]; if (custom_data_layer_matches_attribute_id(layer, attribute_id)) { - CustomData_free_layer(&data, layer.type, size_, i); + CustomData_free_layer(&data, eCustomDataType(layer.type), size_, i); return true; } } diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index 72636e2176c..273e5e2b108 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -2094,7 +2094,7 @@ const CustomData_MeshMasks CD_MASK_EVERYTHING = { CD_MASK_GRID_PAINT_MASK | CD_MASK_PROP_ALL), }; -static const LayerTypeInfo *layerType_getInfo(int type) +static const LayerTypeInfo *layerType_getInfo(const eCustomDataType type) { if (type < 0 || type >= CD_NUMTYPES) { return nullptr; @@ -2103,7 +2103,7 @@ static const LayerTypeInfo *layerType_getInfo(int type) return &LAYERTYPEINFO[type]; } -static const char *layerType_getName(int type) +static const char *layerType_getName(const eCustomDataType type) { if (type < 0 || type >= CD_NUMTYPES) { return nullptr; @@ -2117,35 +2117,35 @@ void customData_mask_layers__print(const CustomData_MeshMasks *mask) printf("verts mask=0x%" PRIx64 ":\n", mask->vmask); for (int i = 0; i < CD_NUMTYPES; i++) { if (mask->vmask & CD_TYPE_AS_MASK(i)) { - printf(" %s\n", layerType_getName(i)); + printf(" %s\n", layerType_getName(eCustomDataType(i))); } } printf("edges mask=0x%" PRIx64 ":\n", mask->emask); for (int i = 0; i < CD_NUMTYPES; i++) { if (mask->emask & CD_TYPE_AS_MASK(i)) { - printf(" %s\n", layerType_getName(i)); + printf(" %s\n", layerType_getName(eCustomDataType(i))); } } printf("faces mask=0x%" PRIx64 ":\n", mask->fmask); for (int i = 0; i < CD_NUMTYPES; i++) { if (mask->fmask & CD_TYPE_AS_MASK(i)) { - printf(" %s\n", layerType_getName(i)); + printf(" %s\n", layerType_getName(eCustomDataType(i))); } } printf("loops mask=0x%" PRIx64 ":\n", mask->lmask); for (int i = 0; i < CD_NUMTYPES; i++) { if (mask->lmask & CD_TYPE_AS_MASK(i)) { - printf(" %s\n", layerType_getName(i)); + printf(" %s\n", layerType_getName(eCustomDataType(i))); } } printf("polys mask=0x%" PRIx64 ":\n", mask->pmask); for (int i = 0; i < CD_NUMTYPES; i++) { if (mask->pmask & CD_TYPE_AS_MASK(i)) { - printf(" %s\n", layerType_getName(i)); + printf(" %s\n", layerType_getName(eCustomDataType(i))); } } } @@ -2159,7 +2159,7 @@ void customData_mask_layers__print(const CustomData_MeshMasks *mask) static void customData_update_offsets(CustomData *data); static CustomDataLayer *customData_add_layer__internal(CustomData *data, - int type, + eCustomDataType type, eCDAllocType alloctype, void *layerdata, int totelem, @@ -2174,7 +2174,7 @@ void CustomData_update_typemap(CustomData *data) } for (int i = 0; i < data->totlayer; i++) { - const int type = data->layers[i].type; + const eCustomDataType type = eCustomDataType(data->layers[i].type); if (type != lasttype) { data->typemap[type] = i; lasttype = type; @@ -2206,9 +2206,9 @@ bool CustomData_merge(const CustomData *source, for (int i = 0; i < source->totlayer; i++) { layer = &source->layers[i]; - // typeInfo = layerType_getInfo(layer->type); /* UNUSED */ + // typeInfo = layerType_getInfo(eCustomDataType(layer->type)); /* UNUSED */ - int type = layer->type; + const eCustomDataType type = eCustomDataType(layer->type); int flag = layer->flag; if (type != lasttype) { @@ -2316,7 +2316,7 @@ void CustomData_realloc(CustomData *data, const int old_size, const int new_size BLI_assert(new_size >= 0); for (int i = 0; i < data->totlayer; i++) { CustomDataLayer *layer = &data->layers[i]; - const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(layer->type)); const int64_t old_size_in_bytes = int64_t(old_size) * typeInfo->size; const int64_t new_size_in_bytes = int64_t(new_size) * typeInfo->size; @@ -2369,7 +2369,7 @@ static void customData_free_layer__internal(CustomDataLayer *layer, const int to layer->anonymous_id = nullptr; } if (!(layer->flag & CD_FLAG_NOFREE) && layer->data) { - typeInfo = layerType_getInfo(layer->type); + typeInfo = layerType_getInfo(eCustomDataType(layer->type)); if (typeInfo->free) { typeInfo->free(layer->data, totelem, typeInfo->size); @@ -2433,7 +2433,7 @@ static void customData_update_offsets(CustomData *data) int offset = 0; for (int i = 0; i < data->totlayer; i++) { - typeInfo = layerType_getInfo(data->layers[i].type); + typeInfo = layerType_getInfo(eCustomDataType(data->layers[i].type)); data->layers[i].offset = offset; offset += typeInfo->size; @@ -2444,7 +2444,8 @@ static void customData_update_offsets(CustomData *data) } /* to use when we're in the middle of modifying layers */ -static int CustomData_get_layer_index__notypemap(const CustomData *data, const int type) +static int CustomData_get_layer_index__notypemap(const CustomData *data, + const eCustomDataType type) { for (int i = 0; i < data->totlayer; i++) { if (data->layers[i].type == type) { @@ -2458,13 +2459,13 @@ static int CustomData_get_layer_index__notypemap(const CustomData *data, const i /* -------------------------------------------------------------------- */ /* index values to access the layers (offset from the layer start) */ -int CustomData_get_layer_index(const CustomData *data, const int type) +int CustomData_get_layer_index(const CustomData *data, const eCustomDataType type) { BLI_assert(customdata_typemap_is_valid(data)); return data->typemap[type]; } -int CustomData_get_layer_index_n(const CustomData *data, const int type, const int n) +int CustomData_get_layer_index_n(const CustomData *data, const eCustomDataType type, const int n) { BLI_assert(n >= 0); int i = CustomData_get_layer_index(data, type); @@ -2477,7 +2478,9 @@ int CustomData_get_layer_index_n(const CustomData *data, const int type, const i return i; } -int CustomData_get_named_layer_index(const CustomData *data, const int type, const char *name) +int CustomData_get_named_layer_index(const CustomData *data, + const eCustomDataType type, + const char *name) { for (int i = 0; i < data->totlayer; i++) { if (data->layers[i].type == type) { @@ -2501,28 +2504,28 @@ int CustomData_get_named_layer_index_notype(const CustomData *data, const char * return -1; } -int CustomData_get_active_layer_index(const CustomData *data, const int type) +int CustomData_get_active_layer_index(const CustomData *data, const eCustomDataType type) { const int layer_index = data->typemap[type]; BLI_assert(customdata_typemap_is_valid(data)); return (layer_index != -1) ? layer_index + data->layers[layer_index].active : -1; } -int CustomData_get_render_layer_index(const CustomData *data, const int type) +int CustomData_get_render_layer_index(const CustomData *data, const eCustomDataType type) { const int layer_index = data->typemap[type]; BLI_assert(customdata_typemap_is_valid(data)); return (layer_index != -1) ? layer_index + data->layers[layer_index].active_rnd : -1; } -int CustomData_get_clone_layer_index(const CustomData *data, const int type) +int CustomData_get_clone_layer_index(const CustomData *data, const eCustomDataType type) { const int layer_index = data->typemap[type]; BLI_assert(customdata_typemap_is_valid(data)); return (layer_index != -1) ? layer_index + data->layers[layer_index].active_clone : -1; } -int CustomData_get_stencil_layer_index(const CustomData *data, const int type) +int CustomData_get_stencil_layer_index(const CustomData *data, const eCustomDataType type) { const int layer_index = data->typemap[type]; BLI_assert(customdata_typemap_is_valid(data)); @@ -2532,7 +2535,9 @@ int CustomData_get_stencil_layer_index(const CustomData *data, const int type) /* -------------------------------------------------------------------- */ /* index values per layer type */ -int CustomData_get_named_layer(const CustomData *data, const int type, const char *name) +int CustomData_get_named_layer(const CustomData *data, + const eCustomDataType type, + const char *name) { const int named_index = CustomData_get_named_layer_index(data, type, name); const int layer_index = data->typemap[type]; @@ -2540,48 +2545,48 @@ int CustomData_get_named_layer(const CustomData *data, const int type, const cha return (named_index != -1) ? named_index - layer_index : -1; } -int CustomData_get_active_layer(const CustomData *data, const int type) +int CustomData_get_active_layer(const CustomData *data, const eCustomDataType type) { const int layer_index = data->typemap[type]; BLI_assert(customdata_typemap_is_valid(data)); return (layer_index != -1) ? data->layers[layer_index].active : -1; } -int CustomData_get_render_layer(const CustomData *data, const int type) +int CustomData_get_render_layer(const CustomData *data, const eCustomDataType type) { const int layer_index = data->typemap[type]; BLI_assert(customdata_typemap_is_valid(data)); return (layer_index != -1) ? data->layers[layer_index].active_rnd : -1; } -int CustomData_get_clone_layer(const CustomData *data, const int type) +int CustomData_get_clone_layer(const CustomData *data, const eCustomDataType type) { const int layer_index = data->typemap[type]; BLI_assert(customdata_typemap_is_valid(data)); return (layer_index != -1) ? data->layers[layer_index].active_clone : -1; } -int CustomData_get_stencil_layer(const CustomData *data, const int type) +int CustomData_get_stencil_layer(const CustomData *data, const eCustomDataType type) { const int layer_index = data->typemap[type]; BLI_assert(customdata_typemap_is_valid(data)); return (layer_index != -1) ? data->layers[layer_index].active_mask : -1; } -const char *CustomData_get_active_layer_name(const CustomData *data, const int type) +const char *CustomData_get_active_layer_name(const CustomData *data, const eCustomDataType type) { /* Get the layer index of the active layer of this type. */ const int layer_index = CustomData_get_active_layer_index(data, type); return layer_index < 0 ? nullptr : data->layers[layer_index].name; } -const char *CustomData_get_render_layer_name(const CustomData *data, const int type) +const char *CustomData_get_render_layer_name(const CustomData *data, const eCustomDataType type) { const int layer_index = CustomData_get_render_layer_index(data, type); return layer_index < 0 ? nullptr : data->layers[layer_index].name; } -void CustomData_set_layer_active(CustomData *data, const int type, const int n) +void CustomData_set_layer_active(CustomData *data, const eCustomDataType type, const int n) { #ifndef NDEBUG const int layer_num = CustomData_number_of_layers(data, type); @@ -2594,7 +2599,7 @@ void CustomData_set_layer_active(CustomData *data, const int type, const int n) } } -void CustomData_set_layer_render(CustomData *data, const int type, const int n) +void CustomData_set_layer_render(CustomData *data, const eCustomDataType type, const int n) { #ifndef NDEBUG const int layer_num = CustomData_number_of_layers(data, type); @@ -2607,7 +2612,7 @@ void CustomData_set_layer_render(CustomData *data, const int type, const int n) } } -void CustomData_set_layer_clone(CustomData *data, const int type, const int n) +void CustomData_set_layer_clone(CustomData *data, const eCustomDataType type, const int n) { #ifndef NDEBUG const int layer_num = CustomData_number_of_layers(data, type); @@ -2620,7 +2625,7 @@ void CustomData_set_layer_clone(CustomData *data, const int type, const int n) } } -void CustomData_set_layer_stencil(CustomData *data, const int type, const int n) +void CustomData_set_layer_stencil(CustomData *data, const eCustomDataType type, const int n) { #ifndef NDEBUG const int layer_num = CustomData_number_of_layers(data, type); @@ -2633,7 +2638,7 @@ void CustomData_set_layer_stencil(CustomData *data, const int type, const int n) } } -void CustomData_set_layer_active_index(CustomData *data, const int type, const int n) +void CustomData_set_layer_active_index(CustomData *data, const eCustomDataType type, const int n) { #ifndef NDEBUG const int layer_num = CustomData_number_of_layers(data, type); @@ -2649,7 +2654,7 @@ void CustomData_set_layer_active_index(CustomData *data, const int type, const i } } -void CustomData_set_layer_render_index(CustomData *data, const int type, const int n) +void CustomData_set_layer_render_index(CustomData *data, const eCustomDataType type, const int n) { #ifndef NDEBUG const int layer_num = CustomData_number_of_layers(data, type); @@ -2665,7 +2670,7 @@ void CustomData_set_layer_render_index(CustomData *data, const int type, const i } } -void CustomData_set_layer_clone_index(CustomData *data, const int type, const int n) +void CustomData_set_layer_clone_index(CustomData *data, const eCustomDataType type, const int n) { #ifndef NDEBUG const int layer_num = CustomData_number_of_layers(data, type); @@ -2681,7 +2686,7 @@ void CustomData_set_layer_clone_index(CustomData *data, const int type, const in } } -void CustomData_set_layer_stencil_index(CustomData *data, const int type, const int n) +void CustomData_set_layer_stencil_index(CustomData *data, const eCustomDataType type, const int n) { #ifndef NDEBUG const int layer_num = CustomData_number_of_layers(data, type); @@ -2697,7 +2702,7 @@ void CustomData_set_layer_stencil_index(CustomData *data, const int type, const } } -void CustomData_set_layer_flag(CustomData *data, const int type, const int flag) +void CustomData_set_layer_flag(CustomData *data, const eCustomDataType type, const int flag) { for (int i = 0; i < data->totlayer; i++) { if (data->layers[i].type == type) { @@ -2706,7 +2711,7 @@ void CustomData_set_layer_flag(CustomData *data, const int type, const int flag) } } -void CustomData_clear_layer_flag(CustomData *data, const int type, const int flag) +void CustomData_clear_layer_flag(CustomData *data, const eCustomDataType type, const int flag) { const int nflag = ~flag; @@ -2717,7 +2722,7 @@ void CustomData_clear_layer_flag(CustomData *data, const int type, const int fla } } -bool CustomData_layer_is_anonymous(const struct CustomData *data, int type, int n) +bool CustomData_layer_is_anonymous(const struct CustomData *data, eCustomDataType type, int n) { const int layer_index = CustomData_get_layer_index_n(data, type, n); @@ -2745,7 +2750,7 @@ static bool customData_resize(CustomData *data, const int amount) } static CustomDataLayer *customData_add_layer__internal(CustomData *data, - const int type, + const eCustomDataType type, const eCDAllocType alloctype, void *layerdata, const int totelem, @@ -2875,8 +2880,11 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, return &data->layers[index]; } -static void *customdata_add_layer( - CustomData *data, const int type, eCDAllocType alloctype, void *layerdata, const int totelem) +static void *customdata_add_layer(CustomData *data, + const eCustomDataType type, + eCDAllocType alloctype, + void *layerdata, + const int totelem) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); @@ -2941,7 +2949,7 @@ const void *CustomData_add_layer_named_with_data( } void *CustomData_add_layer_anonymous(CustomData *data, - const int type, + const eCustomDataType type, const eCDAllocType alloctype, void *layerdata, const int totelem, @@ -2961,7 +2969,10 @@ void *CustomData_add_layer_anonymous(CustomData *data, return layer->data; } -bool CustomData_free_layer(CustomData *data, const int type, const int totelem, const int index) +bool CustomData_free_layer(CustomData *data, + const eCustomDataType type, + const int totelem, + const int index) { const int index_first = CustomData_get_layer_index(data, type); const int n = index - index_first; @@ -3018,14 +3029,14 @@ bool CustomData_free_layer_named(CustomData *data, const char *name, const int t for (const int i : IndexRange(data->totlayer)) { const CustomDataLayer &layer = data->layers[i]; if (StringRef(layer.name) == name) { - CustomData_free_layer(data, layer.type, totelem, i); + CustomData_free_layer(data, eCustomDataType(layer.type), totelem, i); return true; } } return false; } -bool CustomData_free_layer_active(CustomData *data, const int type, const int totelem) +bool CustomData_free_layer_active(CustomData *data, const eCustomDataType type, const int totelem) { const int index = CustomData_get_active_layer_index(data, type); if (index == -1) { @@ -3034,7 +3045,7 @@ bool CustomData_free_layer_active(CustomData *data, const int type, const int to return CustomData_free_layer(data, type, totelem, index); } -void CustomData_free_layers(CustomData *data, const int type, const int totelem) +void CustomData_free_layers(CustomData *data, const eCustomDataType type, const int totelem) { const int index = CustomData_get_layer_index(data, type); while (CustomData_free_layer(data, type, totelem, index)) { @@ -3042,12 +3053,12 @@ void CustomData_free_layers(CustomData *data, const int type, const int totelem) } } -bool CustomData_has_layer(const CustomData *data, const int type) +bool CustomData_has_layer(const CustomData *data, const eCustomDataType type) { return (CustomData_get_layer_index(data, type) != -1); } -int CustomData_number_of_layers(const CustomData *data, const int type) +int CustomData_number_of_layers(const CustomData *data, const eCustomDataType type) { int number = 0; @@ -3060,7 +3071,7 @@ int CustomData_number_of_layers(const CustomData *data, const int type) return number; } -int CustomData_number_of_anonymous_layers(const CustomData *data, const int type) +int CustomData_number_of_anonymous_layers(const CustomData *data, const eCustomDataType type) { int number = 0; @@ -3101,7 +3112,7 @@ static void *customData_duplicate_referenced_layer_index(CustomData *data, * CD_MDEFORMVERT, which has pointers to allocated data... * So in case a custom copy function is defined, use it! */ - const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(layer->type)); if (typeInfo->copy) { void *dst_data = MEM_malloc_arrayN( @@ -3168,7 +3179,7 @@ void CustomData_set_only_copy(const CustomData *data, const eCustomDataMask mask } } -void CustomData_copy_elements(const int type, +void CustomData_copy_elements(const eCustomDataType type, void *src_data_ofs, void *dst_data_ofs, const int count) @@ -3196,7 +3207,7 @@ void CustomData_copy_data_layer(const CustomData *source, const void *src_data = source->layers[src_layer_index].data; void *dst_data = dest->layers[dst_layer_index].data; - typeInfo = layerType_getInfo(source->layers[src_layer_index].type); + typeInfo = layerType_getInfo(eCustomDataType(source->layers[src_layer_index].type)); const size_t src_offset = size_t(src_index) * typeInfo->size; const size_t dst_offset = size_t(dst_index) * typeInfo->size; @@ -3205,7 +3216,7 @@ void CustomData_copy_data_layer(const CustomData *source, if (count && !(src_data == nullptr && dst_data == nullptr)) { CLOG_WARN(&LOG, "null data for %s type (%p --> %p), skipping", - layerType_getName(source->layers[src_layer_index].type), + layerType_getName(eCustomDataType(source->layers[src_layer_index].type)), (void *)src_data, (void *)dst_data); } @@ -3233,7 +3244,7 @@ void CustomData_copy_data_named(const CustomData *source, for (int src_i = 0; src_i < source->totlayer; src_i++) { int dest_i = CustomData_get_named_layer_index( - dest, source->layers[src_i].type, source->layers[src_i].name); + dest, eCustomDataType(source->layers[src_i].type), source->layers[src_i].name); /* if we found a matching layer, copy the data */ if (dest_i != -1) { @@ -3279,7 +3290,7 @@ void CustomData_copy_data(const CustomData *source, void CustomData_copy_layer_type_data(const CustomData *source, CustomData *destination, - int type, + const eCustomDataType type, int source_index, int destination_index, int count) @@ -3305,7 +3316,7 @@ void CustomData_free_elem(CustomData *data, const int index, const int count) { for (int i = 0; i < data->totlayer; i++) { if (!(data->layers[i].flag & CD_FLAG_NOFREE)) { - const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[i].type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(data->layers[i].type)); if (typeInfo->free) { size_t offset = size_t(index) * typeInfo->size; @@ -3353,7 +3364,7 @@ void CustomData_interp(const CustomData *source, /* interpolates a layer at a time */ int dest_i = 0; for (int src_i = 0; src_i < source->totlayer; src_i++) { - const LayerTypeInfo *typeInfo = layerType_getInfo(source->layers[src_i].type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(source->layers[src_i].type)); if (!typeInfo->interp) { continue; } @@ -3404,7 +3415,7 @@ void CustomData_interp(const CustomData *source, void CustomData_swap_corners(CustomData *data, const int index, const int *corner_indices) { for (int i = 0; i < data->totlayer; i++) { - const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[i].type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(data->layers[i].type)); if (typeInfo->swap) { const size_t offset = size_t(index) * typeInfo->size; @@ -3423,7 +3434,7 @@ void CustomData_swap(CustomData *data, const int index_a, const int index_b) } for (int i = 0; i < data->totlayer; i++) { - const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[i].type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(data->layers[i].type)); const size_t size = typeInfo->size; const size_t offset_a = size * index_a; const size_t offset_b = size * index_b; @@ -3441,7 +3452,10 @@ void CustomData_swap(CustomData *data, const int index_a, const int index_b) } } -void *CustomData_get_for_write(CustomData *data, const int index, const int type, int totelem) +void *CustomData_get_for_write(CustomData *data, + const int index, + const eCustomDataType type, + int totelem) { BLI_assert(index >= 0); void *layer_data = CustomData_get_layer_for_write(data, type, totelem); @@ -3452,7 +3466,7 @@ void *CustomData_get_for_write(CustomData *data, const int index, const int type } void *CustomData_get_n_for_write( - CustomData *data, const int type, const int index, const int n, int totelem) + CustomData *data, const eCustomDataType type, const int index, const int n, int totelem) { BLI_assert(index >= 0); void *layer_data = CustomData_get_layer_n_for_write(data, type, n, totelem); @@ -3463,7 +3477,7 @@ void *CustomData_get_n_for_write( return POINTER_OFFSET(layer_data, size_t(index) * layerType_getInfo(type)->size); } -const void *CustomData_get_layer(const CustomData *data, const int type) +const void *CustomData_get_layer(const CustomData *data, const eCustomDataType type) { int layer_index = CustomData_get_active_layer_index(data, type); if (layer_index == -1) { @@ -3473,13 +3487,15 @@ const void *CustomData_get_layer(const CustomData *data, const int type) return data->layers[layer_index].data; } -void *CustomData_get_layer_for_write(CustomData *data, const int type, const int totelem) +void *CustomData_get_layer_for_write(CustomData *data, + const eCustomDataType type, + const int totelem) { const int layer_index = CustomData_get_active_layer_index(data, type); return customData_duplicate_referenced_layer_index(data, layer_index, totelem); } -const void *CustomData_get_layer_n(const CustomData *data, const int type, const int n) +const void *CustomData_get_layer_n(const CustomData *data, const eCustomDataType type, const int n) { int layer_index = CustomData_get_layer_index_n(data, type, n); if (layer_index == -1) { @@ -3490,7 +3506,7 @@ const void *CustomData_get_layer_n(const CustomData *data, const int type, const } void *CustomData_get_layer_n_for_write(CustomData *data, - const int type, + const eCustomDataType type, const int n, const int totelem) { @@ -3498,7 +3514,9 @@ void *CustomData_get_layer_n_for_write(CustomData *data, return customData_duplicate_referenced_layer_index(data, layer_index, totelem); } -const void *CustomData_get_layer_named(const CustomData *data, const int type, const char *name) +const void *CustomData_get_layer_named(const CustomData *data, + const eCustomDataType type, + const char *name) { int layer_index = CustomData_get_named_layer_index(data, type, name); if (layer_index == -1) { @@ -3509,7 +3527,7 @@ const void *CustomData_get_layer_named(const CustomData *data, const int type, c } void *CustomData_get_layer_named_for_write(CustomData *data, - const int type, + const eCustomDataType type, const char *name, const int totelem) { @@ -3517,7 +3535,7 @@ void *CustomData_get_layer_named_for_write(CustomData *data, return customData_duplicate_referenced_layer_index(data, layer_index, totelem); } -int CustomData_get_offset(const CustomData *data, const int type) +int CustomData_get_offset(const CustomData *data, const eCustomDataType type) { int layer_index = CustomData_get_active_layer_index(data, type); if (layer_index == -1) { @@ -3527,7 +3545,7 @@ int CustomData_get_offset(const CustomData *data, const int type) return data->layers[layer_index].offset; } -int CustomData_get_n_offset(const CustomData *data, const int type, const int n) +int CustomData_get_n_offset(const CustomData *data, const eCustomDataType type, const int n) { int layer_index = CustomData_get_layer_index_n(data, type, n); if (layer_index == -1) { @@ -3537,7 +3555,9 @@ int CustomData_get_n_offset(const CustomData *data, const int type, const int n) return data->layers[layer_index].offset; } -int CustomData_get_offset_named(const CustomData *data, int type, const char *name) +int CustomData_get_offset_named(const CustomData *data, + const eCustomDataType type, + const char *name) { int layer_index = CustomData_get_named_layer_index(data, type, name); if (layer_index == -1) { @@ -3547,7 +3567,10 @@ int CustomData_get_offset_named(const CustomData *data, int type, const char *na return data->layers[layer_index].offset; } -bool CustomData_set_layer_name(CustomData *data, const int type, const int n, const char *name) +bool CustomData_set_layer_name(CustomData *data, + const eCustomDataType type, + const int n, + const char *name) { const int layer_index = CustomData_get_layer_index_n(data, type, n); @@ -3560,7 +3583,9 @@ bool CustomData_set_layer_name(CustomData *data, const int type, const int n, co return true; } -const char *CustomData_get_layer_name(const CustomData *data, const int type, const int n) +const char *CustomData_get_layer_name(const CustomData *data, + const eCustomDataType type, + const int n) { const int layer_index = CustomData_get_layer_index_n(data, type, n); @@ -3701,7 +3726,7 @@ void CustomData_bmesh_free_block(CustomData *data, void **block) for (int i = 0; i < data->totlayer; i++) { if (!(data->layers[i].flag & CD_FLAG_NOFREE)) { - const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[i].type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(data->layers[i].type)); if (typeInfo->free) { int offset = data->layers[i].offset; @@ -3724,7 +3749,7 @@ void CustomData_bmesh_free_block_data(CustomData *data, void *block) } for (int i = 0; i < data->totlayer; i++) { if (!(data->layers[i].flag & CD_FLAG_NOFREE)) { - const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[i].type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(data->layers[i].type)); if (typeInfo->free) { const size_t offset = data->layers[i].offset; typeInfo->free(POINTER_OFFSET(block, offset), 1, typeInfo->size); @@ -3759,7 +3784,7 @@ void CustomData_bmesh_free_block_data_exclude_by_type(CustomData *data, } for (int i = 0; i < data->totlayer; i++) { if ((CD_TYPE_AS_MASK(data->layers[i].type) & mask_exclude) == 0) { - const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[i].type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(data->layers[i].type)); const size_t offset = data->layers[i].offset; if (!(data->layers[i].flag & CD_FLAG_NOFREE)) { if (typeInfo->free) { @@ -3771,7 +3796,7 @@ void CustomData_bmesh_free_block_data_exclude_by_type(CustomData *data, } } -void CustomData_data_set_default_value(const int type, void *elem) +void CustomData_data_set_default_value(const eCustomDataType type, void *elem) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); if (typeInfo->set_default_value) { @@ -3785,7 +3810,8 @@ void CustomData_data_set_default_value(const int type, void *elem) static void CustomData_bmesh_set_default_n(CustomData *data, void **block, const int n) { const int offset = data->layers[n].offset; - CustomData_data_set_default_value(data->layers[n].type, POINTER_OFFSET(*block, offset)); + CustomData_data_set_default_value(eCustomDataType(data->layers[n].type), + POINTER_OFFSET(*block, offset)); } void CustomData_bmesh_set_default(CustomData *data, void **block) @@ -3839,7 +3865,8 @@ void CustomData_bmesh_copy_data_exclude_by_type(const CustomData *source, if (no_mask || ((CD_TYPE_AS_MASK(dest->layers[dest_i].type) & mask_exclude) == 0)) { const void *src_data = POINTER_OFFSET(src_block, source->layers[src_i].offset); void *dest_data = POINTER_OFFSET(*dest_block, dest->layers[dest_i].offset); - const LayerTypeInfo *typeInfo = layerType_getInfo(source->layers[src_i].type); + const LayerTypeInfo *typeInfo = layerType_getInfo( + eCustomDataType(source->layers[src_i].type)); if (typeInfo->copy) { typeInfo->copy(src_data, dest_data, 1); } @@ -3870,7 +3897,7 @@ void CustomData_bmesh_copy_data(const CustomData *source, CustomData_bmesh_copy_data_exclude_by_type(source, dest, src_block, dest_block, 0); } -void *CustomData_bmesh_get(const CustomData *data, void *block, const int type) +void *CustomData_bmesh_get(const CustomData *data, void *block, const eCustomDataType type) { int layer_index = CustomData_get_active_layer_index(data, type); if (layer_index == -1) { @@ -3880,7 +3907,10 @@ void *CustomData_bmesh_get(const CustomData *data, void *block, const int type) return POINTER_OFFSET(block, data->layers[layer_index].offset); } -void *CustomData_bmesh_get_n(const CustomData *data, void *block, const int type, const int n) +void *CustomData_bmesh_get_n(const CustomData *data, + void *block, + const eCustomDataType type, + const int n) { int layer_index = CustomData_get_layer_index(data, type); if (layer_index == -1) { @@ -3901,7 +3931,7 @@ void *CustomData_bmesh_get_layer_n(const CustomData *data, void *block, const in bool CustomData_layer_has_math(const CustomData *data, const int layer_n) { - const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[layer_n].type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(data->layers[layer_n].type)); if (typeInfo->equal && typeInfo->add && typeInfo->multiply && typeInfo->initminmax && typeInfo->dominmax) { @@ -3913,7 +3943,7 @@ bool CustomData_layer_has_math(const CustomData *data, const int layer_n) bool CustomData_layer_has_interp(const CustomData *data, const int layer_n) { - const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[layer_n].type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(data->layers[layer_n].type)); if (typeInfo->interp) { return true; @@ -3938,7 +3968,7 @@ bool CustomData_bmesh_has_free(const CustomData *data) { for (int i = 0; i < data->totlayer; i++) { if (!(data->layers[i].flag & CD_FLAG_NOFREE)) { - const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[i].type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(data->layers[i].type)); if (typeInfo->free) { return true; } @@ -3969,7 +3999,7 @@ bool CustomData_has_referenced(const CustomData *data) return false; } -void CustomData_data_copy_value(int type, const void *source, void *dest) +void CustomData_data_copy_value(const eCustomDataType type, const void *source, void *dest) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); @@ -3985,8 +4015,11 @@ void CustomData_data_copy_value(int type, const void *source, void *dest) } } -void CustomData_data_mix_value( - int type, const void *source, void *dest, const int mixmode, const float mixfactor) +void CustomData_data_mix_value(const eCustomDataType type, + const void *source, + void *dest, + const int mixmode, + const float mixfactor) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); @@ -4003,7 +4036,7 @@ void CustomData_data_mix_value( } } -bool CustomData_data_equals(int type, const void *data1, const void *data2) +bool CustomData_data_equals(const eCustomDataType type, const void *data1, const void *data2) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); @@ -4014,7 +4047,7 @@ bool CustomData_data_equals(int type, const void *data1, const void *data2) return !memcmp(data1, data2, typeInfo->size); } -void CustomData_data_initminmax(int type, void *min, void *max) +void CustomData_data_initminmax(const eCustomDataType type, void *min, void *max) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); @@ -4023,7 +4056,7 @@ void CustomData_data_initminmax(int type, void *min, void *max) } } -void CustomData_data_dominmax(int type, const void *data, void *min, void *max) +void CustomData_data_dominmax(const eCustomDataType type, const void *data, void *min, void *max) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); @@ -4032,7 +4065,7 @@ void CustomData_data_dominmax(int type, const void *data, void *min, void *max) } } -void CustomData_data_multiply(int type, void *data, const float fac) +void CustomData_data_multiply(const eCustomDataType type, void *data, const float fac) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); @@ -4041,7 +4074,7 @@ void CustomData_data_multiply(int type, void *data, const float fac) } } -void CustomData_data_add(int type, void *data1, const void *data2) +void CustomData_data_add(const eCustomDataType type, void *data1, const void *data2) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); @@ -4050,7 +4083,10 @@ void CustomData_data_add(int type, void *data1, const void *data2) } } -void CustomData_bmesh_set(const CustomData *data, void *block, const int type, const void *source) +void CustomData_bmesh_set(const CustomData *data, + void *block, + const eCustomDataType type, + const void *source) { void *dest = CustomData_bmesh_get(data, block, type); const LayerTypeInfo *typeInfo = layerType_getInfo(type); @@ -4068,7 +4104,7 @@ void CustomData_bmesh_set(const CustomData *data, void *block, const int type, c } void CustomData_bmesh_set_n( - CustomData *data, void *block, const int type, const int n, const void *source) + CustomData *data, void *block, const eCustomDataType type, const int n, const void *source) { void *dest = CustomData_bmesh_get_n(data, block, type, n); const LayerTypeInfo *typeInfo = layerType_getInfo(type); @@ -4097,7 +4133,7 @@ void CustomData_bmesh_interp_n(CustomData *data, BLI_assert(count > 0); CustomDataLayer *layer = &data->layers[n]; - const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(layer->type)); typeInfo->interp(src_blocks_ofs, weights, sub_weights, count, dst_block_ofs); } @@ -4135,7 +4171,7 @@ void CustomData_bmesh_interp(CustomData *data, /* interpolates a layer at a time */ for (int i = 0; i < data->totlayer; i++) { CustomDataLayer *layer = &data->layers[i]; - const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(layer->type)); if (typeInfo->interp) { for (int j = 0; j < count; j++) { sources[j] = POINTER_OFFSET(src_blocks[j], layer->offset); @@ -4153,7 +4189,9 @@ void CustomData_bmesh_interp(CustomData *data, } } -void CustomData_file_write_info(int type, const char **r_struct_name, int *r_struct_num) +void CustomData_file_write_info(const eCustomDataType type, + const char **r_struct_name, + int *r_struct_num) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); @@ -4181,32 +4219,32 @@ void CustomData_blend_write_prepare(CustomData &data, data.maxlayer = data.totlayer; } -int CustomData_sizeof(int type) +int CustomData_sizeof(const eCustomDataType type) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); return typeInfo->size; } -const char *CustomData_layertype_name(int type) +const char *CustomData_layertype_name(const eCustomDataType type) { return layerType_getName(type); } -bool CustomData_layertype_is_singleton(int type) +bool CustomData_layertype_is_singleton(const eCustomDataType type) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); return typeInfo->defaultname == nullptr; } -bool CustomData_layertype_is_dynamic(int type) +bool CustomData_layertype_is_dynamic(const eCustomDataType type) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); return (typeInfo->free != nullptr); } -int CustomData_layertype_layers_max(const int type) +int CustomData_layertype_layers_max(const eCustomDataType type) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); @@ -4221,7 +4259,10 @@ int CustomData_layertype_layers_max(const int type) return typeInfo->layers_max(); } -static bool cd_layer_find_dupe(CustomData *data, const char *name, const int type, const int index) +static bool cd_layer_find_dupe(CustomData *data, + const char *name, + const eCustomDataType type, + const int index) { /* see if there is a duplicate */ for (int i = 0; i < data->totlayer; i++) { @@ -4246,7 +4287,7 @@ static bool cd_layer_find_dupe(CustomData *data, const char *name, const int typ struct CustomDataUniqueCheckData { CustomData *data; - int type; + eCustomDataType type; int index; }; @@ -4273,9 +4314,9 @@ int CustomData_name_max_length_calc(const blender::StringRef name) void CustomData_set_layer_unique_name(CustomData *data, const int index) { CustomDataLayer *nlayer = &data->layers[index]; - const LayerTypeInfo *typeInfo = layerType_getInfo(nlayer->type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(nlayer->type)); - CustomDataUniqueCheckData data_arg{data, nlayer->type, index}; + CustomDataUniqueCheckData data_arg{data, eCustomDataType(nlayer->type), index}; if (!typeInfo->defaultname) { return; @@ -4293,7 +4334,7 @@ void CustomData_set_layer_unique_name(CustomData *data, const int index) } void CustomData_validate_layer_name(const CustomData *data, - int type, + const eCustomDataType type, const char *name, char *outname) { @@ -4326,7 +4367,7 @@ bool CustomData_verify_versions(CustomData *data, const int index) keeplayer = false; /* unknown layer type from future version */ } else { - typeInfo = layerType_getInfo(layer->type); + typeInfo = layerType_getInfo(eCustomDataType(layer->type)); if (!typeInfo->defaultname && (index > 0) && data->layers[index - 1].type == layer->type) { keeplayer = false; /* multiple layers of which we only support one */ @@ -4365,7 +4406,7 @@ bool CustomData_verify_versions(CustomData *data, const int index) static bool CustomData_layer_ensure_data_exists(CustomDataLayer *layer, size_t count) { BLI_assert(layer); - const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(layer->type)); BLI_assert(typeInfo); if (layer->data || count == 0) { @@ -4377,7 +4418,8 @@ static bool CustomData_layer_ensure_data_exists(CustomDataLayer *layer, size_t c case CD_PROP_BOOL: /* See #84935. */ case CD_MLOOPUV: /* See #90620. */ case CD_PROP_FLOAT2: /* See #90620. */ - layer->data = MEM_calloc_arrayN(count, typeInfo->size, layerType_getName(layer->type)); + layer->data = MEM_calloc_arrayN( + count, typeInfo->size, layerType_getName(eCustomDataType(layer->type))); BLI_assert(layer->data); if (typeInfo->set_default_value) { typeInfo->set_default_value(layer->data, count); @@ -4400,7 +4442,7 @@ static bool CustomData_layer_ensure_data_exists(CustomDataLayer *layer, size_t c bool CustomData_layer_validate(CustomDataLayer *layer, const uint totitems, const bool do_fixes) { BLI_assert(layer); - const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(layer->type)); BLI_assert(typeInfo); if (do_fixes) { @@ -4435,7 +4477,7 @@ void CustomData_external_reload(CustomData *data, ID * /*id*/, eCustomDataMask m { for (int i = 0; i < data->totlayer; i++) { CustomDataLayer *layer = &data->layers[i]; - const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(layer->type)); if (!(mask & CD_TYPE_AS_MASK(layer->type))) { /* pass */ @@ -4462,7 +4504,7 @@ void CustomData_external_read(CustomData *data, ID *id, eCustomDataMask mask, co for (int i = 0; i < data->totlayer; i++) { layer = &data->layers[i]; - const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(layer->type)); if (!(mask & CD_TYPE_AS_MASK(layer->type))) { /* pass */ @@ -4484,13 +4526,16 @@ void CustomData_external_read(CustomData *data, ID *id, eCustomDataMask mask, co CDataFile *cdf = cdf_create(CDF_TYPE_MESH); if (!cdf_read_open(cdf, filepath)) { cdf_free(cdf); - CLOG_ERROR(&LOG, "Failed to read %s layer from %s.", layerType_getName(layer->type), filepath); + CLOG_ERROR(&LOG, + "Failed to read %s layer from %s.", + layerType_getName(eCustomDataType(layer->type)), + filepath); return; } for (int i = 0; i < data->totlayer; i++) { layer = &data->layers[i]; - const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(layer->type)); if (!(mask & CD_TYPE_AS_MASK(layer->type))) { /* pass */ @@ -4536,7 +4581,7 @@ void CustomData_external_write( /* test if there is anything to write */ for (int i = 0; i < data->totlayer; i++) { CustomDataLayer *layer = &data->layers[i]; - const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(layer->type)); if (!(mask & CD_TYPE_AS_MASK(layer->type))) { /* pass */ @@ -4558,7 +4603,7 @@ void CustomData_external_write( for (int i = 0; i < data->totlayer; i++) { CustomDataLayer *layer = &data->layers[i]; - const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(layer->type)); if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->filesize) { if (layer->flag & CD_FLAG_IN_MEMORY) { @@ -4581,7 +4626,7 @@ void CustomData_external_write( int i; for (i = 0; i < data->totlayer; i++) { CustomDataLayer *layer = &data->layers[i]; - const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(layer->type)); if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) { CDataFileLayer *blay = cdf_layer_find(cdf, layer->type, layer->name); @@ -4609,7 +4654,7 @@ void CustomData_external_write( for (i = 0; i < data->totlayer; i++) { CustomDataLayer *layer = &data->layers[i]; - const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); + const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(layer->type)); if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) { if (free) { @@ -4625,8 +4670,11 @@ void CustomData_external_write( cdf_free(cdf); } -void CustomData_external_add( - CustomData *data, ID * /*id*/, const int type, const int /*totelem*/, const char *filepath) +void CustomData_external_add(CustomData *data, + ID * /*id*/, + const eCustomDataType type, + const int /*totelem*/, + const char *filepath) { CustomDataExternal *external = data->external; @@ -4650,7 +4698,10 @@ void CustomData_external_add( layer->flag |= CD_FLAG_EXTERNAL | CD_FLAG_IN_MEMORY; } -void CustomData_external_remove(CustomData *data, ID *id, const int type, const int totelem) +void CustomData_external_remove(CustomData *data, + ID *id, + const eCustomDataType type, + const int totelem) { CustomDataExternal *external = data->external; @@ -4674,7 +4725,7 @@ void CustomData_external_remove(CustomData *data, ID *id, const int type, const } } -bool CustomData_external_test(CustomData *data, const int type) +bool CustomData_external_test(CustomData *data, const eCustomDataType type) { int layer_index = CustomData_get_active_layer_index(data, type); if (layer_index == -1) { @@ -4755,7 +4806,7 @@ static void customdata_data_transfer_interp_generic(const CustomDataTransferLaye * more than 0.5 of weight. */ int best_src_idx = 0; - const int data_type = laymap->data_type; + const eCustomDataType data_type = laymap->data_type; const int mix_mode = laymap->mix_mode; size_t data_size; @@ -4864,7 +4915,7 @@ void customdata_data_transfer_interp_normal_normals(const CustomDataTransferLaye BLI_assert(weights != nullptr); BLI_assert(count > 0); - const int data_type = laymap->data_type; + const eCustomDataType data_type = laymap->data_type; const int mix_mode = laymap->mix_mode; SpaceTransform *space_transform = static_cast(laymap->interp_data); @@ -4896,7 +4947,7 @@ void CustomData_data_transfer(const MeshPairRemap *me_remap, MeshPairRemapItem *mapit = me_remap->items; const int totelem = me_remap->items_num; - const int data_type = laymap->data_type; + const eCustomDataType data_type = laymap->data_type; const void *data_src = laymap->data_src; void *data_dst = laymap->data_dst; @@ -5058,7 +5109,7 @@ void CustomData_blend_write(BlendWriter *writer, default: { const char *structname; int structnum; - CustomData_file_write_info(layer.type, &structname, &structnum); + CustomData_file_write_info(eCustomDataType(layer.type), &structname, &structnum); if (structnum) { int datasize = structnum * count; BLO_write_struct_array_by_name(writer, structname, datasize, layer.data); @@ -5189,7 +5240,8 @@ void CustomData_blend_read(BlendDataReader *reader, CustomData *data, const int void CustomData_debug_info_from_layers(const CustomData *data, const char *indent, DynStr *dynstr) { - for (int type = 0; type < CD_NUMTYPES; type++) { + for (eCustomDataType type = eCustomDataType(0); type < CD_NUMTYPES; + type = eCustomDataType(type + 1)) { if (CustomData_has_layer(data, type)) { /* NOTE: doesn't account for multiple layers. */ const char *name = CustomData_layertype_name(type); diff --git a/source/blender/blenkernel/intern/data_transfer.cc b/source/blender/blenkernel/intern/data_transfer.cc index df706557f39..75d9b702bfb 100644 --- a/source/blender/blenkernel/intern/data_transfer.cc +++ b/source/blender/blenkernel/intern/data_transfer.cc @@ -516,7 +516,7 @@ void data_transfer_layersmapping_add_item(ListBase *r_map, BLI_assert(data_dst != nullptr); - item->data_type = cddata_type; + item->data_type = eCustomDataType(cddata_type); item->mix_mode = mix_mode; item->mix_factor = mix_factor; item->mix_weights = mix_weights; @@ -581,7 +581,7 @@ static void data_transfer_layersmapping_add_item_cd(ListBase *r_map, * according to given parameters. */ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map, - const int cddata_type, + const eCustomDataType cddata_type, const int mix_mode, const float mix_factor, const float *mix_weights, @@ -730,7 +730,7 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map } static bool data_transfer_layersmapping_cdlayers(ListBase *r_map, - const int cddata_type, + const eCustomDataType cddata_type, const int mix_mode, const float mix_factor, const float *mix_weights, @@ -856,7 +856,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map, } } else if (fromlayers == DT_LAYERS_ALL_SRC) { - int num_src = CustomData_number_of_layers(cd_src, cddata_type); + int num_src = CustomData_number_of_layers(cd_src, eCustomDataType(cddata_type)); bool *use_layers_src = num_src ? static_cast(MEM_mallocN( sizeof(*use_layers_src) * size_t(num_src), __func__)) : nullptr; @@ -923,7 +923,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map, cd_dst = &me_dst->vdata; if (!data_transfer_layersmapping_cdlayers(r_map, - cddata_type, + eCustomDataType(cddata_type), mix_mode, mix_factor, mix_weights, @@ -975,7 +975,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map, cd_dst = &me_dst->edata; if (!data_transfer_layersmapping_cdlayers(r_map, - cddata_type, + eCustomDataType(cddata_type), mix_mode, mix_factor, mix_weights, @@ -1048,7 +1048,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map, cd_dst = &me_dst->ldata; if (!data_transfer_layersmapping_cdlayers(r_map, - cddata_type, + eCustomDataType(cddata_type), mix_mode, mix_factor, mix_weights, @@ -1079,7 +1079,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map, cd_dst = &me_dst->pdata; if (!data_transfer_layersmapping_cdlayers(r_map, - cddata_type, + eCustomDataType(cddata_type), mix_mode, mix_factor, mix_weights, diff --git a/source/blender/blenkernel/intern/mesh_boolean_convert.cc b/source/blender/blenkernel/intern/mesh_boolean_convert.cc index b4f208bcfda..d2acb9ca220 100644 --- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc +++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc @@ -374,7 +374,7 @@ static void copy_vert_attributes(Mesh *dest_mesh, CustomData *target_cd = &dest_mesh->vdata; const CustomData *source_cd = &orig_me->vdata; for (int source_layer_i = 0; source_layer_i < source_cd->totlayer; ++source_layer_i) { - int ty = source_cd->layers[source_layer_i].type; + const eCustomDataType ty = eCustomDataType(source_cd->layers[source_layer_i].type); if (StringRef(source_cd->layers->name) == "position") { continue; } @@ -400,7 +400,7 @@ static void copy_poly_attributes(Mesh *dest_mesh, CustomData *target_cd = &dest_mesh->pdata; const CustomData *source_cd = &orig_me->pdata; for (int source_layer_i = 0; source_layer_i < source_cd->totlayer; ++source_layer_i) { - int ty = source_cd->layers[source_layer_i].type; + const eCustomDataType ty = eCustomDataType(source_cd->layers[source_layer_i].type); if (ty == CD_MPOLY) { continue; } @@ -435,7 +435,7 @@ static void copy_edge_attributes(Mesh *dest_mesh, CustomData *target_cd = &dest_mesh->edata; const CustomData *source_cd = &orig_me->edata; for (int source_layer_i = 0; source_layer_i < source_cd->totlayer; ++source_layer_i) { - int ty = source_cd->layers[source_layer_i].type; + const eCustomDataType ty = eCustomDataType(source_cd->layers[source_layer_i].type); if (ty == CD_MEDGE) { continue; } @@ -602,7 +602,7 @@ static void copy_or_interp_loop_attributes(Mesh *dest_mesh, interp_weights_poly_v2(weights.data(), cos_2d, orig_poly->totloop, co); } for (int source_layer_i = 0; source_layer_i < source_cd->totlayer; ++source_layer_i) { - int ty = source_cd->layers[source_layer_i].type; + const eCustomDataType ty = eCustomDataType(source_cd->layers[source_layer_i].type); if (STR_ELEM(source_cd->layers[source_layer_i].name, ".corner_vert", ".corner_edge")) { continue; } diff --git a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc index 1f661f69f12..cfeff33dfab 100644 --- a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc +++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc @@ -375,21 +375,21 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source) while ((layer = BKE_id_attribute_from_index( const_cast(&source->id), i++, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL))) { eAttrDomain domain = BKE_id_attribute_domain(&source->id, layer); + const eCustomDataType type = eCustomDataType(layer->type); CustomData *target_cdata = domain == ATTR_DOMAIN_POINT ? &target->vdata : &target->ldata; const CustomData *source_cdata = domain == ATTR_DOMAIN_POINT ? &source->vdata : &source->ldata; /* Check attribute exists in target. */ - int layer_i = CustomData_get_named_layer_index(target_cdata, layer->type, layer->name); + int layer_i = CustomData_get_named_layer_index(target_cdata, type, layer->name); if (layer_i == -1) { int elem_num = domain == ATTR_DOMAIN_POINT ? target->totvert : target->totloop; - CustomData_add_layer_named( - target_cdata, eCustomDataType(layer->type), CD_SET_DEFAULT, elem_num, layer->name); - layer_i = CustomData_get_named_layer_index(target_cdata, layer->type, layer->name); + CustomData_add_layer_named(target_cdata, type, CD_SET_DEFAULT, elem_num, layer->name); + layer_i = CustomData_get_named_layer_index(target_cdata, type, layer->name); } - size_t data_size = CustomData_sizeof(layer->type); + size_t data_size = CustomData_sizeof(type); void *target_data = target_cdata->layers[layer_i].data; void *source_data = layer->data; const Span target_positions = target->vert_positions(); diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_validate.cc index 34722586e74..b0874bc5bc4 100644 --- a/source/blender/blenkernel/intern/mesh_validate.cc +++ b/source/blender/blenkernel/intern/mesh_validate.cc @@ -935,12 +935,13 @@ static bool mesh_validate_customdata(CustomData *data, while (i < data->totlayer) { CustomDataLayer *layer = &data->layers[i]; + const eCustomDataType type = eCustomDataType(layer->type); bool ok = true; /* Count layers when the type changes. */ - if (layer_num_type != layer->type) { - layer_num = CustomData_number_of_layers(data, layer->type); - layer_num_type = layer->type; + if (layer_num_type != type) { + layer_num = CustomData_number_of_layers(data, type); + layer_num_type = type; } /* Validate active index, for a time this could be set to a negative value, see: #105860. */ @@ -975,33 +976,33 @@ static bool mesh_validate_customdata(CustomData *data, } } - if (CustomData_layertype_is_singleton(layer->type)) { + if (CustomData_layertype_is_singleton(type)) { if (layer_num > 1) { PRINT_ERR("\tCustomDataLayer type %d is a singleton, found %d in Mesh structure\n", - layer->type, + type, layer_num); ok = false; } } if (mask != 0) { - eCustomDataMask layer_typemask = CD_TYPE_AS_MASK(layer->type); + eCustomDataMask layer_typemask = CD_TYPE_AS_MASK(type); if ((layer_typemask & mask) == 0) { - PRINT_ERR("\tCustomDataLayer type %d which isn't in the mask\n", layer->type); + PRINT_ERR("\tCustomDataLayer type %d which isn't in the mask\n", type); ok = false; } } if (ok == false) { if (do_fixes) { - CustomData_free_layer(data, layer->type, 0, i); + CustomData_free_layer(data, type, 0, i); has_fixes = true; } } if (ok) { if (CustomData_layer_validate(layer, totitems, do_fixes)) { - PRINT_ERR("\tCustomDataLayer type %d has some invalid data\n", layer->type); + PRINT_ERR("\tCustomDataLayer type %d has some invalid data\n", type); has_fixes = do_fixes; } i++; diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 77514b70063..7eca790e36f 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -1660,7 +1660,9 @@ void BKE_object_link_modifiers(Object *ob_dst, const Object *ob_src) /** * Copy CCG related data. Used to sync copy of mesh with reshaped original mesh. */ -static void copy_ccg_data(Mesh *mesh_destination, Mesh *mesh_source, int layer_type) +static void copy_ccg_data(Mesh *mesh_destination, + Mesh *mesh_source, + const eCustomDataType layer_type) { BLI_assert(mesh_destination->totloop == mesh_source->totloop); CustomData *data_destination = &mesh_destination->ldata; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.cc b/source/blender/blenkernel/intern/subsurf_ccg.cc index e059a9f88d0..22cd2e5466b 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.cc +++ b/source/blender/blenkernel/intern/subsurf_ccg.cc @@ -1207,7 +1207,7 @@ static void ccgDM_release(DerivedMesh *dm) } } -static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type) +static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, const eCustomDataType type) { if (type == CD_ORIGINDEX) { /* create origindex on demand to save memory */ @@ -1249,7 +1249,7 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type) return DM_get_vert_data_layer(dm, type); } -static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type) +static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, const eCustomDataType type) { if (type == CD_ORIGINDEX) { /* create origindex on demand to save memory */ @@ -1292,7 +1292,7 @@ static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type) return DM_get_edge_data_layer(dm, type); } -static void *ccgDM_get_poly_data_layer(DerivedMesh *dm, int type) +static void *ccgDM_get_poly_data_layer(DerivedMesh *dm, const eCustomDataType type) { if (type == CD_ORIGINDEX) { /* create origindex on demand to save memory */ diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc index 075d80f343c..14c2bfb8362 100644 --- a/source/blender/draw/intern/draw_pbvh.cc +++ b/source/blender/draw/intern/draw_pbvh.cc @@ -903,7 +903,9 @@ struct PBVHBatches { if (need_aliases) { CustomData *cdata = get_cdata(domain, args); - int layer_i = cdata ? CustomData_get_named_layer_index(cdata, type, name.c_str()) : -1; + int layer_i = cdata ? CustomData_get_named_layer_index( + cdata, eCustomDataType(type), name.c_str()) : + -1; CustomDataLayer *layer = layer_i != -1 ? cdata->layers + layer_i : nullptr; if (layer) { @@ -924,8 +926,8 @@ struct PBVHBatches { break; } - const char *active_name = CustomData_get_active_layer_name(cdata, type); - const char *render_name = CustomData_get_render_layer_name(cdata, type); + const char *active_name = CustomData_get_active_layer_name(cdata, eCustomDataType(type)); + const char *render_name = CustomData_get_render_layer_name(cdata, eCustomDataType(type)); is_active = active_name && STREQ(layer->name, active_name); is_render = render_name && STREQ(layer->name, render_name); diff --git a/source/blender/editors/mesh/editmesh_select.cc b/source/blender/editors/mesh/editmesh_select.cc index 2c1c3f9f80c..382ee845314 100644 --- a/source/blender/editors/mesh/editmesh_select.cc +++ b/source/blender/editors/mesh/editmesh_select.cc @@ -3135,7 +3135,7 @@ bool EDBM_select_interior_faces(BMEditMesh *em) #define USE_LINKED_SELECT_DEFAULT_HACK struct DelimitData { - int cd_loop_type; + eCustomDataType cd_loop_type; int cd_loop_offset; }; @@ -3219,7 +3219,7 @@ static void select_linked_delimit_validate(BMesh *bm, int *delimit) static void select_linked_delimit_begin(BMesh *bm, int delimit) { - DelimitData delimit_data = {0}; + DelimitData delimit_data{}; if (delimit & BMO_DELIM_UV) { delimit_data.cd_loop_type = CD_PROP_FLOAT2; diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc index b43ed5b36fd..6c2bdb48f28 100644 --- a/source/blender/editors/mesh/mesh_data.cc +++ b/source/blender/editors/mesh/mesh_data.cc @@ -596,7 +596,9 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot) /* *** CustomData clear functions, we need an operator for each *** */ -static int mesh_customdata_clear_exec__internal(bContext *C, char htype, int type) +static int mesh_customdata_clear_exec__internal(bContext *C, + char htype, + const eCustomDataType type) { Mesh *me = ED_mesh_context(C); @@ -621,7 +623,7 @@ static int mesh_customdata_clear_exec__internal(bContext *C, char htype, int typ return OPERATOR_CANCELLED; } -static int mesh_customdata_add_exec__internal(bContext *C, char htype, int type) +static int mesh_customdata_add_exec__internal(bContext *C, char htype, const eCustomDataType type) { Mesh *mesh = ED_mesh_context(C); diff --git a/source/blender/editors/object/object_bake_api.cc b/source/blender/editors/object/object_bake_api.cc index 8f571f03e7e..05cdf174abb 100644 --- a/source/blender/editors/object/object_bake_api.cc +++ b/source/blender/editors/object/object_bake_api.cc @@ -1169,7 +1169,7 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob) if (em) { /* Copy to bmesh. */ const int active_color_offset = CustomData_get_offset_named( - &em->bm->vdata, active_color_layer->type, active_color_layer->name); + &em->bm->vdata, eCustomDataType(active_color_layer->type), active_color_layer->name); BMVert *v; BMIter viter; int i = 0; @@ -1204,7 +1204,7 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob) if (em) { /* Copy to bmesh. */ const int active_color_offset = CustomData_get_offset_named( - &em->bm->ldata, active_color_layer->type, active_color_layer->name); + &em->bm->ldata, eCustomDataType(active_color_layer->type), active_color_layer->name); BMFace *f; BMIter fiter; int i = 0; diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index ae604443f78..aed43dea458 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -133,7 +133,7 @@ typedef struct UndoSculpt { typedef struct SculptAttrRef { eAttrDomain domain; - int type; + eCustomDataType type; char name[MAX_CUSTOMDATA_LAYER_NAME]; bool was_set; } SculptAttrRef; diff --git a/source/blender/geometry/intern/mesh_merge_by_distance.cc b/source/blender/geometry/intern/mesh_merge_by_distance.cc index 0db6e054174..03402aacbc4 100644 --- a/source/blender/geometry/intern/mesh_merge_by_distance.cc +++ b/source/blender/geometry/intern/mesh_merge_by_distance.cc @@ -1458,7 +1458,7 @@ static void customdata_weld( /* interpolates a layer at a time */ dest_i = 0; for (src_i = 0; src_i < source->totlayer; src_i++) { - const int type = source->layers[src_i].type; + const eCustomDataType type = eCustomDataType(source->layers[src_i].type); /* find the first dest layer with type >= the source type * (this should work because layers are ordered by type) @@ -1507,7 +1507,7 @@ static void customdata_weld( for (dest_i = 0; dest_i < dest->totlayer; dest_i++) { CustomDataLayer *layer_dst = &dest->layers[dest_i]; - const int type = layer_dst->type; + const eCustomDataType type = eCustomDataType(layer_dst->type); if (type == CD_MEDGE) { /* Pass. */ } diff --git a/source/blender/io/collada/DocumentExporter.cpp b/source/blender/io/collada/DocumentExporter.cpp index c547b8a0b09..98e4febe814 100644 --- a/source/blender/io/collada/DocumentExporter.cpp +++ b/source/blender/io/collada/DocumentExporter.cpp @@ -109,7 +109,9 @@ extern "C" char build_hash[]; #include -const char *bc_CustomData_get_layer_name(const struct CustomData *data, int type, int n) +const char *bc_CustomData_get_layer_name(const struct CustomData *data, + const eCustomDataType type, + int n) { int layer_index = CustomData_get_layer_index(data, type); if (layer_index < 0) { @@ -119,7 +121,7 @@ const char *bc_CustomData_get_layer_name(const struct CustomData *data, int type return data->layers[layer_index + n].name; } -const char *bc_CustomData_get_active_layer_name(const CustomData *data, int type) +const char *bc_CustomData_get_active_layer_name(const CustomData *data, const eCustomDataType type) { /* get the layer index of the active layer of type */ int layer_index = CustomData_get_active_layer_index(data, type); diff --git a/source/blender/io/collada/collada_utils.h b/source/blender/io/collada/collada_utils.h index dfa80552059..b1509621111 100644 --- a/source/blender/io/collada/collada_utils.h +++ b/source/blender/io/collada/collada_utils.h @@ -125,8 +125,11 @@ extern Mesh *bc_get_mesh_copy(BlenderContext &blender_context, extern Object *bc_get_assigned_armature(Object *ob); extern bool bc_has_object_type(LinkNode *export_set, short obtype); -extern const char *bc_CustomData_get_layer_name(const CustomData *data, int type, int n); -extern const char *bc_CustomData_get_active_layer_name(const CustomData *data, int type); +extern const char *bc_CustomData_get_layer_name(const CustomData *data, + eCustomDataType type, + int n); +extern const char *bc_CustomData_get_active_layer_name(const CustomData *data, + eCustomDataType type); extern void bc_bubble_sort_by_Object_name(LinkNode *export_set); /**