Fix T95613: remove anonymous attributes when converting object

This is the same behavior as when applying a geometry nodes modifier
that adds anonymous attributes.
This commit is contained in:
Jacques Lucke 2022-02-10 18:03:37 +01:00
parent 720d653b41
commit 25c4000796
Notes: blender-bot 2023-02-14 04:20:36 +01:00
Referenced by issue #95613, Converting object with GN modifier containing Capture Attribute node to mesh creates anonymous attributes
4 changed files with 16 additions and 6 deletions

View File

@ -327,6 +327,8 @@ void BKE_mesh_vert_coords_apply_with_mat4(struct Mesh *mesh,
const float mat[4][4]);
void BKE_mesh_vert_coords_apply(struct Mesh *mesh, const float (*vert_coords)[3]);
void BKE_mesh_anonymous_attributes_remove(struct Mesh *mesh);
/* *** mesh_tessellate.c *** */
/**

View File

@ -1922,6 +1922,14 @@ void BKE_mesh_vert_coords_apply_with_mat4(Mesh *mesh,
BKE_mesh_normals_tag_dirty(mesh);
}
void BKE_mesh_anonymous_attributes_remove(Mesh *mesh)
{
CustomData_free_layers_anonymous(&mesh->vdata, mesh->totvert);
CustomData_free_layers_anonymous(&mesh->edata, mesh->totedge);
CustomData_free_layers_anonymous(&mesh->pdata, mesh->totpoly);
CustomData_free_layers_anonymous(&mesh->ldata, mesh->totloop);
}
void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spacearr)
{
float(*r_loopnors)[3];

View File

@ -2930,7 +2930,10 @@ static int object_convert_exec(bContext *C, wmOperator *op)
/* Full (edge-angle based) draw calculation should ideally be performed. */
BKE_mesh_edges_set_draw_render(me_eval);
BKE_object_material_from_eval_data(bmain, newob, &me_eval->id);
BKE_mesh_nomain_to_mesh(me_eval, newob->data, newob, &CD_MASK_MESH, true);
Mesh *new_mesh = (Mesh *)newob->data;
BKE_mesh_nomain_to_mesh(me_eval, new_mesh, newob, &CD_MASK_MESH, true);
/* Anonymous attributes shouldn't be available on the applied geometry. */
BKE_mesh_anonymous_attributes_remove(new_mesh);
BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */
}
else if (ob->type == OB_FONT) {

View File

@ -763,11 +763,8 @@ 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);
/* Anonymous attributes shouldn't be available on the applied geometry. */
BKE_mesh_anonymous_attributes_remove(me);
if (md_eval->type == eModifierType_Multires) {
multires_customdata_delete(me);