From 7f6e10ff54b4b9f090bc5bbe92fa54988d988934 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 23 Dec 2006 05:40:58 +0000 Subject: [PATCH] Added two menu items to sculpt mode for controlling how much tablet pressure affects brush strength and brush size. --- source/blender/makesdna/DNA_scene_types.h | 3 + source/blender/src/header_view3d.c | 89 +++++++++++++++++++---- source/blender/src/sculptmode.c | 41 +++++++---- 3 files changed, 107 insertions(+), 26 deletions(-) diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 8f3ee4e0e3f..e9fdcd8200b 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -445,6 +445,9 @@ typedef struct SculptData char averaging; char draw_mode; + + /* Control tablet input */ + char tablet_size, tablet_strength, pad[6]; } SculptData; #define SCULPTREPT_DRAG 1 diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 6b25f1a0edd..c3b5c9dc1e5 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -4040,11 +4040,37 @@ static uiBlock *view3d_wpaintmenu(void *arg_unused) 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) { SculptData *sd= &G.scene->sculptdata; BrushData *br= sculptmode_brush(); - short avg= sd->averaging; switch(event) { case 0: case 1: @@ -4066,18 +4092,14 @@ void do_view3d_sculptmenu(void *arg, int event) sd->symm_y= !sd->symm_y; break; case 11: sd->symm_z= !sd->symm_z; break; - case 12: /* Set sculptdata.averaging */ - if(button(&avg,1,10,"Averaging:")==0) return; - sd->averaging= avg; - break; - case 13: + case 12: if(G.vd) G.vd->pivot_last= !G.vd->pivot_last; break; - case 14: + case 13: sd->draw_mode= !sd->draw_mode; break; - case 15: + case 14: add_blockhandler(curarea, VIEW3D_HANDLER_OBJECT, UI_PNL_UNSTOW); break; } @@ -4086,7 +4108,47 @@ void do_view3d_sculptmenu(void *arg, int event) 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; 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); 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, ""); - 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) - 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, ICON_BLANK1, "Mouse averaging", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, ""); + 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, ""); 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_y ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Symmetry Y|Y", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, ""); diff --git a/source/blender/src/sculptmode.c b/source/blender/src/sculptmode.c index d67d7b767f6..ada194e205d 100644 --- a/source/blender/src/sculptmode.c +++ b/source/blender/src/sculptmode.c @@ -178,6 +178,8 @@ void sculptmode_init(Scene *sce) sd->texscale= 100; sd->texrept= SCULPTREPT_DRAG; sd->draw_mode= 0; + sd->tablet_size=3; + sd->tablet_strength=10; } /* Free G.sculptdata->vertexusers */ @@ -672,6 +674,22 @@ void project(const float v[3], short p[2]) /* ===== 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) { @@ -682,17 +700,14 @@ float brush_strength(EditData *e) float flip= e->flip ? -1:1; if(td) { - switch(td->Active) { - case 1: - pressure= td->Pressure; - break; - case 2: - pressure= td->Pressure; - dir = -dir; - break; - default: - break; - } + const float strength_factor= G.scene->sculptdata.tablet_strength / 10.0f; + if(td->Active==1 || td->Active==2) + pressure= G.scene->sculptdata.tablet_strength==0?1: + (1-strength_factor) + td->Pressure*strength_factor; + + /* Flip direction for eraser */ + if(td->Active==2) + dir= -dir; } 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) { short p[2]; - const float radius= sculptmode_brush()->size; + const float radius= brush_size(); RectNode *rn= MEM_mallocN(sizeof(RectNode),"RectNode"); Mesh *me= get_mesh(G.scene->sculptdata.active_ob); unsigned i; @@ -1247,7 +1262,7 @@ void init_editdata(SculptData *sd, EditData *e, short *mouse, short *pr_mouse, c modelspace coords */ e->center= unproject(mouse[0],mouse[1],mouse_depth); brush_edge_loc= unproject(mouse[0] + - sculptmode_brush()->size,mouse[1], + brush_size(),mouse[1], mouse_depth); e->size= VecLenf(&e->center.x,&brush_edge_loc.x);