code cleanup: quiet -Wdouble-promotion, disabled this warnings for a few files since its done throughout the code in some places.

This commit is contained in:
2012-11-04 07:18:29 +00:00
parent 89a454653e
commit fae6c35ca7
28 changed files with 98 additions and 80 deletions

View File

@@ -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]; 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 ) 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); zero_v3(to);
@@ -331,12 +334,12 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
* We don't use dt!! */ * We don't use dt!! */
float spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; 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) { if ( d > ALMOST_ZERO) {
/* stay on the safe side and clamp repulse */ /* stay on the safe side and clamp repulse */
float repulse = d*1.0f/spf; 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 ( i1, collpair->normal, impulse );
VECADDMUL ( i2, collpair->normal, impulse ); VECADDMUL ( i2, collpair->normal, impulse );
@@ -368,6 +371,8 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
return result; return result;
} }
#pragma GCC diagnostic pop
//Determines collisions on overlap, collisions are written to collpair[i] and collision+number_collision_found is returned //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, static CollPair* cloth_collision(ModifierData *md1, ModifierData *md2,
BVHTreeOverlap *overlap, CollPair *collpair, float UNUSED(dt)) BVHTreeOverlap *overlap, CollPair *collpair, float UNUSED(dt))
@@ -459,7 +464,7 @@ static CollPair* cloth_collision(ModifierData *md1, ModifierData *md2,
#endif #endif
// distance -1 means no collision result // 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); normalize_v3_v3(collpair->normal, collpair->vector);
collpair->distance = distance; 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 ); VECADD ( verts[i].tx, verts[i].tx, temp );
} }
else { else {
mul_v3_fl(temp, correction * -0.5); mul_v3_fl(temp, correction * -0.5f);
VECADD ( verts[j].tx, verts[j].tx, temp ); VECADD ( verts[j].tx, verts[j].tx, temp );
sub_v3_v3v3(verts[i].tx, verts[i].tx, temp); sub_v3_v3v3(verts[i].tx, verts[i].tx, temp);

View File

@@ -89,6 +89,9 @@
#include <omp.h> #include <omp.h>
#endif #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 */ /* precalculated gaussian factors for 5x super sampling */
static float gaussianFactors[5] = {0.996849f, static float gaussianFactors[5] = {0.996849f,
0.596145f, 0.596145f,

View File

@@ -844,15 +844,15 @@ int implicit_free(ClothModifierData *clmd)
DO_INLINE float fb(float length, float L) DO_INLINE float fb(float length, float L)
{ {
float x = length/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); 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) DO_INLINE float fbderiv(float length, float L)
{ {
float x = length/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) 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); cp_lfvector(d, r, numverts);
s = dot_lfvector(r, 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) { while (s>starget && conjgrad_loopcount < conjgrad_looplimit) {
// Mul(q, A, d); // q = A*d; // 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. // 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))); // return (outerprod(dir, dir)*k + (I - outerprod(dir, dir))*(k - ((k*L)/length)));
float temp[3][3]; 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); sub_fmatrix_fmatrix(to, I, temp);
mul_fmatrix_S(to, temp1); 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); 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); VECADD(s->f, s->f, damping_force);
// HERE IS THE PROBLEM!!!! // HERE IS THE PROBLEM!!!!
@@ -1321,7 +1321,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
k = clmd->sim_parms->bending; k = clmd->sim_parms->bending;
scaling = k + s->stiffness * ABS(clmd->sim_parms->max_bend-k); 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)); mul_fvector_S(bending_force, dir, fbstar(length, L, k, cb));
VECADD(s->f, s->f, bending_force); 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[0] += vel[0];
colg[i][j][k].velocity[1] += vel[1]; colg[i][j][k].velocity[1] += vel[1];
colg[i][j][k].velocity[2] += vel[2]; 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 triunnormal[3] = {0, 0, 0}; // not-normalized-triangle normal
float tmp[3] = {0, 0, 0}; float tmp[3] = {0, 0, 0};
float factor = (mfaces[i].v4) ? 0.25 : 1.0 / 3.0; float factor = (mfaces[i].v4) ? 0.25 : 1.0 / 3.0;
factor *= 0.02; factor *= 0.02f;
// calculate face normal // calculate face normal
if (mfaces[i].v4) if (mfaces[i].v4)
@@ -1730,7 +1730,7 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothMo
for (i=0; i<cloth->numverts; i++, cv++) { for (i=0; i<cloth->numverts; i++, cv++) {
copy_v3_v3(cos[i], cv->tx); 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; masses[i] = 1e+10;
} }
else { else {
@@ -1758,18 +1758,18 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothMo
normalize_v3(vec); normalize_v3(vec);
c = (len - spring->restlen); c = (len - spring->restlen);
if (c == 0.0) if (c == 0.0f)
continue; 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); add_v3_v3(cos[v1], vec);
sub_v3_v3v3(vec, cos[v2], cos[v1]); sub_v3_v3v3(vec, cos[v2], cos[v1]);
normalize_v3(vec); 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); add_v3_v3(cos[v2], vec);
} }
} }

