[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37186] branches/soc-2011-onion: Revision: 29860
Jason Wilkins
Jason.A.Wilkins at gmail.com
Sat Jun 4 19:10:05 CEST 2011
Revision: 37186
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37186
Author: jwilkins
Date: 2011-06-04 17:10:05 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
Revision: 29860
Author: nicholasbishop
Date: 7:38:04 PM, Thursday, July 01, 2010
Message:
Some cleanups and optimizations for masks:
* Mesh/grid VBO buffers can now be updated separately for coord/normal data and mask data
* Added a typedef for GPU_Buffers so we don't have the void* cast
* Changed the PBVH update to allow separate updating of mask data
* Fixed a memory leak for the mask_set operator
** jwilkins:
** one memory was indeed fixed, this one remains:
SculptUndoNode.pmask len: 7776 06720020
Modified Paths:
--------------
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/editors/sculpt_paint/sculpt.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-29796,29832
/trunk/blender:36833-37054
+ /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29796,29832,29860
/trunk/blender:36833-37054
Modified: branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h 2011-06-04 17:03:46 UTC (rev 37185)
+++ branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h 2011-06-04 17:10:05 UTC (rev 37186)
@@ -117,12 +117,18 @@
PBVH_UpdateNormals = 2,
PBVH_UpdateBB = 4,
PBVH_UpdateOriginalBB = 8,
- PBVH_UpdateDrawBuffers = 16,
- PBVH_UpdateRedraw = 32
+
+ /* Update vertex data (coord + normal */
+ PBVH_UpdateVertBuffers = 16,
+
+ /* Update color data (used for masks) */
+ PBVH_UpdateColorBuffers = 32,
+
+ PBVH_UpdateRedraw = 64
} PBVHNodeFlags;
void BLI_pbvh_node_mark_update(PBVHNode *node);
-void BLI_pbvh_node_mark_update_draw_buffers(PBVHNode *node, void *data);
+void BLI_pbvh_node_set_flags(PBVHNode *node, void *data);
void BLI_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node,
int **grid_indices, int *totgrid, int *maxgrid, int *gridsize,
Modified: branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c 2011-06-04 17:03:46 UTC (rev 37185)
+++ branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c 2011-06-04 17:10:05 UTC (rev 37186)
@@ -426,7 +426,7 @@
node->uniq_verts + node->face_verts);
}
- node->flag |= PBVH_UpdateDrawBuffers;
+ node->flag |= PBVH_UpdateVertBuffers|PBVH_UpdateColorBuffers;
BLI_ghash_free(map, NULL, NULL);
}
@@ -438,7 +438,7 @@
GPU_build_grid_buffers(bvh->grids, node->prim_indices,
node->totprim, bvh->gridsize);
}
- node->flag |= PBVH_UpdateDrawBuffers;
+ node->flag |= PBVH_UpdateVertBuffers|PBVH_UpdateColorBuffers;
}
/* Recursively build a node in the tree
@@ -1125,27 +1125,46 @@
for(n = 0; n < totnode; n++) {
node= nodes[n];
- if(node->flag & PBVH_UpdateDrawBuffers) {
+ if(node->flag & PBVH_UpdateVertBuffers) {
if(bvh->grids) {
- GPU_update_grid_buffers(node->draw_buffers,
- bvh->grids,
- node->prim_indices,
- node->totprim,
- bvh->gridsize,
- bvh->gridkey,
- smooth);
+ GPU_update_grid_vert_buffers(node->draw_buffers,
+ bvh->grids,
+ node->prim_indices,
+ node->totprim,
+ bvh->gridsize,
+ bvh->gridkey,
+ smooth);
}
else {
- GPU_update_mesh_buffers(node->draw_buffers,
- bvh->verts,
- bvh->vdata,
- node->vert_indices,
- node->uniq_verts +
- node->face_verts);
+ GPU_update_mesh_vert_buffers(node->draw_buffers,
+ bvh->verts,
+ node->vert_indices,
+ node->uniq_verts +
+ node->face_verts);
}
- node->flag &= ~PBVH_UpdateDrawBuffers;
+ node->flag &= ~PBVH_UpdateVertBuffers;
}
+
+ if(node->flag & PBVH_UpdateColorBuffers) {
+ if(bvh->grids) {
+ GPU_update_grid_color_buffers(node->draw_buffers,
+ bvh->grids,
+ node->prim_indices,
+ node->totprim,
+ bvh->gridsize,
+ bvh->gridkey);
+ }
+ else {
+ GPU_update_mesh_color_buffers(node->draw_buffers,
+ bvh->vdata,
+ node->vert_indices,
+ node->uniq_verts +
+ node->face_verts);
+ }
+
+ node->flag &= ~PBVH_UpdateColorBuffers;
+ }
}
}
@@ -1276,12 +1295,12 @@
void BLI_pbvh_node_mark_update(PBVHNode *node)
{
- node->flag |= PBVH_UpdateNormals|PBVH_UpdateBB|PBVH_UpdateOriginalBB|PBVH_UpdateDrawBuffers|PBVH_UpdateRedraw;
+ node->flag |= PBVH_UpdateNormals|PBVH_UpdateBB|PBVH_UpdateOriginalBB|PBVH_UpdateVertBuffers|PBVH_UpdateRedraw;
}
-void BLI_pbvh_node_mark_update_draw_buffers(PBVHNode *node, void *data)
+void BLI_pbvh_node_set_flags(PBVHNode *node, void *data)
{
- node->flag |= PBVH_UpdateDrawBuffers|PBVH_UpdateRedraw;
+ node->flag |= GET_INT_FROM_POINTER(data);
}
void BLI_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node, int **vert_indices, MVert **verts, CustomData **vdata)
@@ -1549,7 +1568,8 @@
PBVHNode **nodes;
int totnode;
- BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(PBVH_UpdateNormals|PBVH_UpdateDrawBuffers),
+ BLI_pbvh_search_gather(bvh, update_search_cb,
+ SET_INT_IN_POINTER(PBVH_UpdateNormals|PBVH_UpdateVertBuffers|PBVH_UpdateColorBuffers),
&nodes, &totnode);
pbvh_update_normals(bvh, nodes, totnode, face_nors);
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-04 17:03:46 UTC (rev 37185)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c 2011-06-04 17:10:05 UTC (rev 37186)
@@ -25,6 +25,7 @@
#include "BLI_listbase.h"
#include "BLI_pbvh.h"
+#include "BLI_utildefines.h"
#include "ED_mesh.h"
#include "ED_sculpt.h"
@@ -78,12 +79,14 @@
}
BLI_pbvh_vertex_iter_end;
- BLI_pbvh_node_mark_update(nodes[n]);
+ BLI_pbvh_node_set_flags(nodes[n], SET_INT_IN_POINTER(PBVH_UpdateColorBuffers|PBVH_UpdateRedraw));
}
+ if(nodes)
+ MEM_freeN(nodes);
+
if(mmd)
multires_mark_as_modified(ob);
- BLI_pbvh_update(pbvh, PBVH_UpdateBB|PBVH_UpdateOriginalBB|PBVH_UpdateRedraw, NULL);
sculpt_undo_push_end();
@@ -258,7 +261,7 @@
if(ob->sculpt->pbvh)
BLI_pbvh_search_callback(ob->sculpt->pbvh, NULL, NULL,
- BLI_pbvh_node_mark_update_draw_buffers, NULL);
+ BLI_pbvh_node_set_flags, SET_INT_IN_POINTER(PBVH_UpdateColorBuffers));
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
}
Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c 2011-06-04 17:03:46 UTC (rev 37185)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c 2011-06-04 17:10:05 UTC (rev 37186)
@@ -2857,7 +2857,7 @@
}
BLI_pbvh_vertex_iter_end;
- BLI_pbvh_node_mark_update(nodes[n]);
+ BLI_pbvh_node_set_flags(nodes[n], SET_INT_IN_POINTER(PBVH_UpdateColorBuffers|PBVH_UpdateRedraw));
}
}
Modified: branches/soc-2011-onion/source/blender/gpu/GPU_buffers.h
===================================================================
--- branches/soc-2011-onion/source/blender/gpu/GPU_buffers.h 2011-06-04 17:03:46 UTC (rev 37185)
+++ branches/soc-2011-onion/source/blender/gpu/GPU_buffers.h 2011-06-04 17:10:05 UTC (rev 37186)
@@ -140,16 +140,26 @@
void GPU_drawobject_free( struct DerivedMesh *dm );
/* Buffers for non-DerivedMesh drawing */
-void *GPU_build_mesh_buffers(struct GHash *map, struct MVert *mvert,
- 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,
- 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,
- int *grid_indices, int totgrid, int gridsize, struct GridKey *gridkey, int smooth);
+typedef struct GPU_Buffers GPU_Buffers;
+
+GPU_Buffers *GPU_build_mesh_buffers(struct GHash *map, struct MVert *mvert,
+ struct MFace *mface, CustomData *vdata, int *face_indices,
+ int totface, int *vert_indices, int uniq_verts,
+ int totvert);
+void GPU_update_mesh_vert_buffers(GPU_Buffers *buffers, struct MVert *mvert,
+ int *vert_indices, int totvert);
+void GPU_update_mesh_color_buffers(GPU_Buffers *buffers,
+ struct CustomData *vdata,
+ int *vert_indices, int totvert);
+GPU_Buffers *GPU_build_grid_buffers(struct DMGridData **grids,
+ int *grid_indices, int totgrid, int gridsize);
+void GPU_update_grid_vert_buffers(GPU_Buffers *buffersb, struct DMGridData **grids,
+ int *grid_indices, int totgrid, int gridsize,
+ struct GridKey *gridkey, int smooth);
+void GPU_update_grid_color_buffers(GPU_Buffers *buffers,
+ struct DMGridData **grids,
+ int *grid_indices, int totgrid,
+ int gridsize, struct GridKey *gridkey);
void GPU_draw_buffers(void *buffers);
void GPU_free_buffers(void *buffers);
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-04 17:03:46 UTC (rev 37185)
+++ branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.c 2011-06-04 17:10:05 UTC (rev 37186)
@@ -413,7 +413,7 @@
short no[3];
} VertexBufferFormat;
-typedef struct {
+struct GPU_Buffers {
/* opengl buffer handles */
GLuint vert_buf, index_buf, color_buf;
GLenum index_type;
@@ -432,7 +432,7 @@
struct GridKey *gridkey;
unsigned int tot_tri, tot_quad;
-} GPU_Buffers;
+};
static void delete_buffer(GLuint *buf)
{
@@ -474,9 +474,7 @@
return color_data;
}
-/* 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 *vdata, int *vert_indices, int totvert)
+void GPU_update_mesh_color_buffers(GPU_Buffers *buffers, CustomData *vdata, int *vert_indices, int totvert)
{
unsigned char *color_data;
int i, pmask_totlayer;
@@ -502,10 +500,9 @@
}
}
-void GPU_update_mesh_buffers(void *buffers_v, MVert *mvert,
- CustomData *vdata, int *vert_indices, int totvert)
+void GPU_update_mesh_vert_buffers(GPU_Buffers *buffers, MVert *mvert,
+ int *vert_indices, int totvert)
{
- GPU_Buffers *buffers = buffers_v;
VertexBufferFormat *vert_data;
int i;
@@ -531,15 +528,13 @@
else
delete_buffer(&buffers->vert_buf);
- update_mesh_color_buffers(buffers, vdata, vert_indices, totvert);
-
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
}
buffers->mvert = mvert;
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list