From 51a7e4b488a4df1ce6fec93ee599d70efdbf5e03 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 6 Apr 2022 20:02:04 +0200 Subject: Cleanup: remove unused mface tesselation code from modifier stack This seems to serve no purpose anymore, I don't see anywhere that CD_MFACE is requested for modifier evaluation, and it's confusing to have this in this final normals computation function. Found while looking into D14579. Differential Revision: https://developer.blender.org/D14580 --- source/blender/blenkernel/intern/DerivedMesh.cc | 54 ++++++++----------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc index 604cc3682f0..33f0c331e46 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.cc +++ b/source/blender/blenkernel/intern/DerivedMesh.cc @@ -631,30 +631,23 @@ static void mesh_calc_modifier_final_normals(const Mesh *mesh_input, if (do_loop_normals) { /* Compute loop normals (NOTE: will compute poly and vert normals as well, if needed!). */ BKE_mesh_calc_normals_split(mesh_final); - BKE_mesh_tessface_clear(mesh_final); } - - if (sculpt_dyntopo == false) { - /* watch this! after 2.75a we move to from tessface to looptri (by default) */ - if (final_datamask->fmask & CD_MASK_MFACE) { - BKE_mesh_tessface_ensure(mesh_final); - } - - /* without this, drawing ngon tri's faces will show ugly tessellated face - * normals and will also have to calculate normals on the fly, try avoid - * this where possible since calculating polygon normals isn't fast, - * note that this isn't a problem for subsurf (only quads) or editmode - * which deals with drawing differently. */ - if (!do_loop_normals) { + else { + if (sculpt_dyntopo == false) { + /* without this, drawing ngon tri's faces will show ugly tessellated face + * normals and will also have to calculate normals on the fly, try avoid + * this where possible since calculating polygon normals isn't fast, + * note that this isn't a problem for subsurf (only quads) or editmode + * which deals with drawing differently. */ BKE_mesh_ensure_normals_for_display(mesh_final); } - } - /* Some modifiers, like data-transfer, may generate those data as temp layer, - * we do not want to keep them, as they are used by display code when available - * (i.e. even if autosmooth is disabled). */ - if (!do_loop_normals && CustomData_has_layer(&mesh_final->ldata, CD_NORMAL)) { - CustomData_free_layers(&mesh_final->ldata, CD_NORMAL, mesh_final->totloop); + /* Some modifiers, like data-transfer, may generate those data as temp layer, + * we do not want to keep them, as they are used by display code when available + * (i.e. even if autosmooth is disabled). */ + if (CustomData_has_layer(&mesh_final->ldata, CD_NORMAL)) { + CustomData_free_layers(&mesh_final->ldata, CD_NORMAL, mesh_final->totloop); + } } } @@ -1196,6 +1189,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph, /* Compute normals. */ if (is_own_mesh) { mesh_calc_modifier_final_normals(mesh_input, &final_datamask, sculpt_dyntopo, mesh_final); + mesh_calc_finalize(mesh_input, mesh_final); } else { Mesh_Runtime *runtime = &mesh_input->runtime; @@ -1232,10 +1226,6 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph, } } - if (is_own_mesh) { - mesh_calc_finalize(mesh_input, mesh_final); - } - /* Return final mesh */ *r_final = mesh_final; if (r_deform) { @@ -1299,21 +1289,9 @@ static void editbmesh_calc_modifier_final_normals(Mesh *mesh_final, if (do_loop_normals) { /* Compute loop normals */ BKE_mesh_calc_normals_split(mesh_final); - BKE_mesh_tessface_clear(mesh_final); } - - /* BMESH_ONLY, ensure tessface's used for drawing, - * but don't recalculate if the last modifier in the stack gives us tessfaces - * check if the derived meshes are DM_TYPE_EDITBMESH before calling, this isn't essential - * but quiets annoying error messages since tessfaces won't be created. */ - if (final_datamask->fmask & CD_MASK_MFACE) { - if (mesh_final->edit_mesh == nullptr) { - BKE_mesh_tessface_ensure(mesh_final); - } - } - - /* same as mesh_calc_modifiers (if using loop normals, poly nors have already been computed). */ - if (!do_loop_normals) { + else { + /* Same as mesh_calc_modifiers. If using loop normals, poly nors have already been computed. */ BKE_mesh_ensure_normals_for_display(mesh_final); /* Some modifiers, like data-transfer, may generate those data, we do not want to keep them, -- cgit v1.2.3