View File

@@ -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 */ /* correct values for sequencer curves, that were not locked to frame */
if (seq && (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) { if (seq && (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) {
double mul = (seq->enddisp - seq->startdisp) / 100.0f; const float mul = (seq->enddisp - seq->startdisp) / 100.0f;
double offset = seq->startdisp; const float offset = seq->startdisp;
dst->vec[0][0] *= mul; dst->vec[0][0] *= mul;
dst->vec[0][0] += offset; dst->vec[0][0] += offset;

View File

@@ -1282,7 +1282,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
i= 0; i= 0;
for (p=0; p<totpart; p++, pos+=step) { for (p=0; p<totpart; p++, pos+=step) {
while ((i < totelem) && (pos > element_sum[i+1])) while ((i < totelem) && (pos > (double)element_sum[i + 1]))
i++; i++;
particle_element[p] = MIN2(totelem-1, i); particle_element[p] = MIN2(totelem-1, i);

View File

@@ -719,7 +719,7 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, int lock_range)
#ifdef WITH_AUDASPACE #ifdef WITH_AUDASPACE
if (!seq->sound) if (!seq->sound)
return; 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_startofs;
seq->len -= seq->anim_endofs; seq->len -= seq->anim_endofs;
if (seq->len < 0) { if (seq->len < 0) {
@@ -4009,7 +4009,7 @@ Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoad
/* basic defaults */ /* basic defaults */
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip"); 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; strip->us = 1;
/* we only need 1 element to store the filename */ /* we only need 1 element to store the filename */

View File

@@ -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; *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); Vec3PlusStVec(force, -df, d_nvect);
deflected = 3; deflected = 3;
} }
@@ -4008,8 +4008,8 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
} }
loops++; loops++;
if (sb->solverflags & SBSO_MONITOR ) { if (sb->solverflags & SBSO_MONITOR ) {
sct=PIL_check_seconds_timer(); sct = PIL_check_seconds_timer();
if (sct-sst > 0.5f) printf("%3.0f%% \r", 100.0f*timedone/dtime); if (sct - sst > 0.5) printf("%3.0f%% \r", 100.0f * timedone / dtime);
} }
/* ask for user break */ /* ask for user break */
if (SB_localInterruptCallBack && SB_localInterruptCallBack()) 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 ) { if (sb->solverflags & SBSO_MONITOR ) {
sct=PIL_check_seconds_timer(); 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);
} }
} }

View File

@@ -701,7 +701,7 @@ void sound_update_scene(struct Scene *scene)
if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) { if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) {
if (speaker->sound) 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 { else {
AUD_removeSequence(scene->sound_scene, strip->speaker_handle); AUD_removeSequence(scene->sound_scene, strip->speaker_handle);
strip->speaker_handle = NULL; strip->speaker_handle = NULL;
@@ -709,7 +709,9 @@ void sound_update_scene(struct Scene *scene)
} }
else { else {
if (speaker->sound) { 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); AUD_setRelativeSequence(strip->speaker_handle, 0);
} }
} }

View File

