forked from bartvdbraak/blender
New behaviour for SHIFT+O (set subsurf on/off) or CTRL+0/1/2/3/4 for level.
- Now works on selection of Objects (as do allmost all hotkeys) - If multiple selected have different settings, it sets all the same - Also does subsurf settings within a dupli-group
This commit is contained in:
parent
9ab91ab361
commit
ba04e4bceb
@ -108,7 +108,7 @@ void select_select_keys(void);
|
||||
int vergbaseco(const void *a1, const void *a2);
|
||||
void auto_timeoffs(void);
|
||||
void texspace_edit(void);
|
||||
void flip_subdivison(struct Object *ob, int);
|
||||
void flip_subdivison(int);
|
||||
void mirrormenu(void);
|
||||
|
||||
|
||||
|
@ -2711,16 +2711,25 @@ void convertmenu(void)
|
||||
|
||||
/* Change subdivision properties of mesh object ob, if
|
||||
* level==-1 then toggle subsurf, else set to level.
|
||||
* *set allows to toggle multiple selections
|
||||
*/
|
||||
void flip_subdivison(Object *ob, int level)
|
||||
static void object_flip_subdivison(Object *ob, int *set, int level)
|
||||
{
|
||||
ModifierData *md = modifiers_findByType(ob, eModifierType_Subsurf);
|
||||
ModifierData *md;
|
||||
|
||||
if(ob->type!=OB_MESH)
|
||||
return;
|
||||
|
||||
md = modifiers_findByType(ob, eModifierType_Subsurf);
|
||||
|
||||
if (md) {
|
||||
SubsurfModifierData *smd = (SubsurfModifierData*) md;
|
||||
|
||||
if (level == -1) {
|
||||
if (smd->modifier.mode&(eModifierMode_Render|eModifierMode_Realtime)) {
|
||||
if(*set == -1)
|
||||
*set= smd->modifier.mode&(eModifierMode_Render|eModifierMode_Realtime);
|
||||
|
||||
if (*set) {
|
||||
smd->modifier.mode &= ~(eModifierMode_Render|eModifierMode_Realtime);
|
||||
} else {
|
||||
smd->modifier.mode |= (eModifierMode_Render|eModifierMode_Realtime);
|
||||
@ -2728,7 +2737,8 @@ void flip_subdivison(Object *ob, int level)
|
||||
} else {
|
||||
smd->levels = level;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else if(*set != 0) {
|
||||
SubsurfModifierData *smd = (SubsurfModifierData*) modifier_new(eModifierType_Subsurf);
|
||||
|
||||
BLI_addtail(&ob->modifiers, smd);
|
||||
@ -2736,14 +2746,39 @@ void flip_subdivison(Object *ob, int level)
|
||||
if (level!=-1) {
|
||||
smd->levels = level;
|
||||
}
|
||||
|
||||
if(*set == -1)
|
||||
*set= 1;
|
||||
}
|
||||
ob->recalc |= OB_RECALC_DATA;
|
||||
}
|
||||
|
||||
/* Change subdivision properties of mesh object ob, if
|
||||
* level==-1 then toggle subsurf, else set to level.
|
||||
*/
|
||||
|
||||
void flip_subdivison(int level)
|
||||
{
|
||||
Base *base;
|
||||
int set= -1;
|
||||
|
||||
for(base= G.scene->base.first; base; base= base->next) {
|
||||
if(TESTBASE(base)) {
|
||||
object_flip_subdivison(base->object, &set, level);
|
||||
if(base->object->dup_group) {
|
||||
GroupObject *go;
|
||||
for(go= base->object->dup_group->gobject.first; go; go= go->next)
|
||||
object_flip_subdivison(go->ob, &set, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
countall();
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
allqueue(REDRAWOOPS, 0);
|
||||
allqueue(REDRAWBUTSEDIT, 0);
|
||||
allqueue(REDRAWBUTSOBJECT, 0);
|
||||
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
|
||||
DAG_scene_flush_update(G.scene, screen_view3d_layers());
|
||||
|
||||
BIF_undo_push("Switch subsurf on/off");
|
||||
}
|
||||
|
@ -1195,27 +1195,21 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
|
||||
case ONEKEY:
|
||||
if(G.qual==LR_CTRLKEY) {
|
||||
if(ob && ob->type == OB_MESH) {
|
||||
flip_subdivison(ob, 1);
|
||||
}
|
||||
flip_subdivison(1);
|
||||
}
|
||||
else do_layer_buttons(0);
|
||||
break;
|
||||
|
||||
case TWOKEY:
|
||||
if(G.qual==LR_CTRLKEY) {
|
||||
if(ob && ob->type == OB_MESH) {
|
||||
flip_subdivison(ob, 2);
|
||||
}
|
||||
flip_subdivison(2);
|
||||
}
|
||||
else do_layer_buttons(1);
|
||||
break;
|
||||
|
||||
case THREEKEY:
|
||||
if(G.qual==LR_CTRLKEY) {
|
||||
if(ob && ob->type == OB_MESH) {
|
||||
flip_subdivison(ob, 3);
|
||||
}
|
||||
flip_subdivison(3);
|
||||
}
|
||||
else if ( G.qual == (LR_SHIFTKEY | LR_ALTKEY | LR_CTRLKEY) ) {
|
||||
if ( (G.obedit) && (G.obedit->type==OB_MESH) )
|
||||
@ -1226,9 +1220,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
|
||||
case FOURKEY:
|
||||
if(G.qual==LR_CTRLKEY) {
|
||||
if(ob && ob->type == OB_MESH) {
|
||||
flip_subdivison(ob, 4);
|
||||
}
|
||||
flip_subdivison(4);
|
||||
}
|
||||
else if ( G.qual == (LR_SHIFTKEY | LR_ALTKEY | LR_CTRLKEY) ) {
|
||||
if ( (G.obedit) && (G.obedit->type==OB_MESH) )
|
||||
@ -1736,9 +1728,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
}
|
||||
}
|
||||
else if((G.qual==LR_SHIFTKEY)) {
|
||||
if(ob && ob->type == OB_MESH) {
|
||||
flip_subdivison(ob, -1);
|
||||
}
|
||||
flip_subdivison(-1);
|
||||
}
|
||||
else if(G.qual==LR_ALTKEY) {
|
||||
if(okee("Clear origin")) {
|
||||
|
@ -1077,7 +1077,7 @@ static void tb_do_mesh(void *arg, int event){
|
||||
case 2: G.f ^= G_DRAWEDGES; break;
|
||||
case 3: G.f ^= G_DRAWFACES; break;
|
||||
case 4: G.f ^= G_DRAWNORMALS; break;
|
||||
case 5: flip_subdivison(OBACT, -1); break;
|
||||
case 5: flip_subdivison(-1); break;
|
||||
}
|
||||
addqueue(curarea->win, REDRAW, 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user