Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2006-11-20 07:28:02 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2006-11-20 07:28:02 +0300
commite435fbc3c5a00e5b63c1cd2609ab6828187660d3 (patch)
tree3f1da9c51451dee55a203cd001d37f8774d2582f /source/blender/blenkernel/BKE_customdata.h
parent0a7c43c6e5fc7d5d75a4645eca1164cede2d03a6 (diff)
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are still used of course, but allocating, copying or freeing these arrays should be done through the CustomData API. Work in progress documentation on this is here: http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData Replaced TFace by MTFace: This is the same struct, except that it does not contain color, that now always stays separated in MCol. This was not a good design decision to begin with, and it is needed for adding multiple color layers later. Note that this does mean older Blender versions will not be able to read UV coordinates from the next release, due to an SDNA limitation. Removed DispListMesh: This now fully replaced by DerivedMesh. To provide access to arrays of vertices, edges and faces, like DispListMesh does. The semantics of the DerivedMesh.getVertArray() and similar functions were changed to return a pointer to an array if one exists, or otherwise allocate a temporary one. On releasing the DerivedMesh, this temporary array will be removed automatically. Removed ssDM and meshDM DerivedMesh backends: The ssDM backend was for DispListMesh, so that became obsolete automatically. The meshDM backend was replaced by the custom data backend, that now figures out which layers need to be modified, and only duplicates those. This changes code in many places, and overall removes 2514 lines of code. So, there's a good chance this might break some stuff, although I've been testing it for a few days now. The good news is, adding multiple color and uv layers should now become easy.
Diffstat (limited to 'source/blender/blenkernel/BKE_customdata.h')
-rw-r--r--source/blender/blenkernel/BKE_customdata.h103
1 files changed, 63 insertions, 40 deletions
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index b36ab67f5e1..ce32f06e320 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -33,36 +33,44 @@
#define BKE_CUSTOMDATA_H
struct CustomData;
+struct CustomDataLayer;
+typedef int CustomDataMask;
-#define ORIGINDEX_NONE -1 /* indicates no original index for this element */
+extern CustomDataMask CD_MASK_MESH[];
+extern CustomDataMask CD_MASK_EDITMESH[];
+extern CustomDataMask CD_MASK_DERIVEDMESH[];
-/* layer flags - to be used with CustomData_add_layer */
+/* for ORIGINDEX layer type, indicates no original index for this element */
+#define ORIGINDEX_NONE -1
-/* indicates layer should not be copied by CustomData_from_template or
- * CustomData_copy_data (for temporary utility layers)
- */
-#define LAYERFLAG_NOCOPY 1<<0
+/* initialises a CustomData object with the same layer setup as source and
+ * memory space for totelem elements. mask must be an array of length
+ * CD_NUMTYPES elements, that indicate if a layer can be copied. */
-/* indicates layer should not be freed (for layers backed by external data)
- */
-#define LAYERFLAG_NOFREE 1<<1
+/* copy/merge allocation types */
+#define CD_CALLOC 0 /* allocate blank memory for all layers */
+#define CD_DEFAULT 1 /* allocate layers and set them to their defaults */
+#define CD_DUPLICATE 2 /* do a full copy of all layer */
+#define CD_REFERENCE 3 /* reference original pointers, set layer flag NOFREE */
-/* initialises a CustomData object with space for the given number
- * of data layers and the given number of elements per layer
- */
-void CustomData_init(struct CustomData *data,
- int maxLayers, int maxElems, int subElems);
+/* initialises a CustomData object with the same layer setup as source.
+ * mask must be an array of length CD_NUMTYPES elements, that 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);
-/* initialises a CustomData object with the same layer setup as source
- * and memory space for maxElems elements. flag is added to all layer flags
- */
-void CustomData_from_template(const struct CustomData *source,
- struct CustomData *dest, int flag, int maxElems);
+/* same as the above, except that 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);
/* frees data associated with a CustomData object (doesn't free the object
* itself, though)
*/
-void CustomData_free(struct CustomData *data);
+void CustomData_free(struct CustomData *data, int totelem);
+
+/* frees all layers with flag LAYERFLAG_TEMPORARY */
+void CustomData_free_temporary(struct CustomData *data, int totelem);
/* adds a data layer of the given type to the CustomData object, optionally
* backed by an external data array
@@ -70,20 +78,19 @@ void CustomData_free(struct CustomData *data);
* is allocated
* the layer data will be freed by CustomData_free unless
* (flag & LAYERFLAG_NOFREE) is true
- * grows the number of layers in data if data->maxLayers has been reached
- * returns 1 on success, 0 on failure
+ * returns the data of the layer
*
* in editmode, use EM_add_data_layer instead of this function
*/
-int CustomData_add_layer(struct CustomData *data, int type, int flag,
- void *layer);
+void *CustomData_add_layer(struct CustomData *data, int type, int flag,
+ void *layer, int totelem);
/* frees the first data layer with the give type.
* returns 1 on succes, 0 if no layer with the given type is found
*
* in editmode, use EM_free_data_layer instead of this function
*/
-int CustomData_free_layer(struct CustomData *data, int type);
+int CustomData_free_layer(struct CustomData *data, int type, int totelem);
/* returns 1 if the two objects are compatible (same layer types and
* flags in the same order), 0 if not
@@ -94,22 +101,26 @@ int CustomData_compat(const struct CustomData *data1,
/* returns 1 if a layer with the specified type exists */
int CustomData_has_layer(const struct CustomData *data, int type);
+/* duplicate data of a layer with flag NOFREE, and remove that flag.
+ * returns the layer data */
+void *CustomData_duplicate_referenced_layer(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 struct CustomData *source,
- struct CustomData *dest, int source_index,
- int dest_index, int count);
-int CustomData_em_copy_data(const struct CustomData *source,
+void CustomData_copy_data(const struct CustomData *source,
+ struct CustomData *dest, int source_index,
+ int dest_index, int count);
+void CustomData_em_copy_data(const struct CustomData *source,
struct CustomData *dest, void *src_block,
void **dest_block);
/* frees data in a CustomData object
* return 1 on success, 0 on failure
*/
-int CustomData_free_elem(struct CustomData *data, int index, int count);
+void 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
@@ -125,12 +136,17 @@ int CustomData_free_elem(struct CustomData *data, int index, int count);
*
* returns 1 on success, 0 on failure
*/
-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);
+void CustomData_interp(const struct CustomData *source, struct CustomData *dest,
+ int *src_indices, float *weights, float *sub_weights,
+ int count, int dest_index);
+void CustomData_em_interp(struct CustomData *data, void **src_blocks,
+ float *weights, float *sub_weights, int count,
+ void *dest_block);
+
+/* swaps the data in the element corners, to new corners with indices as
+ specified in corner_indices. for edges this is an array of length 2, for
+ faces an array of length 4 */
+void CustomData_swap(struct CustomData *data, int index, int *corner_indices);
/* gets a pointer to the data element at index from the first layer of type
* returns NULL if there is no layer of type
@@ -143,6 +159,11 @@ void *CustomData_em_get(const struct CustomData *data, void *block, int type);
*/
void *CustomData_get_layer(const struct CustomData *data, int type);
+/* 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
+ */
+void *CustomData_set_layer(const struct CustomData *data, int type, void *ptr);
+
/* 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
@@ -152,10 +173,8 @@ void CustomData_set(const struct CustomData *data, int index, int type,
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(struct CustomData *data, int numElems);
+/* set data layers that have a non-zero default value to their defaults */
+void CustomData_set_default(struct CustomData *data, int index, int count);
/* alloc/free a block of custom data attached to one element in editmode */
void CustomData_em_set_default(struct CustomData *data, void **block);
@@ -168,4 +187,8 @@ void CustomData_to_em_block(const struct CustomData *source,
void CustomData_from_em_block(const struct CustomData *source,
struct CustomData *dest, void *block, int index);
+/* query info over types */
+void CustomData_file_write_info(int type, char **structname, int *structnum);
+int CustomData_sizeof(int type);
+
#endif