@@ -2356,8 +2356,8 @@ void resolve_quad_uv(float r_uv[2], const float st[2], const float st0[2], const
const double a = (st0[0] - st[0]) * (st0[1] - st3[1]) - (st0[1] - st[1]) * (st0[0] - st3[0]); const double a = (st0[0] - st[0]) * (st0[1] - st3[1]) - (st0[1] - st[1]) * (st0[0] - st3[0]);
/* B = ( (p0 - p) X (p1 - p2) + (p1 - p) X (p0 - p3) ) / 2 */ /* B = ( (p0 - p) X (p1 - p2) + (p1 - p) X (p0 - p3) ) / 2 */
const double b = 0.5 * (((st0[0] - st[0]) * (st1[1] - st2[1]) - (st0[1] - st[1]) * (st1[0] - st2[0])) + const double b = 0.5 * (double)(((st0[0] - st[0]) * (st1[1] - st2[1]) - (st0[1] - st[1]) * (st1[0] - st2[0])) +
((st1[0] - st[0]) * (st0[1] - st3[1]) - (st1[1] - st[1]) * (st0[0] - st3[0]))); ((st1[0] - st[0]) * (st0[1] - st3[1]) - (st1[1] - st[1]) * (st0[0] - st3[0])));
/* C = (p1-p) X (p1-p2) */ /* C = (p1-p) X (p1-p2) */
const double fC = (st1[0] - st[0]) * (st1[1] - st2[1]) - (st1[1] - st[1]) * (st1[0] - st2[0]); const double fC = (st1[0] - st[0]) * (st1[1] - st2[1]) - (st1[1] - st[1]) * (st1[0] - st2[0]);
@@ -2393,7 +2393,7 @@ void resolve_quad_uv(float r_uv[2], const float st[2], const float st0[2], const
} }
if (IS_ZERO(denom) == 0) if (IS_ZERO(denom) == 0)
r_uv[1] = (float)(((1.0f - r_uv[0]) * (st0[i] - st[i]) + r_uv[0] * (st1[i] - st[i])) / denom); r_uv[1] = (float)((double)((1.0f - r_uv[0]) * (st0[i] - st[i]) + r_uv[0] * (st1[i] - st[i])) / denom);
} }
} }

View File

@@ -603,15 +603,15 @@ int invert_m4_m4(float inverse[4][4], float mat[4][4])
if (temp == 0) if (temp == 0)
return 0; /* No non-zero pivot */ return 0; /* No non-zero pivot */
for (k = 0; k < 4; k++) { for (k = 0; k < 4; k++) {
tempmat[i][k] = (float)(tempmat[i][k] / temp); tempmat[i][k] = (float)((double)tempmat[i][k] / temp);
inverse[i][k] = (float)(inverse[i][k] / temp); inverse[i][k] = (float)((double)inverse[i][k] / temp);
} }
for (j = 0; j < 4; j++) { for (j = 0; j < 4; j++) {
if (j != i) { if (j != i) {
temp = tempmat[j][i]; temp = tempmat[j][i];
for (k = 0; k < 4; k++) { for (k = 0; k < 4; k++) {
tempmat[j][k] -= (float)(tempmat[i][k] * temp); tempmat[j][k] -= (float)((double)tempmat[i][k] * temp);
inverse[j][k] -= (float)(inverse[i][k] * temp); inverse[j][k] -= (float)((double)inverse[i][k] * temp);
} }
} }
} }

View File

