Revision: 37132
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37132
Author:   jwilkins
Date:     2011-06-03 15:22:54 +0000 (Fri, 03 Jun 2011)
Log Message:
-----------
Revision: 29277
Author: nicholasbishop
Date: 12:03:06 PM, Sunday, June 06, 2010
Message:
* PBVH can now iterate over mask data coming from a mesh (not multires yet)
* The paint_mask_set operator can be used to create a mask layer and fill it 
with zeroes, ones, or random data (for testing)
* gpu_buffers will display the mask layer (again, only for regular meshes not 
multires grids yet.)

** jwilkins:
** note: first masking update that actually does something visible
** note: only works for mesh (not multires) and with VBO enabled

Modified Paths:
--------------
    branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h
    branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
    branches/soc-2011-onion/source/blender/gpu/GPU_buffers.h
    branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.c

Property Changed:
----------------
    branches/soc-2011-onion/


Property changes on: branches/soc-2011-onion
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29265,29324,29350
/trunk/blender:36833-37054
   + /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29265,29277,29324,29350
/trunk/blender:36833-37054

Modified: 
branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c    
2011-06-03 15:15:14 UTC (rev 37131)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c    
2011-06-03 15:22:54 UTC (rev 37132)
@@ -236,7 +236,7 @@
                cddm->pbvh = BLI_pbvh_new();
                cddm->pbvh_draw = can_pbvh_draw(ob, dm);
                BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert,
-                                  me->totface, me->totvert);
+                                   &me->vdata, me->totface, me->totvert);
 
                if(ss->modifiers_active && ob->derivedDeform) {
                        DerivedMesh *deformdm= ob->derivedDeform;

Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c      
2011-06-03 15:15:14 UTC (rev 37131)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c      
2011-06-03 15:22:54 UTC (rev 37132)
@@ -2310,7 +2310,7 @@
                Mesh *me= ob->data;
                ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
                BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert,
-                                  me->totface, me->totvert);
+                                   &me->vdata, me->totface, me->totvert);
        }
 
        return ccgdm->pbvh;

Modified: branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h   2011-06-03 
15:15:14 UTC (rev 37131)
+++ branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h   2011-06-03 
15:22:54 UTC (rev 37132)
@@ -28,6 +28,7 @@
  *  \brief A BVH for high poly meshes.
  */
 
+struct CustomData;
 struct MFace;
 struct MVert;
 struct DMGridAdjacency;
@@ -55,7 +56,7 @@
 
 PBVH *BLI_pbvh_new(void);
 void BLI_pbvh_build_mesh(PBVH *bvh, struct MFace *faces, struct MVert *verts,
-                       int totface, int totvert);
+                        struct CustomData *vdata, int totface, int totvert);
 void BLI_pbvh_build_grids(PBVH *bvh, struct DMGridData **grids,
        struct DMGridAdjacency *gridadj, int totgrid,
        int gridsize, void **gridfaces);
@@ -109,7 +110,7 @@
 void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node,
        int *uniquevert, int *totvert);
 void BLI_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node,
-       int **vert_indices, struct MVert **verts);
+                            int **vert_indices, struct MVert **verts, struct 
CustomData **vdata);
 
 void BLI_pbvh_node_get_BB(PBVHNode *node, float bb_min[3], float bb_max[3]);
 void BLI_pbvh_node_get_original_BB(PBVHNode *node, float bb_min[3], float 
bb_max[3]);
@@ -158,15 +159,20 @@
 
        /* mesh */
        struct MVert *mverts;
+       struct CustomData *vdata;
        int totvert;
        int *vert_indices;
 
+       /* mask */
+       float *vdata_mask;
+
        /* result: these are all computed in the macro, but we assume
           that compiler optimizations will skip the ones we don't use */
        struct MVert *mvert;
        float *co;
        short *no;
        float *fno;
+       float *mask;
 } PBVHVertexIter;
 
 #ifdef _MSC_VER
