Cleanup: use function style casts

This commit is contained in:
Campbell Barton
2024-12-09 09:14:46 +11:00
parent 083b690fb5
commit 21ecc1a804
11 changed files with 146 additions and 150 deletions

View File

@@ -27,7 +27,7 @@
/* works but slower */
uint BLI_ghashutil_ptrhash(const void *key)
{
return (uint)(intptr_t)key;
return uint(intptr_t(key));
}
#else
uint BLI_ghashutil_ptrhash(const void *key)

View File

@@ -31,7 +31,7 @@ double double_round(double x, int ndigits)
double pow1, pow2, y, z;
if (ndigits >= 0) {
pow1 = pow(10.0, (double)ndigits);
pow1 = pow(10.0, double(ndigits));
pow2 = 1.0;
y = (x * pow1) * pow2;
/* if y overflows, then rounded value is exactly x */
@@ -40,7 +40,7 @@ double double_round(double x, int ndigits)
}
}
else {
pow1 = pow(10.0, (double)-ndigits);
pow1 = pow(10.0, double(-ndigits));
pow2 = 1.0; /* unused; silences a gcc compiler warning */
y = x / pow1;
}

View File

@@ -195,10 +195,10 @@ static void quat_to_mat3_no_error(float m[3][3], const float q[4])
{
double q0, q1, q2, q3, qda, qdb, qdc, qaa, qab, qac, qbb, qbc, qcc;
q0 = M_SQRT2 * (double)q[0];
q1 = M_SQRT2 * (double)q[1];
q2 = M_SQRT2 * (double)q[2];
q3 = M_SQRT2 * (double)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;
@@ -210,24 +210,24 @@ static void quat_to_mat3_no_error(float m[3][3], const float q[4])
qbc = q2 * q3;
qcc = q3 * q3;
m[0][0] = (float)(1.0 - qbb - qcc);
m[0][1] = (float)(qdc + qab);
m[0][2] = (float)(-qdb + qac);
m[0][0] = float(1.0 - qbb - qcc);
m[0][1] = float(qdc + qab);
m[0][2] = float(-qdb + qac);
m[1][0] = (float)(-qdc + qab);
m[1][1] = (float)(1.0 - qaa - qcc);
m[1][2] = (float)(qda + qbc);
m[1][0] = float(-qdc + qab);
m[1][1] = float(1.0 - qaa - qcc);
m[1][2] = float(qda + qbc);
m[2][0] = (float)(qdb + qac);
m[2][1] = (float)(-qda + qbc);
m[2][2] = (float)(1.0 - qaa - qbb);
m[2][0] = float(qdb + qac);
m[2][1] = float(-qda + qbc);
m[2][2] = float(1.0 - qaa - qbb);
}
void quat_to_mat3(float m[3][3], const float q[4])
{
#ifndef NDEBUG
float f;
if (!((f = dot_qtqt(q, q)) == 0.0f || (fabsf(f - 1.0f) < (float)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);
@@ -245,14 +245,14 @@ void quat_to_mat4(float m[4][4], const float q[4])
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);
float(q0));
}
#endif
q0 = M_SQRT2 * (double)q[0];
q1 = M_SQRT2 * (double)q[1];
q2 = M_SQRT2 * (double)q[2];
q3 = M_SQRT2 * (double)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;
@@ -264,19 +264,19 @@ void quat_to_mat4(float m[4][4], const float q[4])
qbc = q2 * q3;
qcc = q3 * q3;
m[0][0] = (float)(1.0 - qbb - qcc);
m[0][1] = (float)(qdc + qab);
m[0][2] = (float)(-qdb + qac);
m[0][0] = float(1.0 - qbb - qcc);
m[0][1] = float(qdc + qab);
m[0][2] = float(-qdb + qac);
m[0][3] = 0.0f;
m[1][0] = (float)(-qdc + qab);
m[1][1] = (float)(1.0 - qaa - qcc);
m[1][2] = (float)(qda + qbc);
m[1][0] = float(-qdc + qab);
m[1][1] = float(1.0 - qaa - qcc);
m[1][2] = float(qda + qbc);
m[1][3] = 0.0f;
m[2][0] = (float)(qdb + qac);
m[2][1] = (float)(-qda + qbc);
m[2][2] = (float)(1.0 - qaa - qbb);
m[2][0] = float(qdb + qac);
m[2][1] = float(-qda + qbc);
m[2][2] = float(1.0 - qaa - qbb);
m[2][3] = 0.0f;
m[3][0] = m[3][1] = m[3][2] = 0.0f;
@@ -546,7 +546,7 @@ void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2
else {
/* Colinear but opposed vectors, 180 rotation... */
ortho_v3_v3(axis, v1);
axis_angle_to_quat(q, axis, (float)M_PI);
axis_angle_to_quat(q, axis, float(M_PI));
}
}
}
@@ -730,7 +730,7 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
/* rotate to axis */
if (axis > 2) {
copy_v3_v3(tvec, vec);
axis = (short)(axis - 3);
axis = short(axis - 3);
}
else {
negate_v3_v3(tvec, vec);
@@ -834,7 +834,7 @@ void QuatInterpolW(float *result, float quat1[4], float quat2[4], float t)
if ((1.0f + cosom) > 0.0001f) {
if ((1.0f - cosom) > 0.0001f) {
omega = (float)acos(cosom);
omega = float(acos(cosom));
sinom = sinf(omega);
sc1 = sinf((1.0 - t) * omega) / sinom;
sc2 = sinf(t * omega) / sinom;
@@ -1036,7 +1036,7 @@ void sin_cos_from_fraction(int numerator, int denominator, float *r_sin, float *
BLI_assert(numerator <= denominator / 4);
BLI_assert(ELEM(cos_sign, -1.0f, 1.0f));
const float angle = (float)(2.0 * M_PI) * ((float)numerator / (float)denominator);
const float angle = float(2.0 * M_PI) * (float(numerator) / float(denominator));
*r_sin = sinf(angle);
*r_cos = cosf(angle) * cos_sign;
}
@@ -1075,7 +1075,7 @@ void quat_to_axis_angle(float axis[3], float *angle, const float q[4])
float ha, si;
#ifndef NDEBUG
if (!((ha = dot_qtqt(q, q)) == 0.0f || (fabsf(ha - 1.0f) < (float)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",
@@ -1352,15 +1352,15 @@ void eul_to_mat3(float mat[3][3], const float eul[3])
sc = si * ch;
ss = si * sh;
mat[0][0] = (float)(cj * ch);
mat[1][0] = (float)(sj * sc - cs);
mat[2][0] = (float)(sj * cc + ss);
mat[0][1] = (float)(cj * sh);
mat[1][1] = (float)(sj * ss + cc);
mat[2][1] = (float)(sj * cs - sc);
mat[0][2] = (float)-sj;
mat[1][2] = (float)(cj * si);
mat[2][2] = (float)(cj * ci);
mat[0][0] = float(cj * ch);
mat[1][0] = float(sj * sc - cs);
mat[2][0] = float(sj * cc + ss);
mat[0][1] = float(cj * sh);
mat[1][1] = float(sj * ss + cc);
mat[2][1] = float(sj * cs - sc);
mat[0][2] = float(-sj);
mat[1][2] = float(cj * si);
mat[2][2] = float(cj * ci);
}
void eul_to_mat4(float mat[4][4], const float eul[3])
@@ -1378,15 +1378,15 @@ void eul_to_mat4(float mat[4][4], const float eul[3])
sc = si * ch;
ss = si * sh;
mat[0][0] = (float)(cj * ch);
mat[1][0] = (float)(sj * sc - cs);
mat[2][0] = (float)(sj * cc + ss);
mat[0][1] = (float)(cj * sh);
mat[1][1] = (float)(sj * ss + cc);
mat[2][1] = (float)(sj * cs - sc);
mat[0][2] = (float)-sj;
mat[1][2] = (float)(cj * si);
mat[2][2] = (float)(cj * ci);
mat[0][0] = float(cj * ch);
mat[1][0] = float(sj * sc - cs);
mat[2][0] = float(sj * cc + ss);
mat[0][1] = float(cj * sh);
mat[1][1] = float(sj * ss + cc);
mat[2][1] = float(sj * cs - sc);
mat[0][2] = float(-sj);
mat[1][2] = float(cj * si);
mat[2][2] = float(cj * ci);
mat[3][0] = mat[3][1] = mat[3][2] = mat[0][3] = mat[1][3] = mat[2][3] = 0.0f;
mat[3][3] = 1.0f;
@@ -1401,7 +1401,7 @@ static void mat3_normalized_to_eul2(const float mat[3][3], float eul1[3], float
BLI_ASSERT_UNIT_M3(mat);
if (cy > (float)EULER_HYPOT_EPSILON) {
if (cy > float(EULER_HYPOT_EPSILON)) {
eul1[0] = atan2f(mat[1][2], mat[2][2]);
eul1[1] = atan2f(-mat[0][2], cy);
eul1[2] = atan2f(mat[0][1], mat[0][0]);
@@ -1518,8 +1518,8 @@ void compatible_eul(float eul[3], const float oldrot[3])
* NOTE: Values between `pi` & `2 * pi` work, where `pi` has the lowest number of
* discontinuities and values approaching `2 * pi` center the resulting rotation around zero,
* at the expense of the result being less compatible, see !104856. */
const float pi_thresh = (float)M_PI;
const float pi_x2 = (2.0f * (float)M_PI);
const float pi_thresh = float(M_PI);
const float pi_x2 = (2.0f * float(M_PI));
float deul[3];
uint i;
@@ -1643,9 +1643,9 @@ void eulO_to_quat(float q[4], const float e[3], const short order)
double ti, tj, th, ci, cj, ch, si, sj, sh, cc, cs, sc, ss;
double a[3];
ti = (double)e[i] * 0.5;
tj = (double)e[j] * (R->parity ? -0.5 : 0.5);
th = (double)e[k] * 0.5;
ti = double(e[i]) * 0.5;
tj = double(e[j]) * (R->parity ? -0.5 : 0.5);
th = double(e[k]) * 0.5;
ci = cos(ti);
cj = cos(tj);
@@ -1663,10 +1663,10 @@ void eulO_to_quat(float q[4], const float e[3], const short order)
a[j] = cj * ss + sj * cc;
a[k] = cj * cs - sj * sc;
q[0] = (float)(cj * cc + sj * ss);
q[1] = (float)(a[0]);
q[2] = (float)(a[1]);
q[3] = (float)(a[2]);
q[0] = float(cj * cc + sj * ss);
q[1] = float(a[0]);
q[2] = float(a[1]);
q[3] = float(a[2]);
if (R->parity) {
q[j + 1] = -q[j + 1];
@@ -1710,15 +1710,15 @@ void eulO_to_mat3(float M[3][3], const float e[3], const short order)
sc = si * ch;
ss = si * sh;
M[i][i] = (float)(cj * ch);
M[j][i] = (float)(sj * sc - cs);
M[k][i] = (float)(sj * cc + ss);
M[i][j] = (float)(cj * sh);
M[j][j] = (float)(sj * ss + cc);
M[k][j] = (float)(sj * cs - sc);
M[i][k] = (float)(-sj);
M[j][k] = (float)(cj * si);
M[k][k] = (float)(cj * ci);
M[i][i] = float(cj * ch);
M[j][i] = float(sj * sc - cs);
M[k][i] = float(sj * cc + ss);
M[i][j] = float(cj * sh);
M[j][j] = float(sj * ss + cc);
M[k][j] = float(sj * cs - sc);
M[i][k] = float(-sj);
M[j][k] = float(cj * si);
M[k][k] = float(cj * ci);
}
/* returns two euler calculation methods, so we can pick the best */
@@ -1735,7 +1735,7 @@ static void mat3_normalized_to_eulo2(const float mat[3][3],
cy = hypotf(mat[i][i], mat[i][j]);
if (cy > (float)EULER_HYPOT_EPSILON) {
if (cy > float(EULER_HYPOT_EPSILON)) {
eul1[i] = atan2f(mat[j][k], mat[k][k]);
eul1[j] = atan2f(-mat[i][k], cy);
eul1[k] = atan2f(mat[i][j], mat[i][i]);
@@ -2230,7 +2230,7 @@ void copy_dq_dq(DualQuat *r, const DualQuat *dq)
void quat_apply_track(float quat[4], short axis, short upflag)
{
/* rotations are hard coded to match vec_to_quat */
const float sqrt_1_2 = (float)M_SQRT1_2;
const float sqrt_1_2 = float(M_SQRT1_2);
const float quat_track[][4] = {
/* pos-y90 */
{sqrt_1_2, 0.0, -sqrt_1_2, 0.0},
@@ -2252,7 +2252,7 @@ void quat_apply_track(float quat[4], short axis, short upflag)
mul_qt_qtqt(quat, quat, quat_track[axis]);
if (axis > 2) {
axis = (short)(axis - 3);
axis = short(axis - 3);
}
/* there are 2 possible up-axis for each axis used, the 'quat_track' applies so the first
@@ -2325,7 +2325,7 @@ static float mod_inline(float a, float b)
float angle_wrap_rad(float angle)
{
return mod_inline(angle + (float)M_PI, (float)M_PI * 2.0f) - (float)M_PI;
return mod_inline(angle + float(M_PI), float(M_PI) * 2.0f) - float(M_PI);
}
float angle_wrap_deg(float angle)

View File

@@ -51,7 +51,7 @@ bool BLI_tridiagonal_solve(
return false;
}
size_t bytes = sizeof(double) * (uint)count;
size_t bytes = sizeof(double) * uint(count);
double *c1 = (double *)MEM_mallocN(bytes * 2, "tridiagonal_c1d1");
if (!c1) {
return false;
@@ -63,8 +63,8 @@ bool BLI_tridiagonal_solve(
/* forward pass */
c1[0] = c_prev = ((double)c[0]) / b[0];
d1[0] = d_prev = ((double)d[0]) / b[0];
c1[0] = c_prev = double(c[0]) / b[0];
d1[0] = d_prev = double(d[0]) / b[0];
for (i = 1; i < count; i++) {
double denum = b[i] - a[i] * c_prev;
@@ -76,11 +76,11 @@ bool BLI_tridiagonal_solve(
/* back pass */
x_prev = d_prev;
r_x[--i] = ((float)x_prev);
r_x[--i] = float(x_prev);
while (--i >= 0) {
x_prev = d1[i] - c1[i] * x_prev;
r_x[i] = ((float)x_prev);
r_x[i] = float(x_prev);
}
MEM_freeN(c1);
@@ -117,7 +117,7 @@ bool BLI_tridiagonal_solve_cyclic(
return BLI_tridiagonal_solve(a, b, c, d, r_x, count);
}
size_t bytes = sizeof(float) * (uint)count;
size_t bytes = sizeof(float) * uint(count);
float *tmp = (float *)MEM_mallocN(bytes * 2, "tridiagonal_ex");
if (!tmp) {
return false;

View File

@@ -83,7 +83,7 @@ void BLI_covariance_m_vn_ex(const int n,
/* Note about that division: see https://en.wikipedia.org/wiki/Bessel%27s_correction.
* In a nutshell, it must be 1 / (n - 1) for 'sample data', and 1 / n for 'population data'...
*/
const float covfac = 1.0f / (float)(use_sample_correction ? cos_vn_num - 1 : cos_vn_num);
const float covfac = 1.0f / float(use_sample_correction ? cos_vn_num - 1 : cos_vn_num);
memset(r_covmat, 0, sizeof(*r_covmat) * (size_t)(n * n));
@@ -108,7 +108,7 @@ void BLI_covariance_m3_v3n(const float (*cos_v3)[3],
float r_center[3])
{
float center[3];
const float mean_fac = 1.0f / (float)cos_v3_num;
const float mean_fac = 1.0f / float(cos_v3_num);
int i;
zero_v3(center);

View File

@@ -191,9 +191,9 @@ void interp_v3_v3v3_uchar(uchar target[3], const uchar a[3], const uchar b[3], c
{
const float s = 1.0f - t;
target[0] = (char)floorf(s * a[0] + t * b[0]);
target[1] = (char)floorf(s * a[1] + t * b[1]);
target[2] = (char)floorf(s * a[2] + t * b[2]);
target[0] = char(floorf(s * a[0] + t * b[0]));
target[1] = char(floorf(s * a[1] + t * b[1]));
target[2] = char(floorf(s * a[2] + t * b[2]));
}
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
@@ -232,7 +232,7 @@ void mid_v3_v3v3v3v3(
void mid_v3_v3_array(float r[3], const float (*vec_arr)[3], const uint vec_arr_num)
{
const float factor = 1.0f / (float)vec_arr_num;
const float factor = 1.0f / float(vec_arr_num);
zero_v3(r);
for (uint i = 0; i < vec_arr_num; i++) {
@@ -251,7 +251,7 @@ void mid_v3_v3v3_angle_weighted(float r[3], const float a[3], const float b[3])
BLI_ASSERT_UNIT_V3(b);
add_v3_v3v3(r, a, b);
angle = ((float)M_2_PI *
angle = (float(M_2_PI) *
/* normally we would only multiply by 2,
* but instead of an angle make this 0-1 factor */
2.0f) *
@@ -362,7 +362,7 @@ float angle_normalized_v3v3(const float v1[3], const float v2[3])
float v2_n[3];
negate_v3_v3(v2_n, v2);
return (float)M_PI - 2.0f * safe_asinf(len_v3v3(v1, v2_n) / 2.0f);
return float(M_PI) - 2.0f * safe_asinf(len_v3v3(v1, v2_n) / 2.0f);
}
float angle_normalized_v2v2(const float a[2], const float b[2])
@@ -378,7 +378,7 @@ float angle_normalized_v2v2(const float a[2], const float b[2])
float v2_n[2];
negate_v2_v2(v2_n, b);
return (float)M_PI - 2.0f * safe_asinf(len_v2v2(a, v2_n) / 2.0f);
return float(M_PI) - 2.0f * safe_asinf(len_v2v2(a, v2_n) / 2.0f);
}
float angle_on_axis_v3v3_v3(const float v1[3], const float v2[3], const float axis[3])
@@ -406,7 +406,7 @@ float angle_signed_on_axis_v3v3_v3(const float v1[3], const float v2[3], const f
/* calculate the sign (reuse 'tproj') */
cross_v3_v3v3(tproj, v2_proj, v1_proj);
if (dot_v3v3(tproj, axis) < 0.0f) {
angle = (float)(M_PI * 2.0) - angle;
angle = float(M_PI * 2.0) - angle;
}
return angle;
@@ -450,10 +450,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] = (float)M_PI - angle_normalized_v3v3(ed1, ed2);
angles[1] = (float)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] = (float)M_PI - (angles[0] + angles[1]);
angles[2] = float(M_PI) - (angles[0] + angles[1]);
}
void angle_quad_v3(
@@ -471,10 +471,10 @@ void angle_quad_v3(
normalize_v3(ed3);
normalize_v3(ed4);
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);
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);
}
void angle_poly_v3(float *angles, const float *verts[3], int len)
@@ -487,7 +487,7 @@ void angle_poly_v3(float *angles, const float *verts[3], int len)
for (i = 0; i < len; i++) {
sub_v3_v3v3(vec[i % 3], verts[i % len], verts[(i + 1) % len]);
normalize_v3(vec[i % 3]);
angles[i] = (float)M_PI - angle_normalized_v3v3(vec[(i + 2) % 3], vec[i % 3]);
angles[i] = float(M_PI) - angle_normalized_v3v3(vec[(i + 2) % 3], vec[i % 3]);
}
}
@@ -857,7 +857,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);
int i = size;
while (i--) {
d += (double)(*(array_pt_a--) * *(array_pt_b--));
d += double(*(array_pt_a--) * *(array_pt_b--));
}
return d;
}
@@ -868,7 +868,7 @@ double len_squared_vn(const float *array, const int size)
const float *array_pt = array + (size - 1);
int i = size;
while (i--) {
d += sqr_db((double)*(array_pt--));
d += sqr_db(double(*(array_pt)--));
}
return d;
}
@@ -878,7 +878,7 @@ float normalize_vn_vn(float *array_tar, const float *array_src, const int size)
const double d = len_squared_vn(array_src, size);
float d_sqrt;
if (d > 1.0e-35) {
d_sqrt = (float)sqrt(d);
d_sqrt = float(sqrt(d));
mul_vn_vn_fl(array_tar, array_src, size, 1.0f / d_sqrt);
}
else {
@@ -906,7 +906,7 @@ void range_vn_i(int *array_tar, const int size, const int start)
void range_vn_u(uint *array_tar, const int size, const uint start)
{
uint *array_pt = array_tar + (size - 1);
uint j = start + (uint)(size - 1);
uint j = start + uint(size - 1);
int i = size;
while (i--) {
*(array_pt--) = j--;
@@ -918,7 +918,7 @@ void range_vn_fl(float *array_tar, const int size, const float start, const floa
float *array_pt = array_tar + (size - 1);
int i = size;
while (i--) {
*(array_pt--) = start + step * (float)(i);
*(array_pt--) = start + step * float(i);
}
}

View File

@@ -280,11 +280,11 @@ static float newPerlin(float x, float y, float z)
{
int A, AA, AB, B, BA, BB;
float u = floor(x), v = floor(y), w = floor(z);
int X = ((int)u) & 255;
int Y = ((int)v) & 255;
int Z = ((int)w) & 255; /* FIND UNIT CUBE THAT CONTAINS POINT */
x -= u; /* FIND RELATIVE X,Y,Z */
y -= v; /* OF POINT IN CUBE. */
int X = int(u) & 255;
int Y = int(v) & 255;
int Z = int(w) & 255; /* FIND UNIT CUBE THAT CONTAINS POINT */
x -= u; /* FIND RELATIVE X,Y,Z */
y -= v; /* OF POINT IN CUBE. */
z -= w;
u = npfade(x); /* COMPUTE FADE CURVES */
v = npfade(y); /* FOR EACH OF X,Y,Z. */
@@ -341,9 +341,9 @@ static float orgBlenderNoise(float x, float y, float z)
oy = y - fy;
oz = z - fz;
ix = (int)fx;
iy = (int)fy;
iz = (int)fz;
ix = int(fx);
iy = int(fy);
iz = int(fz);
jx = ox - 1;
jy = oy - 1;
@@ -751,7 +751,7 @@ static const float g_perlin_data_v3[512 + 2][3] = {
#define SETUP(val, b0, b1, r0, r1) \
{ \
t = val + 10000.0f; \
b0 = ((int)t) & 255; \
b0 = (int(t)) & 255; \
b1 = (b0 + 1) & 255; \
r0 = t - floorf(t); \
r1 = r0 - 1.0f; \
@@ -939,9 +939,9 @@ void BLI_noise_voronoi(float x, float y, float z, float *da, float *pa, float me
break;
}
int xi = (int)floor(x);
int yi = (int)floor(y);
int zi = (int)floor(z);
int xi = int(floor(x));
int yi = int(floor(y));
int zi = int(floor(z));
da[0] = da[1] = da[2] = da[3] = 1e10f;
for (int xx = xi - 1; xx <= xi + 1; xx++) {
for (int yy = yi - 1; yy <= yi + 1; yy++) {
@@ -1114,12 +1114,12 @@ static float BLI_cellNoiseU(float x, float y, float z)
y = (y + 0.000001f) * 1.00001f;
z = (z + 0.000001f) * 1.00001f;
int xi = (int)floor(x);
int yi = (int)floor(y);
int zi = (int)floor(z);
int xi = int(floor(x));
int yi = int(floor(y));
int zi = int(floor(z));
uint n = xi + yi * 1301 + zi * 314159;
n ^= (n << 13);
return ((float)(n * (n * n * 15731 + 789221) + 1376312589) / 4294967296.0f);
return (float(n * (n * n * 15731 + 789221) + 1376312589) / 4294967296.0f);
}
float BLI_noise_cell(float x, float y, float z)
@@ -1134,9 +1134,9 @@ void BLI_noise_cell_v3(float x, float y, float z, float r_ca[3])
y = (y + 0.000001f) * 1.00001f;
z = (z + 0.000001f) * 1.00001f;
int xi = (int)floor(x);
int yi = (int)floor(y);
int zi = (int)floor(z);
int xi = int(floor(x));
int yi = int(floor(y));
int zi = int(floor(z));
const float *p = HASHPNT(xi, yi, zi);
r_ca[0] = p[0];
r_ca[1] = p[1];
@@ -1263,7 +1263,7 @@ float BLI_noise_generic_turbulence(
sum += t * amp;
}
sum *= ((float)(1 << oct) / (float)((1 << (oct + 1)) - 1));
sum *= float(1 << oct) / float((1 << (oct + 1)) - 1);
return sum;
}
@@ -1311,7 +1311,7 @@ float BLI_noise_mg_fbm(
}
float value = 0.0, pwr = 1.0, pwHL = powf(lacunarity, -H);
for (int i = 0; i < (int)octaves; i++) {
for (int i = 0; i < int(octaves); i++) {
value += noisefunc(x, y, z) * pwr;
pwr *= pwHL;
x *= lacunarity;
@@ -1372,7 +1372,7 @@ float BLI_noise_mg_multi_fractal(
}
float value = 1.0, pwr = 1.0, pwHL = powf(lacunarity, -H);
for (int i = 0; i < (int)octaves; i++) {
for (int i = 0; i < int(octaves); i++) {
value *= (pwr * noisefunc(x, y, z) + 1.0f);
pwr *= pwHL;
x *= lacunarity;
@@ -1440,7 +1440,7 @@ float BLI_noise_mg_hetero_terrain(float x,
float pwHL = powf(lacunarity, -H);
float pwr = pwHL; /* starts with i=1 instead of 0 */
for (int i = 1; i < (int)octaves; i++) {
for (int i = 1; i < int(octaves); i++) {
float increment = (noisefunc(x, y, z) + offset) * pwr * value;
value += increment;
pwr *= pwHL;
@@ -1511,7 +1511,7 @@ float BLI_noise_mg_hybrid_multi_fractal(float x,
float pwHL = powf(lacunarity, -H);
float pwr = pwHL; /* starts with i=1 instead of 0 */
for (int i = 1; (weight > 0.001f) && (i < (int)octaves); i++) {
for (int i = 1; (weight > 0.001f) && (i < int(octaves)); i++) {
if (weight > 1.0f) {
weight = 1.0f;
}
@@ -1583,7 +1583,7 @@ float BLI_noise_mg_ridged_multi_fractal(float x,
float result = signal;
float pwHL = powf(lacunarity, -H);
float pwr = pwHL; /* starts with i=1 instead of 0 */
for (int i = 1; i < (int)octaves; i++) {
for (int i = 1; i < int(octaves); i++) {
x *= lacunarity;
y *= lacunarity;
z *= lacunarity;

View File

@@ -196,7 +196,7 @@ static eSign span_tri_v2_sign(const float v1[2], const float v2[2], const float
}
#ifdef USE_KDTREE
# define KDNODE_UNSET ((uint32_t)-1)
# define KDNODE_UNSET (uint32_t(-1))
enum {
KDNODE_FLAG_REMOVED = (1 << 0),
@@ -229,7 +229,7 @@ static void kdtree2d_init(KDTree2D *tree, const uint32_t coords_num, const PolyI
}
}
BLI_assert(tree->node_num == (uint32_t)(node - tree->nodes));
BLI_assert(tree->node_num == uint32_t(node - tree->nodes));
}
static uint32_t kdtree2d_balance_recursive(KDTreeNode2D *nodes,
@@ -338,7 +338,7 @@ static void kdtree2d_node_remove(KDTree2D *tree, uint32_t index)
{
KDTreeNode2D *node_parent = &tree->nodes[node->parent];
BLI_assert((uint32_t)(node - tree->nodes) == node_index);
BLI_assert(uint32_t(node - tree->nodes) == node_index);
if (node_parent->neg == node_index) {
node_parent->neg = KDNODE_UNSET;
}
@@ -466,7 +466,7 @@ static void pf_coord_remove(PolyFill *pf, PolyIndex *pi)
pf->indices = pi->next;
}
#ifndef NDEBUG
pi->index = (uint32_t)-1;
pi->index = uint32_t(-1);
pi->next = pi->prev = nullptr;
#endif /* !NDEBUG */

View File

@@ -335,7 +335,7 @@ static void polyedge_rotate(HalfEdge *edges, const HalfEdge *e)
HalfEdge *ed[6];
uint ed_index[6];
ed_index[0] = (uint)(e - edges);
ed_index[0] = uint(e - edges);
ed[0] = &edges[ed_index[0]];
ed_index[1] = ed[0]->e_next;
ed[1] = &edges[ed_index[1]];

View File

@@ -205,17 +205,15 @@ bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b)
* but in modified so corner cases are treated as intersections */
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.0) {
return 1; /* co-linear */
}
const double lambda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) -
(v1[0] - v3[0]) * (v4[1] - v3[1])) /
const double lambda = 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])) /
const double mu = double((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) /
div;
return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
}
@@ -224,17 +222,15 @@ static int isect_segments_fl(const float v1[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.0) {
return 1; /* co-linear */
}
const double lambda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) -
(v1[0] - v3[0]) * (v4[1] - v3[1])) /
const double lambda = 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])) /
const double mu = double((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) /
div;
return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
}

View File

@@ -206,12 +206,12 @@ void ScreenSpaceDrawingMode::do_partial_update(
int offset = 0;
for (int y = gpu_texture_region_to_update.ymin; y < gpu_texture_region_to_update.ymax; y++) {
float yf = y / (float)texture_height;
float yf = y / float(texture_height);
float v = info.clipping_uv_bounds.ymax * yf + info.clipping_uv_bounds.ymin * (1.0 - yf) -
tile_offset_y;
for (int x = gpu_texture_region_to_update.xmin; x < gpu_texture_region_to_update.xmax; x++)
{
float xf = x / (float)texture_width;
float xf = x / float(texture_width);
float u = info.clipping_uv_bounds.xmax * xf + info.clipping_uv_bounds.xmin * (1.0 - xf) -
tile_offset_x;
imbuf::interpolate_nearest_border_fl(tile_buffer,