diff options
Diffstat (limited to 'source/blender/blenkernel/BKE_customdata.h')
-rw-r--r-- | source/blender/blenkernel/BKE_customdata.h | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 5497866b9df..6dc3baa2746 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -38,11 +38,15 @@ extern "C" { #endif +struct BMesh; struct ID; struct CustomData; struct CustomDataLayer; typedef unsigned int CustomDataMask; +/*a data type large enough to hold 1 element from any customdata layer type*/ +typedef struct {unsigned char data[64];} CDBlockBytes; + extern const CustomDataMask CD_MASK_BAREMESH; extern const CustomDataMask CD_MASK_MESH; extern const CustomDataMask CD_MASK_EDITMESH; @@ -65,17 +69,45 @@ extern const CustomDataMask CD_MASK_FACECORNERS; #define CD_DUPLICATE 4 /* do a full copy of all layers, only allowed if source has same number of elements */ +/* Checks if the layer at physical offset layern (in data->layers) support math + * the below operations. + */ +int CustomData_layer_has_math(struct CustomData *data, int layern); + +/*copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to + another, while not overwriting anything else (e.g. flags). probably only + implemented for mloopuv/mloopcol, for now.*/ +void CustomData_data_copy_value(int type, void *source, void *dest); + +/* compares if data1 is equal to data2. type is a valid CustomData type + * enum (e.g. CD_MLOOPUV). the layer type's equal function is used to compare + * the data, if it exists, otherwise memcmp is used.*/ +int CustomData_data_equals(int type, void *data1, void *data2); +void CustomData_data_initminmax(int type, void *min, void *max); +void CustomData_data_dominmax(int type, void *data, void *min, void *max); +void CustomData_data_multiply(int type, void *data, float fac); +void CustomData_data_add(int type, void *data1, void *data2); + /* initialises a CustomData object with the same layer setup as source. * mask is a bitfield where (mask & (1 << (layer type))) indicates * if a layer should be copied or not. alloctype must be one of the above. */ void CustomData_copy(const struct CustomData *source, struct CustomData *dest, CustomDataMask mask, int alloctype, int totelem); +/* BMESH_TODO, not really a public function but readfile.c needs it */ +void CustomData_update_typemap(struct CustomData *data); + /* same as the above, except that this will preserve existing layers, and only * add the layers that were not there yet */ void CustomData_merge(const struct CustomData *source, struct CustomData *dest, CustomDataMask mask, int alloctype, int totelem); +/*bmesh version of CustomData_merge; merges the layouts of source and dest, + then goes through the mesh and makes sure all the customdata blocks are + consistent with the new layout.*/ +void CustomData_bmesh_merge(struct CustomData *source, struct CustomData *dest, + int mask, int alloctype, struct BMesh *bm, int type); + /* frees data associated with a CustomData object (doesn't free the object * itself, though) */ @@ -140,12 +172,13 @@ void CustomData_set_only_copy(const struct CustomData *data, void CustomData_copy_data(const struct CustomData *source, struct CustomData *dest, int source_index, int dest_index, int count); +void CustomData_copy_elements(int type, void *source, void *dest, int count); void CustomData_em_copy_data(const struct CustomData *source, struct CustomData *dest, void *src_block, void **dest_block); void CustomData_bmesh_copy_data(const struct CustomData *source, - struct CustomData *dest,void *src_block, - void **dest_block); + struct CustomData *dest, void *src_block, + void **dest_block); void CustomData_em_validate_data(struct CustomData *data, void *block, int sub_elements); /* frees data in a CustomData object @@ -187,11 +220,18 @@ void CustomData_swap(struct CustomData *data, int index, const int *corner_indic * returns NULL if there is no layer of type */ void *CustomData_get(const struct CustomData *data, int index, int type); +void *CustomData_get_n(const struct CustomData *data, int type, int index, int n); void *CustomData_em_get(const struct CustomData *data, void *block, int type); void *CustomData_em_get_n(const struct CustomData *data, void *block, int type, int n); 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); +/* gets the layer at physical index n, with no type checking. + */ +void *CustomData_bmesh_get_layer_n(const struct CustomData *data, void *block, int n); + +int CustomData_set_layer_name(const struct CustomData *data, int type, int n, const char *name); + /* gets a pointer to the active or first layer of type * returns NULL if there is no layer of type */ @@ -199,8 +239,8 @@ void *CustomData_get_layer(const struct CustomData *data, int type); void *CustomData_get_layer_n(const struct CustomData *data, int type, int n); void *CustomData_get_layer_named(const struct CustomData *data, int type, const char *name); - 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_active_layer_index(const struct CustomData *data, int type); int CustomData_get_render_layer_index(const struct CustomData *data, int type); @@ -227,6 +267,11 @@ void CustomData_bmesh_set(const struct CustomData *data, void *block, int type, void CustomData_bmesh_set_n(struct CustomData *data, void *block, int type, int n, void *source); +/*sets the data of the block at physical layer n. no real type checking + *is performed. + */ +void CustomData_bmesh_set_layer_n(struct CustomData *data, void *block, int n, + void *source); /* set the pointer of to the first layer of type. the old data is not freed. * returns the value of ptr if the layer is found, NULL otherwise @@ -285,7 +330,8 @@ void CustomData_validate_layer_name(const struct CustomData *data, int type, cha int CustomData_verify_versions(struct CustomData *data, int index); /*BMesh specific customdata stuff*/ -void CustomData_to_bmeshpoly(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata); +void CustomData_to_bmeshpoly(struct CustomData *fdata, struct CustomData *pdata, + struct CustomData *ldata, int totloop, int totpoly); void CustomData_from_bmeshpoly(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata, int total); void CustomData_bmesh_init_pool(struct CustomData *data, int allocsize); |