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:
authorCampbell Barton <ideasman42@gmail.com>2011-03-27 19:54:20 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-03-27 19:54:20 +0400
commit59cdbfd8849315984e280b92968d6cf1d9d44c4b (patch)
treecc5cafe931596dc98d6761d07bb766f929ef13c5 /source/blender/blenlib
parent617e6a83bc89ca36e18bd06d851a31c010e11db2 (diff)
math lib and UV project: floats were being implicitly promoted to doubles, adjust to use floats.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/math_color.c20
-rw-r--r--source/blender/blenlib/intern/math_geom.c97
-rw-r--r--source/blender/blenlib/intern/math_matrix.c26
-rw-r--r--source/blender/blenlib/intern/math_rotation.c56
-rw-r--r--source/blender/blenlib/intern/math_vector.c14
-rw-r--r--source/blender/blenlib/intern/uvproject.c18
6 files changed, 115 insertions, 116 deletions
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 8699c3664a6..85636d23f6f 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -45,9 +45,9 @@ void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b)
*b = v;
}
else {
- h= (h - floor(h))*6.0f;
+ h= (h - floorf(h))*6.0f;
- i = (int)floor(h);
+ i = (int)floorf(h);
f = h - i;
p = v*(1.0f-s);
q = v*(1.0f-(s*f));
@@ -308,11 +308,11 @@ unsigned int rgb_to_cpack(float r, float g, float b)
{
int ir, ig, ib;
- ir= (int)floor(255.0*r);
+ ir= (int)floor(255.0f*r);
if(ir<0) ir= 0; else if(ir>255) ir= 255;
- ig= (int)floor(255.0*g);
+ ig= (int)floor(255.0f*g);
if(ig<0) ig= 0; else if(ig>255) ig= 255;
- ib= (int)floor(255.0*b);
+ ib= (int)floor(255.0f*b);
if(ib<0) ib= 0; else if(ib>255) ib= 255;
return (ir+ (ig*256) + (ib*256*256));
@@ -342,9 +342,9 @@ void rgb_float_to_byte(const float *in, unsigned char *out)
{
int r, g, b;
- r= (int)(in[0] * 255.0);
- g= (int)(in[1] * 255.0);
- b= (int)(in[2] * 255.0);
+ r= (int)(in[0] * 255.0f);
+ g= (int)(in[1] * 255.0f);
+ b= (int)(in[2] * 255.0f);
out[0]= (char)((r <= 0)? 0 : (r >= 255)? 255 : r);
out[1]= (char)((g <= 0)? 0 : (g >= 255)? 255 : g);
@@ -509,8 +509,8 @@ void rgb_float_set_hue_float_offset(float rgb[3], float hue_offset)
rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
hsv[0]+= hue_offset;
- if(hsv[0]>1.0) hsv[0]-=1.0;
- else if(hsv[0]<0.0) hsv[0]+= 1.0;
+ if(hsv[0] > 1.0f) hsv[0] -= 1.0f;
+ else if(hsv[0] < 0.0f) hsv[0] += 1.0f;
hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
}
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index b0709c30494..9fa5775c6a1 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -94,12 +94,12 @@ float normal_quad_v3(float n[3], const float v1[3], const float v2[3], const flo
float area_tri_v2(const float v1[2], const float v2[2], const float v3[2])
{
- return (float)(0.5f*fabs((v1[0]-v2[0])*(v2[1]-v3[1]) + (v1[1]-v2[1])*(v3[0]-v2[0])));
+ return 0.5f * fabsf((v1[0]-v2[0])*(v2[1]-v3[1]) + (v1[1]-v2[1])*(v3[0]-v2[0]));
}
float area_tri_signed_v2(const float v1[2], const float v2[2], const float v3[2])
{
- return (float)(0.5f*((v1[0]-v2[0])*(v2[1]-v3[1]) + (v1[1]-v2[1])*(v3[0]-v2[0])));
+ return 0.5f * ((v1[0]-v2[0])*(v2[1]-v3[1]) + (v1[1]-v2[1])*(v3[0]-v2[0]));
}
float area_quad_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3]) /* only convex Quadrilaterals */
@@ -158,7 +158,7 @@ float area_poly_v3(int nr, float verts[][3], float *normal)
cur= verts[a+1];
}
- return (float)fabs(0.5*area/max);
+ return fabsf(0.5f * area / max);
}
/********************************* Distance **********************************/
@@ -174,7 +174,7 @@ float dist_to_line_v2(float *v1, float *v2, float *v3)
deler= (float)sqrt(a[0]*a[0]+a[1]*a[1]);
if(deler== 0.0f) return 0;
- return (float)(fabs((v1[0]-v2[0])*a[0]+(v1[1]-v2[1])*a[1])/deler);
+ return fabsf((v1[0]-v2[0])*a[0]+(v1[1]-v2[1])*a[1])/deler;
}
@@ -186,18 +186,18 @@ float dist_to_line_segment_v2(float *v1, float *v2, float *v3)
rc[0]= v3[0]-v2[0];
rc[1]= v3[1]-v2[1];
len= rc[0]*rc[0]+ rc[1]*rc[1];
- if(len==0.0) {
+ if(len==0.0f) {
rc[0]= v1[0]-v2[0];
rc[1]= v1[1]-v2[1];
return (float)(sqrt(rc[0]*rc[0]+ rc[1]*rc[1]));
}
labda= (rc[0]*(v1[0]-v2[0]) + rc[1]*(v1[1]-v2[1]))/len;
- if(labda<=0.0) {
+ if(labda <= 0.0f) {
pt[0]= v2[0];
pt[1]= v2[1];
}
- else if(labda>=1.0) {
+ else if(labda >= 1.0f) {
pt[0]= v3[0];
pt[1]= v3[1];
}
@@ -263,14 +263,14 @@ int isect_line_line_v2(const float *v1, const float *v2, const float *v3, const
float div, labda, mu;
div= (v2[0]-v1[0])*(v4[1]-v3[1])-(v2[1]-v1[1])*(v4[0]-v3[0]);
- if(div==0.0) return ISECT_LINE_LINE_COLINEAR;
+ if(div==0.0f) return ISECT_LINE_LINE_COLINEAR;
labda= ((float)(v1[1]-v3[1])*(v4[0]-v3[0])-(v1[0]-v3[0])*(v4[1]-v3[1]))/div;
mu= ((float)(v1[1]-v3[1])*(v2[0]-v1[0])-(v1[0]-v3[0])*(v2[1]-v1[1]))/div;
- 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 ISECT_LINE_LINE_EXACT;
+ 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 ISECT_LINE_LINE_EXACT;
return ISECT_LINE_LINE_CROSS;
}
return ISECT_LINE_LINE_NONE;
@@ -407,15 +407,15 @@ static short IsectLLPt2Df(float x0,float y0,float x1,float y1,
int isect_point_tri_v2(float pt[2], float v1[2], float v2[2], float v3[2])
{
- if (line_point_side_v2(v1,v2,pt)>=0.0) {
- if (line_point_side_v2(v2,v3,pt)>=0.0) {
- if (line_point_side_v2(v3,v1,pt)>=0.0) {
+ if (line_point_side_v2(v1,v2,pt)>=0.0f) {
+ if (line_point_side_v2(v2,v3,pt)>=0.0f) {
+ if (line_point_side_v2(v3,v1,pt)>=0.0f) {
return 1;
}
}
} else {
- if (! (line_point_side_v2(v2,v3,pt)>=0.0)) {
- if (! (line_point_side_v2(v3,v1,pt)>=0.0)) {
+ if (! (line_point_side_v2(v2,v3,pt)>=0.0f)) {
+ if (! (line_point_side_v2(v3,v1,pt)>=0.0f)) {
return -1;
}
}
@@ -426,18 +426,18 @@ int isect_point_tri_v2(float pt[2], float v1[2], float v2[2], float v3[2])
/* point in quad - only convex quads */
int isect_point_quad_v2(float pt[2], float v1[2], float v2[2], float v3[2], float v4[2])
{
- if (line_point_side_v2(v1,v2,pt)>=0.0) {
- if (line_point_side_v2(v2,v3,pt)>=0.0) {
- if (line_point_side_v2(v3,v4,pt)>=0.0) {
- if (line_point_side_v2(v4,v1,pt)>=0.0) {
+ if (line_point_side_v2(v1,v2,pt)>=0.0f) {
+ if (line_point_side_v2(v2,v3,pt)>=0.0f) {
+ if (line_point_side_v2(v3,v4,pt)>=0.0f) {
+ if (line_point_side_v2(v4,v1,pt)>=0.0f) {
return 1;
}
}
}
} else {
- if (! (line_point_side_v2(v2,v3,pt)>=0.0)) {
- if (! (line_point_side_v2(v3,v4,pt)>=0.0)) {
- if (! (line_point_side_v2(v4,v1,pt)>=0.0)) {
+ if (! (line_point_side_v2(v2,v3,pt)>=0.0f)) {
+ if (! (line_point_side_v2(v3,v4,pt)>=0.0f)) {
+ if (! (line_point_side_v2(v4,v1,pt)>=0.0f)) {
return -1;
}
}
@@ -463,21 +463,21 @@ int isect_line_tri_v3(float p1[3], float p2[3], float v0[3], float v1[3], float
cross_v3_v3v3(p, d, e2);
a = dot_v3v3(e1, p);
- if ((a > -0.000001) && (a < 0.000001)) return 0;
+ if ((a > -0.000001f) && (a < 0.000001f)) return 0;
f = 1.0f/a;
sub_v3_v3v3(s, p1, v0);
u = f * dot_v3v3(s, p);
- if ((u < 0.0)||(u > 1.0)) return 0;
+ if ((u < 0.0f)||(u > 1.0f)) return 0;
cross_v3_v3v3(q, s, e1);
v = f * dot_v3v3(d, q);
- if ((v < 0.0)||((u + v) > 1.0)) return 0;
+ if ((v < 0.0f)||((u + v) > 1.0f)) return 0;
*lambda = f * dot_v3v3(e2, q);
- if ((*lambda < 0.0)||(*lambda > 1.0)) return 0;
+ if ((*lambda < 0.0f)||(*lambda > 1.0f)) return 0;
if(uv) {
uv[0]= u;
@@ -503,21 +503,21 @@ int isect_ray_tri_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2
a = dot_v3v3(e1, p);
/* note: these values were 0.000001 in 2.4x but for projection snapping on
* a human head (1BU==1m), subsurf level 2, this gave many errors - campbell */
- if ((a > -0.00000001) && (a < 0.00000001)) return 0;
+ if ((a > -0.00000001f) && (a < 0.00000001f)) return 0;
f = 1.0f/a;
sub_v3_v3v3(s, p1, v0);
u = f * dot_v3v3(s, p);
- if ((u < 0.0)||(u > 1.0)) return 0;
-
+ if ((u < 0.0f)||(u > 1.0f)) return 0;
+
cross_v3_v3v3(q, s, e1);
v = f * dot_v3v3(d, q);
- if ((v < 0.0)||((u + v) > 1.0)) return 0;
+ if ((v < 0.0f)||((u + v) > 1.0f)) return 0;
*lambda = f * dot_v3v3(e2, q);
- if ((*lambda < 0.0)) return 0;
+ if ((*lambda < 0.0f)) return 0;
if(uv) {
uv[0]= u;
@@ -572,14 +572,14 @@ int isect_ray_tri_threshold_v3(float p1[3], float d[3], float v0[3], float v1[3]
cross_v3_v3v3(p, d, e2);
a = dot_v3v3(e1, p);
- if ((a > -0.000001) && (a < 0.000001)) return 0;
+ if ((a > -0.000001f) && (a < 0.000001f)) return 0;
f = 1.0f/a;
sub_v3_v3v3(s, p1, v0);
cross_v3_v3v3(q, s, e1);
*lambda = f * dot_v3v3(e2, q);
- if ((*lambda < 0.0)) return 0;
+ if ((*lambda < 0.0f)) return 0;
u = f * dot_v3v3(s, p);
v = f * dot_v3v3(d, q);
@@ -673,10 +673,9 @@ int isect_sweeping_sphere_tri_v3(float p1[3], float p2[3], float radius, float v
a=dot_v3v3(p1,nor)-dot_v3v3(v0,nor);
nordotv=dot_v3v3(nor,vel);
- if (fabs(nordotv) < 0.000001)
+ if (fabsf(nordotv) < 0.000001f)
{
- if(fabs(a)>=radius)
- {
+ if(fabsf(a) >= radius) {
return 0;
}
}
@@ -870,25 +869,25 @@ int isect_axial_line_tri_v3(int axis, float p1[3], float p2[3], float v0[3], flo
sub_v3_v3v3(p,v0,p1);
f= (e2[a1]*e1[a2]-e2[a2]*e1[a1]);
- if ((f > -0.000001) && (f < 0.000001)) return 0;
+ if ((f > -0.000001f) && (f < 0.000001f)) return 0;
v= (p[a2]*e1[a1]-p[a1]*e1[a2])/f;
- if ((v < 0.0)||(v > 1.0)) return 0;
+ if ((v < 0.0f)||(v > 1.0f)) return 0;
f= e1[a1];
- if((f > -0.000001) && (f < 0.000001)){
+ if((f > -0.000001f) && (f < 0.000001f)){
f= e1[a2];
- if((f > -0.000001) && (f < 0.000001)) return 0;
+ if((f > -0.000001f) && (f < 0.000001f)) return 0;
u= (-p[a2]-v*e2[a2])/f;
}
else
u= (-p[a1]-v*e2[a1])/f;
- if ((u < 0.0)||((u + v) > 1.0)) return 0;
+ if ((u < 0.0f) || ((u + v) > 1.0f)) return 0;
*lambda = (p[a0]+u*e1[a0]+v*e2[a0])/(p2[a0]-p1[a0]);
- if ((*lambda < 0.0)||(*lambda > 1.0)) return 0;
+ if ((*lambda < 0.0f) || (*lambda > 1.0f)) return 0;
return 1;
}
@@ -1455,7 +1454,7 @@ static int barycentric_weights(float *v1, float *v2, float *v3, float *co, float
asum= a1 + a2 + a3;
- if (fabs(asum) < FLT_EPSILON) {
+ if (fabsf(asum) < FLT_EPSILON) {
/* zero area triangle */
w[0]= w[1]= w[2]= 1.0f/3.0f;
return 1;
@@ -1750,7 +1749,7 @@ void orthographic_m4(float matrix[][4],float left, float right, float bottom, fl
Xdelta = right - left;
Ydelta = top - bottom;
Zdelta = farClip - nearClip;
- if (Xdelta == 0.0 || Ydelta == 0.0 || Zdelta == 0.0) {
+ if (Xdelta == 0.0f || Ydelta == 0.0f || Zdelta == 0.0f) {
return;
}
unit_m4(matrix);
@@ -1770,7 +1769,7 @@ void perspective_m4(float mat[][4],float left, float right, float bottom, float
Ydelta = top - bottom;
Zdelta = farClip - nearClip;
- if (Xdelta == 0.0 || Ydelta == 0.0 || Zdelta == 0.0) {
+ if (Xdelta == 0.0f || Ydelta == 0.0f || Zdelta == 0.0f) {
return;
}
mat[0][0] = nearClip * 2.0f/Xdelta;
@@ -1857,7 +1856,7 @@ void lookat_m4(float mat[][4],float vx, float vy, float vz, float px, float py,
hyp1 = (float)sqrt(dy*dy + hyp);
hyp = (float)sqrt(hyp); /* the real hyp */
- if (hyp1 != 0.0) { /* rotate X */
+ if (hyp1 != 0.0f) { /* rotate X */
sine = -dy / hyp1;
cosine = hyp /hyp1;
} else {
@@ -1971,7 +1970,7 @@ void map_to_sphere(float *u, float *v,float x, float y, float z)
len= (float)sqrt(x*x+y*y+z*z);
if(len > 0.0f) {
if(x==0.0f && y==0.0f) *u= 0.0f; /* othwise domain error */
- else *u = (float)((1.0 - (float)atan2(x,y) / M_PI) / 2.0);
+ else *u = (1.0f - atan2f(x,y) / (float)M_PI) / 2.0f;
z/=len;
*v = 1.0f - (float)saacos(z)/(float)M_PI;
@@ -2040,7 +2039,7 @@ void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang, float *tang,
/* find a tangent with connected uvs */
for(vt= *vtang; vt; vt=vt->next) {
- if(fabs(uv[0]-vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabs(uv[1]-vt->uv[1]) < STD_UV_CONNECT_LIMIT) {
+ if(fabsf(uv[0]-vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabsf(uv[1]-vt->uv[1]) < STD_UV_CONNECT_LIMIT) {
add_v3_v3(vt->tang, tang);
return;
}
@@ -2063,7 +2062,7 @@ float *find_vertex_tangent(VertexTangent *vtang, float *uv)
static float nulltang[3] = {0.0f, 0.0f, 0.0f};
for(vt= vtang; vt; vt=vt->next)
- if(fabs(uv[0]-vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabs(uv[1]-vt->uv[1]) < STD_UV_CONNECT_LIMIT)
+ if(fabsf(uv[0]-vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabsf(uv[1]-vt->uv[1]) < STD_UV_CONNECT_LIMIT)
return vt->tang;
return nulltang; /* shouldn't happen, except for nan or so */
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 289d279c9a1..9fde87d734f 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -535,7 +535,7 @@ int invert_m4_m4(float inverse[4][4], float mat[4][4])
max = fabs(tempmat[i][i]);
maxj = i;
for(j = i + 1; j < 4; j++) {
- if(fabs(tempmat[j][i]) > max) {
+ if(fabsf(tempmat[j][i]) > max) {
max = fabs(tempmat[j][i]);
maxj = j;
}
@@ -760,13 +760,13 @@ void orthogonalize_m4(float mat[][4], int axis)
int is_orthogonal_m3(float mat[][3])
{
- if (fabs(dot_v3v3(mat[0], mat[1])) > 1.5 * FLT_EPSILON)
+ if (fabsf(dot_v3v3(mat[0], mat[1])) > 1.5f * FLT_EPSILON)
return 0;
- if (fabs(dot_v3v3(mat[1], mat[2])) > 1.5 * FLT_EPSILON)
+ if (fabsf(dot_v3v3(mat[1], mat[2])) > 1.5f * FLT_EPSILON)
return 0;
- if (fabs(dot_v3v3(mat[0], mat[2])) > 1.5 * FLT_EPSILON)
+ if (fabsf(dot_v3v3(mat[0], mat[2])) > 1.5f * FLT_EPSILON)
return 0;
return 1;
@@ -774,13 +774,13 @@ int is_orthogonal_m3(float mat[][3])
int is_orthogonal_m4(float mat[][4])
{
- if (fabs(dot_v3v3(mat[0], mat[1])) > 1.5 * FLT_EPSILON)
+ if (fabsf(dot_v3v3(mat[0], mat[1])) > 1.5f * FLT_EPSILON)
return 0;
- if (fabs(dot_v3v3(mat[1], mat[2])) > 1.5 * FLT_EPSILON)
+ if (fabsf(dot_v3v3(mat[1], mat[2])) > 1.5f * FLT_EPSILON)
return 0;
- if (fabs(dot_v3v3(mat[0], mat[2])) > 1.5 * FLT_EPSILON)
+ if (fabsf(dot_v3v3(mat[0], mat[2])) > 1.5f * FLT_EPSILON)
return 0;
return 1;
@@ -806,11 +806,11 @@ void normalize_m4(float mat[][4])
float len;
len= normalize_v3(mat[0]);
- if(len!=0.0) mat[0][3]/= len;
+ if(len!=0.0f) mat[0][3]/= len;
len= normalize_v3(mat[1]);
- if(len!=0.0) mat[1][3]/= len;
+ if(len!=0.0f) mat[1][3]/= len;
len= normalize_v3(mat[2]);
- if(len!=0.0) mat[2][3]/= len;
+ if(len!=0.0f) mat[2][3]/= len;
}
void normalize_m4_m4(float rmat[][4], float mat[][4])
@@ -818,11 +818,11 @@ void normalize_m4_m4(float rmat[][4], float mat[][4])
float len;
len= normalize_v3_v3(rmat[0], mat[0]);
- if(len!=0.0) rmat[0][3]= mat[0][3] / len;
+ if(len!=0.0f) rmat[0][3]= mat[0][3] / len;
len= normalize_v3_v3(rmat[1], mat[1]);
- if(len!=0.0) rmat[1][3]= mat[1][3] / len;
+ if(len!=0.0f) rmat[1][3]= mat[1][3] / len;
len= normalize_v3_v3(rmat[2], mat[2]);
- if(len!=0.0) rmat[2][3]= mat[2][3] / len;;
+ if(len!=0.0f) rmat[2][3]= mat[2][3] / len;;
}
void adjoint_m3_m3(float m1[][3], float m[][3])
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index d9afd9f3cd4..4e37de93ded 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -167,10 +167,10 @@ static void quat_to_mat3_no_error(float m[][3], const float q[4])
{
double q0, q1, q2, q3, qda,qdb,qdc,qaa,qab,qac,qbb,qbc,qcc;
- q0= M_SQRT2 * q[0];
- q1= M_SQRT2 * q[1];
- q2= M_SQRT2 * q[2];
- q3= M_SQRT2 * q[3];
+ q0= M_SQRT2 * (double)q[0];
+ q1= M_SQRT2 * (double)q[1];
+ q2= M_SQRT2 * (double)q[2];
+ q3= M_SQRT2 * (double)q[3];
qda= q0*q1;
qdb= q0*q2;
@@ -200,7 +200,7 @@ void quat_to_mat3(float m[][3], const float q[4])
{
#ifdef DEBUG
float f;
- if(!((f=dot_qtqt(q, q))==0.0 || (fabs(f-1.0) < QUAT_EPSILON))) {
+ if(!((f=dot_qtqt(q, q))==0.0f || (fabsf(f-1.0f) < (float)QUAT_EPSILON))) {
fprintf(stderr, "Warning! quat_to_mat3() called with non-normalized: size %.8f *** report a bug ***\n", f);
}
#endif
@@ -213,15 +213,15 @@ void quat_to_mat4(float m[][4], const float q[4])
double q0, q1, q2, q3, qda,qdb,qdc,qaa,qab,qac,qbb,qbc,qcc;
#ifdef DEBUG
- if(!((q0=dot_qtqt(q, q))==0.0 || (fabs(q0-1.0) < QUAT_EPSILON))) {
+ if(!((q0=dot_qtqt(q, q))==0.0f || (fabsf(q0-1.0f) < (float)QUAT_EPSILON))) {
fprintf(stderr, "Warning! quat_to_mat4() called with non-normalized: size %.8f *** report a bug ***\n", (float)q0);
}
#endif
- q0= M_SQRT2 * q[0];
- q1= M_SQRT2 * q[1];
- q2= M_SQRT2 * q[2];
- q3= M_SQRT2 * q[3];
+ q0= M_SQRT2 * (double)q[0];
+ q1= M_SQRT2 * (double)q[1];
+ q2= M_SQRT2 * (double)q[2];
+ q3= M_SQRT2 * (double)q[3];
qda= q0*q1;
qdb= q0*q2;
@@ -261,9 +261,9 @@ void mat3_to_quat(float *q, float wmat[][3])
copy_m3_m3(mat, wmat);
normalize_m3(mat); /* this is needed AND a NormalQuat in the end */
- tr= 0.25*(1.0+mat[0][0]+mat[1][1]+mat[2][2]);
+ tr= 0.25* (double)(1.0f+mat[0][0]+mat[1][1]+mat[2][2]);
- if(tr>FLT_EPSILON) {
+ if(tr>(double)FLT_EPSILON) {
s= sqrt(tr);
q[0]= (float)s;
s= 1.0/(4.0*s);
@@ -273,7 +273,7 @@ void mat3_to_quat(float *q, float wmat[][3])
}
else {
if(mat[0][0] > mat[1][1] && mat[0][0] > mat[2][2]) {
- s= 2.0*sqrtf(1.0 + mat[0][0] - mat[1][1] - mat[2][2]);
+ s= 2.0*sqrtf(1.0f + mat[0][0] - mat[1][1] - mat[2][2]);
q[1]= (float)(0.25*s);
s= 1.0/s;
@@ -282,7 +282,7 @@ void mat3_to_quat(float *q, float wmat[][3])
q[3]= (float)((mat[2][0] + mat[0][2])*s);
}
else if(mat[1][1] > mat[2][2]) {
- s= 2.0*sqrtf(1.0 + mat[1][1] - mat[0][0] - mat[2][2]);
+ s= 2.0*sqrtf(1.0f + mat[1][1] - mat[0][0] - mat[2][2]);
q[2]= (float)(0.25*s);
s= 1.0/s;
@@ -361,7 +361,7 @@ float normalize_qt(float *q)
float len;
len= (float)sqrt(dot_qtqt(q, q));
- if(len!=0.0) {
+ if(len!=0.0f) {
mul_qt_fl(q, 1.0f/len);
}
else {
@@ -428,7 +428,7 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
q[1]=q[2]=q[3]= 0.0;
len1= (float)sqrt(x2*x2+y2*y2+z2*z2);
- if(len1 == 0.0) return;
+ if(len1 == 0.0f) return;
/* nasty! I need a good routine for this...
* problem is a rotation of an Y axis to the negative Y-axis for example.
@@ -631,7 +631,7 @@ void tri_to_quat(float quat[4], const float v1[3], const float v2[3], const floa
q2[1]= 0.0f;
q2[2]= 0.0f;
q2[3]= si;
-
+
mul_qt_qtqt(quat, q1, q2);
}
@@ -667,7 +667,7 @@ void quat_to_axis_angle(float axis[3], float *angle, const float q[4])
float ha, si;
#ifdef DEBUG
- if(!((ha=dot_qtqt(q, q))==0.0 || (fabs(ha-1.0) < QUAT_EPSILON))) {
+ if(!((ha=dot_qtqt(q, q))==0.0f || (fabsf(ha-1.0f) < (float)QUAT_EPSILON))) {
fprintf(stderr, "Warning! quat_to_axis_angle() called with non-normalized: size %.8f *** report a bug ***\n", ha);
}
#endif
@@ -846,8 +846,8 @@ void vec_rot_to_quat(float *quat, const float vec[3], const float phi)
unit_qt(quat);
}
else {
- quat[0]= (float)cos(phi/2.0);
- si= (float)sin(phi/2.0);
+ quat[0]= (float)cos((double)phi/2.0);
+ si= (float)sin((double)phi/2.0);
quat[1] *= si;
quat[2] *= si;
quat[3] *= si;
@@ -928,7 +928,7 @@ static void mat3_to_eul2(float tmat[][3], float eul1[3], float eul2[3])
cy = (float)sqrt(mat[0][0]*mat[0][0] + mat[0][1]*mat[0][1]);
- if (cy > 16.0*FLT_EPSILON) {
+ if (cy > 16.0f*FLT_EPSILON) {
eul1[0] = (float)atan2(mat[1][2], mat[2][2]);
eul1[1] = (float)atan2(-mat[0][2], cy);
@@ -1045,13 +1045,13 @@ void compatible_eul(float eul[3], const float oldrot[3])
/* is 1 of the axis rotations larger than 180 degrees and the other small? NO ELSE IF!! */
if(fabs(dx) > 3.2 && fabs(dy)<1.6 && fabs(dz)<1.6) {
- if(dx > 0.0) eul[0] -= 2.0f*(float)M_PI; else eul[0]+= 2.0f*(float)M_PI;
+ if(dx > 0.0f) eul[0] -= 2.0f*(float)M_PI; else eul[0]+= 2.0f*(float)M_PI;
}
if(fabs(dy) > 3.2 && fabs(dz)<1.6 && fabs(dx)<1.6) {
- if(dy > 0.0) eul[1] -= 2.0f*(float)M_PI; else eul[1]+= 2.0f*(float)M_PI;
+ if(dy > 0.0f) eul[1] -= 2.0f*(float)M_PI; else eul[1]+= 2.0f*(float)M_PI;
}
if(fabs(dz) > 3.2 && fabs(dx)<1.6 && fabs(dy)<1.6) {
- if(dz > 0.0) eul[2] -= 2.0f*(float)M_PI; else eul[2]+= 2.0f*(float)M_PI;
+ if(dz > 0.0f) eul[2] -= 2.0f*(float)M_PI; else eul[2]+= 2.0f*(float)M_PI;
}
/* the method below was there from ancient days... but why! probably because the code sucks :)
@@ -1222,7 +1222,7 @@ static void mat3_to_eulo2(float M[3][3], float *e1, float *e2, short order)
cy= sqrt(m[i][i]*m[i][i] + m[i][j]*m[i][j]);
- if (cy > 16*FLT_EPSILON) {
+ if (cy > 16.0*(double)FLT_EPSILON) {
e1[i] = atan2(m[j][k], m[k][k]);
e1[j] = atan2(-m[i][k], cy);
e1[k] = atan2(m[i][j], m[i][i]);
@@ -1417,7 +1417,7 @@ void mat4_to_dquat(DualQuat *dq,float basemat[][4], float mat[][4])
copy_v3_v3(dscale, scale);
dscale[0] -= 1.0f; dscale[1] -= 1.0f; dscale[2] -= 1.0f;
- if((determinant_m4(mat) < 0.0f) || len_v3(dscale) > 1e-4) {
+ if((determinant_m4(mat) < 0.0f) || len_v3(dscale) > 1e-4f) {
/* extract R and S */
float tmp[4][4];
@@ -1668,10 +1668,10 @@ void vec_apply_track(float vec[3], short axis)
/* lens/angle conversion (radians) */
float lens_to_angle(float lens)
{
- return 2.0f * atan(16.0f/lens);
+ return 2.0f * atanf(16.0f/lens);
}
float angle_to_lens(float angle)
{
- return 16.0f / tan(angle * 0.5f);
+ return 16.0f / tanf(angle * 0.5f);
}
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 081f8781d9e..15d671e38d7 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -207,10 +207,10 @@ void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const f
normalize_v3(ed2);
normalize_v3(ed3);
- angles[0]= M_PI - angle_normalized_v3v3(ed1, ed2);
- angles[1]= M_PI - angle_normalized_v3v3(ed2, ed3);
+ angles[0]= (float)M_PI - angle_normalized_v3v3(ed1, ed2);
+ angles[1]= (float)M_PI - angle_normalized_v3v3(ed2, ed3);
// face_angles[2] = M_PI - angle_normalized_v3v3(ed3, ed1);
- angles[2]= M_PI - (angles[0] + angles[1]);
+ angles[2]= (float)M_PI - (angles[0] + angles[1]);
}
void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
@@ -227,10 +227,10 @@ void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const
normalize_v3(ed3);
normalize_v3(ed4);
- angles[0]= M_PI - angle_normalized_v3v3(ed1, ed2);
- angles[1]= M_PI - angle_normalized_v3v3(ed2, ed3);
- angles[2]= M_PI - angle_normalized_v3v3(ed3, ed4);
- angles[3]= M_PI - angle_normalized_v3v3(ed4, ed1);
+ angles[0]= (float)M_PI - angle_normalized_v3v3(ed1, ed2);
+ angles[1]= (float)M_PI - angle_normalized_v3v3(ed2, ed3);
+ angles[2]= (float)M_PI - angle_normalized_v3v3(ed3, ed4);
+ angles[3]= (float)M_PI - angle_normalized_v3v3(ed4, ed1);
}
/********************************* Geometry **********************************/
diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c
index 02b266ec160..d139fb1ab71 100644
--- a/source/blender/blenlib/intern/uvproject.c
+++ b/source/blender/blenlib/intern/uvproject.c
@@ -60,7 +60,7 @@ void project_from_camera(float target[2], float source[3], UvCameraInfo *uci)
mul_m4_v4(uci->caminv, pv4);
if(uci->do_pano) {
- float angle= atan2f(pv4[0], -pv4[2]) / (M_PI * 2.0); /* angle around the camera */
+ float angle= atan2f(pv4[0], -pv4[2]) / ((float)M_PI * 2.0f); /* angle around the camera */
if (uci->do_persp==0) {
target[0]= angle; /* no correct method here, just map to 0-1 */
target[1]= pv4[1] / uci->camsize;
@@ -69,7 +69,7 @@ void project_from_camera(float target[2], float source[3], UvCameraInfo *uci)
float vec2d[2]; /* 2D position from the camera */
vec2d[0]= pv4[0];
vec2d[1]= pv4[2];
- target[0]= angle * (M_PI / uci->camangle);
+ target[0]= angle * ((float)M_PI / uci->camangle);
target[1]= pv4[1] / (len_v2(vec2d) * uci->camsize);
}
}
@@ -109,23 +109,23 @@ void project_from_view(float target[2], float source[3], float persmat[4][4], fl
/* almost project_short */
mul_m4_v4(persmat, pv4);
- if(fabs(pv4[3]) > 0.00001) { /* avoid division by zero */
- target[0] = winx/2.0 + (winx/2.0) * pv4[0] / pv4[3];
- target[1] = winy/2.0 + (winy/2.0) * pv4[1] / pv4[3];
+ if(fabsf(pv4[3]) > 0.00001f) { /* avoid division by zero */
+ target[0] = winx/2.0f + (winx/2.0f) * pv4[0] / pv4[3];
+ target[1] = winy/2.0f + (winy/2.0f) * pv4[1] / pv4[3];
}
else {
/* scaling is lost but give a valid result */
- target[0] = winx/2.0 + (winx/2.0) * pv4[0];
- target[1] = winy/2.0 + (winy/2.0) * pv4[1];
+ target[0] = winx/2.0f + (winx/2.0f) * pv4[0];
+ target[1] = winy/2.0f + (winy/2.0f) * pv4[1];
}
/* v3d->persmat seems to do this funky scaling */
if(winx > winy) {
- y= (winx - winy)/2.0;
+ y= (winx - winy)/2.0f;
winy = winx;
}
else {
- x= (winy - winx)/2.0;
+ x= (winy - winx)/2.0f;
winx = winy;
}