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
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-05-10 16:33:15 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-05-10 16:33:15 +0400
commit0bc5855e5d4c8ff1af74d73784ef9f99518a9fed (patch)
treedf3535240a966ea2ca0c0c042a7405448fe9e448 /source/blender/src/editdeform.c
parent639ea26638673f322882dcefc5559b86c2eff6c0 (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.
Diffstat (limited to 'source/blender/src/editdeform.c')
-rw-r--r--source/blender/src/editdeform.c68
1 files changed, 68 insertions, 0 deletions
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--;