@@ -177,17 +183,14 @@
        { \
                struct DMGridData **grids; \
                struct MVert *verts; \
+               struct CustomData *vdata; \
                int *grid_indices, totgrid, gridsize, *vert_indices, 
uniq_verts, totvert; \
                \
-               vi.grid= 0; \
-               vi.no= 0; \
-               vi.fno= 0; \
-               vi.mvert= 0; \
-               vi.skip= 0; \
+               memset(&vi, 0, sizeof(PBVHVertexIter)); \
                \
                BLI_pbvh_node_get_grids(bvh, node, &grid_indices, &totgrid, 
NULL, &gridsize, &grids, NULL); \
                BLI_pbvh_node_num_verts(bvh, node, &uniq_verts, &totvert); \
-               BLI_pbvh_node_get_verts(bvh, node, &vert_indices, &verts); \
+               BLI_pbvh_node_get_verts(bvh, node, &vert_indices, &verts, 
&vdata); \
                \
                vi.grids= grids; \
                vi.grid_indices= grid_indices; \
@@ -200,6 +203,9 @@
                        vi.totvert= uniq_verts; \
                vi.vert_indices= vert_indices; \
                vi.mverts= verts; \
+               vi.vdata= vdata; \
+               if(vi.vdata) \
+                       vi.vdata_mask= CustomData_get_layer(vi.vdata, 
CD_PAINTMASK); \
        }\
        \
        for(vi.i=0, vi.g=0; vi.g<vi.totgrid; vi.g++) { \
@@ -233,6 +239,8 @@
                                        vi.mvert= 
&vi.mverts[vi.vert_indices[vi.gx]]; \
                                        vi.co= vi.mvert->co; \
                                        vi.no= vi.mvert->no; \
+                                       if(vi.vdata_mask) \
+                                               vi.mask= 
&vi.vdata_mask[vi.vert_indices[vi.gx]]; \
                                } \
 
 #define BLI_pbvh_vertex_iter_end \

Modified: branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c        
2011-06-03 15:15:14 UTC (rev 37131)
+++ branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c        
2011-06-03 15:22:54 UTC (rev 37132)
@@ -122,6 +122,7 @@
        /* Mesh data */
        MVert *verts;
        MFace *faces;
+       CustomData *vdata;
 
        /* Grid Data */
        DMGridData **grids;
@@ -380,6 +381,7 @@
        if(!G.background) {
                node->draw_buffers =
                        GPU_build_mesh_buffers(map, bvh->verts, bvh->faces,
+                                       bvh->vdata,
                                        node->prim_indices,
                                        node->totprim, node->vert_indices,
                                        node->uniq_verts,
@@ -506,7 +508,7 @@
 }
 
 /* Do a full rebuild with on Mesh data structure */
-void BLI_pbvh_build_mesh(PBVH *bvh, MFace *faces, MVert *verts, int totface, 
int totvert)
+void BLI_pbvh_build_mesh(PBVH *bvh, MFace *faces, MVert *verts, CustomData 
*vdata, int totface, int totvert)
 {
        BBC *prim_bbc = NULL;
        BB cb;
@@ -514,6 +516,7 @@
 
        bvh->faces = faces;
        bvh->verts = verts;
+       bvh->vdata = vdata;
        bvh->vert_bitmap = BLI_bitmap_new(totvert);
        bvh->totvert = totvert;
        bvh->leaf_limit = LEAF_LIMIT;
@@ -1042,6 +1045,7 @@
                        else {
                                GPU_update_mesh_buffers(node->draw_buffers,
                                                   bvh->verts,
+                                                  bvh->vdata,
                                                   node->vert_indices,
                                                   node->uniq_verts +
                                                   node->face_verts);
@@ -1182,10 +1186,11 @@
        node->flag |= 
PBVH_UpdateNormals|PBVH_UpdateBB|PBVH_UpdateOriginalBB|PBVH_UpdateDrawBuffers|PBVH_UpdateRedraw;
 }
 
-void BLI_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node, int **vert_indices, 
MVert **verts)
+void BLI_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node, int **vert_indices, 
MVert **verts, CustomData **vdata)
 {
        if(vert_indices) *vert_indices= node->vert_indices;
        if(verts) *verts= bvh->verts;
+       if(vdata) *vdata= bvh->vdata;
 }
 
 void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, int *uniquevert, int 
*totvert)

