Fix T50534: Part I, cleanup loop normals generated during modifier stack evaluation.

Those could stay around, and be displayed in 3DView even when autosmooth
was disabled (but would not be 'active').
This commit is contained in:
2017-01-27 18:47:11 +01:00
parent bfe3b967fa
commit fb2f95c91a

View File

@@ -2215,6 +2215,12 @@ static void mesh_calc_modifiers(
} }
} }
/* Some modifiers, like datatransfer, 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(&finaldm->loopData, CD_NORMAL)) {
CustomData_free_layers(&finaldm->loopData, CD_NORMAL, finaldm->numLoopData);
}
#ifdef WITH_GAMEENGINE #ifdef WITH_GAMEENGINE
/* NavMesh - this is a hack but saves having a NavMesh modifier */ /* NavMesh - this is a hack but saves having a NavMesh modifier */
if ((ob->gameflag & OB_NAVMESH) && (finaldm->type == DM_TYPE_CDDM)) { if ((ob->gameflag & OB_NAVMESH) && (finaldm->type == DM_TYPE_CDDM)) {
@@ -2550,6 +2556,15 @@ static void editbmesh_calc_modifiers(
/* same as mesh_calc_modifiers (if using loop normals, poly nors have already been computed). */ /* same as mesh_calc_modifiers (if using loop normals, poly nors have already been computed). */
if (!do_loop_normals) { if (!do_loop_normals) {
dm_ensure_display_normals(*r_final); dm_ensure_display_normals(*r_final);
/* Some modifiers, like datatransfer, may generate those data, 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(&(*r_final)->loopData, CD_NORMAL)) {
CustomData_free_layers(&(*r_final)->loopData, CD_NORMAL, (*r_final)->numLoopData);
}
if (r_cage && CustomData_has_layer(&(*r_cage)->loopData, CD_NORMAL)) {
CustomData_free_layers(&(*r_cage)->loopData, CD_NORMAL, (*r_cage)->numLoopData);
}
} }
/* add an orco layer if needed */ /* add an orco layer if needed */