[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24693] trunk/blender: * Removed tablet pressure sensitive number field widget scrubbing, wasn' t that useful and I suspect it was the cause of a few bugs
Matt Ebb
matt at mke3.net
Fri Nov 20 02:39:27 CET 2009
Revision: 24693
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24693
Author: broken
Date: 2009-11-20 02:39:27 +0100 (Fri, 20 Nov 2009)
Log Message:
-----------
* Removed tablet pressure sensitive number field widget scrubbing, wasn't that useful and I suspect it was the cause of a few bugs
* Added tablet pressure support (size/strength) for weight paint and vertex paint
* Added tablet eraser support for weight paint and vertex paint (inverts the effect of the current tool)
* Removed the old 'soft' option, now weight paint and vertex paint use the influence curve
* Made the default brush use a smooth influence curve, rather than sharp
Modified Paths:
--------------
trunk/blender/release/scripts/ui/space_view3d_toolbar.py
trunk/blender/source/blender/blenkernel/intern/brush.c
trunk/blender/source/blender/editors/interface/interface_handlers.c
trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
trunk/blender/source/blender/makesdna/DNA_scene_types.h
trunk/blender/source/blender/makesrna/intern/rna_sculpt_paint.c
Modified: trunk/blender/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- trunk/blender/release/scripts/ui/space_view3d_toolbar.py 2009-11-19 23:59:37 UTC (rev 24692)
+++ trunk/blender/release/scripts/ui/space_view3d_toolbar.py 2009-11-20 01:39:27 UTC (rev 24693)
@@ -753,9 +753,7 @@
col.itemR(wpaint, "all_faces")
col.itemR(wpaint, "normals")
col.itemR(wpaint, "spray")
- col.itemR(wpaint, "vertex_dist", text="Distance")
-
data = context.weight_paint_object.data
if type(data) == bpy.types.Mesh:
col.itemR(data, "use_mirror_x")
@@ -787,7 +785,7 @@
col.itemR(vpaint, "all_faces")
col.itemR(vpaint, "normals")
col.itemR(vpaint, "spray")
- col.itemR(vpaint, "vertex_dist", text="Distance")
+
# Commented out because the Apply button isn't an operator yet, making these settings useless
# col.itemL(text="Gamma:")
# col.itemR(vpaint, "gamma", text="")
Modified: trunk/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/brush.c 2009-11-19 23:59:37 UTC (rev 24692)
+++ trunk/blender/source/blender/blenkernel/intern/brush.c 2009-11-20 01:39:27 UTC (rev 24693)
@@ -83,7 +83,7 @@
brush->clone.alpha= 0.5;
brush->sculpt_tool = SCULPT_TOOL_DRAW;
- brush_curve_preset(brush, BRUSH_PRESET_SHARP);
+ brush_curve_preset(brush, BRUSH_PRESET_SMOOTH);
/* enable fake user by default */
brush->id.flag |= LIB_FAKEUSER;
Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c 2009-11-19 23:59:37 UTC (rev 24692)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c 2009-11-20 01:39:27 UTC (rev 24693)
@@ -2224,14 +2224,6 @@
fac= 1.0f;
if(event->shift) fac /= 10.0f;
if(event->alt) fac /= 20.0f;
-
- if(event->custom == EVT_DATA_TABLET) {
- wmTabletData *wmtab= event->customdata;
-
- /* de-sensitise based on tablet pressure */
- if (wmtab->Active != EVT_TABLET_NONE)
- fac *= wmtab->Pressure;
- }
snap= (event->ctrl)? (event->shift)? 2: 1: 0;
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c 2009-11-19 23:59:37 UTC (rev 24692)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c 2009-11-20 01:39:27 UTC (rev 24693)
@@ -120,6 +120,7 @@
PointerRNA itemptr;
float cur_depth, pressure = 1;
float center[3];
+ int flip= event->shift?1:0;
PaintStroke *stroke = op->customdata;
cur_depth = read_cached_depth(&stroke->vc, mouse[0], mouse[1]);
@@ -130,13 +131,15 @@
wmTabletData *wmtab= event->customdata;
if(wmtab->Active != EVT_TABLET_NONE)
pressure= wmtab->Pressure;
+ 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);
RNA_float_set_array(&itemptr, "mouse", mouse);
- RNA_boolean_set(&itemptr, "flip", event->shift);
+ RNA_boolean_set(&itemptr, "flip", flip);
RNA_float_set(&itemptr, "pressure", pressure);
stroke->last_mouse_position[0] = mouse[0];
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c 2009-11-19 23:59:37 UTC (rev 24692)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c 2009-11-20 01:39:27 UTC (rev 24693)
@@ -154,12 +154,10 @@
{
VPaint *vp= MEM_callocN(sizeof(VPaint), "VPaint");
- vp->gamma= vp->mul= 1.0f;
+ vp->flag= VP_AREA+VP_SPRAY;
- vp->flag= VP_AREA+VP_SOFT+VP_SPRAY;
-
if(wpaint)
- vp->flag= VP_AREA+VP_SOFT;
+ vp->flag= VP_AREA;
return vp;
}
@@ -468,7 +466,8 @@
DAG_id_flush_update(&me->id, OB_RECALC_DATA);
}
-
+/* XXX: should be re-implemented as a vertex/weight paint 'colour correct' operator
+
void vpaint_dogamma(Scene *scene)
{
VPaint *vp= scene->toolsettings->vpaint;
@@ -508,6 +507,7 @@
cp+= 4;
}
}
+ */
static unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac)
{
@@ -739,65 +739,83 @@
return tot;
}
-static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], float *vert_nor, float *mval)
+static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], float *vert_nor, float *mval, float pressure)
{
Brush *brush = paint_brush(&vp->paint);
- float fac, dx, dy;
- int alpha;
+ float fac, fac_2, size, dx, dy;
+ float alpha;
short vertco[2];
- if(vp->flag & VP_SOFT) {
- project_short_noclip(vc->ar, vert_nor, vertco);
- dx= mval[0]-vertco[0];
- dy= mval[1]-vertco[1];
+ project_short_noclip(vc->ar, vert_nor, vertco);
+ dx= mval[0]-vertco[0];
+ dy= mval[1]-vertco[1];
+
+ if (brush->flag & BRUSH_SIZE_PRESSURE)
+ size = pressure * brush->size;
+ else
+ size = brush->size;
+
+ fac_2= dx*dx + dy*dy;
+ if(fac_2 > size*size) return 0.f;
+ fac = sqrtf(fac_2);
+
+ alpha= brush->alpha * brush_curve_strength_clamp(brush, fac, size);
+
+ if (brush->flag & BRUSH_ALPHA_PRESSURE)
+ alpha *= pressure;
- fac= sqrt(dx*dx + dy*dy);
- if(fac > brush->size) return 0;
- if(vp->flag & VP_HARD)
- alpha= 255;
- else
- alpha= 255.0*brush->alpha*(1.0-fac/brush->size);
- }
- else {
- alpha= 255.0*brush->alpha;
- }
-
if(vp->flag & VP_NORMALS) {
float *no= vert_nor+3;
- /* transpose ! */
+ /* transpose ! */
fac= vpimat[2][0]*no[0]+vpimat[2][1]*no[1]+vpimat[2][2]*no[2];
if(fac>0.0) {
dx= vpimat[0][0]*no[0]+vpimat[0][1]*no[1]+vpimat[0][2]*no[2];
dy= vpimat[1][0]*no[0]+vpimat[1][1]*no[1]+vpimat[1][2]*no[2];
- alpha*= fac/sqrt(dx*dx + dy*dy + fac*fac);
+ alpha*= fac/sqrtf(dx*dx + dy*dy + fac*fac);
}
- else return 0;
+ else return 0.f;
}
return alpha;
}
-static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *uw, float alpha, float paintval)
+static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *uw, float alpha, float paintval, int flip)
{
Brush *brush = paint_brush(&wp->paint);
+ int mode = wp->mode;
if(dw==NULL || uw==NULL) return;
- if(wp->mode==VP_MIX || wp->mode==VP_BLUR)
+ if (flip) {
+ switch(mode) {
+ case VP_MIX:
+ paintval = 1.f - paintval; break;
+ case VP_ADD:
+ mode= VP_SUB; break;
+ case VP_SUB:
+ mode= VP_ADD; break;
+ case VP_LIGHTEN:
+ mode= VP_DARKEN; break;
+ case VP_DARKEN:
+ mode= VP_LIGHTEN; break;
+ }
+ }
+
+ if(mode==VP_MIX || mode==VP_BLUR)
dw->weight = paintval*alpha + dw->weight*(1.0-alpha);
- else if(wp->mode==VP_ADD)
+ else if(mode==VP_ADD)
dw->weight += paintval*alpha;
- else if(wp->mode==VP_SUB)
+ else if(mode==VP_SUB)
dw->weight -= paintval*alpha;
- else if(wp->mode==VP_MUL)
+ else if(mode==VP_MUL)
/* first mul, then blend the fac */
dw->weight = ((1.0-alpha) + alpha*paintval)*dw->weight;
- else if(wp->mode==VP_LIGHTEN) {
+ else if(mode==VP_LIGHTEN) {
if (dw->weight < paintval)
dw->weight = paintval*alpha + dw->weight*(1.0-alpha);
- } else if(wp->mode==VP_DARKEN) {
+ } else if(mode==VP_DARKEN) {
if (dw->weight > paintval)
dw->weight = paintval*alpha + dw->weight*(1.0-alpha);
}
@@ -808,21 +826,21 @@
float testw=0.0f;
alpha= brush->alpha;
- if(wp->mode==VP_MIX || wp->mode==VP_BLUR)
+ if(mode==VP_MIX || mode==VP_BLUR)
testw = paintval*alpha + uw->weight*(1.0-alpha);
- else if(wp->mode==VP_ADD)
+ else if(mode==VP_ADD)
testw = uw->weight + paintval*alpha;
- else if(wp->mode==VP_SUB)
+ else if(mode==VP_SUB)
testw = uw->weight - paintval*alpha;
- else if(wp->mode==VP_MUL)
+ else if(mode==VP_MUL)
/* first mul, then blend the fac */
testw = ((1.0-alpha) + alpha*paintval)*uw->weight;
- else if(wp->mode==VP_LIGHTEN) {
+ else if(mode==VP_LIGHTEN) {
if (uw->weight < paintval)
testw = paintval*alpha + uw->weight*(1.0-alpha);
else
testw = uw->weight;
- } else if(wp->mode==VP_DARKEN) {
+ } else if(mode==VP_DARKEN) {
if (uw->weight > paintval)
testw = paintval*alpha + uw->weight*(1.0-alpha);
else
@@ -1023,7 +1041,7 @@
}
static void do_weight_paint_vertex(VPaint *wp, Object *ob, int index,
- int alpha, float paintweight,
+ float alpha, float paintweight, int flip,
int vgroup_mirror, char *validmap)
{
Mesh *me= ob->data;
@@ -1041,7 +1059,7 @@
if(dw==NULL || uw==NULL)
return;
- wpaint_blend(wp, dw, uw, (float)alpha/255.0, paintweight);
+ wpaint_blend(wp, dw, uw, alpha, paintweight, flip);
do_weight_paint_auto_normalize(me->dvert+index, vgroup, validmap);
if(me->editflag & ME_EDIT_MIRROR_X) { /* x mirror painting */
@@ -1423,8 +1441,9 @@
float mat[4][4];
float paintweight= ts->vgroup_weight;
int *indexar= wpd->indexar;
- int totindex, index, alpha, totw;
- float mval[2];
+ int totindex, index, totw, flip;
+ float alpha;
+ float mval[2], pressure;
view3d_operator_needs_opengl(C);
@@ -1433,6 +1452,8 @@
wmGetSingleMatrix(mat);
wmLoadMatrix(wpd->vc.rv3d->viewmat);
+ flip = RNA_boolean_get(itemptr, "flip");
+ pressure = RNA_float_get(itemptr, "pressure");
RNA_float_get_array(itemptr, "mouse", mval);
mval[0]-= vc->ar->winrct.xmin;
mval[1]-= vc->ar->winrct.ymin;
@@ -1457,7 +1478,7 @@
if(mface->mat_nr!=ob->actcol-1) {
indexar[index]= 0;
}
- }
+ }
}
}
@@ -1519,30 +1540,30 @@
MFace *mface= me->mface + (indexar[index]-1);
if((me->dvert+mface->v1)->flag) {
- alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v1, mval);
+ alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v1, mval, pressure);
if(alpha) {
do_weight_paint_vertex(wp, ob, mface->v1,
- alpha, paintweight, wpd->vgroup_mirror,
+ alpha, paintweight, flip, wpd->vgroup_mirror,
wpd->vgroup_validmap);
}
(me->dvert+mface->v1)->flag= 0;
}
if((me->dvert+mface->v2)->flag) {
- alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v2, mval);
+ alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v2, mval, pressure);
if(alpha) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list