Don't create MFace's when calculating normals
authorCampbell Barton <ideasman42@gmail.com>
Fri, 17 Jul 2015 10:14:17 +0000 (20:14 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 17 Jul 2015 11:59:07 +0000 (21:59 +1000)
Instead only create MFace layer when its requested

source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/cdderivedmesh.c

index b3be4a4ebcf87f7b2bab407894047cd261cab05c..a77e076784826f4b3cd44c9ccbf4566fd06de3ed 100644 (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);
+                               }
                        }
                }
        }
index 4820514b3141c9fac37d5ce9c62397d28e35256c..6880c1c9b2ae3e7346d38929b92807efa34da0e1 100644 (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");