diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-05-10 16:33:15 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-05-10 16:33:15 +0400 |
commit | 0bc5855e5d4c8ff1af74d73784ef9f99518a9fed (patch) | |
tree | df3535240a966ea2ca0c0c042a7405448fe9e448 | |
parent | 639ea26638673f322882dcefc5559b86c2eff6c0 (diff) |
Fix for second part of bug #11107: physics systems were referring to
vertex groups with a number, but this got out of sync if any vertex
group was deleted, now it properly updates it.
-rw-r--r-- | source/blender/makesdna/DNA_particle_types.h | 2 | ||||
-rw-r--r-- | source/blender/src/editdeform.c | 68 |
2 files changed, 69 insertions, 1 deletions
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index e5f781a3365..baf8de62b7f 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -199,7 +199,7 @@ typedef struct ParticleSystem{ char bb_uvname[3][32]; /* billboard uv name */ /* if you change these remember to update array lengths to PSYS_TOT_VG! */ - short vgroup[11], vg_neg, rt3[2]; /* vertex groups */ + short vgroup[12], vg_neg, rt3; /* vertex groups */ /* temporary storage during render */ void *renderdata; diff --git a/source/blender/src/editdeform.c b/source/blender/src/editdeform.c index a072898327f..5de4c6ed23c 100644 --- a/source/blender/src/editdeform.c +++ b/source/blender/src/editdeform.c @@ -33,11 +33,15 @@ #include "MEM_guardedalloc.h" +#include "DNA_cloth_types.h" #include "DNA_curve_types.h" #include "DNA_lattice_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_object_force.h" +#include "DNA_particle_types.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" @@ -256,6 +260,66 @@ void duplicate_defgroup ( Object *ob ) } } +static void del_defgroup_update_users(Object *ob, int id) +{ + ExplodeModifierData *emd; + ModifierData *md; + ParticleSystem *psys; + ClothModifierData *clmd; + ClothSimSettings *clsim; + int a; + + /* these cases don't use names to refer to vertex groups, so when + * they get deleted the numbers get out of synce, this corrects that */ + + if(ob->soft) { + if(ob->soft->vertgroup == id) + ob->soft->vertgroup= 0; + else if(ob->soft->vertgroup > id) + ob->soft->vertgroup--; + } + + for(md=ob->modifiers.first; md; md=md->next) { + if(md->type == eModifierType_Explode) { + emd= (ExplodeModifierData*)md; + + if(emd->vgroup == id) + emd->vgroup= 0; + else if(emd->vgroup > id) + emd->vgroup--; + } + else if(md->type == eModifierType_Cloth) { + clmd= (ClothModifierData*)md; + clsim= clmd->sim_parms; + + if(clsim) { + if(clsim->vgroup_mass == id) + clsim->vgroup_mass= 0; + else if(clsim->vgroup_mass > id) + clsim->vgroup_mass--; + + if(clsim->vgroup_bend == id) + clsim->vgroup_bend= 0; + else if(clsim->vgroup_bend > id) + clsim->vgroup_bend--; + + if(clsim->vgroup_struct == id) + clsim->vgroup_struct= 0; + else if(clsim->vgroup_struct > id) + clsim->vgroup_struct--; + } + } + } + + for(psys=ob->particlesystem.first; psys; psys=psys->next) { + for(a=0; a<PSYS_TOT_VG; a++) + if(psys->vgroup[a] == id) + psys->vgroup[a]= 0; + else if(psys->vgroup[a] > id) + psys->vgroup[a]--; + } +} + void del_defgroup_in_object_mode ( Object *ob ) { bDeformGroup *dg; @@ -291,6 +355,8 @@ void del_defgroup_in_object_mode ( Object *ob ) } } + del_defgroup_update_users(ob, ob->actdef); + /* Update the active deform index if necessary */ if (ob->actdef == BLI_countlist(&ob->defbase)) ob->actdef--; @@ -348,6 +414,8 @@ void del_defgroup (Object *ob) } } + del_defgroup_update_users(ob, ob->actdef); + /* Update the active deform index if necessary */ if (ob->actdef==BLI_countlist(&ob->defbase)) ob->actdef--; |