@@ -234,7 +234,7 @@ 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; double q0, q1, q2, q3, qda, qdb, qdc, qaa, qab, qac, qbb, qbc, qcc;
#ifdef DEBUG #ifdef DEBUG
if (!((q0 = dot_qtqt(q, q)) == 0.0f || (fabsf(q0 - 1.0) < (float)QUAT_EPSILON))) { if (!((q0 = dot_qtqt(q, q)) == 0.0 || (fabs(q0 - 1.0) < QUAT_EPSILON))) {
fprintf(stderr, "Warning! quat_to_mat4() called with non-normalized: size %.8f *** report a bug ***\n", (float)q0); fprintf(stderr, "Warning! quat_to_mat4() called with non-normalized: size %.8f *** report a bug ***\n", (float)q0);
} }
#endif #endif
@@ -288,9 +288,9 @@ void mat3_to_quat(float q[4], float wmat[][3])
s = sqrt(tr); s = sqrt(tr);
q[0] = (float)s; q[0] = (float)s;
s = 1.0 / (4.0 * s); s = 1.0 / (4.0 * s);
q[1] = (float)((mat[1][2] - mat[2][1]) * s); q[1] = (float)((double)(mat[1][2] - mat[2][1]) * s);
q[2] = (float)((mat[2][0] - mat[0][2]) * s); q[2] = (float)((double)(mat[2][0] - mat[0][2]) * s);
q[3] = (float)((mat[0][1] - mat[1][0]) * s); q[3] = (float)((double)(mat[0][1] - mat[1][0]) * s);
} }
else { else {
if (mat[0][0] > mat[1][1] && mat[0][0] > mat[2][2]) { if (mat[0][0] > mat[1][1] && mat[0][0] > mat[2][2]) {

View File

@@ -492,7 +492,7 @@ double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int s
const float *array_pt_b = array_src_b + (size - 1); const float *array_pt_b = array_src_b + (size - 1);
int i = size; int i = size;
while (i--) { while (i--) {
d += *(array_pt_a--) * *(array_pt_b--); d += (double)(*(array_pt_a--) * *(array_pt_b--));
} }
return d; return d;
} }

View File

@@ -105,25 +105,25 @@ int BLI_rctf_isect_pt_v(const rctf *rect, const float xy[2])
static int isect_segments_i(const int v1[2], const int v2[2], const int v3[2], const int v4[2]) static int isect_segments_i(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
{ {
const double div = (double)((v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0])); const double div = (double)((v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0]));
if (div == 0.0f) { if (div == 0.0) {
return 1; /* co-linear */ return 1; /* co-linear */
} }
else { else {
const double labda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div; const double labda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) / div; const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) / div;
return (labda >= 0.0f && labda <= 1.0f && mu >= 0.0f && mu <= 1.0f); return (labda >= 0.0 && labda <= 1.0 && mu >= 0.0 && mu <= 1.0);
} }
} }
static int isect_segments_fl(const float v1[2], const float v2[2], const float v3[2], const float v4[2]) static int isect_segments_fl(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
{ {
const double div = (double)((v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0])); const double div = (double)((v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0]));
if (div == 0.0f) { if (div == 0.0) {
return 1; /* co-linear */ return 1; /* co-linear */
} }
else { else {
const double labda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div; const double labda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) / div; const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) / div;
return (labda >= 0.0f && labda <= 1.0f && mu >= 0.0f && mu <= 1.0f); return (labda >= 0.0 && labda <= 1.0 && mu >= 0.0 && mu <= 1.0);
} }
} }

View File

