Refactor: Mesh: Don't share code between "clear geomtry" and "free"
Clearing a mesh's geometry without freeing the mesh has the requirement that the mesh remain initialized afterwards. Freeing the mesh doesn't have that requirement and corresponds to a destructor rather than move construction with the default value. Avoiding conflating the two operations simplifies some future feature additions (including #122398).
This commit is contained in:
@@ -233,9 +233,20 @@ static void mesh_free_data(ID *id)
|
||||
{
|
||||
Mesh *mesh = reinterpret_cast<Mesh *>(id);
|
||||
|
||||
BKE_mesh_clear_geometry_and_metadata(mesh);
|
||||
CustomData_free(&mesh->vert_data);
|
||||
CustomData_free(&mesh->edge_data);
|
||||
CustomData_free(&mesh->fdata_legacy);
|
||||
CustomData_free(&mesh->corner_data);
|
||||
CustomData_free(&mesh->face_data);
|
||||
BLI_freelistN(&mesh->vertex_group_names);
|
||||
MEM_SAFE_FREE(mesh->active_color_attribute);
|
||||
MEM_SAFE_FREE(mesh->default_color_attribute);
|
||||
if (mesh->face_offset_indices) {
|
||||
blender::implicit_sharing::free_shared_data(&mesh->face_offset_indices,
|
||||
&mesh->runtime->face_offsets_sharing_info);
|
||||
}
|
||||
MEM_SAFE_FREE(mesh->mselect);
|
||||
MEM_SAFE_FREE(mesh->mat);
|
||||
|
||||
delete mesh->runtime;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user