Revision: 29536
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29536
Author:   nicholasbishop
Date:     2010-06-18 05:28:27 +0200 (Fri, 18 Jun 2010)

Log Message:
-----------
* Changed gridkey to be a struct rather than an int. Has fields for the total 
number of each type it contains (types currently being coords, masks, normals.)
* This is a step towards having multiple layers of coords or masks.
* Should be no visible change in behavior from this commit.

Modified Paths:
--------------
    branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_subsurf.h
    
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/CCGSubSurf.c
    
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/CCGSubSurf.h
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/multires.c
    
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h
    branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2010-nicolasbishop/source/blender/gpu/gpu_buffers.h
    branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c

Modified: 
branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py  
2010-06-18 03:12:35 UTC (rev 29535)
+++ branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py  
2010-06-18 03:28:27 UTC (rev 29536)
@@ -503,7 +503,6 @@
         row.operator("paint.mask_set", text="Clear").mode = 'CLEAR'
         row.operator("paint.mask_set", text="Fill").mode = 'FILL'
         row.operator("paint.mask_set", text="Invert").mode = 'INVERT'
-        row.operator("paint.mask_set", text="Random").mode = 'RANDOM'
 
 
 class VIEW3D_PT_tools_brush(PaintPanel):

Modified: 
branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h 
2010-06-18 03:12:35 UTC (rev 29535)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h 
2010-06-18 03:28:27 UTC (rev 29536)
@@ -69,6 +69,7 @@
 #define SUB_ELEMS_FACE 4
 
 typedef struct DMGridData DMGridData;
+typedef struct GridKey GridKey;
 
 typedef struct DMGridAdjacency {
        int index[4];
@@ -155,7 +156,7 @@
        DMGridData **(*getGridData)(DerivedMesh *dm);
        DMGridAdjacency *(*getGridAdjacency)(DerivedMesh *dm);
        int *(*getGridOffset)(DerivedMesh *dm);
-       int (*getGridKey)(DerivedMesh *dm);
+       struct GridKey *(*getGridKey)(DerivedMesh *dm);
 
        /* Iterate over each mapped vertex in the derived mesh, calling the
         * given function with the original vert and the mapped vert's new

Modified: 
branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_subsurf.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_subsurf.h     
2010-06-18 03:12:35 UTC (rev 29535)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_subsurf.h     
2010-06-18 03:28:27 UTC (rev 29536)
@@ -48,29 +48,25 @@
 
 /* Grids */
 
-/* Format of the data in a grid element */
-typedef enum {
-       GRID_ELEM_KEY_CO_NO = 0,
-       GRID_ELEM_KEY_CO_MASK_NO,
-       GRID_ELEM_KEY_TOTAL
-} DMGridElemKey;
+/* Each grid element can contain zero or more layers of coordinates,
+   paint masks, and normals; these numbers are stored in the GridKey
 
-/* Information about the data stored by each type of key */
-typedef struct {
-       int size;
-       int has_mask;
-       int no_offset;
-       int mask_offset;
-       int interp_count;
-} DMGridElemKeyInfo;
+   For now, co and no can have only zero or one layers, only mask is
+   really variable.
+*/
+struct GridKey {
+       int co;
+       int mask;
+       int no;
+};
 
-extern DMGridElemKeyInfo GridElemKeyInfo[GRID_ELEM_KEY_TOTAL];
+#define GRIDELEM_KEY_INIT(_gridkey, _totco, _totmask, _totno)  \
+       (_gridkey->co = _totco, _gridkey->mask = _totmask, _gridkey->no = 
_totno)
 
-#define GRIDELEM_SIZE(_key) GridElemKeyInfo[_key].size
-#define GRIDELEM_HAS_MASK(_key) GridElemKeyInfo[_key].has_mask
-#define GRIDELEM_NO_OFFSET(_key) GridElemKeyInfo[_key].no_offset
-#define GRIDELEM_MASK_OFFSET(_key) GridElemKeyInfo[_key].mask_offset
-#define GRIDELEM_INTERP_COUNT(_key) GridElemKeyInfo[_key].interp_count
+#define GRIDELEM_SIZE(_key) ((3*_key->co + _key->mask + 3*_key->no) * 
sizeof(float))
+#define GRIDELEM_MASK_OFFSET(_key) (_key->mask ? 3*_key->co*sizeof(float) : -1)
+#define GRIDELEM_NO_OFFSET(_key) (_key->no ? (3*_key->co + _key->mask) * 
sizeof(float) : -1)
+#define GRIDELEM_INTERP_COUNT(_key) (3*_key->co + _key->mask)
 
 #define GRIDELEM_AT(_grid, _elem, _key) (struct DMGridData*)(((char*)(_grid)) 
