Don't create MFace's when calculating normals

Instead only create MFace layer when its requested
This commit is contained in:
Campbell Barton
2015-07-17 20:14:17 +10:00
parent 19614f4395
commit e1606e8c87
2 changed files with 14 additions and 13 deletions

View File

@@ -2085,11 +2085,10 @@ static void mesh_calc_modifiers(
if (sculpt_dyntopo == false) {
/* watch this! after 2.75a we move to from tessface to looptri (by default) */
#if 0
DM_ensure_tessface(finaldm);
#else
if (dataMask & CD_MASK_MFACE) {
DM_ensure_tessface(finaldm);
}
DM_ensure_looptri(finaldm);
#endif
/* 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
@@ -2416,18 +2415,19 @@ static void editbmesh_calc_modifiers(
}
}
/* --- */
/* 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 wont be created. */
if ((*r_final)->type != DM_TYPE_EDITBMESH) {
DM_ensure_tessface(*r_final);
}
if (r_cage && *r_cage) {
if ((*r_cage)->type != DM_TYPE_EDITBMESH) {
if (*r_cage != *r_final) {
DM_ensure_tessface(*r_cage);
if (dataMask & CD_MASK_MFACE) {
if ((*r_final)->type != DM_TYPE_EDITBMESH) {
DM_ensure_tessface(*r_final);
}
if (r_cage && *r_cage) {
if ((*r_cage)->type != DM_TYPE_EDITBMESH) {
if (*r_cage != *r_final) {
DM_ensure_tessface(*r_cage);
}
}
}
}

View File

@@ -2495,7 +2495,7 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const bool only_face_normals)
cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
#endif
#if 0
if (dm->numTessFaceData == 0) {
/* No tessellation on this mesh yet, need to calculate one.
*
@@ -2509,6 +2509,7 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const bool only_face_normals)
BLI_assert(CustomData_has_layer(&dm->faceData, CD_ORIGINDEX));
CustomData_free_layers(&dm->faceData, CD_NORMAL, dm->numTessFaceData);
}
#endif
face_nors = MEM_mallocN(sizeof(*face_nors) * dm->numPolyData, "face_nors");