From b83f3183c0bd2000c871af6f45bf072c51545a64 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 19 Oct 2005 11:15:36 +0000 Subject: [PATCH] Overflow was possible for vertex index numbers in deformgroups, causing the table with bones in deform code not to work. Added a check for amount of Bones. (Orange bug!) --- source/blender/blenkernel/intern/armature.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 887d0dfe174..5b73505c7f6 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -667,6 +667,7 @@ void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], MDeformVert *dverts= NULL; float obinv[4][4], premat[4][4], postmat[4][4]; int use_envelope= arm->deformflag & ARM_DEF_ENVELOPE; + int numGroups= 0; /* safety for vertexgroup index overflow too */ int i; Mat4Invert(obinv, target->obmat); @@ -687,9 +688,10 @@ void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], /* get a vertex-deform-index to posechannel array */ if(arm->deformflag & ARM_DEF_VGROUP) { if (target->type==OB_MESH){ - int numGroups = BLI_countlist(&target->defbase); bDeformGroup *dg; + numGroups = BLI_countlist(&target->defbase); + dverts = ((Mesh*)target->data)->dvert; if(dverts) { defnrToPC = MEM_callocN(sizeof(*defnrToPC)*numGroups, "defnrToBone"); @@ -726,7 +728,8 @@ void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], int deformed= 0; for (j=0; jtotweight; j++){ - pchan = defnrToPC[dvert->dw[j].def_nr]; + int index= dvert->dw[j].def_nr; + pchan = indexdw[j].weight; Bone *bone= pchan->bone;