Cleanup: various non functional changes

This commit is contained in:
Campbell Barton
2024-05-28 14:07:13 +10:00
parent f7f23541f0
commit 0cbadd00a3
7 changed files with 65 additions and 64 deletions

View File

@@ -1832,7 +1832,7 @@ static void ghost_wl_display_report_error_from_code(wl_display *display, const i
}
if (ecode == EPROTO) {
const struct wl_interface *interface = nullptr;
const wl_interface *interface = nullptr;
const int ecode_proto = wl_display_get_protocol_error(display, &interface, nullptr);
fprintf(stderr,
"The Wayland connection experienced a protocol error %d in interface: %s\n",

View File

@@ -201,9 +201,9 @@ void hex_to_rgb(const char *hexcol, float *r_r, float *r_g, float *r_b)
return;
}
*r_r = (float)ri * (1.0f / 255.0f);
*r_g = (float)gi * (1.0f / 255.0f);
*r_b = (float)bi * (1.0f / 255.0f);
*r_r = float(ri) * (1.0f / 255.0f);
*r_g = float(gi) * (1.0f / 255.0f);
*r_b = float(bi) * (1.0f / 255.0f);
CLAMP(*r_r, 0.0f, 1.0f);
CLAMP(*r_g, 0.0f, 1.0f);
CLAMP(*r_b, 0.0f, 1.0f);
@@ -341,9 +341,9 @@ uint hsv_to_cpack(float h, float s, float v)
hsv_to_rgb(h, s, v, &rf, &gf, &bf);
r = (uint)(rf * 255.0f);
g = (uint)(gf * 255.0f);
b = (uint)(bf * 255.0f);
r = uint(rf * 255.0f);
g = uint(gf * 255.0f);
b = uint(bf * 255.0f);
col = (r + (g * 256) + (b * 256 * 256));
return col;
@@ -353,9 +353,9 @@ uint rgb_to_cpack(float r, float g, float b)
{
uint ir, ig, ib;
ir = (uint)floorf(255.0f * max_ff(r, 0.0f));
ig = (uint)floorf(255.0f * max_ff(g, 0.0f));
ib = (uint)floorf(255.0f * max_ff(b, 0.0f));
ir = uint(floorf(255.0f * max_ff(r, 0.0f)));
ig = uint(floorf(255.0f * max_ff(g, 0.0f)));
ib = uint(floorf(255.0f * max_ff(b, 0.0f)));
if (ir > 255) {
ir = 255;
@@ -372,24 +372,24 @@ uint rgb_to_cpack(float r, float g, float b)
void cpack_to_rgb(uint col, float *r_r, float *r_g, float *r_b)
{
*r_r = (float)(col & 0xFF) * (1.0f / 255.0f);
*r_g = (float)((col >> 8) & 0xFF) * (1.0f / 255.0f);
*r_b = (float)((col >> 16) & 0xFF) * (1.0f / 255.0f);
*r_r = float(col & 0xFF) * (1.0f / 255.0f);
*r_g = float((col >> 8) & 0xFF) * (1.0f / 255.0f);
*r_b = float((col >> 16) & 0xFF) * (1.0f / 255.0f);
}
void rgb_uchar_to_float(float r_col[3], const uchar col_ub[3])
{
r_col[0] = ((float)col_ub[0]) * (1.0f / 255.0f);
r_col[1] = ((float)col_ub[1]) * (1.0f / 255.0f);
r_col[2] = ((float)col_ub[2]) * (1.0f / 255.0f);
r_col[0] = float(col_ub[0]) * (1.0f / 255.0f);
r_col[1] = float(col_ub[1]) * (1.0f / 255.0f);
r_col[2] = float(col_ub[2]) * (1.0f / 255.0f);
}
void rgba_uchar_to_float(float r_col[4], const uchar col_ub[4])
{
r_col[0] = ((float)col_ub[0]) * (1.0f / 255.0f);
r_col[1] = ((float)col_ub[1]) * (1.0f / 255.0f);
r_col[2] = ((float)col_ub[2]) * (1.0f / 255.0f);
r_col[3] = ((float)col_ub[3]) * (1.0f / 255.0f);
r_col[0] = float(col_ub[0]) * (1.0f / 255.0f);
r_col[1] = float(col_ub[1]) * (1.0f / 255.0f);
r_col[2] = float(col_ub[2]) * (1.0f / 255.0f);
r_col[3] = float(col_ub[3]) * (1.0f / 255.0f);
}
void rgb_float_to_uchar(uchar r_col[3], const float col_f[3])
@@ -806,7 +806,7 @@ static float index_to_float(const ushort i)
return tmp.f;
}
void BLI_init_srgb_conversion(void)
void BLI_init_srgb_conversion()
{
static bool initialized = false;
uint i, b;
@@ -818,12 +818,12 @@ void BLI_init_srgb_conversion(void)
/* Fill in the lookup table to convert floats to bytes: */
for (i = 0; i < 0x10000; i++) {
float f = linearrgb_to_srgb(index_to_float((ushort)i)) * 255.0f;
float f = linearrgb_to_srgb(index_to_float(ushort(i))) * 255.0f;
if (f <= 0) {
BLI_color_to_srgb_table[i] = 0;
}
else if (f < 255) {
BLI_color_to_srgb_table[i] = (ushort)(f * 0x100 + 0.5f);
BLI_color_to_srgb_table[i] = ushort(f * 0x100 + 0.5f);
}
else {
BLI_color_to_srgb_table[i] = 0xff00;
@@ -832,10 +832,10 @@ void BLI_init_srgb_conversion(void)
/* Fill in the lookup table to convert bytes to float: */
for (b = 0; b <= 255; b++) {
float f = srgb_to_linearrgb(((float)b) * (1.0f / 255.0f));
float f = srgb_to_linearrgb(float(b) * (1.0f / 255.0f));
BLI_color_from_srgb_table[b] = f;
i = hipart(f);
/* replace entries so byte->float->byte does not change the data: */
BLI_color_to_srgb_table[i] = (ushort)(b * 0x100);
BLI_color_to_srgb_table[i] = ushort(b * 0x100);
}
}

View File

@@ -209,17 +209,17 @@ void copy_m4d_m4(double m1[4][4], const float m2[4][4])
void copy_m3_m3d(float m1[3][3], const double m2[3][3])
{
/* Keep it stupid simple for better data flow in CPU. */
m1[0][0] = (float)m2[0][0];
m1[0][1] = (float)m2[0][1];
m1[0][2] = (float)m2[0][2];
m1[0][0] = float(m2[0][0]);
m1[0][1] = float(m2[0][1]);
m1[0][2] = float(m2[0][2]);
m1[1][0] = (float)m2[1][0];
m1[1][1] = (float)m2[1][1];
m1[1][2] = (float)m2[1][2];
m1[1][0] = float(m2[1][0]);
m1[1][1] = float(m2[1][1]);
m1[1][2] = float(m2[1][2]);
m1[2][0] = (float)m2[2][0];
m1[2][1] = (float)m2[2][1];
m1[2][2] = (float)m2[2][2];
m1[2][0] = float(m2[2][0]);
m1[2][1] = float(m2[2][1]);
m1[2][2] = float(m2[2][2]);
}
void swap_m3m3(float m1[3][3], float m2[3][3])
@@ -860,14 +860,14 @@ void mul_v4d_m4v4d(double r[4], const float mat[4][4], const double v[4])
const double y = v[1];
const double z = v[2];
r[0] = x * (double)mat[0][0] + y * (double)mat[1][0] + z * (double)mat[2][0] +
(double)mat[3][0] * v[3];
r[1] = x * (double)mat[0][1] + y * (double)mat[1][1] + z * (double)mat[2][1] +
(double)mat[3][1] * v[3];
r[2] = x * (double)mat[0][2] + y * (double)mat[1][2] + z * (double)mat[2][2] +
(double)mat[3][2] * v[3];
r[3] = x * (double)mat[0][3] + y * (double)mat[1][3] + z * (double)mat[2][3] +
(double)mat[3][3] * v[3];
r[0] = x * double(mat[0][0]) + y * double(mat[1][0]) + z * double(mat[2][0]) +
double(mat[3][0]) * v[3];
r[1] = x * double(mat[0][1]) + y * double(mat[1][1]) + z * double(mat[2][1]) +
double(mat[3][1]) * v[3];
r[2] = x * double(mat[0][2]) + y * double(mat[1][2]) + z * double(mat[2][2]) +
double(mat[3][2]) * v[3];
r[3] = x * double(mat[0][3]) + y * double(mat[1][3]) + z * double(mat[2][3]) +
double(mat[3][3]) * v[3];
}
void mul_m4_v4d(const float mat[4][4], double r[4])
@@ -1014,9 +1014,9 @@ void mul_m3_v3_double(const float M[3][3], double r[3])
const double x = r[0];
const double y = r[1];
r[0] = x * (double)M[0][0] + y * (double)M[1][0] + (double)M[2][0] * r[2];
r[1] = x * (double)M[0][1] + y * (double)M[1][1] + (double)M[2][1] * r[2];
r[2] = x * (double)M[0][2] + y * (double)M[1][2] + (double)M[2][2] * r[2];
r[0] = x * double(M[0][0]) + y * double(M[1][0]) + double(M[2][0]) * r[2];
r[1] = x * double(M[0][1]) + y * double(M[1][1]) + double(M[2][1]) * r[2];
r[2] = x * double(M[0][2]) + y * double(M[1][2]) + double(M[2][2]) * r[2];
}
void add_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
@@ -1256,17 +1256,17 @@ bool invert_m4_m4_fallback(float inverse[4][4], const float mat[4][4])
if (UNLIKELY(tempmat[i][i] == 0.0f)) {
return false; /* No non-zero pivot */
}
temp = (double)tempmat[i][i];
temp = double(tempmat[i][i]);
for (k = 0; k < 4; k++) {
tempmat[i][k] = (float)((double)tempmat[i][k] / temp);
inverse[i][k] = (float)((double)inverse[i][k] / temp);
tempmat[i][k] = float(double(tempmat[i][k]) / temp);
inverse[i][k] = float(double(inverse[i][k]) / temp);
}
for (j = 0; j < 4; j++) {
if (j != i) {
temp = tempmat[j][i];
for (k = 0; k < 4; k++) {
tempmat[j][k] -= (float)((double)tempmat[i][k] * temp);
inverse[j][k] -= (float)((double)inverse[i][k] * temp);
tempmat[j][k] -= float(double(tempmat[i][k]) * temp);
inverse[j][k] -= float(double(inverse[i][k]) * temp);
}
}
}
@@ -1622,7 +1622,7 @@ static void orthogonalize_stable(float v1[3], float v2[3], float v3[3], bool nor
/* Adjust v2 by half of the necessary angle correction.
* Thus the angle change is the same for both axis directions. */
float angle = acosf(cos_angle);
float target_angle = angle + ((float)M_PI_2 - angle) / 2;
float target_angle = angle + (float(M_PI_2) - angle) / 2;
madd_v3_v3fl(norm_v2, norm_v3, -cos_angle);
mul_v3_fl(norm_v2, sinf(target_angle) / len_v3(norm_v2));
@@ -2179,7 +2179,7 @@ float mat3_to_scale(const float mat[3][3])
{
/* unit length vector */
float unit_vec[3];
copy_v3_fl(unit_vec, (float)M_SQRT1_3);
copy_v3_fl(unit_vec, float(M_SQRT1_3));
mul_m3_v3(mat, unit_vec);
return len_v3(unit_vec);
}
@@ -2188,7 +2188,7 @@ float mat4_to_scale(const float mat[4][4])
{
/* unit length vector */
float unit_vec[3];
copy_v3_fl(unit_vec, (float)M_SQRT1_3);
copy_v3_fl(unit_vec, float(M_SQRT1_3));
mul_mat3_m4_v3(mat, unit_vec);
return len_v3(unit_vec);
}
@@ -2196,7 +2196,7 @@ float mat4_to_scale(const float mat[4][4])
float mat4_to_xy_scale(const float mat[4][4])
{
/* unit length vector in xy plane */
float unit_vec[3] = {(float)M_SQRT1_2, (float)M_SQRT1_2, 0.0f};
float unit_vec[3] = {float(M_SQRT1_2), float(M_SQRT1_2), 0.0f};
mul_mat3_m4_v3(mat, unit_vec);
return len_v3(unit_vec);
}

View File

@@ -2847,8 +2847,9 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
/* Unify Material::blend_shadow and Cycles.use_transparent_shadows into the
* Material::blend_flag. */
Scene *scene = static_cast<Scene *>(bmain->scenes.first);
bool is_eevee = scene && (STREQ(scene->r.engine, RE_engine_id_BLENDER_EEVEE) ||
STREQ(scene->r.engine, RE_engine_id_BLENDER_EEVEE_NEXT));
bool is_eevee = scene && STR_ELEM(scene->r.engine,
RE_engine_id_BLENDER_EEVEE,
RE_engine_id_BLENDER_EEVEE_NEXT);
LISTBASE_FOREACH (Material *, material, &bmain->materials) {
bool transparent_shadows = true;
if (is_eevee) {

View File

@@ -87,8 +87,8 @@ class CopyDriversToSelected : public testing::Test {
ANIM_add_driver(&tmp_report_list, &cube->id, "rotation_quaternion", 1, 0, DRIVER_TYPE_PYTHON);
FCurve *cube_quat_0_driver = static_cast<FCurve *>(BLI_findlink(&adt_cube->drivers, 0));
FCurve *cube_quat_1_driver = static_cast<FCurve *>(BLI_findlink(&adt_cube->drivers, 1));
BLI_strncpy(cube_quat_0_driver->driver->expression, "0.0", 256);
BLI_strncpy(cube_quat_1_driver->driver->expression, "1.0", 256);
STRNCPY(cube_quat_0_driver->driver->expression, "0.0");
STRNCPY(cube_quat_1_driver->driver->expression, "1.0");
/* Set up suzanne drivers. */
ANIM_add_driver(
@@ -103,10 +103,10 @@ class CopyDriversToSelected : public testing::Test {
FCurve *suzanne_quat_3_driver = static_cast<FCurve *>(BLI_findlink(&adt_suzanne->drivers, 2));
FCurve *suzanne_rotation_mode_driver = static_cast<FCurve *>(
BLI_findlink(&adt_suzanne->drivers, 3));
BLI_strncpy(suzanne_quat_0_driver->driver->expression, "0.5", 256);
BLI_strncpy(suzanne_quat_2_driver->driver->expression, "2.5", 256);
BLI_strncpy(suzanne_quat_3_driver->driver->expression, "3.5", 256);
BLI_strncpy(suzanne_rotation_mode_driver->driver->expression, "4", 256);
STRNCPY(suzanne_quat_0_driver->driver->expression, "0.5");
STRNCPY(suzanne_quat_2_driver->driver->expression, "2.5");
STRNCPY(suzanne_quat_3_driver->driver->expression, "3.5");
STRNCPY(suzanne_rotation_mode_driver->driver->expression, "4");
/* Add animation to cube's fourth quaternion element. */
PointerRNA cube_ptr = RNA_pointer_create(&cube->id, &RNA_Object, &cube->id);

View File

@@ -27,7 +27,7 @@ void set_array_prop(IDProperty *idgroup,
}
IDPropertyTemplate val = {0};
val.array.len = static_cast<int>(vec.dimension);
val.array.len = int(vec.dimension);
if (val.array.len <= 0) {
CLOG_WARN(&LOG, "Invalid array length for prop %s", prop_name);

View File

@@ -8439,7 +8439,7 @@ static void def_cmp_translate(StructRNA *srna)
RNA_def_struct_sdna_from(srna, "NodeTranslateData", "storage");
prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "interpolation");
RNA_def_property_enum_sdna(prop, nullptr, "interpolation");
RNA_def_property_enum_items(prop, interpolation_items);
RNA_def_property_ui_text(prop, "", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");