Added two menu items to sculpt mode for controlling how much tablet pressure affects brush strength and brush size.

This commit is contained in:
Nicholas Bishop 2006-12-23 05:40:58 +00:00
parent 8dcf6c2602
commit 7f6e10ff54
3 changed files with 107 additions and 26 deletions

@ -445,6 +445,9 @@ typedef struct SculptData
char averaging; char averaging;
char draw_mode; char draw_mode;
/* Control tablet input */
char tablet_size, tablet_strength, pad[6];
} SculptData; } SculptData;
#define SCULPTREPT_DRAG 1 #define SCULPTREPT_DRAG 1

@ -4040,11 +4040,37 @@ static uiBlock *view3d_wpaintmenu(void *arg_unused)
return block; return block;
} }
void do_view3d_sculpt_inputmenu(void *arg, int event)
{
SculptData *sd= &G.scene->sculptdata;
short val;
switch(event) {
case 0:
val= sd->averaging;
if(button(&val,1,10,"Averaging:")==0) return;
sd->averaging= val;
break;
case 1:
val= sd->tablet_size;
if(button(&val,0,10,"Tablet Size:")==0) return;
sd->tablet_size= val;
break;
case 2:
val= sd->tablet_strength;
if(button(&val,0,10,"Tablet Strength:")==0) return;
sd->tablet_strength= val;
break;
}
allqueue(REDRAWBUTSEDIT, 0);
allqueue(REDRAWVIEW3D, 0);
}
void do_view3d_sculptmenu(void *arg, int event) void do_view3d_sculptmenu(void *arg, int event)
{ {
SculptData *sd= &G.scene->sculptdata; SculptData *sd= &G.scene->sculptdata;
BrushData *br= sculptmode_brush(); BrushData *br= sculptmode_brush();
short avg= sd->averaging;
switch(event) { switch(event) {
case 0: case 0:
case 1: case 1:
@ -4066,18 +4092,14 @@ void do_view3d_sculptmenu(void *arg, int event)
sd->symm_y= !sd->symm_y; break; sd->symm_y= !sd->symm_y; break;
case 11: case 11:
sd->symm_z= !sd->symm_z; break; sd->symm_z= !sd->symm_z; break;
case 12: /* Set sculptdata.averaging */ case 12:
if(button(&avg,1,10,"Averaging:")==0) return;
sd->averaging= avg;
break;
case 13:
if(G.vd) if(G.vd)
G.vd->pivot_last= !G.vd->pivot_last; G.vd->pivot_last= !G.vd->pivot_last;
break; break;
case 14: case 13:
sd->draw_mode= !sd->draw_mode; sd->draw_mode= !sd->draw_mode;
break; break;
case 15: case 14:
add_blockhandler(curarea, VIEW3D_HANDLER_OBJECT, UI_PNL_UNSTOW); add_blockhandler(curarea, VIEW3D_HANDLER_OBJECT, UI_PNL_UNSTOW);
break; break;
} }
@ -4086,7 +4108,47 @@ void do_view3d_sculptmenu(void *arg, int event)
allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWVIEW3D, 0);
} }
uiBlock *view3d_sculptmenu(void *arg_unused_so_why_have_it/*?*/) uiBlock *view3d_sculpt_inputmenu(void *arg_unused)
{
uiBlock *block;
short yco= 0, menuwidth= 120;
block= uiNewBlock(&curarea->uiblocks, "view3d_sculpt_inputmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
uiBlockSetButmFunc(block, do_view3d_sculpt_inputmenu, NULL);
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Averaging", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Tablet Size Adjust", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Tablet Strength Adjust", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 50);
return block;
}
/*static uiBlock *view3d_view_alignviewmenu(void *arg_unused)
{
block= uiNewBlock(&curarea->uiblocks, "view3d_view_alignviewmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
uiBlockSetButmFunc(block, do_view3d_view_alignviewmenu, NULL);
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center View to Cursor|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center Cursor and View All|Shift C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align Active Camera to View|Ctrl Alt NumPad 0", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
if (((G.obedit) && (G.obedit->type == OB_MESH)) || (G.f & G_FACESELECT)) {
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Top)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Front)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Side)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
} else {
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected|NumPad *", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
}
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 50);
return block;
}*/
uiBlock *view3d_sculptmenu(void *arg_unused)
{ {
uiBlock *block; uiBlock *block;
short yco= 0, menuwidth= 120; short yco= 0, menuwidth= 120;
@ -4096,12 +4158,13 @@ uiBlock *view3d_sculptmenu(void *arg_unused_so_why_have_it/*?*/)
block= uiNewBlock(&curarea->uiblocks, "view3d_sculptmenu", UI_EMBOSSP, UI_HELV, curarea->headwin); block= uiNewBlock(&curarea->uiblocks, "view3d_sculptmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
uiBlockSetButmFunc(block, do_view3d_sculptmenu, NULL); uiBlockSetButmFunc(block, do_view3d_sculptmenu, NULL);
uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Sculpt Properties|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 15, ""); uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Sculpt Properties|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 14, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, (sd->draw_mode ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Partial Redraw", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 14, ""); uiDefIconTextBlockBut(block, view3d_sculpt_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input Devices", 0, yco-=20, 120, 19, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, (sd->draw_mode ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Partial Redraw", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, "");
if(G.vd) if(G.vd)
uiDefIconTextBut(block, BUTM, 1, (G.vd->pivot_last ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Pivot last", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, ""); uiDefIconTextBut(block, BUTM, 1, (G.vd->pivot_last ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Pivot last", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Mouse averaging", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, (sd->symm_z ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Symmetry Z|Z", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, ""); uiDefIconTextBut(block, BUTM, 1, (sd->symm_z ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Symmetry Z|Z", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
uiDefIconTextBut(block, BUTM, 1, (sd->symm_y ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Symmetry Y|Y", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, ""); uiDefIconTextBut(block, BUTM, 1, (sd->symm_y ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Symmetry Y|Y", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");

@ -178,6 +178,8 @@ void sculptmode_init(Scene *sce)
sd->texscale= 100; sd->texscale= 100;
sd->texrept= SCULPTREPT_DRAG; sd->texrept= SCULPTREPT_DRAG;
sd->draw_mode= 0; sd->draw_mode= 0;
sd->tablet_size=3;
sd->tablet_strength=10;
} }
/* Free G.sculptdata->vertexusers */ /* Free G.sculptdata->vertexusers */
@ -672,6 +674,22 @@ void project(const float v[3], short p[2])
/* ===== Sculpting ===== /* ===== Sculpting =====
* *
*/ */
char brush_size()
{
const BrushData *b= sculptmode_brush();
float size= b->size;
const GHOST_TabletData *td= get_tablet_data();
if(td) {
const float size_factor= G.scene->sculptdata.tablet_size / 10.0f;
if(td->Active==1 || td->Active==2)
size*= G.scene->sculptdata.tablet_size==0?1:
(1-size_factor) + td->Pressure*size_factor;
}
return size;
}
float brush_strength(EditData *e) float brush_strength(EditData *e)
{ {
@ -682,17 +700,14 @@ float brush_strength(EditData *e)
float flip= e->flip ? -1:1; float flip= e->flip ? -1:1;
if(td) { if(td) {
switch(td->Active) { const float strength_factor= G.scene->sculptdata.tablet_strength / 10.0f;
case 1: if(td->Active==1 || td->Active==2)
pressure= td->Pressure; pressure= G.scene->sculptdata.tablet_strength==0?1:
break; (1-strength_factor) + td->Pressure*strength_factor;
case 2:
pressure= td->Pressure; /* Flip direction for eraser */
dir = -dir; if(td->Active==2)
break; dir= -dir;
default:
break;
}
} }
switch(G.scene->sculptdata.brush_type){ switch(G.scene->sculptdata.brush_type){
@ -997,7 +1012,7 @@ float tex_strength(EditData *e, float *point, const float len,const unsigned vin
void sculptmode_add_damaged_rect(EditData *e, ListBase *damaged_rects) void sculptmode_add_damaged_rect(EditData *e, ListBase *damaged_rects)
{ {
short p[2]; short p[2];
const float radius= sculptmode_brush()->size; const float radius= brush_size();
RectNode *rn= MEM_mallocN(sizeof(RectNode),"RectNode"); RectNode *rn= MEM_mallocN(sizeof(RectNode),"RectNode");
Mesh *me= get_mesh(G.scene->sculptdata.active_ob); Mesh *me= get_mesh(G.scene->sculptdata.active_ob);
unsigned i; unsigned i;
@ -1247,7 +1262,7 @@ void init_editdata(SculptData *sd, EditData *e, short *mouse, short *pr_mouse, c
modelspace coords */ modelspace coords */
e->center= unproject(mouse[0],mouse[1],mouse_depth); e->center= unproject(mouse[0],mouse[1],mouse_depth);
brush_edge_loc= unproject(mouse[0] + brush_edge_loc= unproject(mouse[0] +
sculptmode_brush()->size,mouse[1], brush_size(),mouse[1],
mouse_depth); mouse_depth);
e->size= VecLenf(&e->center.x,&brush_edge_loc.x); e->size= VecLenf(&e->center.x,&brush_edge_loc.x);