[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37139] branches/soc-2011-onion: Revision: 29288
Jason Wilkins
Jason.A.Wilkins at gmail.com
Fri Jun 3 19:38:49 CEST 2011
Revision: 37139
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37139
Author: jwilkins
Date: 2011-06-03 17:38:48 +0000 (Fri, 03 Jun 2011)
Log Message:
-----------
Revision: 29288
Author: nicholasbishop
Date: 6:46:14 PM, Sunday, June 06, 2010
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-2011-onion/source/blender/editors/sculpt_paint/sculpt.c
branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.c
branches/soc-2011-onion/source/blender/makesdna/DNA_brush_types.h
branches/soc-2011-onion/source/blender/makesrna/intern/rna_brush.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-29285,29324,29350
/trunk/blender:36833-37054
+ /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29285,29288,29324,29350
/trunk/blender:36833-37054
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-03 16:49:49 UTC (rev 37138)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c 2011-06-03 17:38:48 UTC (rev 37139)
@@ -673,6 +673,7 @@
case SCULPT_TOOL_DRAW:
case SCULPT_TOOL_GRAVITY:
case SCULPT_TOOL_LAYER:
+ case SCULPT_TOOL_MASK:
return alpha * flip * pressure * overlap * feather;
case SCULPT_TOOL_CREASE:
@@ -2816,6 +2817,39 @@
}
}
+static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
+{
+ SculptSession *ss = ob->sculpt;
+ 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(ob, 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, Object* ob, Brush *brush)
{
SculptSession *ss= ob->sculpt;
@@ -2824,6 +2858,7 @@
int n, totnode;
/* Build a list of all nodes that are potentially within the brush's area of influence */
+ memset(&data, 0, sizeof(data));
data.ss = ss;
data.sd = sd;
data.radius_squared = ss->cache->radius_squared;
@@ -2896,6 +2931,9 @@
case SCULPT_TOOL_SCRAPE:
do_scrape_brush(sd, ob, nodes, totnode);
break;
+ case SCULPT_TOOL_MASK:
+ do_mask_brush(sd, ob, nodes, totnode);
+ break;
}
if (brush->sculpt_tool != SCULPT_TOOL_SMOOTH && brush->autosmooth_factor > 0) {
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 16:49:49 UTC (rev 37138)
+++ branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.c 2011-06-03 17:38:48 UTC (rev 37139)
@@ -473,7 +473,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;
@@ -486,7 +486,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);
}
}
@@ -520,7 +520,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-2011-onion/source/blender/makesdna/DNA_brush_types.h
===================================================================
--- branches/soc-2011-onion/source/blender/makesdna/DNA_brush_types.h 2011-06-03 16:49:49 UTC (rev 37138)
+++ branches/soc-2011-onion/source/blender/makesdna/DNA_brush_types.h 2011-06-03 17:38:48 UTC (rev 37139)
@@ -148,25 +148,28 @@
#define BRUSH_INVERTED (1<<29)
/* 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
-#define SCULPT_TOOL_FILL 9
-#define SCULPT_TOOL_SCRAPE 10
-#define SCULPT_TOOL_NUDGE 11
-#define SCULPT_TOOL_THUMB 12
-#define SCULPT_TOOL_SNAKE_HOOK 13
-#define SCULPT_TOOL_ROTATE 14
-//#define SCULPT_TOOL_WAX 15 // XXX: reuse this slot later
-#define SCULPT_TOOL_CREASE 16
-#define SCULPT_TOOL_BLOB 17
-#define SCULPT_TOOL_CLAY_STRIPS 18
-#define SCULPT_TOOL_GRAVITY 19
+enum {
+ SCULPT_TOOL_DRAW = 1,
+ SCULPT_TOOL_SMOOTH = 2,
+ SCULPT_TOOL_PINCH = 3,
+ SCULPT_TOOL_INFLATE = 4,
+ SCULPT_TOOL_GRAB = 5,
+ SCULPT_TOOL_LAYER = 6,
+ SCULPT_TOOL_FLATTEN = 7,
+ SCULPT_TOOL_CLAY = 8,
+ SCULPT_TOOL_FILL = 9,
+ SCULPT_TOOL_SCRAPE = 10,
+ SCULPT_TOOL_NUDGE = 11,
+ SCULPT_TOOL_THUMB = 12,
+ SCULPT_TOOL_SNAKE_HOOK = 13,
+ SCULPT_TOOL_ROTATE = 14,
+ SCULPT_TOOL_WAX = 15, // XXX: not used, reuse this slot later
+ SCULPT_TOOL_CREASE = 16,
+ SCULPT_TOOL_BLOB = 17,
+ SCULPT_TOOL_CLAY_STRIPS = 18,
+ SCULPT_TOOL_GRAVITY = 19,
+ SCULPT_TOOL_MASK = 20,
+} SculptTool;
/* ImagePaintSettings.tool */
#define PAINT_TOOL_DRAW 0
Modified: branches/soc-2011-onion/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- branches/soc-2011-onion/source/blender/makesrna/intern/rna_brush.c 2011-06-03 16:49:49 UTC (rev 37138)
+++ branches/soc-2011-onion/source/blender/makesrna/intern/rna_brush.c 2011-06-03 17:38:48 UTC (rev 37139)
@@ -75,6 +75,7 @@
{SCULPT_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_SMOOTH, "Smooth", ""},
{SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", ICON_BRUSH_SNAKE_HOOK, "Snake Hook", ""},
{SCULPT_TOOL_THUMB, "THUMB", ICON_BRUSH_THUMB, "Thumb", ""},
+ {SCULPT_TOOL_MASK, "MASK", ICON_BRUSH_SUBTRACT, "Mask", ""},
{0, NULL, 0, NULL, NULL}};
More information about the Bf-blender-cvs
mailing list