@@ -1319,7 +1319,7 @@ void RIG_printArc(RigGraph *rg, RigArc *arc)
for (edge = arc->edges.first; edge; edge = edge->next) { for (edge = arc->edges.first; edge; edge = edge->next) {
printf("\tinner joints %0.3f %0.3f %0.3f\n", edge->tail[0], edge->tail[1], edge->tail[2]); printf("\tinner joints %0.3f %0.3f %0.3f\n", edge->tail[0], edge->tail[1], edge->tail[2]);
printf("\t\tlength %f\n", edge->length); printf("\t\tlength %f\n", edge->length);
printf("\t\tangle %f\n", edge->angle * 180 / M_PI); printf("\t\tangle %f\n", edge->angle * (float)(180 / M_PI));
if (edge->bone) { if (edge->bone) {
printf("\t\t%s\n", edge->bone->name); printf("\t\t%s\n", edge->bone->name);
RIG_printLinkedCtrl(rg, edge->bone, 3); RIG_printLinkedCtrl(rg, edge->bone, 3);

View File

@@ -209,7 +209,7 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts
triflags = MEM_callocN(sizeof(unsigned char) * ntris, "buildNavMesh triflags"); triflags = MEM_callocN(sizeof(unsigned char) * ntris, "buildNavMesh triflags");
/* Find triangles which are walkable based on their slope and rasterize them */ /* Find triangles which are walkable based on their slope and rasterize them */
recast_markWalkableTriangles(RAD2DEG(recastParams->agentmaxslope), verts, nverts, tris, ntris, triflags); recast_markWalkableTriangles(RAD2DEGF(recastParams->agentmaxslope), verts, nverts, tris, ntris, triflags);
recast_rasterizeTriangles(verts, nverts, tris, triflags, ntris, solid); recast_rasterizeTriangles(verts, nverts, tris, triflags, ntris, solid);
MEM_freeN(triflags); MEM_freeN(triflags);

View File

@@ -242,7 +242,7 @@ static void init_time(FluidsimSettings *domainSettings, FluidAnimChannels *chann
channels->timeAtFrame[0] = channels->timeAtFrame[1] = domainSettings->animStart; // start at index 1 channels->timeAtFrame[0] = channels->timeAtFrame[1] = domainSettings->animStart; // start at index 1
for (i=2; i <= channels->length; i++) { for (i=2; i <= channels->length; i++) {
channels->timeAtFrame[i] = channels->timeAtFrame[i-1] + channels->aniFrameTime; channels->timeAtFrame[i] = channels->timeAtFrame[i - 1] + (float)channels->aniFrameTime;
} }
} }
@@ -426,7 +426,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
/* Domain time */ /* Domain time */
// TODO: have option for not running sim, time mangling, in which case second case comes in handy // TODO: have option for not running sim, time mangling, in which case second case comes in handy
if (channels->DomainTime) { if (channels->DomainTime) {
time = get_fluid_rate(domainSettings) * channels->aniFrameTime; time = get_fluid_rate(domainSettings) * (float)channels->aniFrameTime;
timeAtFrame = channels->timeAtFrame[i] + time; timeAtFrame = channels->timeAtFrame[i] + time;
channels->timeAtFrame[i+1] = timeAtFrame; channels->timeAtFrame[i+1] = timeAtFrame;
@@ -456,11 +456,11 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
/* get the rotation from ob->obmat rather than ob->rot to account for parent animations */ /* get the rotation from ob->obmat rather than ob->rot to account for parent animations */
if (i) { if (i) {
copy_v3_v3(old_rot, fobj->Rotation + 4*(i-1)); copy_v3_v3(old_rot, fobj->Rotation + 4*(i-1));
mul_v3_fl(old_rot, -M_PI/180.f); mul_v3_fl(old_rot, (float)-M_PI / 180.f);
} }
mat4_to_compatible_eulO(rot_d, old_rot, 0, ob->obmat); mat4_to_compatible_eulO(rot_d, old_rot, 0, ob->obmat);
mul_v3_fl(rot_d, -180.f/M_PI); mul_v3_fl(rot_d, -180.0f / (float)M_PI);
set_channel(fobj->Translation, timeAtFrame, ob->loc, i, CHANNEL_VEC); set_channel(fobj->Translation, timeAtFrame, ob->loc, i, CHANNEL_VEC);
set_channel(fobj->Rotation, timeAtFrame, rot_d, i, CHANNEL_VEC); set_channel(fobj->Rotation, timeAtFrame, rot_d, i, CHANNEL_VEC);
@@ -962,7 +962,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
/* ******** prepare output file paths ******** */ /* ******** prepare output file paths ******** */
outStringsChanged = fluid_init_filepaths(fsDomain, targetDir, targetFile, debugStrBuffer); outStringsChanged = fluid_init_filepaths(fsDomain, targetDir, targetFile, debugStrBuffer);
channels->length = scene->r.efra; channels->length = scene->r.efra;
channels->aniFrameTime = (domainSettings->animEnd - domainSettings->animStart)/(double)noFrames; channels->aniFrameTime = (double)(domainSettings->animEnd - domainSettings->animStart) / (double)noFrames;
/* ******** initialize and allocate animation channels ******** */ /* ******** initialize and allocate animation channels ******** */
fluid_init_all_channels(C, fsDomain, domainSettings, channels, fobjects); fluid_init_all_channels(C, fsDomain, domainSettings, channels, fobjects);

View File

@@ -855,8 +855,8 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event)
vec[0] *= data->width; vec[0] *= data->width;
vec[1] *= data->height; vec[1] *= data->height;
data->corners[a][0] = (vec[0] * cos(angle) - vec[1] * sin(angle)) / data->width; data->corners[a][0] = (vec[0] * cosf(angle) - vec[1] * sinf(angle)) / data->width;
data->corners[a][1] = (vec[1] * cos(angle) + vec[0] * sin(angle)) / data->height; data->corners[a][1] = (vec[1] * cosf(angle) + vec[0] * sinf(angle)) / data->height;
} }
BKE_tracking_marker_clamp(data->marker, CLAMP_PAT_DIM); BKE_tracking_marker_clamp(data->marker, CLAMP_PAT_DIM);

View File

@@ -775,7 +775,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
glColor3fv(color); glColor3fv(color);
} }
else { else {
float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3 : 1.0f; float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3f : 1.0f;
glColor4f(color[0], color[1], color[2], alpha); glColor4f(color[0], color[1], color[2], alpha);
} }

