Add DerivedMesh.gridHidden and CCGDM implementation.
authorNicholas Bishop <nicholasbishop@gmail.com>
Wed, 14 Mar 2012 06:31:49 +0000 (06:31 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Wed, 14 Mar 2012 06:31:49 +0000 (06:31 +0000)
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/BKE_subsurf.h
source/blender/blenkernel/intern/subsurf_ccg.c

index b8cedfb5708c7874ac1507eb8d932e049f48410a..0416e217168173911b5023385245722869a4ba4d 100644 (file)
@@ -248,6 +248,7 @@ struct DerivedMesh {
        DMGridAdjacency *(*getGridAdjacency)(DerivedMesh *dm);
        int *(*getGridOffset)(DerivedMesh *dm);
        DMFlagMat *(*getGridFlagMats)(DerivedMesh *dm);
+       unsigned int **(*getGridHidden)(DerivedMesh *dm);
        
 
        /* Iterate over each mapped vertex in the derived mesh, calling the
index bc333f8fd665d9193b2550540c509ce977a6877b..4b80e2ec9df133d2291c9e9c409e43ddfb4019a6 100644 (file)
@@ -102,6 +102,7 @@ typedef struct CCGDerivedMesh {
        int *gridOffset;
        struct CCGFace **gridFaces;
        struct DMFlagMat *gridFlagMats;
+       unsigned int **gridHidden;
 
        struct {
                struct MultiresModifierData *mmd;
index 401f678344b64abda6510405da267c2ceb47160e..ba7394c9e915d5eb1400fd55aea09f215f57f905 100644 (file)
@@ -45,6 +45,7 @@
 #include "DNA_scene_types.h"
 
 #include "BLI_utildefines.h"
+#include "BLI_bitmap.h"
 #include "BLI_blenlib.h"
 #include "BLI_edgehash.h"
 #include "BLI_math.h"
@@ -2357,6 +2358,14 @@ static void ccgDM_release(DerivedMesh *dm)
                if(ccgdm->gridAdjacency) MEM_freeN(ccgdm->gridAdjacency);
                if(ccgdm->gridOffset) MEM_freeN(ccgdm->gridOffset);
                if(ccgdm->gridFlagMats) MEM_freeN(ccgdm->gridFlagMats);
+               if(ccgdm->gridHidden) {
+                       int i, numGrids = dm->getNumGrids(dm);
+                       for(i = 0; i < numGrids; i++) {
+                               if(ccgdm->gridHidden[i])
+                                       MEM_freeN(ccgdm->gridHidden[i]);
+                       }
+                       MEM_freeN(ccgdm->gridHidden);
+               }
                if(ccgdm->freeSS) ccgSubSurf_free(ccgdm->ss);
                if(ccgdm->fmap) MEM_freeN(ccgdm->fmap);
                if(ccgdm->fmap_mem) MEM_freeN(ccgdm->fmap_mem);
@@ -2663,6 +2672,8 @@ static void ccgdm_create_grids(DerivedMesh *dm)
        gridFaces = MEM_mallocN(sizeof(CCGFace*)*numGrids, "ccgdm.gridFaces");
        gridFlagMats = MEM_mallocN(sizeof(DMFlagMat)*numGrids, "ccgdm.gridFlagMats");
 
+       ccgdm->gridHidden = MEM_callocN(sizeof(BLI_bitmap)*numGrids, "ccgdm.gridHidden");
+
        for(gIndex = 0, index = 0; index < numFaces; index++) {
                CCGFace *f = ccgdm->faceMap[index].face;
                int numVerts = ccgSubSurf_getFaceNumVerts(f);
@@ -2727,6 +2738,14 @@ static DMFlagMat *ccgDM_getGridFlagMats(DerivedMesh *dm)
        return ccgdm->gridFlagMats;
 }
 
+static BLI_bitmap *ccgDM_getGridHidden(DerivedMesh *dm)
+{
+       CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
+       
+       ccgdm_create_grids(dm);
+       return ccgdm->gridHidden;
+}
+
 static ListBase *ccgDM_getPolyMap(Object *ob, DerivedMesh *dm)
 {
        CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
@@ -2909,6 +2928,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
        ccgdm->dm.getGridAdjacency = ccgDM_getGridAdjacency;
        ccgdm->dm.getGridOffset = ccgDM_getGridOffset;
        ccgdm->dm.getGridFlagMats = ccgDM_getGridFlagMats;
+       ccgdm->dm.getGridHidden = ccgDM_getGridHidden;
        ccgdm->dm.getPolyMap = ccgDM_getPolyMap;
        ccgdm->dm.getPBVH = ccgDM_getPBVH;