diff options
Diffstat (limited to 'source/blender/blenkernel/BKE_customdata.h')
-rw-r--r-- | source/blender/blenkernel/BKE_customdata.h | 93 |
1 files changed, 49 insertions, 44 deletions
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 6f8d9911d89..9733c26ade2 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -27,39 +27,12 @@ * ***** END GPL LICENSE BLOCK ***** */ -/* CustomData interface. - * CustomData is a structure which stores custom element data associated - * with mesh elements (vertices, edges or faces). The custom data is - * organised into a series of layers, each with a data type (e.g. TFace, - * MDeformVert, etc.). - */ +/* CustomData interface, see also DNA_customdata_types.h. */ #ifndef BKE_CUSTOMDATA_H #define BKE_CUSTOMDATA_H -typedef struct CustomData { - struct LayerDesc *layers; /* data layer descriptors, ordered by type */ - int numLayers; /* current number of layers */ - int maxLayers; /* maximum number of layers */ - int numElems; /* current number of elements */ - int maxElems; /* maximum number of elements */ - int subElems; /* number of sub-elements layers can have */ -} CustomData; - -/* custom data types */ -enum { - LAYERTYPE_MVERT = 0, - LAYERTYPE_MSTICKY, - LAYERTYPE_MDEFORMVERT, - LAYERTYPE_MEDGE, - LAYERTYPE_MFACE, - LAYERTYPE_TFACE, - LAYERTYPE_MCOL, - LAYERTYPE_ORIGINDEX, - LAYERTYPE_NORMAL, - LAYERTYPE_FLAGS, - LAYERTYPE_NUMTYPES -}; +struct CustomData; #define ORIGINDEX_NONE -1 /* indicates no original index for this element */ @@ -77,19 +50,19 @@ enum { /* initialises a CustomData object with space for the given number * of data layers and the given number of elements per layer */ -void CustomData_init(CustomData *data, +void CustomData_init(struct CustomData *data, int maxLayers, int maxElems, int subElems); /* initialises a CustomData object with the same layer setup as source - * and memory space for maxElems elements + * and memory space for maxElems elements. flag is added to all layer flags */ -void CustomData_from_template(const CustomData *source, CustomData *dest, - int maxElems); +void CustomData_from_template(const struct CustomData *source, + struct CustomData *dest, int flag, int maxElems); /* frees data associated with a CustomData object (doesn't free the object * itself, though) */ -void CustomData_free(CustomData *data); +void CustomData_free(struct CustomData *data); /* adds a data layer of the given type to the CustomData object, optionally * backed by an external data array @@ -100,25 +73,38 @@ void CustomData_free(CustomData *data); * grows the number of layers in data if data->maxLayers has been reached * returns 1 on success, 0 on failure */ -int CustomData_add_layer(CustomData *data, int type, int flag, void *layer); +int CustomData_add_layer(struct CustomData *data, int type, int flag, + void *layer); + +/* frees the first data layer with the give type. + * returns 1 on succes, 0 if no layer with the given type is found + */ +int CustomData_free_layer(struct CustomData *data, int type); /* returns 1 if the two objects are compatible (same layer types and * flags in the same order), 0 if not */ -int CustomData_compat(const CustomData *data1, const CustomData *data2); +int CustomData_compat(const struct CustomData *data1, + const struct CustomData *data2); + +/* returns 1 if a layer with the specified type exists */ +int CustomData_has_layer(const struct CustomData *data, int type); /* copies data from one CustomData object to another * objects need not be compatible, each source layer is copied to the * first dest layer of correct type (if there is none, the layer is skipped) * return 1 on success, 0 on failure */ -int CustomData_copy_data(const CustomData *source, CustomData *dest, - int source_index, int dest_index, int count); +int CustomData_copy_data(const struct CustomData *source, + struct CustomData *dest, int source_index, + int dest_index, int count); +int CustomData_em_copy_data(struct CustomData *data, void *src_block, + void **dest_block); /* frees data in a CustomData object * return 1 on success, 0 on failure */ -int CustomData_free_elem(CustomData *data, int index, int count); +int CustomData_free_elem(struct CustomData *data, int index, int count); /* interpolates data from one CustomData object to another * objects need not be compatible, each source layer is interpolated to the @@ -134,28 +120,47 @@ int CustomData_free_elem(CustomData *data, int index, int count); * * returns 1 on success, 0 on failure */ -int CustomData_interp(const CustomData *source, CustomData *dest, +int CustomData_interp(const struct CustomData *source, struct CustomData *dest, int *src_indices, float *weights, float *sub_weights, int count, int dest_index); +int CustomData_em_interp(struct CustomData *data, void **src_blocks, + float *weights, float *sub_weights, int count, + void *dest_block); /* gets a pointer to the data element at index from the first layer of type * returns NULL if there is no layer of type */ -void *CustomData_get(const CustomData *data, int index, int type); +void *CustomData_get(const struct CustomData *data, int index, int type); +void *CustomData_em_get(const struct CustomData *data, void *block, int type); /* gets a pointer to the first layer of type * returns NULL if there is no layer of type */ -void *CustomData_get_layer(const CustomData *data, int type); +void *CustomData_get_layer(const struct CustomData *data, int type); /* copies the data from source to the data element at index in the first * layer of type * no effect if there is no layer of type */ -void CustomData_set(const CustomData *data, int index, int type, void *source); +void CustomData_set(const struct CustomData *data, int index, int type, + void *source); +void CustomData_em_set(struct CustomData *data, void *block, int type, + void *source); /* sets the number of elements in a CustomData object * if the value given is more than the maximum, the maximum is used */ -void CustomData_set_num_elems(CustomData *data, int numElems); +void CustomData_set_num_elems(struct CustomData *data, int numElems); + +/* alloc/free a block of custom data attached to one element in editmode */ +void CustomData_em_set_default(struct CustomData *data, void **block); +void CustomData_em_free_block(struct CustomData *data, void **block); + +/* copy custom data to/from layers as in mesh/derivedmesh, to editmesh + blocks of data. the CustomData's must be compatible */ +void CustomData_to_em_block(const struct CustomData *source, + struct CustomData *dest, int index, void **block); +void CustomData_from_em_block(const struct CustomData *source, + struct CustomData *dest, void *block, int index); + #endif |