Modified: 
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c    
2011-06-03 15:15:14 UTC (rev 37131)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c    
2011-06-03 15:22:54 UTC (rev 37132)
@@ -60,7 +60,8 @@
                        PBVHVertexIter vd;
 
                        BLI_pbvh_vertex_iter_begin(pbvh, nodes[n], vd, 
PBVH_ITER_UNIQUE) {
-                               /* *vd.mask = get_mask_value(mode) */
+                               if(vd.mask)
+                                       *vd.mask = get_mask_value(mode);
                        }
                        BLI_pbvh_vertex_iter_end;
 
@@ -68,8 +69,7 @@
                }
 
                BLI_pbvh_update(pbvh, 
PBVH_UpdateBB|PBVH_UpdateOriginalBB|PBVH_UpdateRedraw, NULL);
-               //WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
-               //ED_region_tag_redraw(CTX_wm_region(C));
+               WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
        }
        
        return OPERATOR_FINISHED;
@@ -102,7 +102,8 @@
        ot->poll= mask_poll;
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       /* XXX: seems there is no need to register and undo will be handled by 
the operator itself */
+       ot->flag= 0;//OPTYPE_REGISTER|OPTYPE_UNDO;
 
        /* properties */
        RNA_def_enum(ot->srna, "mode", mask_items, MASKING_CLEAR, "Mode", "");

Modified: branches/soc-2011-onion/source/blender/gpu/GPU_buffers.h
===================================================================
--- branches/soc-2011-onion/source/blender/gpu/GPU_buffers.h    2011-06-03 
15:15:14 UTC (rev 37131)
+++ branches/soc-2011-onion/source/blender/gpu/GPU_buffers.h    2011-06-03 
15:22:54 UTC (rev 37132)
@@ -140,11 +140,11 @@
 
 /* Buffers for non-DerivedMesh drawing */
 void *GPU_build_mesh_buffers(struct GHash *map, struct MVert *mvert,
-                       struct MFace *mface, int *face_indices,
+                       struct MFace *mface, CustomData *vdata, int 
*face_indices,
                        int totface, int *vert_indices, int uniq_verts,
                        int totvert);
 void GPU_update_mesh_buffers(void *buffers, struct MVert *mvert,
-                       int *vert_indices, int totvert);
+                       struct CustomData *vdata, int *vert_indices, int 
totvert);
 void *GPU_build_grid_buffers(struct DMGridData **grids,
        int *grid_indices, int totgrid, int gridsize);
 void GPU_update_grid_buffers(void *buffers_v, struct DMGridData **grids,

Modified: branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.c
===================================================================
--- branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.c     
2011-06-03 15:15:14 UTC (rev 37131)
+++ branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.c     
2011-06-03 15:22:54 UTC (rev 37132)
@@ -449,7 +449,7 @@
 
 /* For now this looks for just a single mask layer, eventually might include
    other color layers like vertex colors or weights */
-static void update_mesh_color_buffers(GPU_Buffers *buffers, CustomData 
*vert_customdata, int totvert)
+static void update_mesh_color_buffers(GPU_Buffers *buffers, CustomData *vdata, 
int totvert)
 {
        unsigned char *color_data = NULL;
        int i;
@@ -457,7 +457,7 @@
 
        /* Make a color buffer if there's a mask layer and
           get rid of any color buffer if there's no mask layer */
-       pmask = CustomData_get_layer(vert_customdata, CD_PAINTMASK);
+       pmask = CustomData_get_layer(vdata, CD_PAINTMASK);
        if(pmask && !buffers->color_buf)
                glGenBuffersARB(1, &buffers->color_buf);
        else if(!pmask && buffers->color_buf)
@@ -480,7 +480,7 @@
 }
 
 void GPU_update_mesh_buffers(void *buffers_v, MVert *mvert,
-                       int *vert_indices, int totvert)
+                            CustomData *vdata, int *vert_indices, int totvert)
 {
        GPU_Buffers *buffers = buffers_v;
        VertexBufferFormat *vert_data;
@@ -508,6 +508,8 @@
                else
                        delete_buffer(&buffers->vert_buf);
 
+               update_mesh_color_buffers(buffers, vdata, totvert);
+
                glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
        }
 
@@ -515,9 +517,10 @@
 }
 

@@ 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