From f28516e7b02062fb8a875d87346366a896863300 Mon Sep 17 00:00:00 2001 From: Rob Haarsma Date: Wed, 7 May 2003 19:27:29 +0000 Subject: [PATCH] hotkey for changing a mesh to a subsurface and back again: shift+o hotkey for changing display resolution for subdiv: ctrl+1 or 2 or 3 or 4 written by Green --- source/blender/include/BDR_editobject.h | 1 + source/blender/src/buttons.c | 19 ++++++--- source/blender/src/editobject.c | 24 +++++++++++ source/blender/src/space.c | 56 +++++++++++++++++++++++-- 4 files changed, 92 insertions(+), 8 deletions(-) diff --git a/source/blender/include/BDR_editobject.h b/source/blender/include/BDR_editobject.h index 8eab5c3cb16..31674372466 100644 --- a/source/blender/include/BDR_editobject.h +++ b/source/blender/include/BDR_editobject.h @@ -113,6 +113,7 @@ void auto_timeoffs(void); void texspace_edit(void); void first_base(void); void make_displists_by_obdata(void *obdata); +void flip_subdivison(struct Object *ob, int); #endif /* BDR_EDITOBJECT_H */ diff --git a/source/blender/src/buttons.c b/source/blender/src/buttons.c index baf57f5d384..7d85b70cdf0 100644 --- a/source/blender/src/buttons.c +++ b/source/blender/src/buttons.c @@ -217,6 +217,7 @@ char texstr[15][8]= {"None" , "Clouds" , "Wood", #define B_LAMPREDRAW 1101 #define B_COLLAMP 1102 #define B_TEXCLEARLAMP 1103 +#define B_SBUFF 1104 /* *********************** */ #define B_MATBUTS 1300 @@ -4844,6 +4845,15 @@ void do_lampbuts(unsigned short event) BIF_preview_changed(G.buts); } break; + case B_SBUFF: + { + la= G.buts->lockpoin; + la->bufsize = la->bufsize&=(~15); + allqueue(REDRAWBUTSLAMP, 0); + allqueue(REDRAWOOPS, 0); + /*la->bufsize = la->bufsize % 64;*/ + } + break; } if(event) freefastshade(); @@ -4899,11 +4909,10 @@ void lampbuts(void) #endif uiBlockSetCol(block, BUTGREY); - uiDefButS(block, ROW,B_DIFF,"BufSi 512", 203,30,89,19, &la->bufsize,2.0,512.0, 0, 0, "Set the size of the shadow buffer"); - uiDefButS(block, ROW,B_DIFF,"768", 293,30,48,19, &la->bufsize,2.0,768.0, 0, 0, "Set the size of the shadow buffer"); - uiDefButS(block, ROW,B_DIFF,"1024", 203,10,43,19, &la->bufsize,2.0,1024.0, 0, 0, "Set the size of the shadow buffer"); - uiDefButS(block, ROW,B_DIFF,"1536", 248,10,45,19, &la->bufsize,2.0,1536.0, 0, 0, "Set the size of the shadow buffer"); - uiDefButS(block, ROW,B_DIFF,"2560", 293,10,48,19, &la->bufsize,2.0,2560.0, 0, 0, "Set the size of the shadow buffer"); + uiDefButS(block, NUM,B_SBUFF,"ShadowBuffSize:", 203,30,140,19, &la->bufsize,512,5120, 0, 0, "Set the size of the shadow buffer"); + uiDefButF(block, NUM,REDRAWVIEW3D,"ClipSta:", 346,30,146,19, &la->clipsta, 0.1*grid,1000.0*grid, 10, 0, "Set the shadow map clip start"); + uiDefButF(block, NUM,REDRAWVIEW3D,"ClipEnd:", 346,9,146,19,&la->clipend, 1.0, 5000.0*grid, 100, 0, "Set the shadow map clip end"); + uiDefButF(block, NUM,REDRAWVIEW3D,"ClipSta:", 346,30,146,19, &la->clipsta, 0.1*grid,1000.0*grid, 10, 0, "Set the shadow map clip start"); uiDefButF(block, NUM,REDRAWVIEW3D,"ClipEnd:", 346,9,146,19,&la->clipend, 1.0, 5000.0*grid, 100, 0, "Set the shadow map clip end"); diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index b4825869f37..de0f0791c42 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -1745,6 +1745,30 @@ void convertmenu(void) allqueue(REDRAWBUTSEDIT, 0); } +void flip_subdivison(Object *ob, int level) +{ + Base *base; + Mesh *me, *tme; + short i, j; + + me = ob->data; + + if (level == 0) + { + if(me->flag & ME_SUBSURF) + me->flag &= ~ME_SUBSURF; + else + me->flag |= ME_SUBSURF; + } else { + me->subdiv = level; + } + + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWOOPS, 0); + allqueue(REDRAWBUTSEDIT, 0); + makeDispList(ob); +} + void copymenu_properties(Object *ob) { bProperty *prop, *propn, *propc; diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 3e159bd989c..d934fa58f8f 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -610,12 +610,53 @@ void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) break; case ONEKEY: - do_layer_buttons(0); break; + ob= OBACT; + if(G.qual & LR_CTRLKEY) { + if(G.obedit) { + flip_subdivison(G.obedit, 1); + } + else if(ob->type == OB_MESH) { + flip_subdivison(ob, 1); + } + } + else + do_layer_buttons(0); break; case TWOKEY: - do_layer_buttons(1); break; + ob= OBACT; + if(G.qual & LR_CTRLKEY) { + if(G.obedit) { + flip_subdivison(G.obedit, 2); + } + else if(ob->type == OB_MESH) { + flip_subdivison(ob, 2); + } + } + else + do_layer_buttons(1); + break; case THREEKEY: + ob= OBACT; + if(G.qual & LR_CTRLKEY) { + if(G.obedit) { + flip_subdivison(G.obedit, 3); + } + else if(ob->type == OB_MESH) { + flip_subdivison(ob, 3); + } + } + else do_layer_buttons(2); break; case FOURKEY: + ob= OBACT; + if(G.qual & LR_CTRLKEY) { + if(G.obedit) { + flip_subdivison(G.obedit, 4); + } + else if(ob->type == OB_MESH) { + flip_subdivison(ob, 4); + } + } + else do_layer_buttons(3); break; case FIVEKEY: do_layer_buttons(4); break; @@ -860,7 +901,16 @@ void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) } break; case OKEY: - if(G.qual & LR_ALTKEY) clear_object('o'); + ob= OBACT; + if(G.qual & LR_SHIFTKEY) { + if(G.obedit) { + flip_subdivison(G.obedit, 0); + } + else if(ob->type == OB_MESH) { + flip_subdivison(ob, 0); + } + } + else if(G.qual & LR_ALTKEY) clear_object('o'); else if(G.obedit) { extern int prop_mode;