View File

@@ -439,7 +439,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
uiDefButR(block, NUM, 0, "Radius", 0, yi -= buth + but_margin, 200, buth, uiDefButR(block, NUM, 0, "Radius", 0, yi -= buth + but_margin, 200, buth,
&data_ptr, "radius", 0, 0.0, 100.0, 1, 3, NULL); &data_ptr, "radius", 0, 0.0, 100.0, 1, 3, NULL);
uiDefButR(block, NUM, 0, "Tilt", 0, yi -= buth + but_margin, 200, buth, uiDefButR(block, NUM, 0, "Tilt", 0, yi -= buth + but_margin, 200, buth,
&data_ptr, "tilt", 0, -M_PI * 2.0f, M_PI * 2.0f, 1, 3, NULL); &data_ptr, "tilt", 0, -M_PI * 2.0, M_PI * 2.0, 1, 3, NULL);
} }
else if (totcurvedata > 1) { else if (totcurvedata > 1) {
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Weight:"), uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Weight:"),
@@ -450,7 +450,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&(tfp->ve_median[C_RADIUS]), 0.0, 100.0, 1, 3, TIP_("Radius of curve control points")); &(tfp->ve_median[C_RADIUS]), 0.0, 100.0, 1, 3, TIP_("Radius of curve control points"));
but = uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Tilt:"), but = uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Tilt:"),
0, yi -= buth + but_margin, 200, buth, 0, yi -= buth + but_margin, 200, buth,
&(tfp->ve_median[C_TILT]), -M_PI * 2.0f, M_PI * 2.0f, 1, 3, &(tfp->ve_median[C_TILT]), -M_PI * 2.0, M_PI * 2.0, 1, 3,
TIP_("Tilt of curve control points")); TIP_("Tilt of curve control points"));
uiButSetUnitType(but, PROP_UNIT_ROTATION); uiButSetUnitType(but, PROP_UNIT_ROTATION);
} }

View File

@@ -5516,7 +5516,7 @@ void drawNonPropEdge(const struct bContext *C, TransInfo *t)
float v1[3], v2[3]; float v1[3], v2[3];
float interp_v; float interp_v;
TransDataSlideVert *curr_sv = &sld->sv[sld->curr_sv_index]; TransDataSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5; const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f;
const float guide_size = ctrl_size - 0.5f; const float guide_size = ctrl_size - 0.5f;
const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f; const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f;
const int alpha_shade = -30; const int alpha_shade = -30;

View File

