diff --git a/source/blender/include/BDR_editobject.h b/source/blender/include/BDR_editobject.h index 4a175728d99..f3af74d1c24 100644 --- a/source/blender/include/BDR_editobject.h +++ b/source/blender/include/BDR_editobject.h @@ -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); diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 63dadb6e6c1..102d77dbc07 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -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"); } diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 4589af745a1..ad42225f40b 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -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")) { diff --git a/source/blender/src/toolbox.c b/source/blender/src/toolbox.c index 70e5012b9c6..4ce4045a170 100644 --- a/source/blender/src/toolbox.c +++ b/source/blender/src/toolbox.c @@ -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); }