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:
@@ -1089,7 +1089,14 @@ static void curve_surf_to_softbody(Object *ob, int *rcs)
|
|||||||
{
|
{
|
||||||
Curve *cu= ob->data;
|
Curve *cu= ob->data;
|
||||||
SoftBody *sb;
|
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);
|
totvert= count_curveverts(&cu->nurb);
|
||||||
|
|
||||||
@@ -1103,27 +1110,27 @@ static void curve_surf_to_softbody(Object *ob, int *rcs)
|
|||||||
renew_softbody(ob, totvert, totspring, rcs);
|
renew_softbody(ob, totvert, totspring, rcs);
|
||||||
sb= ob->soft; /* can be created in renew_softbody() */
|
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 */
|
/* weights from bpoints, same code used as for mesh vertices */
|
||||||
if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) {
|
if((ob->softflag & OB_SB_GOAL) && sb->vertgroup)
|
||||||
BodyPoint *bp= sb->bpoint;
|
setgoal= 1;
|
||||||
BodySpring *bs= sb->bspring;
|
|
||||||
Nurb *nu;
|
|
||||||
BezTriple *bezt;
|
|
||||||
BPoint *bpnt;
|
|
||||||
float goalfac= ABS(sb->maxgoal - sb->mingoal);
|
|
||||||
int a, curindex=0;
|
|
||||||
|
|
||||||
for(nu= cu->nurb.first; nu; nu= nu->next) {
|
for(nu= cu->nurb.first; nu; nu= nu->next) {
|
||||||
if(nu->bezt) {
|
if(nu->bezt) {
|
||||||
for(bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++, bp++, curindex+=3) {
|
for(bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++, bp+=3, curindex+=3) {
|
||||||
|
if(setgoal) {
|
||||||
bp->goal= sb->mingoal + bezt->weight*goalfac;
|
bp->goal= sb->mingoal + bezt->weight*goalfac;
|
||||||
/* a little ad hoc changing the goal control to be less *sharp* */
|
/* a little ad hoc changing the goal control to be less *sharp* */
|
||||||
bp->goal = (float)pow(bp->goal, 4.0f);
|
bp->goal = (float)pow(bp->goal, 4.0f);
|
||||||
|
|
||||||
/* all three triples */
|
/* all three triples */
|
||||||
bp++;
|
(bp+1)->goal= bp->goal;
|
||||||
bp->goal= (bp-1)->goal;
|
(bp+2)->goal= bp->goal;
|
||||||
bp++;
|
}
|
||||||
bp->goal= (bp-1)->goal;
|
|
||||||
|
|
||||||
if(totspring) {
|
if(totspring) {
|
||||||
if(a>0) {
|
if(a>0) {
|
||||||
@@ -1146,10 +1153,11 @@ static void curve_surf_to_softbody(Object *ob, int *rcs)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(bpnt=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bpnt++, bp++, curindex++) {
|
for(bpnt=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bpnt++, bp++, curindex++) {
|
||||||
|
if(setgoal) {
|
||||||
bp->goal= sb->mingoal + bpnt->weight*goalfac;
|
bp->goal= sb->mingoal + bpnt->weight*goalfac;
|
||||||
/* a little ad hoc changing the goal control to be less *sharp* */
|
/* a little ad hoc changing the goal control to be less *sharp* */
|
||||||
bp->goal = (float)pow(bp->goal, 4.0f);
|
bp->goal = (float)pow(bp->goal, 4.0f);
|
||||||
|
}
|
||||||
if(totspring && a>0) {
|
if(totspring && a>0) {
|
||||||
bs->v1= curindex-1;
|
bs->v1= curindex-1;
|
||||||
bs->v2= curindex;
|
bs->v2= curindex;
|
||||||
@@ -1159,7 +1167,6 @@ static void curve_surf_to_softbody(Object *ob, int *rcs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(totspring)
|
if(totspring)
|
||||||
build_bps_springlist(ob); /* link bps to springs */
|
build_bps_springlist(ob); /* link bps to springs */
|
||||||
|
|||||||
Reference in New Issue
Block a user