diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 20 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 63 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/effect.c | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/exotic.c | 23 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 8 |
7 files changed, 80 insertions, 59 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 9f5de3f34fa..ccaabbff144 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -218,12 +218,14 @@ blend_poses ( /* Do the transformation blend */ for (i=0; i<3; i++){ - if (schan->flag & POSE_LOC) + if (schan->flag) { + if (POSE_LOC) dchan->loc[i] = (dchan->loc[i]*dstweight) + (schan->loc[i]*srcweight); - if (schan->flag & POSE_SIZE) + if (POSE_SIZE) dchan->size[i] = 1.0f + ((dchan->size[i]-1.0f)*dstweight) + ((schan->size[i]-1.0f)*srcweight); - if (schan->flag & POSE_ROT) + if (POSE_ROT) dchan->quat[i+1] = (dquat[i+1]*dstweight) + (squat[i+1]*srcweight); + } } /* Do one more iteration for the quaternions only and normalize the quaternion if needed */ @@ -850,15 +852,16 @@ bPoseChannel *set_pose_channel (bPose *pose, bPoseChannel *chan){ /* Determine if an equivalent channel exists already */ for (curChan=pose->chanbase.first; curChan; curChan=curChan->next){ if (!strcmp (curChan->name, chan->name)){ - if (chan->flag & POSE_ROT) + if (chan->flag) { + if (POSE_ROT) memcpy (curChan->quat, chan->quat, sizeof(chan->quat)); - if (chan->flag & POSE_SIZE) + if (POSE_SIZE) memcpy (curChan->size, chan->size, sizeof(chan->size)); - if (chan->flag & POSE_LOC) + if (POSE_LOC) memcpy (curChan->loc, chan->loc, sizeof(chan->loc)); - if (chan->flag & PCHAN_DONE) + if (PCHAN_DONE) Mat4CpyMat4 (curChan->obmat, chan->obmat); - + } curChan->flag |= chan->flag; MEM_freeN (chan); return curChan; @@ -870,4 +873,3 @@ bPoseChannel *set_pose_channel (bPose *pose, bPoseChannel *chan){ /* If an equivalent channel doesn't exist, then don't bother setting it. */ } - diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 0fa358b30a0..afaf8b4ae66 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -70,7 +70,7 @@ void free_path(Path *path) void calc_curvepath(Object *ob) { BevList *bl; - BevPoint *bevp, *bevpn, *bevpfirst, *bevplast; + BevPoint *bevp, *bevpn, *bevpfirst, *bevplast, *tempbevp; Curve *cu; Nurb *nu; Path *path; @@ -125,9 +125,10 @@ void calc_curvepath(Object *ob) z= bevpfirst->z - bevp->z; } else { - x= (bevp+1)->x - bevp->x; - y= (bevp+1)->y - bevp->y; - z= (bevp+1)->z - bevp->z; + tempbevp = bevp+1; + x= (tempbevp)->x - bevp->x; + y= (tempbevp)->y - bevp->y; + z= (tempbevp)->z - bevp->z; } *fp= *(fp-1)+ (float)sqrt(x*x+y*y+z*z); @@ -146,10 +147,11 @@ void calc_curvepath(Object *ob) fp= dist+1; maxdist= dist+tot; fac= 1.0f/((float)path->len-1.0f); + fac = fac * path->totdist; for(a=0; a<path->len; a++) { - d= ((float)a)*fac*path->totdist; + d= ((float)a)*fac; /* we zoeken plek 'd' in het array */ while((d>= *fp) && fp<maxdist) { diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 1f0c838e816..06022977e2d 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -86,27 +86,30 @@ int cu_isectLL(float *v1, float *v2, float *v3, float *v4, old[] and new[] can be the same ! */ int copyintoExtendedArray(float *old, int oldx, int oldy, float *new, int newx, int newy) { - int x, y; + int x, y, ttt, ooo; float *oldp, *newp; + if (newx < oldx || newy < oldy) return 0; for (y = newy - 1; y >= oldy; y--) { + ttt = y * newx; for (x = newx - 1; x >= 0; x--) { - newp = new + 3 * (y * newx + x); + newp = new + 3 * (ttt + x); newp[0] = 0.0; newp[1] = 0.0; newp[2] = 0.0; } } for (; y >= 0; y--) { - + ttt = y * newx; + ooo = y * oldx; for (x = newx - 1; x >= oldx; x--) { - newp = new + 3 * (y * newx + x); + newp = new + 3 * (ttt + x); newp[0] = 0.0; newp[1] = 0.0; newp[2] = 0.0; } for (; x >= 0; x--) { - oldp = old + 3 * (y * oldx + x); - newp = new + 3 * (y * newx + x); + oldp = old + 3 * (ooo + x); + newp = new + 3 * (ttt + x); VECCOPY(newp, oldp); } } @@ -525,11 +528,13 @@ void extend_spline(float * pnts, int in, int out) { float *_pnts; double * add; - int i, j, k; + int i, j, k, in2; _pnts = pnts; add = (double*)MEM_mallocN((in)* sizeof(double), "extend_spline"); + in2 = in -1; + for (k = 3; k > 0; k--){ pnts = _pnts; @@ -540,8 +545,8 @@ void extend_spline(float * pnts, int in, int out) } /* inverse forward differencen */ - for (i = 0; i < in - 1; i++){ - for (j = in - 1; j > i; j--){ + for (i = 0; i < in2; i++){ + for (j = in2; j > i; j--){ add[j] -= add[j - 1]; } } @@ -550,7 +555,7 @@ void extend_spline(float * pnts, int in, int out) for (i = out; i > 0; i--){ *pnts = (float)(add[0]); pnts += 3; - for (j = 0; j < in - 1; j++){ + for (j = 0; j < in2; j++){ add[j] += add[j+1]; } } @@ -567,16 +572,18 @@ void calcknots(float *knots, short aantal, short order, short type) /* aantal, order, type; 0: uniform, 1: endpoints, 2: bezier */ { float k; - int a; + int a, t; + t = aantal+order; if(type==0) { - for(a=0;a<aantal+order;a++) { + + for(a=0;a<t;a++) { knots[a]= (float)a; } } else if(type==1) { k= 0.0; - for(a=1;a<=aantal+order;a++) { + for(a=1;a<=t;a++) { knots[a-1]= k; if(a>=order && a<=aantal) k+= 1.0; } @@ -584,14 +591,14 @@ void calcknots(float *knots, short aantal, short order, short type) else if(type==2) { if(order==4) { k= 0.34; - for(a=0;a<aantal+order;a++) { + for(a=0;a<t;a++) { knots[a]= (float)floor(k); k+= (1.0/3.0); } } else if(order==3) { k= 0.6; - for(a=0;a<aantal+order;a++) { + for(a=0;a<t;a++) { if(a>=order && a<=aantal) k+= (0.5); knots[a]= (float)floor(k); } @@ -602,21 +609,23 @@ void calcknots(float *knots, short aantal, short order, short type) void makecyclicknots(float *knots, short pnts, short order) /* pnts, order: aantal pnts NIET gecorrigeerd voor cyclic */ { - int a, b; + int a, b, order2, c; if(knots==0) return; + order2=order-1; /* eerst lange rijen (order -1) dezelfde knots aan uiteinde verwijderen */ if(order>2) { - b= pnts+order-1; - for(a=1; a<order-1; a++) { + b= pnts+order2; + for(a=1; a<order2; a++) { if(knots[b]!= knots[b-a]) break; } - if(a==order-1) knots[pnts+order-2]+= 1.0; + if(a==order2) knots[pnts+order-2]+= 1.0; } b= order; - for(a=pnts+order-1; a<pnts+order+order-1; a++) { + c=pnts + order + order2; + for(a=pnts+order2; a<c; a++) { knots[a]= knots[a-1]+ (knots[b]-knots[b-1]); b--; } @@ -650,23 +659,25 @@ void makeknots(Nurb *nu, short uv, short type) /* 0: uniform, 1: endpoints, 2: b void basisNurb(float t, short order, short pnts, float *knots, float *basis, int *start, int *end) { float d, e; - int i, i1 = 0, i2 = 0 ,j, orderpluspnts; + int i, i1 = 0, i2 = 0 ,j, orderpluspnts, opp2, o2; orderpluspnts= order+pnts; + opp2 = orderpluspnts-1; /* this is for float inaccuracy */ if(t < knots[0]) t= knots[0]; - else if(t > knots[orderpluspnts-1]) t= knots[orderpluspnts-1]; + else if(t > knots[opp2]) t= knots[opp2]; /* dit stuk is order '1' */ - for(i=0;i<orderpluspnts-1;i++) { + o2 = order + 1; + for(i=0;i<opp2;i++) { if(knots[i]!=knots[i+1] && t>= knots[i] && t<=knots[i+1]) { basis[i]= 1.0; - i1= i-order+1; + i1= i-o2; if(i1<0) i1= 0; i2= i; i++; - while(i<orderpluspnts-1) { + while(i<opp2) { basis[i]= 0.0; i++; } @@ -681,7 +692,7 @@ void basisNurb(float t, short order, short pnts, float *knots, float *basis, int /* dit is order 2,3,... */ for(j=2; j<=order; j++) { - if(i2+j>= orderpluspnts) i2= orderpluspnts-j-1; + if(i2+j>= orderpluspnts) i2= opp2-j; for(i= i1; i<=i2; i++) { if(basis[i]!=0.0) diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index c39ad72ecdf..bdcb17e2d54 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -435,7 +435,7 @@ void make_particle_keys(int depth, int nr, PartEff *paf, Particle *part, float * void init_mv_jit(float *jit, int num) { float *jit2, x, rad1, rad2, rad3; - int i; + int i, num2; if(num==0) return; @@ -445,7 +445,8 @@ void init_mv_jit(float *jit, int num) BLI_srand(31415926 + num); x= 0; - for(i=0; i<2*num; i+=2) { + num2 = 2 * num; + for(i=0; i<num2; i+=2) { jit[i]= x+ (float)(rad1*(0.5-BLI_drand())); jit[i+1]= ((float)i/2)/num +(float)(rad1*(0.5-BLI_drand())); diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 104b1b24efe..1359240a59a 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -891,7 +891,7 @@ static void read_inventor(char *str, struct ListBase *listb) struct IvNode *iv, *ivp, *ivn; char *maindata, *md, *cpa; float *index, *data, *fp; - int file, filelen, count, face, nr = 0; + int file, filelen, count, lll, face, nr = 0; int skipdata, ok, a, b, tot, first, colnr, coordtype, polytype, *idata; struct DispList *dl; @@ -1106,7 +1106,8 @@ static void read_inventor(char *str, struct ListBase *listb) /* tel het aantal lijnen */ tot= 0; index= iv->data[0]; - for(a=0; a<iv->datalen[0]-1; a++) { + lll = iv->datalen[0]-1; + for(a=0; a<lll; a++) { if(index[0]!= -1 && index[1]!= -1) tot++; index++; } @@ -1121,7 +1122,7 @@ static void read_inventor(char *str, struct ListBase *listb) data= (float *)(dl+1); index= iv->data[0]; - for(a=0; a<iv->datalen[0]-1; a++) { + for(a=0; a<lll; a++) { if(index[0]!= -1 && index[1]!= -1) { read_iv_index(data, ivp->data[0], index, 2, coordtype); data+= 6; @@ -1252,7 +1253,8 @@ static void read_inventor(char *str, struct ListBase *listb) } /* indices */ - for(b=0; b<index[0]-2; b++) { + lll = index[0] - 2; + for(b=0; b<lll; b++) { idata[0]= first; idata[1]= first+1; idata[2]= first+2; @@ -1287,7 +1289,8 @@ static void read_inventor(char *str, struct ListBase *listb) /* tel het aantal driehoeken */ face= 0; index= iv->data[0]; - for(a=0; a<iv->datalen[0]-2; a++) { + lll = iv->datalen[0]-2; + for(a=0; lll; a++) { if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) face++; index++; } @@ -1319,8 +1322,8 @@ static void read_inventor(char *str, struct ListBase *listb) index= iv->data[0]; idata= dl->index; first= 1; - - for(a=0; a<iv->datalen[0]-2; a++) { + lll=iv->datalen[0]-2; + for(a=0; a<lll; a++) { if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) { @@ -1364,7 +1367,8 @@ static void read_inventor(char *str, struct ListBase *listb) /* tel het aantal driehoeken */ face= 0; index= iv->data[0]; - for(a=0; a<iv->datalen[0]-2; a++) { + lll=iv->datalen[0]-2; + for(a=0; a<lll; a++) { if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) face++; index++; } @@ -1395,7 +1399,8 @@ static void read_inventor(char *str, struct ListBase *listb) index= iv->data[0]; idata= dl->index; - for(a=iv->datalen[0]-2; a>0; a--) { + lll=iv->datalen[0]-2; + for(a=lll; a>0; a--) { if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) { idata[0]= (int) index[0]; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index a6895d2a8ea..64d4ca367b2 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -280,7 +280,7 @@ void calc_latt_deform(float *co) Lattice *lt; float fu, du, u, v, w, tu[4], tv[4], tw[4]; float *fpw, *fpv, *fpu, vec[3]; - int ui, vi, wi, uu, vv, ww; + int ui, vi, wi, uu, vv, ww, end, end2; if(latticedata==0) return; @@ -329,7 +329,8 @@ void calc_latt_deform(float *co) wi= 0; } - for(ww= wi-1; ww<=wi+2; ww++) { + end = wi+2; + for(ww= wi-1; ww<=end; ww++) { w= tw[ww-wi+1]; if(w!=0.0) { @@ -339,7 +340,8 @@ void calc_latt_deform(float *co) } else fpw= latticedata; - for(vv= vi-1; vv<=vi+2; vv++) { + end2 = vi+2; + for(vv= vi-1; vv<=end; vv++) { v= w*tv[vv-vi+1]; if(v!=0.0) { diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 720d02ee7bb..b691441f099 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -463,13 +463,11 @@ void make_orco_displist_mesh(Object *ob, int subdivlvl) me->orco= MEM_mallocN(dlm->totvert*3*sizeof(float), "mesh displist orco"); - for (i=0; i<dlm->totvert; i++) { - float *fp= &me->orco[i*3]; - VECCOPY(fp, dlm->mvert[i].co); - } - for(i=0; i<dlm->totvert; i++) { float *fp= &me->orco[i*3]; + + VECCOPY(fp, dlm->mvert[i].co); + fp[0]= (fp[0]-me->loc[0])/me->size[0]; fp[1]= (fp[1]-me->loc[1])/me->size[1]; fp[2]= (fp[2]-me->loc[2])/me->size[2]; |