diff options
Diffstat (limited to 'source/blender/blenkernel/BKE_customdata.h')
-rw-r--r-- | source/blender/blenkernel/BKE_customdata.h | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 010fbb27172..f761e28cbb4 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -11,7 +11,9 @@ #include "BLI_sys_types.h" #include "BLI_utildefines.h" #ifdef __cplusplus +# include "BLI_set.hh" # include "BLI_span.hh" +# include "BLI_string_ref.hh" # include "BLI_vector.hh" #endif @@ -53,14 +55,17 @@ extern const CustomData_MeshMasks CD_MASK_EVERYTHING; typedef enum eCDAllocType { /** Use the data pointer. */ CD_ASSIGN = 0, - /** Allocate blank memory. */ - CD_CALLOC = 1, - /** Allocate and set to default. */ - CD_DEFAULT = 2, + /** Allocate and set to default, which is usually just zeroed memory. */ + CD_SET_DEFAULT = 2, /** Use data pointers, set layer flag NOFREE. */ CD_REFERENCE = 3, /** Do a full copy of all layers, only allowed if source has same number of elements. */ CD_DUPLICATE = 4, + /** + * Default construct new layer values. Does nothing for trivial types. This should be used + * if all layer values will be set by the caller after creating the layer. + */ + CD_CONSTRUCT = 5, } eCDAllocType; #define CD_TYPE_AS_MASK(_type) (eCustomDataMask)((eCustomDataMask)1 << (eCustomDataMask)(_type)) @@ -132,7 +137,7 @@ void CustomData_data_add(int type, void *data1, const void *data2); /** * Initializes a CustomData object with the same layer setup as source. - * mask is a bitfield where `(mask & (1 << (layer type)))` indicates + * mask is a bit-field 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, @@ -155,13 +160,11 @@ bool CustomData_merge(const struct CustomData *source, int totelem); /** - * Reallocate custom data to a new element count. - * Only affects on data layers which are owned by the CustomData itself, - * referenced data is kept unchanged, - * - * \note Take care of referenced layers by yourself! + * Reallocate custom data to a new element count. If the new size is larger, the new values use + * the #CD_CONSTRUCT behavior, so trivial types must be initialized by the caller. After being + * resized, the #CustomData does not contain any referenced layers. */ -void CustomData_realloc(struct CustomData *data, int totelem); +void CustomData_realloc(struct CustomData *data, int old_size, int new_size); /** * BMesh version of CustomData_merge; merges the layouts of source and `dest`, @@ -176,6 +179,14 @@ bool CustomData_bmesh_merge(const struct CustomData *source, char htype); /** + * Remove layers that aren't stored in BMesh or are stored as flags on BMesh. + * The `layers` array of the returned #CustomData must be freed, but may be null. + * Used during conversion of #Mesh data to #BMesh storage format. + */ +CustomData CustomData_shallow_copy_remove_non_bmesh_attributes(const CustomData *src, + eCustomDataMask mask); + +/** * NULL's all members and resets the #CustomData.typemap. */ void CustomData_reset(struct CustomData *data); @@ -397,7 +408,7 @@ 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(const struct CustomData *data, int type, int n, const char *name); +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); /** @@ -408,6 +419,7 @@ 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_offset(const struct CustomData *data, int type); +int CustomData_get_offset_named(const CustomData *data, int type, const char *name); int CustomData_get_n_offset(const struct CustomData *data, int type, int n); int CustomData_get_layer_index(const struct CustomData *data, int type); @@ -430,10 +442,10 @@ int CustomData_get_stencil_layer(const struct CustomData *data, int type); const char *CustomData_get_active_layer_name(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. + * Returns name of the default layer of the given type or NULL + * if no such active layer is defined. */ -void CustomData_set(const struct CustomData *data, int index, int type, const void *source); +const char *CustomData_get_render_layer_name(const struct CustomData *data, int type); void CustomData_bmesh_set(const struct CustomData *data, void *block, @@ -442,18 +454,6 @@ void CustomData_bmesh_set(const struct CustomData *data, void CustomData_bmesh_set_n( struct CustomData *data, void *block, int type, int n, const 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, const 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. - */ -void *CustomData_set_layer(const struct CustomData *data, int type, void *ptr); -void *CustomData_set_layer_n(const struct CustomData *data, int type, int n, void *ptr); /** * Sets the nth layer of type as active. @@ -562,7 +562,6 @@ void CustomData_bmesh_init_pool(struct CustomData *data, int totelem, char htype * \return True if some errors were found. */ bool CustomData_layer_validate(struct CustomDataLayer *layer, uint totitems, bool do_fixes); -void CustomData_layers__print(struct CustomData *data); /* External file storage */ @@ -606,11 +605,9 @@ enum { CD_SHAPEKEY, /* Not available as real CD layer in non-bmesh context. */ /* Edges. */ - CD_FAKE_SEAM = CD_FAKE | 100, /* UV seam flag for edges. */ - CD_FAKE_CREASE = CD_FAKE | CD_CREASE, /* *sigh*. */ + CD_FAKE_SEAM = CD_FAKE | 100, /* UV seam flag for edges. */ /* Multiple types of mesh elements... */ - CD_FAKE_BWEIGHT = CD_FAKE | CD_BWEIGHT, /* *sigh*. */ CD_FAKE_UV = CD_FAKE | CD_MLOOPUV, /* UV flag, because we handle both loop's UVs and poly's textures. */ @@ -666,7 +663,7 @@ typedef struct CustomDataTransferLayerMap { size_t data_size; /** Offset of actual data we transfer (in element contained in data_src/dst). */ size_t data_offset; - /** For bitflag transfer, flag(s) to affect in transferred data. */ + /** For bit-flag transfer, flag(s) to affect in transferred data. */ uint64_t data_flag; /** Opaque pointer, to be used by specific interp callback (e.g. transformspace for normals). */ @@ -696,7 +693,8 @@ void CustomData_data_transfer(const struct MeshPairRemap *me_remap, * the struct. */ void CustomData_blend_write_prepare(CustomData &data, - blender::Vector<CustomDataLayer, 16> &layers_to_write); + blender::Vector<CustomDataLayer, 16> &layers_to_write, + const blender::Set<std::string> &skip_names = {}); /** * \param layers_to_write: Layers created by #CustomData_blend_write_prepare. @@ -712,6 +710,8 @@ void CustomData_blend_write(BlendWriter *writer, void CustomData_blend_read(struct BlendDataReader *reader, struct CustomData *data, int count); +size_t CustomData_get_elem_size(struct CustomDataLayer *layer); + #ifndef NDEBUG struct DynStr; /** Use to inspect mesh data when debugging. */ |