fix [#35795] Edge split modifier do not show result in viewport with curves.
authorCampbell Barton <ideasman42@gmail.com>
Wed, 19 Jun 2013 08:19:36 +0000 (08:19 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 19 Jun 2013 08:19:36 +0000 (08:19 +0000)
caused by recent changes in normal calculation, however curves were not being very smart about calculating modifiers (calling unneeded re-tessellation for every modifier)

source/blender/blenkernel/intern/displist.c
source/blender/modifiers/intern/MOD_edgesplit.c

index f3de4001dea4f44c2df923a94e9343e615b29ff2..ed8d7bd3d2f517ca60661d4e29baba54f290514f 100644 (file)
@@ -976,7 +976,6 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
                                        dm = tdm;
 
                                        CDDM_apply_vert_coords(dm, vertCos);
                                        dm = tdm;
 
                                        CDDM_apply_vert_coords(dm, vertCos);
-                                       CDDM_calc_normals_mapping(dm);
                                }
                        }
                        else {
                                }
                        }
                        else {
@@ -989,8 +988,6 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
                                }
 
                                dm = CDDM_from_curve_displist(ob, dispbase);
                                }
 
                                dm = CDDM_from_curve_displist(ob, dispbase);
-
-                               CDDM_calc_normals_mapping(dm);
                        }
 
                        if (vertCos) {
                        }
 
                        if (vertCos) {
@@ -1001,7 +998,8 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
 
                        if (useCache)
                                appf |= MOD_APPLY_USECACHE;
 
                        if (useCache)
                                appf |= MOD_APPLY_USECACHE;
-                       ndm = mti->applyModifier(md, ob, dm, appf);
+
+                       ndm = modwrap_applyModifier(md, ob, dm, appf);
 
                        if (ndm) {
                                /* Modifier returned a new derived mesh */
 
                        if (ndm) {
                                /* Modifier returned a new derived mesh */
@@ -1031,8 +1029,19 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
        }
 
        if (derivedFinal) {
        }
 
        if (derivedFinal) {
-               if (dm)
-                       DM_ensure_tessface(dm);  /* needed for drawing */
+               if (dm) {
+                       /* see: mesh_calc_modifiers */
+                       if (dm->getNumTessFaces(dm) == 0) {
+                               dm->recalcTessellation(dm);
+                       }
+                       /* Even if tessellation is not needed, some modifiers might have modified CD layers
+                        * (like mloopcol or mloopuv), hence we have to update those. */
+                       else if (dm->dirty & DM_DIRTY_TESS_CDLAYERS) {
+                               DM_update_tessface_data(dm);
+                       }
+
+                       CDDM_calc_normals_mapping_ex(dm, (dm->dirty & DM_DIRTY_NORMALS) ? false : true);
+               }
                (*derivedFinal) = dm;
        }
 
                (*derivedFinal) = dm;
        }
 
index d877932b81de9fb34b27a44aa1862f0bc722b64a..e37fc56d08c757888d2ce0992caaccdde32622fe 100644 (file)
@@ -49,7 +49,7 @@
 #include "DNA_object_types.h"
 
 
 #include "DNA_object_types.h"
 
 
-static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Object *UNUSED(ob))
+static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd)
 {
        DerivedMesh *result;
        BMesh *bm;
 {
        DerivedMesh *result;
        BMesh *bm;
@@ -97,7 +97,8 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj
 
        result = CDDM_from_bmesh(bm, TRUE);
        BM_mesh_free(bm);
 
        result = CDDM_from_bmesh(bm, TRUE);
        BM_mesh_free(bm);
-       
+
+       result->dirty |= DM_DIRTY_NORMALS;
        return result;
 }
 
        return result;
 }
 
@@ -119,25 +120,16 @@ static void copyData(ModifierData *md, ModifierData *target)
        temd->flags = emd->flags;
 }
 
        temd->flags = emd->flags;
 }
 
-static DerivedMesh *edgesplitModifier_do(EdgeSplitModifierData *emd,
-                                         Object *ob, DerivedMesh *dm)
-{
-       if (!(emd->flags & (MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG)))
-               return dm;
-
-       return doEdgeSplit(dm, emd, ob);
-}
-
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData,
+static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), DerivedMesh *dm,
                                   ModifierApplyFlag UNUSED(flag))
 {
        DerivedMesh *result;
        EdgeSplitModifierData *emd = (EdgeSplitModifierData *) md;
 
                                   ModifierApplyFlag UNUSED(flag))
 {
        DerivedMesh *result;
        EdgeSplitModifierData *emd = (EdgeSplitModifierData *) md;
 
-       result = edgesplitModifier_do(emd, ob, derivedData);
+       if (!(emd->flags & (MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG)))
+               return dm;
 
 
-       if (result != derivedData)
-               result->dirty |= DM_DIRTY_NORMALS;
+       result = doEdgeSplit(dm, emd);
 
        return result;
 }
 
        return result;
 }