+ (_elem) * GRIDELEM_SIZE(_key))
 #define GRIDELEM_INC(_grid, _inc, _key) ((_grid) = GRIDELEM_AT(_grid, _inc, 
_key))

Modified: 
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/CCGSubSurf.c
===================================================================
--- 
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/CCGSubSurf.c   
    2010-06-18 03:12:35 UTC (rev 29535)
+++ 
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/CCGSubSurf.c   
    2010-06-18 03:28:27 UTC (rev 29536)
@@ -749,6 +749,8 @@
        _ehash_free(ss->eMap, (EHEntryFreeFP) _edge_free, ss);
        _ehash_free(ss->vMap, (EHEntryFreeFP) _vert_free, ss);
 
+       MEM_freeN(ss->meshIFC.gridkey);
+
        CCGSUBSURF_free(ss, ss);
 
        if (allocatorIFC.release) {
@@ -2555,7 +2557,7 @@
        }
 }
 
-int ccgSubSurf_getGridKey(CCGSubSurf *ss) {
+struct GridKey *ccgSubSurf_getGridKey(CCGSubSurf *ss) {
        return ss->meshIFC.gridkey;
 }
 

Modified: 
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/CCGSubSurf.h
===================================================================
--- 
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/CCGSubSurf.h   
    2010-06-18 03:12:35 UTC (rev 29535)
+++ 
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/CCGSubSurf.h   
    2010-06-18 03:28:27 UTC (rev 29536)
@@ -19,7 +19,7 @@
           that would be (3+1) floats, so finterpCount would be 4. */
        int                     finterpCount;
 
-       int                     gridkey;
+       struct GridKey*         gridkey;
 };
 
 /***/
@@ -92,7 +92,7 @@
 int                    ccgSubSurf_getEdgeLevelSize                     
(CCGSubSurf *ss, int level);
 int                    ccgSubSurf_getGridSize                          
(CCGSubSurf *ss);
 int                    ccgSubSurf_getGridLevelSize                     
(CCGSubSurf *ss, int level);
-int                    ccgSubSurf_getGridKey                           
(CCGSubSurf *ss);
+struct GridKey*                ccgSubSurf_getGridKey                           
(CCGSubSurf *ss);
 
 CCGVert*       ccgSubSurf_getVert                                      
(CCGSubSurf *ss, CCGVertHDL v);
 CCGVertHDL     ccgSubSurf_getVertVertHandle            (CCGVert *v);

Modified: 
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/multires.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/multires.c 
2010-06-18 03:12:35 UTC (rev 29535)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/multires.c 
2010-06-18 03:28:27 UTC (rev 29536)
@@ -359,7 +359,7 @@
        }
 }
 
-static void multires_copy_dm_grid(DMGridData *gridA, DMGridData *gridB, int 
gridkey, int sizeA, int sizeB)
+static void multires_copy_dm_grid(DMGridData *gridA, DMGridData *gridB, 
GridKey *gridkey, int sizeA, int sizeB)
 {
        int x, y, j, skip;
        int size = sizeof(float)*GRIDELEM_INTERP_COUNT(gridkey);
@@ -462,7 +462,7 @@
        return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0);
 }
 
-static DMGridData **copy_grids(DMGridData **grids, int totgrid, int gridsize, 
int gridkey)
+static DMGridData **copy_grids(DMGridData **grids, int totgrid, int gridsize, 
GridKey *gridkey)
 {
        DMGridData **grids_copy = MEM_callocN(sizeof(DMGridData*) * totgrid, 
"subgrids");
        int i;
@@ -496,7 +496,8 @@
                DerivedMesh *lowdm, *cddm, *highdm;
                DMGridData **highGridData, **lowGridData, **subGridData;
                CCGSubSurf *ss;
-               int i, numGrids, highGridSize, lowGridSize, gridkey;
+               int i, numGrids, highGridSize, lowGridSize;
+               GridKey *gridkey;
 
                /* create subsurf DM from original mesh at high level */
                cddm = CDDM_from_mesh(me, NULL);
@@ -549,7 +550,7 @@
        multires_set_tot_level(ob, mmd, totlvl);
 }
 
