[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29288] branches/soc-2010-nicolasbishop/ source/blender: * Fixed a bug in the mesh color buffer updating
Nicholas Bishop
nicholasbishop at gmail.com
Mon Jun 7 01:46:14 CEST 2010
Revision: 29288
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29288
Author: nicholasbishop
Date: 2010-06-07 01:46:14 +0200 (Mon, 07 Jun 2010)
Log Message:
-----------
* Fixed a bug in the mesh color buffer updating
* Added a mask brush to sculpt mode, behaves as a normal brush but affects mask not coords. Note that for non-multires, you have to create a mask layer before the brush will do anything.
* Cleared some memory that valgrind warned was uninitialized
Modified Paths:
--------------
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c
branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c
branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_brush_types.h
branches/soc-2010-nicolasbishop/source/blender/makesrna/intern/rna_brush.c
Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c 2010-06-06 23:17:32 UTC (rev 29287)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c 2010-06-06 23:46:14 UTC (rev 29288)
@@ -570,6 +570,7 @@
case SCULPT_TOOL_CLAY:
case SCULPT_TOOL_FLATTEN:
case SCULPT_TOOL_LAYER:
+ case SCULPT_TOOL_MASK:
return alpha * dir * pressure * flip; /*XXX: not sure why? was multiplied by G.vd->grid */;
case SCULPT_TOOL_SMOOTH:
return alpha * 4 * pressure;
@@ -1368,7 +1369,38 @@
BLI_pbvh_node_mark_update(nodes[n]);
}
}
+static void do_mask_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode)
+{
+ Brush *brush = paint_brush(&sd->paint);
+ float bstrength= ss->cache->bstrength;
+ int n;
+ for(n=0; n<totnode; n++) {
+ PBVHVertexIter vd;
+ SculptBrushTest test;
+
+ sculpt_undo_push_node(ss, nodes[n]);
+ sculpt_brush_test_init(ss, &test);
+
+ BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
+ /* TODO: should add a mask layer if needed */
+ if(vd.mask) {
+ if(sculpt_brush_test(&test, vd.co)) {
+ float fade = tex_strength(ss, brush, vd.co, NULL, test.dist)*bstrength;
+
+ *vd.mask -= fade;
+ CLAMP(*vd.mask, 0, 1);
+
+ if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ }
+ BLI_pbvh_vertex_iter_end;
+
+ BLI_pbvh_node_mark_update(nodes[n]);
+ }
+}
+
static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache)
{
SculptSearchSphereData data;
@@ -1376,6 +1408,7 @@
PBVHNode **nodes= NULL;
int totnode;
+ memset(&data, 0, sizeof(data));
data.ss = ss;
data.sd = sd;
data.radius_squared = ss->cache->radius * ss->cache->radius;
@@ -1425,6 +1458,9 @@
case SCULPT_TOOL_CLAY:
do_flatten_clay_brush(sd, ss, nodes, totnode, 1);
break;
+ case SCULPT_TOOL_MASK:
+ do_mask_brush(sd, ss, nodes, totnode);
+ break;
}
/* copy the modified vertices from mesh to the active key */
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 23:17:32 UTC (rev 29287)
+++ branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c 2010-06-06 23:46:14 UTC (rev 29288)
@@ -448,7 +448,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 *vdata, int totvert)
+static void update_mesh_color_buffers(GPU_Buffers *buffers, CustomData *vdata, int *vert_indices, int totvert)
{
unsigned char *color_data;
int i;
@@ -461,7 +461,7 @@
if(color_data) {
for(i = 0; i < totvert; ++i)
- mask_to_gpu_colors(color_data + i*3, pmask[i]);
+ mask_to_gpu_colors(color_data + i*3, pmask[vert_indices[i]]);
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
}
}
@@ -495,7 +495,7 @@
else
delete_buffer(&buffers->vert_buf);
- update_mesh_color_buffers(buffers, vdata, totvert);
+ update_mesh_color_buffers(buffers, vdata, vert_indices, totvert);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
}
Modified: branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_brush_types.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_brush_types.h 2010-06-06 23:17:32 UTC (rev 29287)
+++ branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_brush_types.h 2010-06-06 23:46:14 UTC (rev 29288)
@@ -89,14 +89,17 @@
#define BRUSH_LOCK_ALPHA 16384
/* Brush.sculpt_tool */
-#define SCULPT_TOOL_DRAW 1
-#define SCULPT_TOOL_SMOOTH 2
-#define SCULPT_TOOL_PINCH 3
-#define SCULPT_TOOL_INFLATE 4
-#define SCULPT_TOOL_GRAB 5
-#define SCULPT_TOOL_LAYER 6
-#define SCULPT_TOOL_FLATTEN 7
-#define SCULPT_TOOL_CLAY 8
+typedef enum {
+ SCULPT_TOOL_DRAW = 1,
+ SCULPT_TOOL_SMOOTH,
+ SCULPT_TOOL_PINCH,
+ SCULPT_TOOL_INFLATE,
+ SCULPT_TOOL_GRAB,
+ SCULPT_TOOL_LAYER,
+ SCULPT_TOOL_FLATTEN,
+ SCULPT_TOOL_CLAY,
+ SCULPT_TOOL_MASK,
+} SculptTool;
/* ImagePaintSettings.tool */
#define PAINT_TOOL_DRAW 0
Modified: branches/soc-2010-nicolasbishop/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/makesrna/intern/rna_brush.c 2010-06-06 23:17:32 UTC (rev 29287)
+++ branches/soc-2010-nicolasbishop/source/blender/makesrna/intern/rna_brush.c 2010-06-06 23:46:14 UTC (rev 29288)
@@ -106,6 +106,7 @@
{SCULPT_TOOL_LAYER, "LAYER", 0, "Layer", ""},
{SCULPT_TOOL_FLATTEN, "FLATTEN", 0, "Flatten", ""},
{SCULPT_TOOL_CLAY, "CLAY", 0, "Clay", ""},
+ {SCULPT_TOOL_MASK, "MASK", 0, "Mask", ""},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem brush_vertexpaint_tool_items[] = {
More information about the Bf-blender-cvs
mailing list