Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2006-11-14 21:13:34 +0300
committerTon Roosendaal <ton@blender.org>2006-11-14 21:13:34 +0300
commitba04e4bceb6e54bc55e1c9257ce3c5c4c2ce58f0 (patch)
treeb6f21012f52fe320f61ca04e8363dbf7c397fabe /source
parent9ab91ab3616f667f39610c4e076644615d2fe632 (diff)
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
Diffstat (limited to 'source')
-rw-r--r--source/blender/include/BDR_editobject.h2
-rw-r--r--source/blender/src/editobject.c45
-rw-r--r--source/blender/src/space.c20
-rw-r--r--source/blender/src/toolbox.c2
4 files changed, 47 insertions, 22 deletions
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);
}