Bug in SoftBody for Curve/Surface: in some cases the edge spring array was

not initialized, like when adding a SoftBody to Object in EditMode.
This commit is contained in:
2005-11-17 12:24:29 +00:00
parent ec477f7a63
commit f0593ea8e8

View File

@@ -1089,7 +1089,14 @@ static void curve_surf_to_softbody(Object *ob, int *rcs)
{
Curve *cu= ob->data;
SoftBody *sb;
int totvert, totspring = 0;
BodyPoint *bp;
BodySpring *bs;
Nurb *nu;
BezTriple *bezt;
BPoint *bpnt;
float goalfac;
int a, curindex=0;
int totvert, totspring = 0, setgoal=0;
totvert= count_curveverts(&cu->nurb);
@@ -1102,60 +1109,60 @@ static void curve_surf_to_softbody(Object *ob, int *rcs)
/* renew ends with ob->soft with points and edges, also checks & makes ob->soft */
renew_softbody(ob, totvert, totspring, rcs);
sb= ob->soft; /* can be created in renew_softbody() */
/* set vars now */
goalfac= ABS(sb->maxgoal - sb->mingoal);
bp= sb->bpoint;
bs= sb->bspring;
/* weights from bpoints, same code used as for mesh vertices */
if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) {
BodyPoint *bp= sb->bpoint;
BodySpring *bs= sb->bspring;
Nurb *nu;
BezTriple *bezt;
BPoint *bpnt;
float goalfac= ABS(sb->maxgoal - sb->mingoal);
int a, curindex=0;
if((ob->softflag & OB_SB_GOAL) && sb->vertgroup)
setgoal= 1;
for(nu= cu->nurb.first; nu; nu= nu->next) {
if(nu->bezt) {
for(bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++, bp++, curindex+=3) {
for(nu= cu->nurb.first; nu; nu= nu->next) {
if(nu->bezt) {
for(bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++, bp+=3, curindex+=3) {
if(setgoal) {
bp->goal= sb->mingoal + bezt->weight*goalfac;
/* a little ad hoc changing the goal control to be less *sharp* */
bp->goal = (float)pow(bp->goal, 4.0f);
/* all three triples */
bp++;
bp->goal= (bp-1)->goal;
bp++;
bp->goal= (bp-1)->goal;
if(totspring) {
if(a>0) {
bs->v1= curindex-1;
bs->v2= curindex;
bs->strength= 1.0;
bs++;
}
bs->v1= curindex;
bs->v2= curindex+1;
bs->strength= 1.0;
bs++;
bs->v1= curindex+1;
bs->v2= curindex+2;
bs->strength= 1.0;
bs++;
}
(bp+1)->goal= bp->goal;
(bp+2)->goal= bp->goal;
}
}
else {
for(bpnt=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bpnt++, bp++, curindex++) {
bp->goal= sb->mingoal + bpnt->weight*goalfac;
/* a little ad hoc changing the goal control to be less *sharp* */
bp->goal = (float)pow(bp->goal, 4.0f);
if(totspring && a>0) {
if(totspring) {
if(a>0) {
bs->v1= curindex-1;
bs->v2= curindex;
bs->strength= 1.0;
bs++;
}
bs->v1= curindex;
bs->v2= curindex+1;
bs->strength= 1.0;
bs++;
bs->v1= curindex+1;
bs->v2= curindex+2;
bs->strength= 1.0;
bs++;
}
}
}
else {
for(bpnt=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bpnt++, bp++, curindex++) {
if(setgoal) {
bp->goal= sb->mingoal + bpnt->weight*goalfac;
/* a little ad hoc changing the goal control to be less *sharp* */
bp->goal = (float)pow(bp->goal, 4.0f);
}
if(totspring && a>0) {
bs->v1= curindex-1;
bs->v2= curindex;
bs->strength= 1.0;
bs++;
}
}
}