[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35821] trunk/blender/source/blender/ blenlib/intern: math lib and UV project: floats were being implicitly promoted to doubles, adjust to use floats.
Campbell Barton
ideasman42 at gmail.com
Sun Mar 27 17:54:21 CEST 2011
Revision: 35821
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35821
Author: campbellbarton
Date: 2011-03-27 15:54:20 +0000 (Sun, 27 Mar 2011)
Log Message:
-----------
math lib and UV project: floats were being implicitly promoted to doubles, adjust to use floats.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/intern/math_color.c
trunk/blender/source/blender/blenlib/intern/math_geom.c
trunk/blender/source/blender/blenlib/intern/math_matrix.c
trunk/blender/source/blender/blenlib/intern/math_rotation.c
trunk/blender/source/blender/blenlib/intern/math_vector.c
trunk/blender/source/blender/blenlib/intern/uvproject.c
Modified: trunk/blender/source/blender/blenlib/intern/math_color.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_color.c 2011-03-27 14:59:55 UTC (rev 35820)
+++ trunk/blender/source/blender/blenlib/intern/math_color.c 2011-03-27 15:54:20 UTC (rev 35821)
@@ -45,9 +45,9 @@
*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 @@
{
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 @@
{
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 @@
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);
}
Modified: trunk/blender/source/blender/blenlib/intern/math_geom.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_geom.c 2011-03-27 14:59:55 UTC (rev 35820)
+++ trunk/blender/source/blender/blenlib/intern/math_geom.c 2011-03-27 15:54:20 UTC (rev 35821)
@@ -94,12 +94,12 @@
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 @@
cur= verts[a+1];
}
- return (float)fabs(0.5*area/max);
+ return fabsf(0.5f * area / max);
}
/********************************* Distance **********************************/
@@ -174,7 +174,7 @@
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 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
/* 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 @@
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 output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list