diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2007-12-17 15:54:39 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2007-12-17 15:54:39 +0300 |
commit | bb6640a63cb2e1988eb5a06e6538f537c79a0711 (patch) | |
tree | 1b998151513c4054d0b602f907e46846f1222090 | |
parent | f33f7ed62a99f44df5a3c21830841504617cc9f1 (diff) |
Shift+O subdivision switching now also allows to switch
particle systems on/off if they exist.
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 2 | ||||
-rw-r--r-- | source/blender/src/buttons_editing.c | 2 | ||||
-rw-r--r-- | source/blender/src/editobject.c | 127 |
3 files changed, 94 insertions, 37 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 61ad1bd0ebf..dd56fe2df61 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2099,7 +2099,7 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], } } - for(md=first; md; md=md->next) + for(md=firstmd; md; md=md->next) modifier_freeTemporaryData(md); /* Yay, we are done. If we have a DerivedMesh and deformed vertices diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 116a2c117d2..92ee7af26cc 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -1639,7 +1639,7 @@ void modifiers_explodeFacepa(void *arg1, void *arg2) emd->flag |= eExplodeFlag_CalcFaces; } -static void modifiers_psysEnable(void *ob_v, void *md_v) +void modifiers_psysEnable(void *ob_v, void *md_v) { ParticleSystemModifierData *psmd = (ParticleSystemModifierData*) md_v; diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 193bd0f46c4..7e88c8278b5 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -2818,54 +2818,90 @@ void convertmenu(void) DAG_scene_sort(G.scene); } - /* Change subdivision properties of mesh object ob, if - * level==-1 then toggle subsurf, else set to level. - * *set allows to toggle multiple selections - */ -static void object_flip_subdivison(Object *ob, int *set, int level, int mode, int ingroup) +/* Change subdivision or particle properties of mesh object ob, if level==-1 + * then toggle subsurf, else set to level set allows to toggle multiple + * selections */ + +static void object_has_subdivision_particles(Object *ob, int *havesubdiv, int *havepart, int depth) { + if(ob->type==OB_MESH) { + if(modifiers_findByType(ob, eModifierType_Subsurf)) + *havesubdiv= 1; + if(modifiers_findByType(ob, eModifierType_ParticleSystem)) + *havepart= 1; + } + + if(ob->dup_group && depth <= 4) { + GroupObject *go; + + for(go= ob->dup_group->gobject.first; go; go= go->next) + object_has_subdivision_particles(go->ob, havesubdiv, havepart, depth+1); + } +} + +static void object_flip_subdivison_particles(Object *ob, int *set, int level, int mode, int particles, int depth) +{ + void modifiers_psysEnable(void *ob_v, void *md_v); ModifierData *md; if(ob->type==OB_MESH) { - md = modifiers_findByType(ob, eModifierType_Subsurf); - - if (md) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; - - if (level == -1) { - if(*set == -1) - *set= smd->modifier.mode&(mode); - - if (*set) { - smd->modifier.mode &= ~(mode); - } else { - smd->modifier.mode |= (mode); + if(particles) { + for(md=ob->modifiers.first; md; md=md->next) { + if(md->type == eModifierType_ParticleSystem) { + ParticleSystemModifierData *psmd = (ParticleSystemModifierData*)md; + + if(*set == -1) + *set= psmd->modifier.mode&(mode); + + if (*set) + psmd->modifier.mode &= ~(mode); + else + psmd->modifier.mode |= (mode); + + modifiers_psysEnable(ob, md); } - } else { - smd->levels = level; } - } - else if(!ingroup && *set != 0) { - SubsurfModifierData *smd = (SubsurfModifierData*) modifier_new(eModifierType_Subsurf); + } + else { + md = modifiers_findByType(ob, eModifierType_Subsurf); + + if (md) { + SubsurfModifierData *smd = (SubsurfModifierData*) md; - BLI_addtail(&ob->modifiers, smd); + if (level == -1) { + if(*set == -1) + *set= smd->modifier.mode&(mode); - if (level!=-1) { - smd->levels = level; + if (*set) + smd->modifier.mode &= ~(mode); + else + smd->modifier.mode |= (mode); + } else { + smd->levels = level; + } + } + else if(depth == 0 && *set != 0) { + SubsurfModifierData *smd = (SubsurfModifierData*) modifier_new(eModifierType_Subsurf); + + BLI_addtail(&ob->modifiers, smd); + + if (level!=-1) { + smd->levels = level; + } + + if(*set == -1) + *set= 1; } - - if(*set == -1) - *set= 1; } - ob->recalc |= OB_RECALC_DATA; + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); } - if(ob->dup_group) { + if(ob->dup_group && depth<=4) { GroupObject *go; for(go= ob->dup_group->gobject.first; go; go= go->next) - object_flip_subdivison(go->ob, set, level, mode, 1); + object_flip_subdivison_particles(go->ob, set, level, mode, particles, depth+1); } } @@ -2877,16 +2913,34 @@ void flip_subdivison(int level) { Base *base; int set= -1; - int mode; + int mode, pupmode, particles= 0, havesubdiv= 0, havepart= 0; if(G.qual & LR_ALTKEY) mode= eModifierMode_Realtime; else mode= eModifierMode_Render|eModifierMode_Realtime; + if(level == -1) { + for(base= G.scene->base.first; base; base= base->next) + if(((level==-1) && (TESTBASE(base))) || (TESTBASELIB(base))) + object_has_subdivision_particles(base->object, &havesubdiv, &havepart, 0); + } + else + havesubdiv= 1; + + if(havesubdiv && havepart) { + pupmode= pupmenu("Switch%t|Subsurf %x1|Particle Systems %x2"); + if(pupmode <= 0) + return; + else if(pupmode == 2) + particles= 1; + } + else if(havepart) + particles= 1; + for(base= G.scene->base.first; base; base= base->next) if(((level==-1) && (TESTBASE(base))) || (TESTBASELIB(base))) - object_flip_subdivison(base->object, &set, level, mode, 0); + object_flip_subdivison_particles(base->object, &set, level, mode, particles, 0); countall(); allqueue(REDRAWVIEW3D, 0); @@ -2895,7 +2949,10 @@ void flip_subdivison(int level) allqueue(REDRAWBUTSOBJECT, 0); DAG_scene_flush_update(G.scene, screen_view3d_layers()); - BIF_undo_push("Switch subsurf on/off"); + if(particles) + BIF_undo_push("Switch particles on/off"); + else + BIF_undo_push("Switch subsurf on/off"); } static void copymenu_properties(Object *ob) |