diff options
author | Hans Goudey <h.goudey@me.com> | 2022-06-08 11:42:21 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-06-08 11:48:19 +0300 |
commit | 6eea5f70e3b79e3c6683b7bc0e3e2998b67955d6 (patch) | |
tree | 94cce89b472021d174349477303a3faeab9cb73d /source/blender/bmesh/intern/bmesh_interp.c | |
parent | 1af652d42eb917e257d0f4f2773258f4f6ad2a45 (diff) |
Attributes: Use names instead of layers for some functions
This mirrors the C++ attribute API better, separates the implementation
of attributes from CustomData slightly, and makes functions simpler,
clearer, and safer.
Also fix an issue with removing an attribute caused by 97712b018df71c
meant the first attribute with the given type was removed instead of
the attribute with the given name.
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_interp.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_interp.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 2f5827bdc4c..0c3db31dd1f 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -894,6 +894,27 @@ void BM_data_layer_free(BMesh *bm, CustomData *data, int type) } } +bool BM_data_layer_free_named(BMesh *bm, CustomData *data, const char *name) +{ + CustomData olddata = *data; + olddata.layers = (olddata.layers) ? MEM_dupallocN(olddata.layers) : NULL; + + /* the pool is now owned by olddata and must not be shared */ + data->pool = NULL; + + const bool has_layer = CustomData_free_layer_named(data, name, 0); + + if (has_layer) { + update_data_blocks(bm, &olddata, data); + } + + if (olddata.layers) { + MEM_freeN(olddata.layers); + } + + return has_layer; +} + void BM_data_layer_free_n(BMesh *bm, CustomData *data, int type, int n) { CustomData olddata; |