diff options
author | Jacques Lucke <jacques@blender.org> | 2022-02-03 18:52:16 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-02-03 18:52:16 +0300 |
commit | 4be87e97f48533e16594b6ec73980ffb2ba12ade (patch) | |
tree | 03d0199a32288f20c766b010ee815bf8163733d8 /source/blender | |
parent | 946c70e6a7892985289bf8dfaead8512d33eba79 (diff) |
Fix T94435: remove anonymous attributes when applying modifier
Differential Revision: https://developer.blender.org/D13994
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_customdata.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/customdata.cc | 18 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 6 |
3 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 76389b0c66f..38b43e36feb 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -254,6 +254,11 @@ bool CustomData_free_layer_active(struct CustomData *data, int type, int totelem void CustomData_free_layers(struct CustomData *data, int type, int totelem); /** + * Free all anonymous attributes. + */ +void CustomData_free_layers_anonymous(struct CustomData *data, int totelem); + +/** * Returns true if a layer with the specified type exists. */ bool CustomData_has_layer(const struct CustomData *data, int type); diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index 02b50027ef9..e4c18325d76 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -2780,6 +2780,24 @@ void CustomData_free_layers(CustomData *data, int type, int totelem) } } +void CustomData_free_layers_anonymous(struct CustomData *data, int totelem) +{ + while (true) { + bool found_anonymous_layer = false; + for (int i = 0; i < data->totlayer; i++) { + const CustomDataLayer *layer = &data->layers[i]; + if (layer->anonymous_id != NULL) { + CustomData_free_layer(data, layer->type, totelem, i); + found_anonymous_layer = true; + break; + } + } + if (!found_anonymous_layer) { + break; + } + } +} + bool CustomData_has_layer(const CustomData *data, int type) { return (CustomData_get_layer_index(data, type) != -1); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 71ad54383a6..4ac2a9dca62 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -763,6 +763,12 @@ static bool modifier_apply_obdata( BKE_object_material_from_eval_data(bmain, ob, &mesh_applied->id); BKE_mesh_nomain_to_mesh(mesh_applied, me, ob, &CD_MASK_MESH, true); + /* Anonymous attributes shouldn't by available on the applied geometry. */ + CustomData_free_layers_anonymous(&me->vdata, me->totvert); + CustomData_free_layers_anonymous(&me->edata, me->totedge); + CustomData_free_layers_anonymous(&me->pdata, me->totpoly); + CustomData_free_layers_anonymous(&me->ldata, me->totloop); + if (md_eval->type == eModifierType_Multires) { multires_customdata_delete(me); } |