[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29277] branches/soc-2010-nicolasbishop/ source/blender: * PBVH can now iterate over mask data coming from a mesh ( not multires yet)
Nicholas Bishop
nicholasbishop at gmail.com
Sun Jun 6 19:03:07 CEST 2010
Revision: 29277
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29277
Author: nicholasbishop
Date: 2010-06-06 19:03:06 +0200 (Sun, 06 Jun 2010)
Log 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.)
Modified Paths:
--------------
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.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/paint_mask.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/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c 2010-06-06 16:26:49 UTC (rev 29276)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c 2010-06-06 17:03:06 UTC (rev 29277)
@@ -210,7 +210,7 @@
cddm->pbvh = BLI_pbvh_new();
cddm->pbvh_draw = (cddm->mvert == me->mvert);
BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert,
- me->totface, me->totvert);
+ &me->vdata, me->totface, me->totvert);
}
return cddm->pbvh;
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-06 16:26:49 UTC (rev 29276)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c 2010-06-06 17:03:06 UTC (rev 29277)
@@ -2300,7 +2300,7 @@
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);
ccgdm->pbvh_draw = 0;
}
Modified: branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h 2010-06-06 16:26:49 UTC (rev 29276)
+++ branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h 2010-06-06 17:03:06 UTC (rev 29277)
@@ -25,6 +25,7 @@
#ifndef BLI_PBVH_H
#define BLI_PBVH_H
+struct CustomData;
struct MFace;
struct MVert;
struct DMGridAdjacency;
@@ -47,7 +48,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);
@@ -101,7 +102,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]);
@@ -142,28 +143,34 @@
/* 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;
#define BLI_pbvh_vertex_iter_begin(bvh, node, vi, mode) \
{ \
struct DMGridData **grids; \
struct MVert *verts; \
+ struct CustomData *vdata; \
int *grid_indices, totgrid, gridsize, *vert_indices, uniq_verts, totvert; \
\
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; \
@@ -176,6 +183,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++) { \
@@ -209,6 +219,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-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c 2010-06-06 16:26:49 UTC (rev 29276)
+++ branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c 2010-06-06 17:03:06 UTC (rev 29277)
@@ -105,6 +105,7 @@
/* Mesh data */
MVert *verts;
MFace *faces;
+ CustomData *vdata;
/* Grid Data */
DMGridData **grids;
@@ -348,6 +349,7 @@
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,
@@ -472,7 +474,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;
@@ -480,6 +482,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;
@@ -880,6 +883,7 @@
else {
GPU_update_mesh_buffers(node->draw_buffers,
bvh->verts,
+ bvh->vdata,
node->vert_indices,
node->uniq_verts +
node->face_verts);
@@ -1019,10 +1023,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-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_mask.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_mask.c 2010-06-06 16:26:49 UTC (rev 29276)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_mask.c 2010-06-06 17:03:06 UTC (rev 29277)
@@ -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;
Modified: branches/soc-2010-nicolasbishop/source/blender/gpu/gpu_buffers.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/gpu/gpu_buffers.h 2010-06-06 16:26:49 UTC (rev 29276)
+++ branches/soc-2010-nicolasbishop/source/blender/gpu/gpu_buffers.h 2010-06-06 17:03:06 UTC (rev 29277)
@@ -129,11 +129,11 @@
/* Buffers for non-DerivedMesh drawing */
void *GPU_build_mesh_buffers(struct GHash *map, struct MVert *mvert,
- struct MFace *mface, int *face_indices,
- int totface, int *vert_indices, int uniq_verts,
- int totvert);
+ 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-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c 2010-06-06 16:26:49 UTC (rev 29276)
+++ branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c 2010-06-06 17:03:06 UTC (rev 29277)
@@ -424,7 +424,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;
@@ -432,7 +432,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)
@@ -455,7 +455,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;
@@ -483,6 +483,8 @@
else
delete_buffer(&buffers->vert_buf);
+ update_mesh_color_buffers(buffers, vdata, totvert);
+
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
}
@@ -490,9 +492,10 @@
}
void *GPU_build_mesh_buffers(GHash *map, MVert *mvert, MFace *mface,
- int *face_indices, int totface,
- int *vert_indices, int tot_uniq_verts,
- int totvert)
+ CustomData *vdata,
+ int *face_indices, int totface,
+ int *vert_indices, int tot_uniq_verts,
+ int totvert)
{
GPU_Buffers *buffers;
unsigned short *tri_data;
@@ -552,7 +555,7 @@
if(buffers->index_buf)
glGenBuffersARB(1, &buffers->vert_buf);
- GPU_update_mesh_buffers(buffers, mvert, vert_indices, totvert);
+ GPU_update_mesh_buffers(buffers, mvert, vdata, vert_indices, totvert);
buffers->tot_tri = tottri;
@@ -730,7 +733,7 @@
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list