[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29369] branches/soc-2010-jwilkins: * Fixed layer brush so that it works in subtract mode.
Jason Wilkins
Jason.A.Wilkins at gmail.com
Wed Jun 9 18:15:45 CEST 2010
Revision: 29369
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29369
Author: jwilkins
Date: 2010-06-09 18:15:45 +0200 (Wed, 09 Jun 2010)
Log Message:
-----------
* Fixed layer brush so that it works in subtract mode.
* Shift key can no longer turn Contrast into Flatten and visa versa
* reduced the range in which brush changes transparency so that it doesn't become too bold or too hard to see
* the old brush cursor no longer changes opacity so that it does not become too hard to see
* if the on-surface brush radius shrinks to smaller than 6 pixels, it is drawn as a solid circle to avoid it becoming hard to see
* adjusted thickness of on-surface brush upwards so that it doesn't get too thin
* when drawing anchored, the on-surface brush now drawn outside of the area being affected
* renamed Restore Mesh to Drag and Drop
Modified Paths:
--------------
branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
branches/soc-2010-jwilkins/source/blender/makesdna/DNA_brush_types.h
branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c
Modified: branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py 2010-06-09 15:56:50 UTC (rev 29368)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py 2010-06-09 16:15:45 UTC (rev 29369)
@@ -763,10 +763,10 @@
if context.sculpt_object:
if brush.sculpt_tool != 'LAYER':
- layout.prop(brush, "restore_mesh")
+ layout.prop(brush, "restore_mesh", "Drag And Drop")
layout.prop(brush, "use_anchor")
if brush.use_anchor:
- layout.prop(brush, "edge_to_edge")
+ layout.prop(brush, "edge_to_edge", "Edge To Edge")
layout.prop(brush, "use_rake")
if brush.sculpt_tool in ('DRAW', 'LAYER', 'FLATTEN', 'CLAY', 'FILL', 'SCRAPE', 'CONTRAST'):
layout.prop(brush, "use_original_normal")
Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c 2010-06-09 15:56:50 UTC (rev 29368)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c 2010-06-09 16:15:45 UTC (rev 29369)
@@ -210,7 +210,8 @@
int i, j;
float xlim, ylim;
- int procedural = !brush->mtex.tex->ima;
+ // XXX there has to be a better way to guess if a texture is procedural
+ int procedural = brush->mtex.tex && !brush->mtex.tex->ima;
if (brush->overlay_texture) glDeleteTextures(1, &brush->overlay_texture);
@@ -428,6 +429,12 @@
return len_v3(delta)/scale;
}
+// XXX paint cursor now does a lot of the same work that is needed during a sculpt stroke
+// problem: all this stuff was not intended to be used at this point, so things feel a
+// bit hacked. I've put lots of stuff in Brush that probably better goes in Paint
+// Functions should be refactored so that they can be used between sculpt.c and
+// paint_stroke.c clearly and optimally and the lines of communication between the
+// two modules should be more clearly defined.
static void paint_draw_cursor(bContext *C, int x, int y, void *customdata)
{
Paint *paint = paint_get_active(CTX_data_scene(C));
@@ -438,7 +445,6 @@
int hit;
-
/* keep track of mouse movement angle so rack can start at a sensible angle */
int dx = brush->last_x - x;
@@ -461,14 +467,32 @@
if (hit) {
ViewContext vc;
float unprojected_radius;
+ int flip;
+ int sign;
+ float visual_strength;
- { // duplicated from brush_strength, refactor later
- float alpha = brush->alpha * brush->alpha;
- float pressure;
- PointerRNA ptr;
- RNA_id_pointer_create(&brush->id, &ptr);
- pressure = brush->flag & BRUSH_ALPHA_PRESSURE ? RNA_float_get(&ptr, "pressure") : 1;
- brush->visual_strength = alpha * pressure;
+ const float min_alpha = 0.30f;
+ const float max_alpha = 0.70f;
+ float* col;
+ float alpha;
+
+ // XXX duplicated from brush_strength & paint_stroke_add_step, refactor later
+ {
+ float strength = brush->alpha * brush->alpha;
+ float pressure = 1.0f;
+ wmEvent* event = CTX_wm_window(C)->eventstate;
+
+ flip = event->shift ? -1 : 1;
+
+ if(event->custom == EVT_DATA_TABLET) {
+ wmTabletData *wmtab= event->customdata;
+ if(wmtab->Active != EVT_TABLET_NONE)
+ pressure = brush->flag & BRUSH_ALPHA_PRESSURE ? wmtab->Pressure : 1;
+ if(wmtab->Active == EVT_TABLET_ERASER)
+ flip = 1;
+ }
+
+ visual_strength = strength * pressure;
}
view3d_set_viewcontext(C, &vc);
@@ -489,29 +513,36 @@
if(!(paint->flags & PAINT_SHOW_BRUSH))
return;
- glEnable(GL_BLEND);
+ sign = flip * ((brush->flag & BRUSH_DIR_IN)? -1 : 1);
- if ((brush->flag & BRUSH_DIR_IN) && ELEM4(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_PINCH))
- glColor4f(brush->sub_col[0], brush->sub_col[1], brush->sub_col[2], 0.20f + (brush->visual_strength*.7));
+ if (sign < 0 && ELEM4(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_PINCH))
+ col = brush->sub_col;
else
- glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], 0.20f + (brush->visual_strength*.7));
+ col = brush->add_col;
+ alpha = (paint->flags & PAINT_SHOW_BRUSH_ON_SURFACE) ? min_alpha + (visual_strength*(max_alpha-min_alpha)) : 0.50f;
+
+ glColor4f(col[0], col[1], col[2], alpha);
+
+ glEnable(GL_BLEND);
+
if (paint->flags & PAINT_SHOW_BRUSH_ON_SURFACE) {
+ const float max_thickness= 0.16;
+ const float min_thickness= 0.06;
+ const float thickness= 1.0 - min_thickness - visual_strength*max_thickness;
+ const float inner_radius= brush->draw_anchored ? unprojected_radius : unprojected_radius*thickness;
+ const float outer_radius= brush->draw_anchored ? 1.0f/thickness * unprojected_radius : unprojected_radius;
+
GLUquadric* sphere;
- float anchored_offset;
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadMatrixf(modelview);
- if (brush->draw_anchored) {
+ if (brush->draw_anchored)
glTranslatef(brush->anchored_location[0], brush->anchored_location[1], brush->anchored_location[2]);
- anchored_offset = 0;//0.96f - brush->visual_strength*0.20;
- }
- else {
- anchored_offset = 0;
+ else
glTranslatef(location[0], location[1], location[2]);
- }
glMatrixMode(GL_PROJECTION);
glPushMatrix();
@@ -535,25 +566,25 @@
sphere = gluNewQuadric();
- gluSphere(sphere, unprojected_radius, 40, 40);
+ gluSphere(sphere, outer_radius, 40, 40);
glStencilFunc(GL_ALWAYS, 1, 0xFF);
glStencilOp(GL_KEEP, GL_DECR, GL_KEEP);
- if (brush->draw_anchored || !(brush->flag & BRUSH_ANCHORED))
- gluSphere(sphere, unprojected_radius * (0.96f - brush->visual_strength*0.20) + anchored_offset, 40, 40);
+ if (brush->size >= 8)
+ gluSphere(sphere, inner_radius, 40, 40);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glStencilFunc(GL_EQUAL, 1, 0xFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
- gluSphere(sphere, unprojected_radius + anchored_offset, 40, 40);
+ gluSphere(sphere, outer_radius, 40, 40);
glStencilFunc(GL_EQUAL, 3, 0xFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
- gluSphere(sphere, unprojected_radius + anchored_offset, 40, 40);
+ gluSphere(sphere, outer_radius, 40, 40);
gluDeleteQuadric(sphere);
@@ -569,7 +600,6 @@
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
-
}
else {
glEnable(GL_LINE_SMOOTH);
@@ -674,7 +704,7 @@
if(wmtab->Active == EVT_TABLET_ERASER)
flip = 1;
}
-
+
/* Add to stroke */
RNA_collection_add(op->ptr, "stroke", &itemptr);
RNA_float_set_array(&itemptr, "location", center);
@@ -830,9 +860,16 @@
;//ED_region_tag_redraw(ar);
}
}
+
/* we want the stroke to have the first daub at the start location instead of waiting till we have moved the space distance */
- if(first && stroke->stroke_started && paint_space_stroke_enabled(stroke->brush) && !(stroke->brush->flag & BRUSH_ANCHORED))
+ if(first &&
+ stroke->stroke_started &&
+ paint_space_stroke_enabled(stroke->brush) &&
+ !(stroke->brush->flag & BRUSH_ANCHORED) &&
+ !(stroke->brush->flag & BRUSH_SMOOTH_STROKE))
+ {
paint_brush_stroke_add_step(C, op, event, mouse);
+ }
return OPERATOR_RUNNING_MODAL;
}
Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c 2010-06-09 15:56:50 UTC (rev 29368)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c 2010-06-09 16:15:45 UTC (rev 29369)
@@ -745,20 +745,18 @@
//float overlap = (brush->flag & BRUSH_SPACE && !(brush->flag & BRUSH_ANCHORED)) && (brush->spacing < 100.0f) ? 1 - circle_overlap_percent(brush->spacing/50.0f) : 1; // spacing is integer percentage of radius, divide by 50 to get normalized diameter
float overlap = (brush->flag & BRUSH_SPACE_ATTEN && brush->flag & BRUSH_SPACE && !(brush->flag & BRUSH_ANCHORED)) && (brush->spacing < 100) ? (float)brush->spacing/100.0f : 1; // spacing is integer percentage of radius, divide by 50 to get normalized diameter
- brush->visual_strength = alpha * pressure;
-
switch(brush->sculpt_tool){
case SCULPT_TOOL_DRAW:
case SCULPT_TOOL_INFLATE:
case SCULPT_TOOL_CLAY:
- return alpha * dir * pressure * flip * overlap;
-
- case SCULPT_TOOL_FLATTEN:
case SCULPT_TOOL_LAYER:
case SCULPT_TOOL_FILL:
case SCULPT_TOOL_SCRAPE:
+ return alpha * dir * flip * pressure * overlap;
+
+ case SCULPT_TOOL_FLATTEN:
case SCULPT_TOOL_CONTRAST:
- return alpha * pressure * flip * overlap;
+ return alpha * pressure * overlap;
case SCULPT_TOOL_SMOOTH:
return alpha * 4 * pressure * overlap;
@@ -766,6 +764,7 @@
case SCULPT_TOOL_PINCH:
return alpha / 2 * dir * pressure * flip * overlap;
+ case SCULPT_TOOL_YANK:
case SCULPT_TOOL_GRAB:
return 1;
@@ -1398,6 +1397,46 @@
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if(sculpt_brush_test(&test, origco[vd.i])) {
+ float fade = tex_strength(ss, brush, origco[vd.i], test.dist/3.0f)*bstrength;
+ float val[3];
+
+ mul_v3_v3fl(val, grab_delta, fade);
+ symmetry_feather(sd, ss, vd.co, val);
+ add_v3_v3(val, vd.co);
+
+ sculpt_clip(sd, ss, vd.co, val);
+ if(vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1;
+ }
+ }
+ }
+ BLI_pbvh_vertex_iter_end;
+
+ BLI_pbvh_node_mark_update(nodes[n]);
+ }
+}
+
+static void do_yank_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode)
+{
+ Brush *brush = paint_brush(&sd->paint);
+ float bstrength= ss->cache->bstrength;
+ float grab_delta[3];
+ int n;
+
+ copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
+
+ //#pragma omp parallel for private(n) schedule(static)
+ for(n=0; n<totnode; n++) {
+ PBVHVertexIter vd;
+ SculptBrushTest test;
+ float (*origco)[3];
+
+ origco= sculpt_undo_push_node(ss, nodes[n])->co;
+ sculpt_brush_test_init(ss, &test);
+
+ BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
+ if(sculpt_brush_test(&test, origco[vd.i])) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list