Index: source/blender/blenkernel/intern/colortools.c =================================================================== --- source/blender/blenkernel/intern/colortools.c (revision 10746) +++ source/blender/blenkernel/intern/colortools.c (working copy) @@ -175,6 +175,25 @@ cuma->totpoint++; } +void curvemap_resetsculptdefault(CurveMap *cuma, rctf *clipr) +{ + float width, height; + MEM_freeN(cuma->curve); + cuma->curve= MEM_callocN(4*sizeof(CurveMapPoint), "curve points"); + cuma->flag &= ~CUMA_EXTEND_EXTRAPOLATE; + cuma->totpoint= 4; + width=(clipr->xmax-clipr->xmin); + height=(clipr->ymax-clipr->ymin); + cuma->curve[0].x= clipr->xmin; + cuma->curve[0].y= clipr->ymax; + cuma->curve[1].x= width*0.2; + cuma->curve[1].y= height*0.95; + cuma->curve[2].x= width*0.8; + cuma->curve[2].y= height*0.05; + cuma->curve[3].x= clipr->xmax; + cuma->curve[3].y= clipr->ymin; +} + void curvemap_reset(CurveMap *cuma, rctf *clipr) { cuma->totpoint= 2; Index: source/blender/blenkernel/BKE_colortools.h =================================================================== --- source/blender/blenkernel/BKE_colortools.h (revision 10746) +++ source/blender/blenkernel/BKE_colortools.h (working copy) @@ -41,6 +41,7 @@ void curvemap_remove(struct CurveMap *cuma, int flag); void curvemap_insert(struct CurveMap *cuma, float x, float y); +void curvemap_resetsculptdefault(struct CurveMap *cuma, struct rctf *clipr); void curvemap_reset(struct CurveMap *cuma, struct rctf *clipr); void curvemap_sethandle(struct CurveMap *cuma, int type); Index: source/blender/makesdna/DNA_scene_types.h =================================================================== --- source/blender/makesdna/DNA_scene_types.h (revision 10746) +++ source/blender/makesdna/DNA_scene_types.h (working copy) @@ -397,6 +397,7 @@ /* Symmetry is separate from the other BrushData because the same settings are always used for all brush types */ char symm; + struct CurveMapping *cumap; } SculptData; typedef struct Scene { Index: source/blender/include/BDR_sculptmode.h =================================================================== --- source/blender/include/BDR_sculptmode.h (revision 10746) +++ source/blender/include/BDR_sculptmode.h (working copy) @@ -94,6 +94,7 @@ void sculptmode_correct_state(void); /* Interface */ +void sculptmode_draw_interface_curve(struct uiBlock *block,unsigned short cx, unsigned short cy); void sculptmode_draw_interface_tools(struct uiBlock *block,unsigned short cx, unsigned short cy); void sculptmode_draw_interface_textures(struct uiBlock *block,unsigned short cx, unsigned short cy); void sculptmode_rem_tex(void*,void*); Index: source/blender/src/buttons_editing.c =================================================================== --- source/blender/src/buttons_editing.c (revision 10746) +++ source/blender/src/buttons_editing.c (working copy) @@ -4629,14 +4629,39 @@ sculptmode_draw_interface_textures(block,0,200); } +static void sculptmode_curves_reset (void *cumap_v, void *ibuf_v) +{ + CurveMapping *cumap = cumap_v; + curvemap_resetsculptdefault(cumap->cm, &cumap->clipr); + curvemapping_changed(cumap, 0); +} + +void sculptmode_draw_interface_curve(struct uiBlock *block,unsigned short cx, unsigned short cy) +{ + uiBut *but; + rctf rect; + SculptData *sd; + + if(!G.scene) return; + sd= &G.scene->sculptdata; + rect.xmin= cx; rect.xmax= cx+210; + rect.ymin= cy-175; rect.ymax= cy; + uiBlockBeginAlign(block); + curvemap_buttons(block, sd->cumap, (char)0, B_NOP, 0, &rect); + uiBlockEndAlign(block); + uiBlockBeginAlign(block); + but=uiDefBut(block, BUT, REDRAWBUTSEDIT, "Reset", cx, cy-200, 60, 19, NULL, 0.0f, 0.0f, 0, 0, "Default curve preset"); + uiButSetFunc(but, sculptmode_curves_reset, sd->cumap, NULL); + uiBlockEndAlign(block); +} + void sculptmode_draw_interface_tools(uiBlock *block, unsigned short cx, unsigned short cy) { SculptData *sd; - uiBut *but; if(!G.scene) return; sd= &G.scene->sculptdata; - + uiBlockBeginAlign(block); uiDefBut(block,LABEL,B_NOP,"Brush",cx,cy,90,19,NULL,0,0,0,0,""); @@ -4665,7 +4690,7 @@ if(sd->brush_type!=GRAB_BRUSH) uiDefButC(block,TOG,B_NOP,"Airbrush",cx+178,cy,89,19,&sculptmode_brush()->airbrush,0,0,0,0,"Brush makes changes without waiting for the mouse to move"); cy-= 20; - but= uiDefButS(block,NUMSLI,B_NOP,"Size: ",cx,cy,268,19,&sculptmode_brush()->size,1.0,200.0,0,0,"Set brush radius in pixels"); + uiDefButS(block,NUMSLI,B_NOP,"Size: ",cx,cy,268,19,&sculptmode_brush()->size,1.0,200.0,0,0,"Set brush radius in pixels"); cy-= 20; if(sd->brush_type!=GRAB_BRUSH) uiDefButC(block,NUMSLI,B_NOP,"Strength: ",cx,cy,268,19,&sculptmode_brush()->strength,1.0,100.0,0,0,"Set brush strength"); @@ -4693,12 +4718,14 @@ char *strp; uiBut *but; + if(sd->texfade) sculptmode_draw_interface_curve(block, cx+190, cy); + uiBlockBeginAlign(block); uiDefBut(block,LABEL,B_NOP,"Common",cx,cy,80,20,0,0,0,0,0,""); cy-= 20; uiBlockBeginAlign(block); - uiDefButC(block,TOG,B_NOP, "Fade", cx,cy,80,19, &sd->texfade, 0,0,0,0,"Smooth the edges of the texture"); + uiDefButC(block,TOG,REDRAWBUTSEDIT, "Curve", cx,cy,80,19, &sd->texfade, 0,0,0,0,"Use Curve for radial brush intensity"); cy-= 20; uiDefButS(block,NUM,B_NOP, "Space", cx,cy,80,19, &sd->spacing, 0,500,20,0,"Non-zero inserts N pixels between dots"); cy-= 20; Index: source/blender/src/drawview.c =================================================================== --- source/blender/src/drawview.c (revision 10746) +++ source/blender/src/drawview.c (working copy) @@ -2258,6 +2258,7 @@ else if(G.f & G_SCULPTMODE) { uiNewPanelTitle(block, "Sculpt Properties"); sculptmode_draw_interface_tools(block,10,150); + if(G.scene->sculptdata.texfade) sculptmode_draw_interface_curve(block,320,185); } else { BoundBox *bb = NULL; Index: source/blender/src/sculptmode.c =================================================================== --- source/blender/src/sculptmode.c (revision 10746) +++ source/blender/src/sculptmode.c (working copy) @@ -53,6 +53,7 @@ #include "DNA_texture_types.h" #include "DNA_view3d_types.h" #include "DNA_userdef_types.h" +#include "DNA_color_types.h" #include "BKE_customdata.h" #include "BKE_DerivedMesh.h" @@ -66,6 +67,7 @@ #include "BKE_modifier.h" #include "BKE_texture.h" #include "BKE_utildefines.h" +#include "BKE_colortools.h" #include "BIF_editkey.h" #include "BIF_editview.h" @@ -224,6 +226,10 @@ sd->draw_flag= SCULPTDRAW_BRUSH; sd->tablet_size=3; sd->tablet_strength=10; + if(sd->cumap==NULL) { + sd->cumap= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + curvemap_resetsculptdefault(sd->cumap->cm, &sd->cumap->clipr); + } } void sculptmode_free_session(Scene *); @@ -273,6 +279,10 @@ MEM_freeN(mtex); } } + if(sd->cumap!=NULL) { + curvemapping_free(sd->cumap); + sd->cumap=NULL; + } } /* vertex_users is an array of Lists that store all the faces that use a @@ -729,10 +739,11 @@ /* Creates a smooth curve for the brush shape. This is the cos(x) curve from [0,PI] scaled to [0,len]. The range is scaled to [0,1]. */ -float simple_strength(float p, const float len) +float curve_strength(float p, const float len) { if(p > len) p= len; - return 0.5f * (cos(M_PI*p/len) + 1); + //return 0.5f * (cos(M_PI*p/len) + 1); + return curvemapping_evaluateF(G.scene->sculptdata.cumap, 0, p/len); } /* Uses symm to selectively flip any axis of a coordinate. */ @@ -873,7 +884,7 @@ } if(sd->texfade) - avg*= simple_strength(len,e->size); /* Smooth curve */ + avg*= curve_strength(len,e->size); /* Smooth curve */ return avg; } @@ -1256,7 +1267,7 @@ for(j=0; jtexfade) - pd->texdata[i*tsz+j]= simple_strength(magn,tsz/2); + pd->texdata[i*tsz+j]= curve_strength(magn,tsz/2); else pd->texdata[i*tsz+j]= magn < tsz/2 ? 1 : 0; } Index: source/blender/blenloader/intern/writefile.c =================================================================== --- source/blender/blenloader/intern/writefile.c (revision 10746) +++ source/blender/blenloader/intern/writefile.c (working copy) @@ -1365,6 +1365,8 @@ for(a=0; asculptdata.mtex[a]); + if(sce->sculptdata.cumap) + write_curvemapping(wd, sce->sculptdata.cumap); ed= sce->ed; if(ed) { Index: source/blender/blenloader/intern/readfile.c =================================================================== --- source/blender/blenloader/intern/readfile.c (revision 10746) +++ source/blender/blenloader/intern/readfile.c (working copy) @@ -3155,6 +3155,10 @@ /* SculptData textures */ for(a=0; asculptdata.mtex[a]= newdataadr(fd,sce->sculptdata.mtex[a]); + /* Sculpt intensity curve */ + sce->sculptdata.cumap= newdataadr(fd, sce->sculptdata.cumap); + if(sce->sculptdata.cumap) + direct_link_curvemapping(fd, sce->sculptdata.cumap); if(sce->ed) { ListBase *old_seqbasep= &((Editing *)sce->ed)->seqbase;