@@ -357,7 +357,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int
ibuf->planes = planes; ibuf->planes = planes;
ibuf->ftype = TGA; ibuf->ftype = TGA;
ibuf->channels = 4; /* float option, is set to other values when buffers get assigned */ ibuf->channels = 4; /* float option, is set to other values when buffers get assigned */
ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254; /* IMB_DPI_DEFAULT -> pixels-per-meter */ ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254f; /* IMB_DPI_DEFAULT -> pixels-per-meter */
if (flags & IB_rect) { if (flags & IB_rect) {
if (imb_addrectImBuf(ibuf) == FALSE) { if (imb_addrectImBuf(ibuf) == FALSE) {

View File

@@ -45,8 +45,7 @@ static bNodeSocketTemplate sh_node_squeeze_out[] = {
{ -1, 0, "" } { -1, 0, "" }
}; };
static void node_shader_exec_squeeze(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in, static void node_shader_exec_squeeze(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in, bNodeStack **out)
bNodeStack **out)
{ {
float vec[3]; float vec[3];
@@ -54,7 +53,7 @@ bNodeStack **out)
nodestack_get_vec(vec+1, SOCK_FLOAT, in[1]); nodestack_get_vec(vec+1, SOCK_FLOAT, in[1]);
nodestack_get_vec(vec+2, SOCK_FLOAT, in[2]); nodestack_get_vec(vec+2, SOCK_FLOAT, in[2]);
out[0]->vec[0] = 1.0f / (1.0f + pow(M_E, -((vec[0] - vec[2]) * vec[1]))); out[0]->vec[0] = 1.0f / (1.0f + powf(M_E, -((vec[0] - vec[2]) * vec[1])));
} }
static int gpu_shader_squeeze(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) static int gpu_shader_squeeze(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)

View File

@@ -2008,7 +2008,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
for (row = 0; row < mat1->num_row; row++) { for (row = 0; row < mat1->num_row; row++) {
double dot = 0.0f; double dot = 0.0f;
for (item = 0; item < mat1->num_col; item++) { for (item = 0; item < mat1->num_col; item++) {
dot += MATRIX_ITEM(mat1, row, item) * MATRIX_ITEM(mat2, item, col); dot += (double)(MATRIX_ITEM(mat1, row, item) * MATRIX_ITEM(mat2, item, col));
} }
mat[(col * mat1->num_row) + row] = (float)dot; mat[(col * mat1->num_row) + row] = (float)dot;
} }

View File

@@ -2713,7 +2713,7 @@ static int row_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *
for (col = 0; col < mat->num_col; col++) { for (col = 0; col < mat->num_col; col++) {
double dot = 0.0; double dot = 0.0;
for (row = 0; row < mat->num_row; row++) { for (row = 0; row < mat->num_row; row++) {
dot += MATRIX_ITEM(mat, row, col) * vec_cpy[row]; dot += (double)(MATRIX_ITEM(mat, row, col) * vec_cpy[row]);
} }
r_vec[z++] = (float)dot; r_vec[z++] = (float)dot;
} }

View File

@@ -124,6 +124,9 @@
/* or for checking vertex normal flips */ /* or for checking vertex normal flips */
#define FLT_EPSILON10 1.19209290e-06F #define FLT_EPSILON10 1.19209290e-06F
/* could enable at some point but for now there are far too many conversions */
#pragma GCC diagnostic ignored "-Wdouble-promotion"
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* Stuff for stars. This sits here because it uses gl-things. Part of /* Stuff for stars. This sits here because it uses gl-things. Part of

View File

@@ -159,9 +159,9 @@ static void make_jitter_weight_tab(Render *re, ShadBuf *shb, short filtertype)
for (jit= shb->jit, a=0; a<tot; a++, jit+=2) { for (jit= shb->jit, a=0; a<tot; a++, jit+=2) {
if (filtertype==LA_SHADBUF_TENT) if (filtertype==LA_SHADBUF_TENT)
shb->weight[a]= 0.71f - sqrt(jit[0]*jit[0] + jit[1]*jit[1]); shb->weight[a] = 0.71f - sqrtf(jit[0] * jit[0] + jit[1] * jit[1]);
else if (filtertype==LA_SHADBUF_GAUSS) else if (filtertype==LA_SHADBUF_GAUSS)
shb->weight[a]= RE_filter_value(R_FILTER_GAUSS, 1.8f*sqrt(jit[0]*jit[0] + jit[1]*jit[1])); shb->weight[a] = RE_filter_value(R_FILTER_GAUSS, 1.8f * sqrtf(jit[0] * jit[0] + jit[1] * jit[1]));
else else
shb->weight[a]= 1.0f; shb->weight[a]= 1.0f;
@@ -217,15 +217,15 @@ static int compress_deepsamples(DeepSample *dsample, int tot, float epsilon)
if (ds->z == newds->z) { if (ds->z == newds->z) {
/* still in same z position, simply check /* still in same z position, simply check
* visibility difference against epsilon */ * visibility difference against epsilon */
if (!(fabs(newds->v - ds->v) <= epsilon)) { if (!(fabsf(newds->v - ds->v) <= epsilon)) {
break; break;
} }
} }
else { else {
/* compute slopes */ /* compute slopes */
div= (double)0x7FFFFFFF/((double)ds->z - (double)newds->z); div= (double)0x7FFFFFFF / ((double)ds->z - (double)newds->z);
min= ((ds->v - epsilon) - newds->v)*div; min= (double)((ds->v - epsilon) - newds->v) * div;
max= ((ds->v + epsilon) - newds->v)*div; max= (double)((ds->v + epsilon) - newds->v) * div;
/* adapt existing slopes */ /* adapt existing slopes */
if (first) { if (first) {
@@ -264,8 +264,8 @@ static int compress_deepsamples(DeepSample *dsample, int tot, float epsilon)
} }
else { else {
/* compute visibility at center between slopes at z */ /* compute visibility at center between slopes at z */
slope= (slopemin+slopemax)*0.5f; slope = (slopemin + slopemax) * 0.5;
v= newds->v + slope*((z - newds->z)/(double)0x7FFFFFFF); v = (double)newds->v + slope * ((double)(z - newds->z) / (double)0x7FFFFFFF);
} }
newds++; newds++;
@@ -778,7 +778,7 @@ void makeshadowbuf(Render *re, LampRen *lar)
* transforming from observer view to lamp view, including lamp window matrix */ * transforming from observer view to lamp view, including lamp window matrix */
angle= saacos(lar->spotsi); angle= saacos(lar->spotsi);
temp= 0.5f*shb->size*cos(angle)/sin(angle); temp = 0.5f * shb->size * cosf(angle) / sinf(angle);
shb->pixsize= (shb->d)/temp; shb->pixsize= (shb->d)/temp;
wsize= shb->pixsize*(shb->size/2.0f); wsize= shb->pixsize*(shb->size/2.0f);
@@ -1663,9 +1663,9 @@ static void bspface_init_strand(BSPFace *face)
face->len= face->rc[0]*face->rc[0]+ face->rc[1]*face->rc[1]; face->len= face->rc[0]*face->rc[0]+ face->rc[1]*face->rc[1];
if (face->len!=0.0f) { if (face->len != 0.0f) {
face->radline_end= face->radline/sqrt(face->len); face->radline_end = face->radline / sqrtf(face->len);
face->len= 1.0f/face->len; face->len = 1.0f / face->len;
} }
} }

