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:
Diffstat (limited to 'source/blender/blenkernel/intern/curve.c')
-rw-r--r--source/blender/blenkernel/intern/curve.c135
1 files changed, 69 insertions, 66 deletions
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 67e988249f5..b374727b87c 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -30,6 +30,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenkernel/intern/curve.c
+ * \ingroup bke
+ */
+
+
#include <math.h> // floor
#include <string.h>
#include <stdlib.h>
@@ -329,19 +334,19 @@ void tex_space_curve(Curve *cu)
cu->size[1]= (max[1]-min[1])/2.0f;
cu->size[2]= (max[2]-min[2])/2.0f;
- cu->rot[0]= cu->rot[1]= cu->rot[2]= 0.0;
+ cu->rot[0]= cu->rot[1]= cu->rot[2]= 0.0f;
- if(cu->size[0]==0.0) cu->size[0]= 1.0;
- else if(cu->size[0]>0.0 && cu->size[0]<0.00001) cu->size[0]= 0.00001;
- else if(cu->size[0]<0.0 && cu->size[0]> -0.00001) cu->size[0]= -0.00001;
+ if(cu->size[0]==0.0f) cu->size[0]= 1.0f;
+ else if(cu->size[0]>0.0f && cu->size[0]<0.00001f) cu->size[0]= 0.00001f;
+ else if(cu->size[0]<0.0f && cu->size[0]> -0.00001f) cu->size[0]= -0.00001f;
- if(cu->size[1]==0.0) cu->size[1]= 1.0;
- else if(cu->size[1]>0.0 && cu->size[1]<0.00001) cu->size[1]= 0.00001;
- else if(cu->size[1]<0.0 && cu->size[1]> -0.00001) cu->size[1]= -0.00001;
+ if(cu->size[1]==0.0f) cu->size[1]= 1.0f;
+ else if(cu->size[1]>0.0f && cu->size[1]<0.00001f) cu->size[1]= 0.00001f;
+ else if(cu->size[1]<0.0f && cu->size[1]> -0.00001f) cu->size[1]= -0.00001f;
- if(cu->size[2]==0.0) cu->size[2]= 1.0;
- else if(cu->size[2]>0.0 && cu->size[2]<0.00001) cu->size[2]= 0.00001;
- else if(cu->size[2]<0.0 && cu->size[2]> -0.00001) cu->size[2]= -0.00001;
+ if(cu->size[2]==0.0f) cu->size[2]= 1.0f;
+ else if(cu->size[2]>0.0f && cu->size[2]<0.00001f) cu->size[2]= 0.00001f;
+ else if(cu->size[2]<0.0f && cu->size[2]> -0.00001f) cu->size[2]= -0.00001f;
}
}
@@ -586,7 +591,7 @@ static void calcknots(float *knots, short aantal, short order, short type)
k= 0.0;
for(a=1;a<=t;a++) {
knots[a-1]= k;
- if(a>=order && a<=aantal) k+= 1.0;
+ if(a>=order && a<=aantal) k+= 1.0f;
}
}
else if(type==2) {
@@ -594,15 +599,15 @@ static void calcknots(float *knots, short aantal, short order, short type)
if(order==4) {
k= 0.34;
for(a=0;a<t;a++) {
- knots[a]= (float)floor(k);
- k+= (1.0/3.0);
+ knots[a]= floorf(k);
+ k+= (1.0f/3.0f);
}
}
else if(order==3) {
- k= 0.6;
+ k= 0.6f;
for(a=0;a<t;a++) {
- if(a>=order && a<=aantal) k+= (0.5);
- knots[a]= (float)floor(k);
+ if(a>=order && a<=aantal) k+= 0.5f;
+ knots[a]= floorf(k);
}
}
else {
@@ -626,7 +631,7 @@ static void makecyclicknots(float *knots, short pnts, short order)
for(a=1; a<order2; a++) {
if(knots[b]!= knots[b-a]) break;
}
- if(a==order2) knots[pnts+order-2]+= 1.0;
+ if(a==order2) knots[pnts+order-2]+= 1.0f;
}
b= order;
@@ -718,12 +723,12 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas
if(i2+j>= orderpluspnts) i2= opp2-j;
for(i= i1; i<=i2; i++) {
- if(basis[i]!=0.0)
+ if(basis[i]!=0.0f)
d= ((t-knots[i])*basis[i]) / (knots[i+j-1]-knots[i]);
else
- d= 0.0;
+ d= 0.0f;
- if(basis[i+1]!=0.0)
+ if(basis[i+1] != 0.0f)
e= ((knots[i+j]-t)*basis[i+1]) / (knots[i+j]-knots[i+1]);
else
e= 0.0;
@@ -736,7 +741,7 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas
*end= 0;
for(i=i1; i<=i2; i++) {
- if(basis[i]>0.0) {
+ if(basis[i] > 0.0f) {
*end= i;
if(*start==1000) *start= i;
}
@@ -778,7 +783,7 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int
i= nu->pntsu*nu->pntsv;
ratcomp=0;
while(i--) {
- if(bp->vec[3]!=1.0) {
+ if(bp->vec[3] != 1.0f) {
ratcomp= 1;
break;
}
@@ -884,7 +889,7 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int
}
else bp++;
- if(*fp!=0.0) {
+ if(*fp != 0.0f) {
in[0]+= (*fp) * bp->vec[0];
in[1]+= (*fp) * bp->vec[1];
in[2]+= (*fp) * bp->vec[2];
@@ -960,7 +965,7 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu
*fp= basisu[i]*bp->vec[3];
sumdiv+= *fp;
}
- if(sumdiv!=0.0) if(sumdiv<0.999 || sumdiv>1.001) {
+ if(sumdiv != 0.0f) if(sumdiv < 0.999f || sumdiv > 1.001f) {
/* is normalizing needed? */
fp= sum;
for(i= istart; i<=iend; i++, fp++) {
@@ -976,7 +981,7 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu
if(i>=nu->pntsu) bp= nu->bp+(i - nu->pntsu);
else bp++;
- if(*fp!=0.0) {
+ if(*fp != 0.0f) {
coord_fp[0]+= (*fp) * bp->vec[0];
coord_fp[1]+= (*fp) * bp->vec[1];
@@ -1260,7 +1265,7 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
if (cu->bevobj->type!=OB_CURVE) return;
bevcu= cu->bevobj->data;
- if(bevcu->ext1==0.0 && bevcu->ext2==0.0) {
+ if(bevcu->ext1==0.0f && bevcu->ext2==0.0f) {
ListBase bevdisp= {NULL, NULL};
facx= cu->bevobj->size[0];
facy= cu->bevobj->size[1];
@@ -1301,10 +1306,10 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
freedisplist(&bevdisp);
}
}
- else if(cu->ext1==0.0 && cu->ext2==0.0) {
+ else if(cu->ext1==0.0f && cu->ext2==0.0f) {
;
}
- else if(cu->ext2==0.0) {
+ else if(cu->ext2==0.0f) {
dl= MEM_callocN(sizeof(DispList), "makebevelcurve2");
dl->verts= MEM_mallocN(2*3*sizeof(float), "makebevelcurve2");
BLI_addtail(disp, dl);
@@ -1333,13 +1338,13 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
/* a circle */
fp= dl->verts;
- dangle= (2.0f*M_PI/(nr));
+ dangle= (2.0f*(float)M_PI/(nr));
angle= -(nr-1)*dangle;
for(a=0; a<nr; a++) {
fp[0]= 0.0;
- fp[1]= (float)(cos(angle)*(cu->ext2));
- fp[2]= (float)(sin(angle)*(cu->ext2)) - cu->ext1;
+ fp[1]= (cosf(angle)*(cu->ext2));
+ fp[2]= (sinf(angle)*(cu->ext2)) - cu->ext1;
angle+= dangle;
fp+= 3;
}
@@ -1370,15 +1375,15 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
for(a=0; a<nr; a++) {
fp[0]= 0.0;
- fp[1]= (float)(cos(angle)*(cu->ext2));
- fp[2]= (float)(sin(angle)*(cu->ext2)) - cu->ext1;
+ fp[1]= (float)(cosf(angle)*(cu->ext2));
+ fp[2]= (float)(sinf(angle)*(cu->ext2)) - cu->ext1;
angle+= dangle;
fp+= 3;
}
}
/* part 2, sidefaces */
- if(cu->ext1!=0.0) {
+ if(cu->ext1!=0.0f) {
nr= 2;
dl= MEM_callocN(sizeof(DispList), "makebevelcurve p2");
@@ -1428,8 +1433,8 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
for(a=0; a<nr; a++) {
fp[0]= 0.0;
- fp[1]= (float)(cos(angle)*(cu->ext2));
- fp[2]= (float)(sin(angle)*(cu->ext2)) + cu->ext1;
+ fp[1]= (float)(cosf(angle)*(cu->ext2));
+ fp[2]= (float)(sinf(angle)*(cu->ext2)) + cu->ext1;
angle+= dangle;
fp+= 3;
}
@@ -1448,7 +1453,7 @@ static int cu_isectLL(float *v1, float *v2, float *v3, float *v4, short cox, sho
float deler;
deler= (v1[cox]-v2[cox])*(v3[coy]-v4[coy])-(v3[cox]-v4[cox])*(v1[coy]-v2[coy]);
- if(deler==0.0) return -1;
+ if(deler==0.0f) return -1;
*labda= (v1[coy]-v3[coy])*(v3[cox]-v4[cox])-(v1[cox]-v3[cox])*(v3[coy]-v4[coy]);
*labda= -(*labda/deler);
@@ -1463,8 +1468,8 @@ static int cu_isectLL(float *v1, float *v2, float *v3, float *v4, short cox, sho
vec[cox]= *labda*(v2[cox]-v1[cox])+v1[cox];
vec[coy]= *labda*(v2[coy]-v1[coy])+v1[coy];
- if(*labda>=0.0 && *labda<=1.0 && *mu>=0.0 && *mu<=1.0) {
- if(*labda==0.0 || *labda==1.0 || *mu==0.0 || *mu==1.0) return 1;
+ if(*labda>=0.0f && *labda<=1.0f && *mu>=0.0f && *mu<=1.0f) {
+ if(*labda==0.0f || *labda==1.0f || *mu==0.0f || *mu==1.0f) return 1;
return 2;
}
return 0;
@@ -1509,7 +1514,7 @@ static short bevelinside(BevList *bl1,BevList *bl2)
/* if lab==0.0 or lab==1.0 then the edge intersects exactly a transition
only allow for one situation: we choose lab= 1.0
*/
- if(mode>=0 && lab!=0.0) {
+ if(mode >= 0 && lab != 0.0f) {
if(vec[0]<hvec1[0]) links++;
else rechts++;
}
@@ -1547,8 +1552,8 @@ static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *si
t01= (float)sqrt(x1*x1+y1*y1);
t02= (float)sqrt(x2*x2+y2*y2);
- if(t01==0.0) t01= 1.0;
- if(t02==0.0) t02= 1.0;
+ if(t01==0.0f) t01= 1.0f;
+ if(t02==0.0f) t02= 1.0f;
x1/=t01;
y1/=t01;
@@ -1560,7 +1565,7 @@ static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *si
else t02= (saacos(t02))/2.0f;
t02= (float)sin(t02);
- if(t02==0.0) t02= 1.0;
+ if(t02==0.0f) t02= 1.0f;
x3= x1-x2;
y3= y1-y2;
@@ -1697,7 +1702,7 @@ static void bevel_list_flip_tangents(BevList *bl)
nr= bl->nr;
while(nr--) {
- if(RAD2DEG(angle_v2v2(bevp0->tan, bevp1->tan)) > 90)
+ if(RAD2DEGF(angle_v2v2(bevp0->tan, bevp1->tan)) > 90.0f)
negate_v3(bevp1->tan);
bevp0= bevp1;
@@ -1708,13 +1713,12 @@ static void bevel_list_flip_tangents(BevList *bl)
/* apply user tilt */
static void bevel_list_apply_tilt(BevList *bl)
{
- BevPoint *bevp2, *bevp1, *bevp0;
+ BevPoint *bevp2, *bevp1;
int nr;
float q[4];
bevp2= (BevPoint *)(bl+1);
bevp1= bevp2+(bl->nr-1);
- bevp0= bevp1-1;
nr= bl->nr;
while(nr--) {
@@ -1722,7 +1726,6 @@ static void bevel_list_apply_tilt(BevList *bl)
mul_qt_qtqt(bevp1->quat, q, bevp1->quat);
normalize_qt(bevp1->quat);
- bevp0= bevp1;
bevp1= bevp2;
bevp2++;
}
@@ -1887,7 +1890,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
/* flip rotation if needs be */
cross_v3_v3v3(cross_tmp, vec_1, vec_2);
normalize_v3(cross_tmp);
- if(angle_normalized_v3v3(bevp_first->dir, cross_tmp) < 90/(180.0/M_PI))
+ if(angle_normalized_v3v3(bevp_first->dir, cross_tmp) < 90.0f/(float)(180.0/M_PI))
angle = -angle;
bevp2= (BevPoint *)(bl+1);
@@ -2281,7 +2284,7 @@ void makeBevelList(Object *ob)
inp= (bevp1->vec[0]- bevp0->vec[0]) * (bevp0->vec[1]- bevp2->vec[1]) + (bevp0->vec[1]- bevp1->vec[1]) * (bevp0->vec[0]- bevp2->vec[0]);
- if(inp>0.0) sd->dir= 1;
+ if(inp > 0.0f) sd->dir= 1;
else sd->dir= 0;
sd++;
@@ -2481,11 +2484,11 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
if(mode==2 && next && prev) { // keep horizontal if extrema
float ydiff1= prev->vec[1][1] - bezt->vec[1][1];
float ydiff2= next->vec[1][1] - bezt->vec[1][1];
- if( (ydiff1<=0.0 && ydiff2<=0.0) || (ydiff1>=0.0 && ydiff2>=0.0) ) {
+ if( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) {
bezt->vec[0][1]= bezt->vec[1][1];
}
else { // handles should not be beyond y coord of two others
- if(ydiff1<=0.0) {
+ if(ydiff1 <= 0.0f) {
if(prev->vec[1][1] > bezt->vec[0][1]) {
bezt->vec[0][1]= prev->vec[1][1];
leftviolate= 1;
@@ -2509,11 +2512,11 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
if(mode==2 && next && prev) { // keep horizontal if extrema
float ydiff1= prev->vec[1][1] - bezt->vec[1][1];
float ydiff2= next->vec[1][1] - bezt->vec[1][1];
- if( (ydiff1<=0.0 && ydiff2<=0.0) || (ydiff1>=0.0 && ydiff2>=0.0) ) {
+ if( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) {
bezt->vec[2][1]= bezt->vec[1][1];
}
else { // handles should not be beyond y coord of two others
- if(ydiff1<=0.0) {
+ if(ydiff1 <= 0.0f) {
if(next->vec[1][1] < bezt->vec[2][1]) {
bezt->vec[2][1]= next->vec[1][1];
rightviolate= 1;
@@ -2554,17 +2557,17 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
}
if(bezt->h1==HD_VECT) { /* vector */
- dx/=3.0;
- dy/=3.0;
- dz/=3.0;
+ dx/=3.0f;
+ dy/=3.0f;
+ dz/=3.0f;
*(p2-3)= *p2-dx;
*(p2-2)= *(p2+1)-dy;
*(p2-1)= *(p2+2)-dz;
}
if(bezt->h2==HD_VECT) {
- dx1/=3.0;
- dy1/=3.0;
- dz1/=3.0;
+ dx1/=3.0f;
+ dy1/=3.0f;
+ dz1/=3.0f;
*(p2+3)= *p2+dx1;
*(p2+4)= *(p2+1)+dy1;
*(p2+5)= *(p2+2)+dz1;
@@ -2572,8 +2575,8 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
len2= len_v3v3(p2, p2+3);
len1= len_v3v3(p2, p2-3);
- if(len1==0.0) len1=1.0;
- if(len2==0.0) len2=1.0;
+ if(len1==0.0f) len1= 1.0f;
+ if(len2==0.0f) len2= 1.0f;
if(bezt->f1 & SELECT) { /* order of calculation */
if(bezt->h2==HD_ALIGN) { /* aligned */
@@ -2698,18 +2701,18 @@ void autocalchandlesNurb(Nurb *nu, int flag)
if(flag==0 || (bezt1->f1 & flag) ) {
bezt1->h1= 0;
/* distance too short: vectorhandle */
- if( len_v3v3( bezt1->vec[1], bezt0->vec[1] ) < 0.0001) {
+ if( len_v3v3( bezt1->vec[1], bezt0->vec[1] ) < 0.0001f) {
bezt1->h1= HD_VECT;
leftsmall= 1;
}
else {
/* aligned handle? */
- if(dist_to_line_v2(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001) {
+ if(dist_to_line_v2(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001f) {
align= 1;
bezt1->h1= HD_ALIGN;
}
/* or vector handle? */
- if(dist_to_line_v2(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001)
+ if(dist_to_line_v2(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001f)
bezt1->h1= HD_VECT;
}
@@ -2718,7 +2721,7 @@ void autocalchandlesNurb(Nurb *nu, int flag)
if(flag==0 || (bezt1->f3 & flag) ) {
bezt1->h2= 0;
/* distance too short: vectorhandle */
- if( len_v3v3( bezt1->vec[1], bezt2->vec[1] ) < 0.0001) {
+ if( len_v3v3( bezt1->vec[1], bezt2->vec[1] ) < 0.0001f) {
bezt1->h2= HD_VECT;
rightsmall= 1;
}
@@ -2727,7 +2730,7 @@ void autocalchandlesNurb(Nurb *nu, int flag)
if(align) bezt1->h2= HD_ALIGN;
/* or vector handle? */
- if(dist_to_line_v2(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001)
+ if(dist_to_line_v2(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001f)
bezt1->h2= HD_VECT;
}