diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-18 22:00:23 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-03-13 15:46:55 +0300 |
commit | a1a7317f6b098ab6928f33754e57de219877cb64 (patch) | |
tree | d14b44056f99d292567fe82c39d6f8d14e6f634d /source/blender/blenkernel/intern/customdata.c | |
parent | 2ef2f085fb743c12d1cabd71d42dd00334de696b (diff) |
Add argument to DM_to_mesh() function to take ownership over the DM
The idea is pretty simple: instead of making temporary copy of all the
related custom data layers just pass the ownership from the DM to the
mesh.
This is really handy in cases when you've got DM which you need to
convert to Mesh datablock and wouldn't need that DM after conversion
anyway.
Foe example, render database conversion, exporters and even Modifier
Apply will benefit from this option.
Reviewers: campbellbarton
Differential Revision: https://developer.blender.org/D1127
Diffstat (limited to 'source/blender/blenkernel/intern/customdata.c')
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 65ec6be5a60..999f411cece 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -1559,6 +1559,25 @@ void CustomData_free(CustomData *data, int totelem) CustomData_reset(data); } +void CustomData_free_typemask(struct CustomData *data, int totelem, CustomDataMask mask) +{ + int i; + + for (i = 0; i < data->totlayer; ++i) { + CustomDataLayer *layer = &data->layers[i]; + if (!(mask & CD_TYPE_AS_MASK(layer->type))) { + continue; + } + customData_free_layer__internal(layer, totelem); + } + + if (data->layers) + MEM_freeN(data->layers); + + CustomData_external_free(data); + CustomData_reset(data); +} + static void customData_update_offsets(CustomData *data) { const LayerTypeInfo *typeInfo; @@ -2876,6 +2895,17 @@ bool CustomData_has_interp(const struct CustomData *data) return false; } +bool CustomData_has_referenced(const struct CustomData *data) +{ + int i; + for (i = 0; i < data->totlayer; ++i) { + if (data->layers[i].flag & CD_FLAG_NOFREE) { + return true; + } + } + return false; +} + /* copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to * another, while not overwriting anything else (e.g. flags)*/ void CustomData_data_copy_value(int type, const void *source, void *dest) |