From fae6c35ca7ae4e73cc32a0f5c235fd0ff8f00be1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 4 Nov 2012 07:18:29 +0000 Subject: code cleanup: quiet -Wdouble-promotion, disabled this warnings for a few files since its done throughout the code in some places. --- source/blender/blenkernel/intern/collision.c | 13 +++++++--- source/blender/blenkernel/intern/dynamicpaint.c | 3 +++ source/blender/blenkernel/intern/implicit.c | 30 +++++++++++----------- source/blender/blenkernel/intern/ipo.c | 4 +-- source/blender/blenkernel/intern/particle_system.c | 2 +- source/blender/blenkernel/intern/sequencer.c | 4 +-- source/blender/blenkernel/intern/softbody.c | 8 +++--- source/blender/blenkernel/intern/sound.c | 6 +++-- 8 files changed, 40 insertions(+), 30 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 8da0538a08d..b488e683947 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -198,6 +198,9 @@ static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3 w3[0] = 1.0f - w1[0] - w2[0]; } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdouble-promotion" + DO_INLINE void collision_interpolateOnTriangle ( float to[3], float v1[3], float v2[3], float v3[3], double w1, double w2, double w3 ) { zero_v3(to); @@ -331,12 +334,12 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM * We don't use dt!! */ float spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; - float d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - collpair->distance; + float d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - (float)collpair->distance; if ( d > ALMOST_ZERO) { /* stay on the safe side and clamp repulse */ float repulse = d*1.0f/spf; - float impulse = repulse / ( 3.0 * ( 1.0f + w1*w1 + w2*w2 + w3*w3 )); /* original 2.0 / 0.25 */ + float impulse = repulse / ( 3.0f * ( 1.0f + w1*w1 + w2*w2 + w3*w3 )); /* original 2.0 / 0.25 */ VECADDMUL ( i1, collpair->normal, impulse ); VECADDMUL ( i2, collpair->normal, impulse ); @@ -368,6 +371,8 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM return result; } +#pragma GCC diagnostic pop + //Determines collisions on overlap, collisions are written to collpair[i] and collision+number_collision_found is returned static CollPair* cloth_collision(ModifierData *md1, ModifierData *md2, BVHTreeOverlap *overlap, CollPair *collpair, float UNUSED(dt)) @@ -459,7 +464,7 @@ static CollPair* cloth_collision(ModifierData *md1, ModifierData *md2, #endif // distance -1 means no collision result - if (distance != -1.0f && (distance <= (epsilon1 + epsilon2 + ALMOST_ZERO))) { + if (distance != -1.0 && (distance <= (double)(epsilon1 + epsilon2 + ALMOST_ZERO))) { normalize_v3_v3(collpair->normal, collpair->vector); collpair->distance = distance; @@ -869,7 +874,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData * clmd, float step, flo VECADD ( verts[i].tx, verts[i].tx, temp ); } else { - mul_v3_fl(temp, correction * -0.5); + mul_v3_fl(temp, correction * -0.5f); VECADD ( verts[j].tx, verts[j].tx, temp ); sub_v3_v3v3(verts[i].tx, verts[i].tx, temp); diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 3b2f099b981..89d728c0419 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -89,6 +89,9 @@ #include #endif +/* could enable at some point but for now there are far too many conversions */ +#pragma GCC diagnostic ignored "-Wdouble-promotion" + /* precalculated gaussian factors for 5x super sampling */ static float gaussianFactors[5] = {0.996849f, 0.596145f, diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 2de5425a04d..90cd7bc2df5 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -844,15 +844,15 @@ int implicit_free(ClothModifierData *clmd) DO_INLINE float fb(float length, float L) { - float x = length/L; - return (-11.541f*pow(x, 4)+34.193f*pow(x, 3)-39.083f*pow(x, 2)+23.116f*x-9.713f); + float x = length / L; + return (-11.541f * powf(x, 4) + 34.193f * powf(x, 3) - 39.083f * powf(x, 2) + 23.116f * x - 9.713f); } DO_INLINE float fbderiv(float length, float L) { float x = length/L; - return (-46.164f*pow(x, 3)+102.579f*pow(x, 2)-78.166f*x+23.116f); + return (-46.164f * powf(x, 3) + 102.579f * powf(x, 2) - 78.166f * x + 23.116f); } DO_INLINE float fbstar(float length, float L, float kb, float cb) @@ -917,7 +917,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z cp_lfvector(d, r, numverts); s = dot_lfvector(r, r, numverts); - starget = s * sqrt(conjgrad_epsilon); + starget = s * sqrtf(conjgrad_epsilon); while (s>starget && conjgrad_loopcount < conjgrad_looplimit) { // Mul(q, A, d); // q = A*d; @@ -1148,9 +1148,9 @@ DO_INLINE void dfdx_spring_type1(float to[3][3], float extent[3], float length, // dir is unit length direction, rest is spring's restlength, k is spring constant. // return (outerprod(dir, dir)*k + (I - outerprod(dir, dir))*(k - ((k*L)/length))); float temp[3][3]; - float temp1 = k*(1.0 - (L/length)); + float temp1 = k * (1.0f - (L / length)); - mul_fvectorT_fvectorS(temp, extent, extent, 1.0 / dot); + mul_fvectorT_fvectorS(temp, extent, extent, 1.0f / dot); sub_fmatrix_fmatrix(to, I, temp); mul_fmatrix_S(to, temp1); @@ -1307,7 +1307,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, VECADDS(s->f, s->f, extent, -k); - mul_fvector_S(damping_force, dir, clmd->sim_parms->goalfrict * 0.01 * dot_v3v3(vel, dir)); + mul_fvector_S(damping_force, dir, clmd->sim_parms->goalfrict * 0.01f * dot_v3v3(vel, dir)); VECADD(s->f, s->f, damping_force); // HERE IS THE PROBLEM!!!! @@ -1321,7 +1321,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, k = clmd->sim_parms->bending; scaling = k + s->stiffness * ABS(clmd->sim_parms->max_bend-k); - cb = k = scaling / (20.0*(clmd->sim_parms->avg_spring_len + FLT_EPSILON)); + cb = k = scaling / (20.0f * (clmd->sim_parms->avg_spring_len + FLT_EPSILON)); mul_fvector_S(bending_force, dir, fbstar(length, L, k, cb)); VECADD(s->f, s->f, bending_force); @@ -1479,7 +1479,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec colg[i][j][k].velocity[0] += vel[0]; colg[i][j][k].velocity[1] += vel[1]; colg[i][j][k].velocity[2] += vel[2]; - colg[i][j][k].density += 1.0; + colg[i][j][k].density += 1.0f; } } } @@ -1592,7 +1592,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec float triunnormal[3] = {0, 0, 0}; // not-normalized-triangle normal float tmp[3] = {0, 0, 0}; float factor = (mfaces[i].v4) ? 0.25 : 1.0 / 3.0; - factor *= 0.02; + factor *= 0.02f; // calculate face normal if (mfaces[i].v4) @@ -1730,7 +1730,7 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothMo for (i=0; inumverts; i++, cv++) { copy_v3_v3(cos[i], cv->tx); - if (cv->goal == 1.0f || len_squared_v3v3(initial_cos[i], cv->tx) != 0.0) { + if (cv->goal == 1.0f || len_squared_v3v3(initial_cos[i], cv->tx) != 0.0f) { masses[i] = 1e+10; } else { @@ -1758,18 +1758,18 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothMo normalize_v3(vec); c = (len - spring->restlen); - if (c == 0.0) + if (c == 0.0f) continue; - l = c / ((1.0/masses[v1]) + (1.0/masses[v2])); + l = c / ((1.0f / masses[v1]) + (1.0f / masses[v2])); - mul_v3_fl(vec, -(1.0/masses[v1])*l); + mul_v3_fl(vec, -(1.0f / masses[v1]) * l); add_v3_v3(cos[v1], vec); sub_v3_v3v3(vec, cos[v2], cos[v1]); normalize_v3(vec); - mul_v3_fl(vec, -(1.0/masses[v2])*l); + mul_v3_fl(vec, -(1.0f / masses[v2]) * l); add_v3_v3(cos[v2], vec); } } diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 3b08e3d2fa1..59dd02849dd 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1359,8 +1359,8 @@ static void icu_to_fcurves(ID *id, ListBase *groups, ListBase *list, IpoCurve *i /* correct values for sequencer curves, that were not locked to frame */ if (seq && (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) { - double mul = (seq->enddisp - seq->startdisp) / 100.0f; - double offset = seq->startdisp; + const float mul = (seq->enddisp - seq->startdisp) / 100.0f; + const float offset = seq->startdisp; dst->vec[0][0] *= mul; dst->vec[0][0] += offset; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index e959ef35cb0..2b95946f571 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1282,7 +1282,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D i= 0; for (p=0; p element_sum[i+1])) + while ((i < totelem) && (pos > (double)element_sum[i + 1])) i++; particle_element[p] = MIN2(totelem-1, i); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index b6ebc42fcf6..80ea00fc703 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -719,7 +719,7 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, int lock_range) #ifdef WITH_AUDASPACE if (!seq->sound) return; - seq->len = ceil(AUD_getInfo(seq->sound->playback_handle).length * FPS); + seq->len = ceil((double)AUD_getInfo(seq->sound->playback_handle).length * FPS); seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; if (seq->len < 0) { @@ -4009,7 +4009,7 @@ Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoad /* basic defaults */ seq->strip = strip = MEM_callocN(sizeof(Strip), "strip"); - seq->len = ceil(info.length * FPS); + seq->len = (int)ceil((double)info.length * FPS); strip->us = 1; /* we only need 1 element to store the filename */ diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 3a16158c374..bb0cfe1a5c6 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1170,7 +1170,7 @@ static int sb_detect_face_pointCached(float face_v1[3], float face_v2[3], float *damp=df*tune*ob->pd->pdef_sbdamp; - df = 0.01f*exp(- 100.0f*df); + df = 0.01f * expf(-100.0f * df); Vec3PlusStVec(force, -df, d_nvect); deflected = 3; } @@ -4008,8 +4008,8 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) } loops++; if (sb->solverflags & SBSO_MONITOR ) { - sct=PIL_check_seconds_timer(); - if (sct-sst > 0.5f) printf("%3.0f%% \r", 100.0f*timedone/dtime); + sct = PIL_check_seconds_timer(); + if (sct - sst > 0.5) printf("%3.0f%% \r", 100.0f * timedone / dtime); } /* ask for user break */ if (SB_localInterruptCallBack && SB_localInterruptCallBack()) break; @@ -4045,7 +4045,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) if (sb->solverflags & SBSO_MONITOR ) { sct=PIL_check_seconds_timer(); - if ((sct-sst > 0.5f) || (G.debug & G_DEBUG)) printf(" solver time %f sec %s\n", sct-sst, ob->id.name); + if ((sct - sst > 0.5) || (G.debug & G_DEBUG)) printf(" solver time %f sec %s\n", sct-sst, ob->id.name); } } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 385d1bb6fc5..aad205bb5bf 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -701,7 +701,7 @@ void sound_update_scene(struct Scene *scene) if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) { if (speaker->sound) - AUD_moveSequence(strip->speaker_handle, strip->start / FPS, -1, 0); + AUD_moveSequence(strip->speaker_handle, (double)strip->start / FPS, -1, 0); else { AUD_removeSequence(scene->sound_scene, strip->speaker_handle); strip->speaker_handle = NULL; @@ -709,7 +709,9 @@ void sound_update_scene(struct Scene *scene) } else { if (speaker->sound) { - strip->speaker_handle = AUD_addSequence(scene->sound_scene, speaker->sound->playback_handle, strip->start / FPS, -1, 0); + strip->speaker_handle = AUD_addSequence(scene->sound_scene, + speaker->sound->playback_handle, + (double)strip->start / FPS, -1, 0); AUD_setRelativeSequence(strip->speaker_handle, 0); } } -- cgit v1.2.3