Merged changes in the trunk up to revision 55357.
[blender.git] / source / blender / blenkernel / intern / subsurf_ccg.c
index d38a2e5..3d633dc 100644 (file)
@@ -1015,7 +1015,7 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf)
        }
        else {
                mf->flag = ME_SMOOTH;
-       }
+}
 
        mf->edcode = 0;
 }
@@ -3108,6 +3108,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
        MEdge *medge = NULL;
        /* MFace *mface = NULL; */
        MPoly *mpoly = NULL;
+#ifdef WITH_FREESTYLE
+       FreestyleEdge *fed = NULL, *ccgdm_fed = NULL;
+       FreestyleFace *ffa = NULL, *ccgdm_ffa = NULL;
+#endif
 
        DM_from_template(&ccgdm->dm, dm, DM_TYPE_CCGDM,
                         ccgSubSurf_getNumFinalVerts(ss),
@@ -3282,6 +3286,18 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
 
        has_edge_origindex = CustomData_has_layer(&ccgdm->dm.edgeData, CD_ORIGINDEX);
 
+#ifdef WITH_FREESTYLE
+       fed = DM_get_edge_data_layer(dm, CD_FREESTYLE_EDGE);
+       if (fed) {
+               ccgdm_fed = CustomData_add_layer(&ccgdm->dm.edgeData, CD_FREESTYLE_EDGE, CD_CALLOC, NULL,
+                                                ccgSubSurf_getNumFinalEdges(ss));
+       }
+       ffa = DM_get_poly_data_layer(dm, CD_FREESTYLE_FACE);
+       if (ffa) {
+               ccgdm_ffa = CustomData_add_layer(&ccgdm->dm.faceData, CD_FREESTYLE_FACE, CD_CALLOC, NULL,
+                                                ccgSubSurf_getNumFinalFaces(ss));
+       }
+#endif
 
        loopindex = loopindex2 = 0; /* current loop index */
        for (index = 0; index < totface; index++) {
@@ -3419,6 +3435,12 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
                                        /* This is a simple one to one mapping, here... */
                                        polyidx[faceNum] = faceNum;
 
+#ifdef WITH_FREESTYLE
+                                       if (ffa && ffa[index].flag & FREESTYLE_FACE_MARK) {
+                                               ccgdm_ffa[faceNum].flag |= FREESTYLE_FACE_MARK;
+                                       }
+#endif
+
                                        faceNum++;
                                }
                        }
@@ -3468,6 +3490,14 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
                        }
                }
 
+#ifdef WITH_FREESTYLE
+               if (fed && fed[index].flag & FREESTYLE_EDGE_MARK) {
+                       for (i = 0; i < numFinalEdges; ++i) {
+                               ccgdm_fed[edgeNum + i].flag |= FREESTYLE_EDGE_MARK;
+                       }
+               }
+#endif
+
                edgeNum += numFinalEdges;
        }