-static void grid_tangent(int gridSize, int index, int x, int y, int axis, 
DMGridData **gridData, int gridkey, float t[3])
+static void grid_tangent(int gridSize, int index, int x, int y, int axis, 
DMGridData **gridData, GridKey *gridkey, float t[3])
 {
        DMGridData *grid = gridData[index];
 
@@ -601,7 +602,8 @@
        MFace *mface = me->mface;
        MDisps *mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS);
        CustomData *stored_grids;
-       int *gridOffset, gridkey;
+       int *gridOffset;
+       GridKey *gridkey;
        int i, numGrids, gridSize, dGridSize, dSkip;
 
        if(!mdisps) {
@@ -757,7 +759,8 @@
                        DerivedMesh *lowdm, *cddm, *highdm;
                        DMGridData **highGridData, **lowGridData, 
**subGridData, **gridData, *diffGrid;
                        CCGSubSurf *ss;
-                       int i, j, numGrids, highGridSize, lowGridSize, gridkey;
+                       int i, j, numGrids, highGridSize, lowGridSize;
+                       GridKey *gridkey;
 
                        /* create subsurf DM from original mesh at high level */
                        if (ob->derivedDeform) cddm = 
CDDM_copy(ob->derivedDeform);
@@ -855,7 +858,8 @@
        CCGDerivedMesh *ccgdm;
        DMGridData **gridData, **subGridData;
        int lvl= multires_get_level(ob, mmd, useRenderParams);
-       int i, gridSize, numGrids, gridkey;
+       int i, gridSize, numGrids;
+       GridKey *gridkey;
 
        if(lvl == 0)
                return dm;

Modified: 
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- 
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c  
    2010-06-18 03:12:35 UTC (rev 29535)
+++ 
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c  
    2010-06-18 03:28:27 UTC (rev 29536)
@@ -65,13 +65,6 @@
 
 #include "CCGSubSurf.h"
 
-/* Declared extern in BKE_subsurf.h */
-DMGridElemKeyInfo GridElemKeyInfo[GRID_ELEM_KEY_TOTAL] = {
-       /*size,            has_mask,  no_offset,        mask_offset,      
interp_count */
-       {sizeof(float)*6,  0,         sizeof(float)*3,  -1,               3     
       },
-       {sizeof(float)*7,  1,         sizeof(float)*4,  sizeof(float)*3,  4     
       }
-};
-
 static int ccgDM_getVertMapIndex(CCGSubSurf *ss, CCGVert *v);
 static int ccgDM_getEdgeMapIndex(CCGSubSurf *ss, CCGEdge *e);
 static int ccgDM_getFaceMapIndex(CCGSubSurf *ss, CCGFace *f);
@@ -94,7 +87,7 @@
        BLI_memarena_free(a);
 }
 
-static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int gridkey, int 
subdivLevels, int useAging, int useArena, int useFlatSubdiv) {
+static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, GridKey *gridkey, int 
subdivLevels, int useAging, int useArena, int useFlatSubdiv) {
        CCGMeshIFC ifc;
        CCGSubSurf *ccgSS;
 
@@ -323,11 +316,14 @@
        int index, gridSize, gridFaces, edgeSize, totface, x, y, S;
        MTFace *dmtface = CustomData_get_layer_n(&dm->faceData, CD_MTFACE, n);
        MTFace *tface = CustomData_get_layer_n(&result->faceData, CD_MTFACE, n);
-       int gridkey = GRID_ELEM_KEY_CO_NO; /* TODO */
+       GridKey *gridkey;
 
        if(!dmtface || !tface)
                return;
 
+       gridkey = MEM_callocN(sizeof(GridKey), "Subsurf UV GridKey");
+       GRIDELEM_KEY_INIT(gridkey, 1, 0, 0); /* TODO */
+
        /* create a CCGSubSurf from uv's */
        uvss = _getSubSurf(NULL, gridkey, ccgSubSurf_getSubdivisionLevels(ss), 
0, 1, 0);
 
@@ -536,7 +532,7 @@
        CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);
        int i, edgeSize = ccgSubSurf_getEdgeSize(ss);
        int gridSize = ccgSubSurf_getGridSize(ss);
-       int gridkey = ccgSubSurf_getGridKey(ss);

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to