NLA SoC: Start of 'Meta' Strips
[blender.git] / source / blender / blenkernel / intern / subsurf_ccg.c
index f5124ed90562267cef6377053bd020b8ed022530..15969fc9ab91b810b26735afb4f743a861e46018 100644 (file)
@@ -48,6 +48,7 @@
 #include "BKE_utildefines.h"
 #include "BKE_global.h"
 #include "BKE_mesh.h"
+#include "BKE_multires.h"
 #include "BKE_scene.h"
 #include "BKE_subsurf.h"
 
@@ -471,7 +472,7 @@ static void calc_ss_weights(int gridFaces,
 
 static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh,
                                  int drawInteriorEdges, int useSubsurfUv,
-                                 DerivedMesh *dm)
+                                 DerivedMesh *dm, MultiresSubsurf *ms)
 {
        DerivedMesh *result;
        int edgeSize = ccgSubSurf_getEdgeSize(ss);
@@ -524,14 +525,21 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh,
        }
        ccgFaceIterator_free(fi);
 
-       if(dm) {
-               result = CDDM_from_template(dm, ccgSubSurf_getNumFinalVerts(ss),
-                                           ccgSubSurf_getNumFinalEdges(ss),
-                                           ccgSubSurf_getNumFinalFaces(ss));
-       } else {
-               result = CDDM_new(ccgSubSurf_getNumFinalVerts(ss),
-                                 ccgSubSurf_getNumFinalEdges(ss),
-                                 ccgSubSurf_getNumFinalFaces(ss));
+       if(ms) {
+               result = MultiresDM_new(ms, dm, ccgSubSurf_getNumFinalVerts(ss),
+                                       ccgSubSurf_getNumFinalEdges(ss),
+                                       ccgSubSurf_getNumFinalFaces(ss));
+       }
+       else {
+               if(dm) {
+                       result = CDDM_from_template(dm, ccgSubSurf_getNumFinalVerts(ss),
+                                                   ccgSubSurf_getNumFinalEdges(ss),
+                                                   ccgSubSurf_getNumFinalFaces(ss));
+               } else {
+                       result = CDDM_new(ccgSubSurf_getNumFinalVerts(ss),
+                                         ccgSubSurf_getNumFinalEdges(ss),
+                                         ccgSubSurf_getNumFinalFaces(ss));
+               }
        }
 
        // load verts
@@ -557,11 +565,12 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh,
                ++mvert;
                ++origIndex;
                i++;
-               
+
                for(S = 0; S < numVerts; S++) {
                        int prevS = (S - 1 + numVerts) % numVerts;
                        int nextS = (S + 1) % numVerts;
                        int otherS = (numVerts == 4) ? (S + 2) % numVerts : 3;
+
                        for(x = 1; x < gridFaces; x++) {
                                float w[4];
                                w[prevS]  = weight[x][0][0];
@@ -571,6 +580,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh,
                                DM_interp_vert_data(dm, result, vertIdx, w, numVerts, i);
                                VecCopyf(mvert->co,
                                         ccgSubSurf_getFaceGridEdgeData(ss, f, S, x));
+
                                *origIndex = ORIGINDEX_NONE;
                                ++mvert;
                                ++origIndex;
@@ -582,6 +592,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh,
                        int prevS = (S - 1 + numVerts) % numVerts;
                        int nextS = (S + 1) % numVerts;
                        int otherS = (numVerts == 4) ? (S + 2) % numVerts : 3;
+
                        for(y = 1; y < gridFaces; y++) {
                                for(x = 1; x < gridFaces; x++) {
                                        float w[4];
@@ -2097,7 +2108,7 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *u
                        if (draw) {
                                if (draw==2) {
                                        glEnable(GL_POLYGON_STIPPLE);
-                                       glPolygonStipple(0); //XXX stipple_quarttone);
+                                       glPolygonStipple(stipple_quarttone);
                                }
                                
                                for (S=0; S<numVerts; S++) {
@@ -2565,9 +2576,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
 
 /***/
 
-struct DerivedMesh *subsurf_make_derived_from_derived(
+struct DerivedMesh *subsurf_make_derived_from_derived_with_multires(
                         struct DerivedMesh *dm,
                         struct SubsurfModifierData *smd,
+                       struct MultiresSubsurf *ms,
                         int useRenderParams, float (*vertCos)[3],
                         int isFinalCalc, int editMode)
 {
@@ -2590,7 +2602,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
                CCGSubSurf *ss;
                int levels;
                
-               levels= get_render_subsurf_level(&G.scene->r, smd->renderLevels);
+               levels= smd->renderLevels; // XXX get_render_subsurf_level(&scene->r, smd->renderLevels);
                if(levels == 0)
                        return dm;
                
@@ -2599,7 +2611,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
                ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple);
 
                result = ss_to_cdderivedmesh(ss, 0, drawInteriorEdges,
-                                            useSubsurfUv, dm);
+                                            useSubsurfUv, dm, ms);
 
                ccgSubSurf_free(ss);
                
@@ -2630,7 +2642,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
 
 
                        return ss_to_cdderivedmesh(ss, 0, drawInteriorEdges,
-                                              useSubsurfUv, dm);
+                                                  useSubsurfUv, dm, ms);
 
                        /*return (DerivedMesh *)getCCGDerivedMesh(smd->mCache,
                                                        drawInteriorEdges,
@@ -2650,7 +2662,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
                                                    useSubsurfUv, dm);*/
 
                        result = ss_to_cdderivedmesh(ss, 0, drawInteriorEdges,
-                                                    useSubsurfUv, dm);
+                                                    useSubsurfUv, dm, ms);
 
                        ccgSubSurf_free(ss);
 
@@ -2659,6 +2671,15 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
        }
 }
 
+struct DerivedMesh *subsurf_make_derived_from_derived(
+                        struct DerivedMesh *dm,
+                        struct SubsurfModifierData *smd,
+                        int useRenderParams, float (*vertCos)[3],
+                        int isFinalCalc, int editMode)
+{
+       return subsurf_make_derived_from_derived_with_multires(dm, smd, NULL, useRenderParams, vertCos, isFinalCalc, editMode);
+}
+
 void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]) 
 {
        /* Finds the subsurf limit positions for the verts in a mesh