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 21:22:04 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-03-27 21:22:04 +0400
commita73c3fe5c992777718431d5e5bb5f8a2c3b7a1bc (patch)
tree51ca1d7a06715f0dde24196157c915b12da334c0 /source/blender/blenkernel
parent9c8f1e2ef487483bc374feaed9ff709e07638623 (diff)
subsurf, derived mesh and other misc files: floats were being implicitly promoted to doubles, adjust to use floats.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c58
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c14
-rw-r--r--source/blender/blenkernel/intern/anim.c2
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c4
-rw-r--r--source/blender/blenkernel/intern/lattice.c14
-rw-r--r--source/blender/blenkernel/intern/object.c36
6 files changed, 62 insertions, 66 deletions
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index c682b189ae8..2cfd17a95f3 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -229,9 +229,9 @@ static int VertDataEqual(float *a, float *b) {
#define VertDataAvg4(tv, av, bv, cv, dv) \
{ \
float *_t = (float*) tv, *_a = (float*) av, *_b = (float*) bv, *_c = (float*) cv, *_d = (float*) dv; \
- _t[0] = (_a[0]+_b[0]+_c[0]+_d[0])*.25; \
- _t[1] = (_a[1]+_b[1]+_c[1]+_d[1])*.25; \
- _t[2] = (_a[2]+_b[2]+_c[2]+_d[2])*.25; \
+ _t[0] = (_a[0]+_b[0]+_c[0]+_d[0])*.25f; \
+ _t[1] = (_a[1]+_b[1]+_c[1]+_d[1])*.25f; \
+ _t[2] = (_a[2]+_b[2]+_c[2]+_d[2])*.25f; \
}
#define NormZero(av) { float *_a = (float*) av; _a[0] = _a[1] = _a[2] = 0.0f; }
#define NormCopy(av, bv) { float *_a = (float*) av, *_b = (float*) bv; _a[0] =_b[0]; _a[1] =_b[1]; _a[2] =_b[2]; }
@@ -507,9 +507,9 @@ static float EDGE_getSharpness(CCGEdge *e, int lvl) {
if (!lvl)
return e->crease;
else if (!e->crease)
- return 0.0;
- else if (e->crease - lvl < 0.0)
- return 0.0;
+ return 0.0f;
+ else if (e->crease - lvl < 0.0f)
+ return 0.0f;
else
return e->crease - lvl;
}
@@ -1447,7 +1447,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
float sharpness = EDGE_getSharpness(e, curLvl);
int x, j;
- if (_edge_isBoundary(e) || sharpness>1.0) {
+ if (_edge_isBoundary(e) || sharpness > 1.0f) {
for (x=0; x<edgeSize-1; x++) {
int fx = x*2 + 1;
void *co0 = EDGE_getCo(e, curLvl, x+0);
@@ -1456,7 +1456,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
VertDataCopy(co, co0);
VertDataAdd(co, co1);
- VertDataMulN(co, 0.5);
+ VertDataMulN(co, 0.5f);
}
} else {
for (x=0; x<edgeSize-1; x++) {
@@ -1479,7 +1479,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
VertDataCopy(r, co0);
VertDataAdd(r, co1);
- VertDataMulN(r, 0.5);
+ VertDataMulN(r, 0.5f);
VertDataCopy(co, q);
VertDataSub(r, q);
@@ -1519,8 +1519,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
if(sharpCount) {
avgSharpness /= sharpCount;
- if (avgSharpness>1.0) {
- avgSharpness = 1.0;
+ if (avgSharpness > 1.0f) {
+ avgSharpness = 1.0f;
}
}
@@ -1542,7 +1542,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
VertDataCopy(nCo, co);
- VertDataMulN(nCo, 0.75);
+ VertDataMulN(nCo, 0.75f);
VertDataMulN(r, 0.25f/numBoundary);
VertDataAdd(nCo, r);
} else {
@@ -1587,7 +1587,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
if (seam) {
if (_edge_isBoundary(e))
VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize));
- } else if (sharpness != 0.0) {
+ } else if (sharpness != 0.0f) {
VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize));
}
}
@@ -1604,8 +1604,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
// r = co*.75 + q*.25
VertDataCopy(r, co);
- VertDataMulN(r, .75);
- VertDataMulN(q, .25);
+ VertDataMulN(r, .75f);
+ VertDataMulN(q, .25f);
VertDataAdd(r, q);
// nCo = nCo + (r-nCo)*avgSharpness
@@ -1631,8 +1631,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
sharpCount = 2;
avgSharpness += sharpness;
- if (avgSharpness>1.0) {
- avgSharpness = 1.0;
+ if (avgSharpness > 1.0f) {
+ avgSharpness = 1.0f;
}
} else {
sharpCount = 0;
@@ -1646,10 +1646,10 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
void *nCo = EDGE_getCo(e, nextLvl, fx);
VertDataCopy(r, EDGE_getCo(e, curLvl, x-1));
VertDataAdd(r, EDGE_getCo(e, curLvl, x+1));
- VertDataMulN(r, 0.5);
+ VertDataMulN(r, 0.5f);
VertDataCopy(nCo, co);
- VertDataMulN(nCo, 0.75);
- VertDataMulN(r, 0.25);
+ VertDataMulN(nCo, 0.75f);
+ VertDataMulN(r, 0.25f);
VertDataAdd(nCo, r);
}
} else {
@@ -1671,8 +1671,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
VertDataAdd(r, _face_getIFCoEdge(f, e, curLvl, x, 1, subdivLevels, vertDataSize));
numFaces++;
}
- VertDataMulN(q, 1.0/(numFaces*2.0f));
- VertDataMulN(r, 1.0/(2.0f + numFaces));
+ VertDataMulN(q, 1.0f/(numFaces*2.0f));
+ VertDataMulN(r, 1.0f/(2.0f + numFaces));
VertDataCopy(nCo, co);
VertDataMulN(nCo, (float) numFaces);
@@ -1895,7 +1895,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
void *co = EDGE_getCo(e, nextLvl, 1);
float sharpness = EDGE_getSharpness(e, curLvl);
- if (_edge_isBoundary(e) || sharpness>=1.0) {
+ if (_edge_isBoundary(e) || sharpness >= 1.0f) {
VertDataCopy(co, VERT_getCo(e->v0, curLvl));
VertDataAdd(co, VERT_getCo(e->v1, curLvl));
VertDataMulN(co, 0.5f);
@@ -1947,8 +1947,8 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
if(sharpCount) {
avgSharpness /= sharpCount;
- if (avgSharpness>1.0) {
- avgSharpness = 1.0;
+ if (avgSharpness > 1.0f) {
+ avgSharpness = 1.0f;
}
}
@@ -1969,7 +1969,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
}
}
VertDataCopy(nCo, co);
- VertDataMulN(nCo, 0.75);
+ VertDataMulN(nCo, 0.75f);
VertDataMulN(r, 0.25f/numBoundary);
VertDataAdd(nCo, r);
} else {
@@ -2015,7 +2015,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
CCGVert *oV = _edge_getOtherVert(e, v);
VertDataAdd(q, VERT_getCo(oV, curLvl));
}
- } else if (sharpness != 0.0) {
+ } else if (sharpness != 0.0f) {
CCGVert *oV = _edge_getOtherVert(e, v);
VertDataAdd(q, VERT_getCo(oV, curLvl));
}
@@ -2033,8 +2033,8 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
// r = co*.75 + q*.25
VertDataCopy(r, co);
- VertDataMulN(r, .75);
- VertDataMulN(q, .25);
+ VertDataMulN(r, 0.75f);
+ VertDataMulN(q, 0.25f);
VertDataAdd(r, q);
// nCo = nCo + (r-nCo)*avgSharpness
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 987f70e67ca..b0a1e74c30f 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1123,9 +1123,7 @@ static void emDM_getVert(DerivedMesh *dm, int index, MVert *vert_r)
VECCOPY(vert_r->co, ev->co);
- vert_r->no[0] = ev->no[0] * 32767.0;
- vert_r->no[1] = ev->no[1] * 32767.0;
- vert_r->no[2] = ev->no[2] * 32767.0;
+ normal_float_to_short_v3(vert_r->no, ev->no);
/* TODO what to do with vert_r->flag? */
vert_r->bweight = (unsigned char) (ev->bweight*255.0f);
@@ -1220,9 +1218,7 @@ static void emDM_copyVertArray(DerivedMesh *dm, MVert *vert_r)
else
copy_v3_v3(vert_r->co, ev->co);
- vert_r->no[0] = ev->no[0] * 32767.0;
- vert_r->no[1] = ev->no[1] * 32767.0;
- vert_r->no[2] = ev->no[2] * 32767.0;
+ normal_float_to_short_v3(vert_r->no, ev->no);
/* TODO what to do with vert_r->flag? */
vert_r->flag = 0;
@@ -1425,7 +1421,7 @@ DerivedMesh *editmesh_get_derived(EditMesh *em, float (*vertexCos)[3])
float *no = emdm->vertexNos[i];
/* following Mesh convention; we use vertex coordinate itself
* for normal in this case */
- if (normalize_v3(no)==0.0) {
+ if (normalize_v3(no) == 0.0f) {
normalize_v3_v3(no, vertexCos[i]);
}
}
@@ -1596,12 +1592,12 @@ void weight_to_rgb(float input, float *fr, float *fg, float *fb)
*fg= blend;
*fb= blend*(1.0f-((input-0.25f)*4.0f));
}
- else if (input<=0.75){ // green->yellow
+ else if (input <= 0.75f){ // green->yellow
*fr= blend * ((input-0.50f)*4.0f);
*fg= blend;
*fb= 0.0f;
}
- else if (input<=1.0){ // yellow->red
+ else if (input <= 1.0f){ // yellow->red
*fr= blend;
*fg= blend * (1.0f-((input-0.75f)*4.0f));
*fb= 0.0f;
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 2e1fbf2917a..e12ec559f4b 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -1125,7 +1125,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
/* scale */
if(par->transflag & OB_DUPLIFACES_SCALE) {
float size= v4? area_quad_v3(v1, v2, v3, v4): area_tri_v3(v1, v2, v3);
- size= sqrt(size) * par->dupfacesca;
+ size= sqrtf(size) * par->dupfacesca;
mul_m3_fl(mat, size);
}
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index b4adaa0ab07..6e933ddd386 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1905,7 +1905,7 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime)
/* action range is calculated taking F-Modifiers into account (which making new strips doesn't do due to the troublesome nature of that) */
calc_action_range(dummy_strip.act, &dummy_strip.actstart, &dummy_strip.actend, 1);
dummy_strip.start = dummy_strip.actstart;
- dummy_strip.end = (IS_EQ(dummy_strip.actstart, dummy_strip.actend)) ? (dummy_strip.actstart + 1.0f): (dummy_strip.actend);
+ dummy_strip.end = (IS_EQF(dummy_strip.actstart, dummy_strip.actend)) ? (dummy_strip.actstart + 1.0f): (dummy_strip.actend);
dummy_strip.blendmode= adt->act_blendmode;
dummy_strip.extendmode= adt->act_extendmode;
@@ -2072,7 +2072,7 @@ void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short re
void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
{
ID *id;
-
+
if (G.f & G_DEBUG)
printf("Evaluate all animation - %f \n", ctime);
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 091c4a2fe50..f66afff0741 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -412,7 +412,7 @@ void calc_latt_deform(Object *ob, float *co, float weight)
for(ww= wi-1; ww<=wi+2; ww++) {
w= tw[ww-wi+1];
- if(w!=0.0) {
+ if(w != 0.0f) {
if(ww>0) {
if(ww<lt->pntsw) idx_w= ww*lt->pntsu*lt->pntsv;
else idx_w= (lt->pntsw-1)*lt->pntsu*lt->pntsv;
@@ -422,7 +422,7 @@ void calc_latt_deform(Object *ob, float *co, float weight)
for(vv= vi-1; vv<=vi+2; vv++) {
v= w*tv[vv-vi+1];
- if(v!=0.0) {
+ if(v != 0.0f) {
if(vv>0) {
if(vv<lt->pntsv) idx_v= idx_w + vv*lt->pntsu;
else idx_v= idx_w + (lt->pntsv-1)*lt->pntsu;
@@ -432,7 +432,7 @@ void calc_latt_deform(Object *ob, float *co, float weight)
for(uu= ui-1; uu<=ui+2; uu++) {
u= weight*v*tu[uu-ui+1];
- if(u!=0.0) {
+ if(u != 0.0f) {
if(uu>0) {
if(uu<lt->pntsu) idx_u= idx_v + uu;
else idx_u= idx_v + (lt->pntsu-1);
@@ -508,7 +508,7 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir,
if(bl && bl->poly> -1) cycl= 1;
if(cycl==0) {
- ctime1= CLAMPIS(ctime, 0.0, 1.0);
+ ctime1= CLAMPIS(ctime, 0.0f, 1.0f);
}
else ctime1= ctime;
@@ -519,16 +519,16 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir,
Path *path= cu->path;
float dvec[3];
- if(ctime < 0.0) {
+ if(ctime < 0.0f) {
sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec);
mul_v3_fl(dvec, ctime*(float)path->len);
add_v3_v3(vec, dvec);
if(quat) copy_qt_qt(quat, path->data[0].quat);
if(radius) *radius= path->data[0].radius;
}
- else if(ctime > 1.0) {
+ else if(ctime > 1.0f) {
sub_v3_v3v3(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec);
- mul_v3_fl(dvec, (ctime-1.0)*(float)path->len);
+ mul_v3_fl(dvec, (ctime-1.0f)*(float)path->len);
add_v3_v3(vec, dvec);
if(quat) copy_qt_qt(quat, path->data[path->len-1].quat);
if(radius) *radius= path->data[path->len-1].radius;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 0348d188a7d..ca31cd1b0b1 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1814,19 +1814,19 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
* we divide the curvetime calculated in the previous step by the length of the path, to get a time
* factor, which then gets clamped to lie within 0.0 - 1.0 range
*/
- if (IS_EQ(cu->pathlen, 0.0f) == 0)
+ if (IS_EQF(cu->pathlen, 0.0f) == 0)
ctime= cu->ctime / cu->pathlen;
else
ctime= cu->ctime;
-
- CLAMP(ctime, 0.0, 1.0);
+
+ CLAMP(ctime, 0.0f, 1.0f);
}
else {
ctime= scene->r.cfra - give_timeoffset(ob);
- if (IS_EQ(cu->pathlen, 0.0f) == 0)
+ if (IS_EQF(cu->pathlen, 0.0f) == 0)
ctime /= cu->pathlen;
- CLAMP(ctime, 0.0, 1.0);
+ CLAMP(ctime, 0.0f, 1.0f);
}
/* time calculus is correct, now apply distance offset */
@@ -2332,9 +2332,9 @@ void object_get_dimensions(Object *ob, float *value)
mat4_to_size( scale,ob->obmat);
- value[0] = fabs(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]);
- value[1] = fabs(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]);
- value[2] = fabs(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]);
+ value[0] = fabsf(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]);
+ value[1] = fabsf(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]);
+ value[2] = fabsf(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]);
} else {
value[0] = value[1] = value[2] = 0.f;
}
@@ -2853,18 +2853,18 @@ void object_camera_matrix(
}
else if(camera->type==OB_LAMP) {
Lamp *la= camera->data;
- float fac= cos( M_PI*la->spotsize/360.0 );
+ float fac= cosf((float)M_PI*la->spotsize/360.0f);
float phi= acos(fac);
- (*lens)= 16.0*fac/sin(phi);
+ (*lens)= 16.0f*fac/sinf(phi);
if((*lens)==0.0f)
- (*lens)= 35.0;
+ (*lens)= 35.0f;
(*clipsta)= la->clipsta;
(*clipend)= la->clipend;
}
else { /* envmap exception... */;
if((*lens)==0.0f)
- (*lens)= 16.0;
+ (*lens)= 16.0f;
if((*clipsta)==0.0f || (*clipend)==0.0f) {
(*clipsta)= 0.1f;
@@ -2884,8 +2884,8 @@ void object_camera_matrix(
pixsize= cam->ortho_scale/viewfac;
}
else {
- if(rd->xasp*winx >= rd->yasp*winy) viewfac= ((*lens) * winx)/32.0;
- else viewfac= (*ycor) * ((*lens) * winy)/32.0;
+ if(rd->xasp*winx >= rd->yasp*winy) viewfac= ((*lens) * winx)/32.0f;
+ else viewfac= (*ycor) * ((*lens) * winy)/32.0f;
pixsize= (*clipsta) / viewfac;
}
@@ -2898,12 +2898,12 @@ void object_camera_matrix(
if(field_second) {
if(rd->mode & R_ODDFIELD) {
- viewplane->ymin-= 0.5 * (*ycor);
- viewplane->ymax-= 0.5 * (*ycor);
+ viewplane->ymin-= 0.5f * (*ycor);
+ viewplane->ymax-= 0.5f * (*ycor);
}
else {
- viewplane->ymin+= 0.5 * (*ycor);
- viewplane->ymax+= 0.5 * (*ycor);
+ viewplane->ymin+= 0.5f * (*ycor);
+ viewplane->ymax+= 0.5f * (*ycor);
}
}
/* the window matrix is used for clipping, and not changed during OSA steps */