View File

@@ -57,6 +57,9 @@
#include "shading.h" /* own include */ #include "shading.h" /* own include */
/* could enable at some point but for now there are far too many conversions */
#pragma GCC diagnostic ignored "-Wdouble-promotion"
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */ /* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
/* only to be used here in this file, it's for speed */ /* only to be used here in this file, it's for speed */
@@ -314,8 +317,8 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens)
/* calculate t0: is the maximum visible z (when halo is intersected by face) */ /* calculate t0: is the maximum visible z (when halo is intersected by face) */
if (do_clip) { if (do_clip) {
if (use_yco == FALSE) t0 = (maxz - npos[2]) / nray[2]; if (use_yco == FALSE) t0 = ((double)maxz - npos[2]) / nray[2];
else t0 = (maxy - npos[1]) / nray[1]; else t0 = ((double)maxy - npos[1]) / nray[1];
if (t0 < t1) return; if (t0 < t1) return;
if (t0 < t2) t2= t0; if (t0 < t2) t2= t0;

View File

@@ -76,6 +76,9 @@
/* own includes */ /* own includes */
#include "zbuf.h" #include "zbuf.h"
/* could enable at some point but for now there are far too many conversions */
#pragma GCC diagnostic ignored "-Wdouble-promotion"
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */ /* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
/* only to be used here in this file, it's for speed */ /* only to be used here in this file, it's for speed */
@@ -2732,7 +2735,7 @@ static void zbuf_fill_in_rgba(ZSpan *zspan, DrawBufPixel *col, float *v1, float
x= sn2-sn1; x= sn2-sn1;
while (x>=0) { while (x>=0) {
if ( zverg < *rz) { if (zverg < (double)*rz) {
*rz= zverg; *rz= zverg;
*rp= *col; *rp= *col;
} }