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 <campbell@blender.org>2022-09-25 11:33:28 +0300
committerCampbell Barton <campbell@blender.org>2022-09-25 13:17:08 +0300
commitf68cfd6bb078482c4a779a6e26a56e2734edb5b8 (patch)
tree2878e5b80dba5bdeba186d99661d604eb38879cd /source/blender/io
parentc7b247a118e302a3afc6473797e53b6af28b69e2 (diff)
Cleanup: replace C-style casts with functional casts for numeric types
Diffstat (limited to 'source/blender/io')
-rw-r--r--source/blender/io/collada/AnimationImporter.cpp22
-rw-r--r--source/blender/io/collada/BCAnimationCurve.cpp10
-rw-r--r--source/blender/io/collada/BCMath.cpp4
-rw-r--r--source/blender/io/collada/CameraExporter.cpp4
-rw-r--r--source/blender/io/collada/DocumentImporter.cpp10
-rw-r--r--source/blender/io/collada/ExtraTags.cpp6
-rw-r--r--source/blender/io/collada/GeometryExporter.cpp10
-rw-r--r--source/blender/io/collada/MeshImporter.cpp2
-rw-r--r--source/blender/io/collada/TransformReader.cpp12
-rw-r--r--source/blender/io/collada/collada_internal.cpp6
-rw-r--r--source/blender/io/collada/collada_utils.cpp12
-rw-r--r--source/blender/io/gpencil/intern/gpencil_io_base.cc14
-rw-r--r--source/blender/io/gpencil/intern/gpencil_io_import_base.cc2
-rw-r--r--source/blender/io/gpencil/intern/gpencil_io_import_svg.cc18
-rw-r--r--source/blender/io/usd/intern/usd_reader_curve.cc6
-rw-r--r--source/blender/io/usd/intern/usd_reader_light.cc4
-rw-r--r--source/blender/io/usd/intern/usd_reader_nurbs.cc8
-rw-r--r--source/blender/io/usd/intern/usd_writer_volume.cc2
-rw-r--r--source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc6
-rw-r--r--source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc8
-rw-r--r--source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc10
-rw-r--r--source/blender/io/wavefront_obj/importer/obj_import_mesh.cc2
-rw-r--r--source/blender/io/wavefront_obj/importer/obj_import_mtl.cc6
-rw-r--r--source/blender/io/wavefront_obj/tests/obj_mtl_parser_tests.cc2
24 files changed, 93 insertions, 93 deletions
diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp
index 094f62e3c13..2b56cf188f1 100644
--- a/source/blender/io/collada/AnimationImporter.cpp
+++ b/source/blender/io/collada/AnimationImporter.cpp
@@ -55,7 +55,7 @@ void AnimationImporter::add_bezt(FCurve *fcu,
float value,
eBezTriple_Interpolation ipo)
{
- // float fps = (float)FPS;
+ // float fps = float(FPS);
BezTriple bez;
memset(&bez, 0, sizeof(BezTriple));
bez.vec[1][0] = frame;
@@ -72,7 +72,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
COLLADAFW::FloatOrDoubleArray &input = curve->getInputValues();
COLLADAFW::FloatOrDoubleArray &output = curve->getOutputValues();
- float fps = (float)FPS;
+ float fps = float(FPS);
size_t dim = curve->getOutDimension();
uint i;
@@ -141,7 +141,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
default:
fprintf(stderr,
"Output dimension of %d is not yet supported (animation id = %s)\n",
- (int)dim,
+ int(dim),
curve->getOriginalId().c_str());
}
}
@@ -262,7 +262,7 @@ AnimationImporter::~AnimationImporter()
}
if (!unused_curves.empty()) {
- fprintf(stderr, "removed %d unused curves\n", (int)unused_curves.size());
+ fprintf(stderr, "removed %d unused curves\n", int(unused_curves.size()));
}
}
@@ -530,7 +530,7 @@ void AnimationImporter::Assign_transform_animations(
binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
if (!((!xyz && curves->size() == 1) || (xyz && curves->size() == 3) || is_matrix)) {
- fprintf(stderr, "expected %d curves, got %d\n", xyz ? 3 : 1, (int)curves->size());
+ fprintf(stderr, "expected %d curves, got %d\n", xyz ? 3 : 1, int(curves->size()));
return;
}
@@ -1536,7 +1536,7 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames,
}
}
else {
- fprintf(stderr, "expected %d curves, got %d\n", xyz ? 3 : 1, (int)curves.size());
+ fprintf(stderr, "expected %d curves, got %d\n", xyz ? 3 : 1, int(curves.size()));
}
}
}
@@ -1934,7 +1934,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
if (type == COLLADAFW::Transformation::ROTATE) {
if (curves.size() != 1) {
- fprintf(stderr, "expected 1 curve, got %d\n", (int)curves.size());
+ fprintf(stderr, "expected 1 curve, got %d\n", int(curves.size()));
return false;
}
@@ -1946,7 +1946,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
COLLADABU::Math::Vector3 &axis = ((COLLADAFW::Rotate *)tm)->getRotationAxis();
- float ax[3] = {(float)axis[0], (float)axis[1], (float)axis[2]};
+ float ax[3] = {float(axis[0]), float(axis[1]), float(axis[2])};
float angle = evaluate_fcurve(curves[0], fra);
axis_angle_to_mat4(mat, ax, angle);
@@ -1957,10 +1957,10 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
if ((!is_xyz && curves.size() != 1) || (is_xyz && curves.size() != 3)) {
if (is_xyz) {
- fprintf(stderr, "%s: expected 3 curves, got %d\n", path, (int)curves.size());
+ fprintf(stderr, "%s: expected 3 curves, got %d\n", path, int(curves.size()));
}
else {
- fprintf(stderr, "%s: expected 1 curve, got %d\n", path, (int)curves.size());
+ fprintf(stderr, "%s: expected 1 curve, got %d\n", path, int(curves.size()));
}
return false;
}
@@ -1989,7 +1989,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
/* for now, of matrix animation,
* support only the case when all values are packed into one animation */
if (curves.size() != 16) {
- fprintf(stderr, "%s: expected 16 curves, got %d\n", path, (int)curves.size());
+ fprintf(stderr, "%s: expected 16 curves, got %d\n", path, int(curves.size()));
return false;
}
diff --git a/source/blender/io/collada/BCAnimationCurve.cpp b/source/blender/io/collada/BCAnimationCurve.cpp
index fe90dc5d5fa..710758bd77b 100644
--- a/source/blender/io/collada/BCAnimationCurve.cpp
+++ b/source/blender/io/collada/BCAnimationCurve.cpp
@@ -426,10 +426,10 @@ bool BCAnimationCurve::add_value_from_rna(const int frame_index)
if ((array_index >= 0) && (array_index < RNA_property_array_length(&ptr, prop))) {
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
- value = (float)RNA_property_boolean_get_index(&ptr, prop, array_index);
+ value = float(RNA_property_boolean_get_index(&ptr, prop, array_index));
break;
case PROP_INT:
- value = (float)RNA_property_int_get_index(&ptr, prop, array_index);
+ value = float(RNA_property_int_get_index(&ptr, prop, array_index));
break;
case PROP_FLOAT:
value = RNA_property_float_get_index(&ptr, prop, array_index);
@@ -449,16 +449,16 @@ bool BCAnimationCurve::add_value_from_rna(const int frame_index)
/* not an array */
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
- value = (float)RNA_property_boolean_get(&ptr, prop);
+ value = float(RNA_property_boolean_get(&ptr, prop));
break;
case PROP_INT:
- value = (float)RNA_property_int_get(&ptr, prop);
+ value = float(RNA_property_int_get(&ptr, prop));
break;
case PROP_FLOAT:
value = RNA_property_float_get(&ptr, prop);
break;
case PROP_ENUM:
- value = (float)RNA_property_enum_get(&ptr, prop);
+ value = float(RNA_property_enum_get(&ptr, prop));
break;
default:
fprintf(stderr,
diff --git a/source/blender/io/collada/BCMath.cpp b/source/blender/io/collada/BCMath.cpp
index 924cee7f3b2..6e052ee960d 100644
--- a/source/blender/io/collada/BCMath.cpp
+++ b/source/blender/io/collada/BCMath.cpp
@@ -140,9 +140,9 @@ void BCMatrix::sanitize(Matrix &mat, int precision)
{
for (auto &row : mat) {
for (float &cell : row) {
- double val = (double)cell;
+ double val = double(cell);
val = double_round(val, precision);
- cell = (float)val;
+ cell = float(val);
}
}
}
diff --git a/source/blender/io/collada/CameraExporter.cpp b/source/blender/io/collada/CameraExporter.cpp
index 45a73914256..7c3f304b722 100644
--- a/source/blender/io/collada/CameraExporter.cpp
+++ b/source/blender/io/collada/CameraExporter.cpp
@@ -51,7 +51,7 @@ void CamerasExporter::operator()(Object *ob, Scene *sce)
case CAM_PERSP: {
COLLADASW::PerspectiveOptic persp(mSW);
persp.setXFov(RAD2DEGF(focallength_to_fov(cam->lens, cam->sensor_x)), "xfov");
- persp.setAspectRatio((float)(sce->r.xsch) / (float)(sce->r.ysch), false, "aspect_ratio");
+ persp.setAspectRatio(float(sce->r.xsch) / float(sce->r.ysch), false, "aspect_ratio");
persp.setZFar(cam->clip_end, false, "zfar");
persp.setZNear(cam->clip_start, false, "znear");
COLLADASW::Camera ccam(mSW, &persp, cam_id, cam_name);
@@ -64,7 +64,7 @@ void CamerasExporter::operator()(Object *ob, Scene *sce)
default: {
COLLADASW::OrthographicOptic ortho(mSW);
ortho.setXMag(cam->ortho_scale / 2, "xmag");
- ortho.setAspectRatio((float)(sce->r.xsch) / (float)(sce->r.ysch), false, "aspect_ratio");
+ ortho.setAspectRatio(float(sce->r.xsch) / float(sce->r.ysch), false, "aspect_ratio");
ortho.setZFar(cam->clip_end, false, "zfar");
ortho.setZNear(cam->clip_start, false, "znear");
COLLADASW::Camera ccam(mSW, &ortho, cam_id, cam_name);
diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp
index 851e57bb750..660bbd7edb2 100644
--- a/source/blender/io/collada/DocumentImporter.cpp
+++ b/source/blender/io/collada/DocumentImporter.cpp
@@ -241,7 +241,7 @@ void DocumentImporter::finish()
if (!libnode_ob.empty()) {
- fprintf(stderr, "| Cleanup: free %d library nodes\n", (int)libnode_ob.size());
+ fprintf(stderr, "| Cleanup: free %d library nodes\n", int(libnode_ob.size()));
/* free all library_nodes */
std::vector<Object *>::iterator it;
for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) {
@@ -434,7 +434,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
Object *new_child = nullptr;
if (inodes.getCount()) { /* \todo loop through instance nodes */
const COLLADAFW::UniqueId &id = inodes[0]->getInstanciatedObjectId();
- fprintf(stderr, "Doing %d child nodes\n", (int)node_map.count(id));
+ fprintf(stderr, "Doing %d child nodes\n", int(node_map.count(id)));
new_child = create_instance_node(
object_map.find(id)->second, node_map[id], child_node, sce, is_library_node);
}
@@ -869,7 +869,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
double ymag = 2 * camera->getYMag().getValue();
double aspect = camera->getAspectRatio().getValue();
double xmag = aspect * ymag;
- cam->ortho_scale = (float)xmag;
+ cam->ortho_scale = float(xmag);
} break;
case CAM_PERSP:
default: {
@@ -890,7 +890,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
case COLLADAFW::Camera::X_AND_Y: {
switch (cam->type) {
case CAM_ORTHO:
- cam->ortho_scale = (float)camera->getXMag().getValue() * 2;
+ cam->ortho_scale = float(camera->getXMag().getValue()) * 2;
break;
case CAM_PERSP:
default: {
@@ -903,7 +903,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
case COLLADAFW::Camera::SINGLE_Y: {
switch (cam->type) {
case CAM_ORTHO:
- cam->ortho_scale = (float)camera->getYMag().getValue();
+ cam->ortho_scale = float(camera->getYMag().getValue());
break;
case CAM_PERSP:
default: {
diff --git a/source/blender/io/collada/ExtraTags.cpp b/source/blender/io/collada/ExtraTags.cpp
index 398718f1133..9fb7bbb2295 100644
--- a/source/blender/io/collada/ExtraTags.cpp
+++ b/source/blender/io/collada/ExtraTags.cpp
@@ -49,7 +49,7 @@ float ExtraTags::asFloat(std::string tag, bool *ok)
return -1.0f;
}
*ok = true;
- return (float)atof(tags[tag].c_str());
+ return float(atof(tags[tag].c_str()));
}
std::string ExtraTags::asString(std::string tag, bool *ok)
@@ -67,7 +67,7 @@ bool ExtraTags::setData(std::string tag, short *data)
bool ok = false;
int tmp = asInt(tag, &ok);
if (ok) {
- *data = (short)tmp;
+ *data = short(tmp);
}
return ok;
}
@@ -97,7 +97,7 @@ bool ExtraTags::setData(std::string tag, char *data)
bool ok = false;
int tmp = asInt(tag, &ok);
if (ok) {
- *data = (char)tmp;
+ *data = char(tmp);
}
return ok;
}
diff --git a/source/blender/io/collada/GeometryExporter.cpp b/source/blender/io/collada/GeometryExporter.cpp
index 0e74c3ed516..a069c32026b 100644
--- a/source/blender/io/collada/GeometryExporter.cpp
+++ b/source/blender/io/collada/GeometryExporter.cpp
@@ -64,7 +64,7 @@ void GeometryExporter::operator()(Object *ob)
exportedGeometry.insert(geom_id);
- bool has_color = (bool)CustomData_has_layer(&me->fdata, CD_MCOL);
+ bool has_color = bool(CustomData_has_layer(&me->fdata, CD_MCOL));
create_normals(nor, norind, me);
@@ -77,7 +77,7 @@ void GeometryExporter::operator()(Object *ob)
/* writes <source> for normal coords */
createNormalsSource(geom_id, me, nor);
- bool has_uvs = (bool)CustomData_has_layer(&me->ldata, CD_MLOOPUV);
+ bool has_uvs = bool(CustomData_has_layer(&me->ldata, CD_MLOOPUV));
/* writes <source> for uv coords if mesh has uv coords */
if (has_uvs) {
@@ -147,7 +147,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
exportedGeometry.insert(geom_id);
- bool has_color = (bool)CustomData_has_layer(&me->fdata, CD_MCOL);
+ bool has_color = bool(CustomData_has_layer(&me->fdata, CD_MCOL));
create_normals(nor, norind, me);
@@ -160,7 +160,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
/* writes <source> for normal coords */
createNormalsSource(geom_id, me, nor);
- bool has_uvs = (bool)CustomData_has_layer(&me->ldata, CD_MLOOPUV);
+ bool has_uvs = bool(CustomData_has_layer(&me->ldata, CD_MLOOPUV));
/* writes <source> for uv coords if mesh has uv coords */
if (has_uvs) {
@@ -585,7 +585,7 @@ void GeometryExporter::createNormalsSource(std::string geom_id, Mesh *me, std::v
COLLADASW::FloatSourceF source(mSW);
source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL));
source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL) + ARRAY_ID_SUFFIX);
- source.setAccessorCount((ulong)nor.size());
+ source.setAccessorCount(ulong(nor.size()));
source.setAccessorStride(3);
COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
param.push_back("X");
diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp
index fea57698261..6f77c233aac 100644
--- a/source/blender/io/collada/MeshImporter.cpp
+++ b/source/blender/io/collada/MeshImporter.cpp
@@ -1172,7 +1172,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom)
fprintf(stderr,
"Can't apply custom normals, me->totloop != loop_normals.size() (%d != %d)\n",
me->totloop,
- (int)loop_normals.size());
+ int(loop_normals.size()));
}
else {
BKE_mesh_set_custom_normals(me, reinterpret_cast<float(*)[3]>(loop_normals.data()));
diff --git a/source/blender/io/collada/TransformReader.cpp b/source/blender/io/collada/TransformReader.cpp
index 47deddb5feb..cc1334bd99b 100644
--- a/source/blender/io/collada/TransformReader.cpp
+++ b/source/blender/io/collada/TransformReader.cpp
@@ -87,8 +87,8 @@ void TransformReader::dae_rotate_to_mat4(COLLADAFW::Transformation *tm, float m[
{
COLLADAFW::Rotate *ro = (COLLADAFW::Rotate *)tm;
COLLADABU::Math::Vector3 &axis = ro->getRotationAxis();
- const float angle = (float)DEG2RAD(ro->getRotationAngle());
- const float ax[] = {(float)axis[0], (float)axis[1], (float)axis[2]};
+ const float angle = float(DEG2RAD(ro->getRotationAngle()));
+ const float ax[] = {float(axis[0]), float(axis[1]), float(axis[2])};
#if 0
float quat[4];
axis_angle_to_quat(quat, axis, angle);
@@ -104,15 +104,15 @@ void TransformReader::dae_translate_to_mat4(COLLADAFW::Transformation *tm, float
unit_m4(m);
- m[3][0] = (float)t[0];
- m[3][1] = (float)t[1];
- m[3][2] = (float)t[2];
+ m[3][0] = float(t[0]);
+ m[3][1] = float(t[1]);
+ m[3][2] = float(t[2]);
}
void TransformReader::dae_scale_to_mat4(COLLADAFW::Transformation *tm, float m[4][4])
{
COLLADABU::Math::Vector3 &s = ((COLLADAFW::Scale *)tm)->getScale();
- float size[3] = {(float)s[0], (float)s[1], (float)s[2]};
+ float size[3] = {float(s[0]), float(s[1]), float(s[2])};
size_to_mat4(m, size);
}
diff --git a/source/blender/io/collada/collada_internal.cpp b/source/blender/io/collada/collada_internal.cpp
index c4f13f1cbd2..60e8edaa3bc 100644
--- a/source/blender/io/collada/collada_internal.cpp
+++ b/source/blender/io/collada/collada_internal.cpp
@@ -47,7 +47,7 @@ UnitConverter::UnitSystem UnitConverter::isMetricSystem()
float UnitConverter::getLinearMeter()
{
- return (float)unit.getLinearUnitMeter();
+ return float(unit.getLinearUnitMeter());
}
void UnitConverter::convertVector3(COLLADABU::Math::Vector3 &vec, float *v)
@@ -212,9 +212,9 @@ std::string translate_id(const std::string &id)
}
std::string id_translated = id;
- id_translated[0] = translate_start_name_map[(uint)id_translated[0]];
+ id_translated[0] = translate_start_name_map[uint(id_translated[0])];
for (uint i = 1; i < id_translated.size(); i++) {
- id_translated[i] = translate_name_map[(uint)id_translated[i]];
+ id_translated[i] = translate_name_map[uint(id_translated[i])];
}
/* It's so much workload now, the if () should speed up things. */
if (id_translated != id) {
diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp
index bfa150faf8b..22a73cd7db2 100644
--- a/source/blender/io/collada/collada_utils.cpp
+++ b/source/blender/io/collada/collada_utils.cpp
@@ -710,13 +710,13 @@ float bc_get_property(Bone *bone, std::string key, float def)
if (property) {
switch (property->type) {
case IDP_INT:
- result = (float)(IDP_Int(property));
+ result = float(IDP_Int(property));
break;
case IDP_FLOAT:
- result = (float)(IDP_Float(property));
+ result = float(IDP_Float(property));
break;
case IDP_DOUBLE:
- result = (float)(IDP_Double(property));
+ result = float(IDP_Double(property));
break;
default:
result = def;
@@ -1008,9 +1008,9 @@ void bc_create_restpose_mat(BCExportSettings &export_settings,
void bc_sanitize_v3(float v[3], int precision)
{
for (int i = 0; i < 3; i++) {
- double val = (double)v[i];
+ double val = double(v[i]);
val = double_round(val, precision);
- v[i] = (float)val;
+ v[i] = float(val);
}
}
@@ -1339,7 +1339,7 @@ bool bc_get_float_from_shader(bNode *shader, double &val, std::string nodeid)
bNodeSocket *socket = nodeFindSocket(shader, SOCK_IN, nodeid.c_str());
if (socket) {
bNodeSocketValueFloat *ref = (bNodeSocketValueFloat *)socket->default_value;
- val = (double)ref->value;
+ val = double(ref->value);
return true;
}
return false;
diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.cc b/source/blender/io/gpencil/intern/gpencil_io_base.cc
index bcf9a36c200..b9d7b6719b1 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_base.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_base.cc
@@ -227,16 +227,16 @@ float2 GpencilIO::gpencil_3D_point_to_render_space(const float3 co)
float2 r_co;
mul_v2_project_m4_v3(&r_co.x, persmat_, &parent_co.x);
- r_co.x = (r_co.x + 1.0f) / 2.0f * (float)render_x_;
- r_co.y = (r_co.y + 1.0f) / 2.0f * (float)render_y_;
+ r_co.x = (r_co.x + 1.0f) / 2.0f * float(render_x_);
+ r_co.y = (r_co.y + 1.0f) / 2.0f * float(render_y_);
/* Invert X axis. */
if (invert_axis_[0]) {
- r_co.x = (float)render_x_ - r_co.x;
+ r_co.x = float(render_x_) - r_co.x;
}
/* Invert Y axis. */
if (invert_axis_[1]) {
- r_co.y = (float)render_y_ - r_co.y;
+ r_co.y = float(render_y_) - r_co.y;
}
return r_co;
@@ -244,7 +244,7 @@ float2 GpencilIO::gpencil_3D_point_to_render_space(const float3 co)
float2 GpencilIO::gpencil_3D_point_to_2D(const float3 co)
{
- const bool is_camera = (bool)(rv3d_->persp == RV3D_CAMOB);
+ const bool is_camera = bool(rv3d_->persp == RV3D_CAMOB);
if (is_camera) {
return gpencil_3D_point_to_render_space(co);
}
@@ -292,9 +292,9 @@ void GpencilIO::prepare_stroke_export_colors(Object *ob, bGPDstroke *gps)
avg_opacity_ += pt.strength;
}
- mul_v4_v4fl(avg_color, avg_color, 1.0f / (float)gps->totpoints);
+ mul_v4_v4fl(avg_color, avg_color, 1.0f / float(gps->totpoints));
interp_v3_v3v3(stroke_color_, stroke_color_, avg_color, avg_color[3]);
- avg_opacity_ /= (float)gps->totpoints;
+ avg_opacity_ /= float(gps->totpoints);
/* Fill color. */
copy_v4_v4(fill_color_, gp_style->fill_rgba);
diff --git a/source/blender/io/gpencil/intern/gpencil_io_import_base.cc b/source/blender/io/gpencil/intern/gpencil_io_import_base.cc
index 6d4439243fd..f6d02d36a17 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_import_base.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_import_base.cc
@@ -31,7 +31,7 @@ Object *GpencilImporter::create_object()
const float *cur_loc = scene_->cursor.location;
const float rot[3] = {0.0f};
ushort local_view_bits = (params_.v3d && params_.v3d->localvd) ? params_.v3d->local_view_uuid :
- (ushort)0;
+ ushort(0);
Object *ob_gpencil = ED_object_add_type(params_.C,
OB_GPENCIL,
diff --git a/source/blender/io/gpencil/intern/gpencil_io_import_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_import_svg.cc
index ebad236bada..23c80900659 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_import_svg.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_import_svg.cc
@@ -93,8 +93,8 @@ bool GpencilImporterSVG::read()
/* Check frame. */
bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, cfra_, GP_GETFRAME_ADD_NEW);
/* Create materials. */
- bool is_stroke = (bool)shape->stroke.type;
- bool is_fill = (bool)shape->fill.type;
+ bool is_stroke = bool(shape->stroke.type);
+ bool is_fill = bool(shape->fill.type);
if ((!is_stroke) && (!is_fill)) {
is_stroke = true;
}
@@ -148,11 +148,11 @@ void GpencilImporterSVG::create_stroke(bGPdata *gpd,
const int32_t mat_index,
const float matrix[4][4])
{
- const bool is_stroke = (bool)shape->stroke.type;
- const bool is_fill = (bool)shape->fill.type;
+ const bool is_stroke = bool(shape->stroke.type);
+ const bool is_fill = bool(shape->fill.type);
const int edges = params_.resolution;
- const float step = 1.0f / (float)(edges - 1);
+ const float step = 1.0f / float(edges - 1);
const int totpoints = (path->npts / 3) * params_.resolution;
@@ -221,10 +221,10 @@ static void unpack_nano_color(const uint pack, float r_col[4])
rgb_u[2] = ((pack) >> 16) & 0xFF;
rgb_u[3] = ((pack) >> 24) & 0xFF;
- r_col[0] = (float)rgb_u[0] / 255.0f;
- r_col[1] = (float)rgb_u[1] / 255.0f;
- r_col[2] = (float)rgb_u[2] / 255.0f;
- r_col[3] = (float)rgb_u[3] / 255.0f;
+ r_col[0] = float(rgb_u[0]) / 255.0f;
+ r_col[1] = float(rgb_u[1]) / 255.0f;
+ r_col[2] = float(rgb_u[2]) / 255.0f;
+ r_col[3] = float(rgb_u[3]) / 255.0f;
}
void GpencilImporterSVG::convert_color(const int32_t color, float r_linear_rgba[4])
diff --git a/source/blender/io/usd/intern/usd_reader_curve.cc b/source/blender/io/usd/intern/usd_reader_curve.cc
index 0d3c2feb8f3..ca48f3c2391 100644
--- a/source/blender/io/usd/intern/usd_reader_curve.cc
+++ b/source/blender/io/usd/intern/usd_reader_curve.cc
@@ -139,9 +139,9 @@ void USDCurvesReader::read_curve_sample(Curve *cu, const double motionSampleTime
BPoint *bp = nu->bp;
for (int j = 0; j < nu->pntsu; j++, bp++, idx++) {
- bp->vec[0] = (float)usdPoints[idx][0];
- bp->vec[1] = (float)usdPoints[idx][1];
- bp->vec[2] = (float)usdPoints[idx][2];
+ bp->vec[0] = float(usdPoints[idx][0]);
+ bp->vec[1] = float(usdPoints[idx][1]);
+ bp->vec[2] = float(usdPoints[idx][2]);
bp->vec[3] = weight;
bp->f1 = SELECT;
bp->weight = weight;
diff --git a/source/blender/io/usd/intern/usd_reader_light.cc b/source/blender/io/usd/intern/usd_reader_light.cc
index 55b9557dfb5..7204ea91896 100644
--- a/source/blender/io/usd/intern/usd_reader_light.cc
+++ b/source/blender/io/usd/intern/usd_reader_light.cc
@@ -203,7 +203,7 @@ void USDLightReader::read_object_data(Main *bmain, const double motionSampleTime
if (pxr::UsdAttribute cone_angle_attr = shaping_api.GetShapingConeAngleAttr()) {
float cone_angle = 0.0f;
if (cone_angle_attr.Get(&cone_angle, motionSampleTime)) {
- blight->spotsize = cone_angle * ((float)M_PI / 180.0f) * 2.0f;
+ blight->spotsize = cone_angle * (float(M_PI) / 180.0f) * 2.0f;
}
}
@@ -226,7 +226,7 @@ void USDLightReader::read_object_data(Main *bmain, const double motionSampleTime
if (pxr::UsdAttribute angle_attr = distant_light.GetAngleAttr()) {
float angle = 0.0f;
if (angle_attr.Get(&angle, motionSampleTime)) {
- blight->sun_angle = angle * (float)M_PI / 180.0f;
+ blight->sun_angle = angle * float(M_PI) / 180.0f;
}
}
}
diff --git a/source/blender/io/usd/intern/usd_reader_nurbs.cc b/source/blender/io/usd/intern/usd_reader_nurbs.cc
index a838450a4c0..0a7058fb100 100644
--- a/source/blender/io/usd/intern/usd_reader_nurbs.cc
+++ b/source/blender/io/usd/intern/usd_reader_nurbs.cc
@@ -33,7 +33,7 @@ static bool set_knots(const pxr::VtDoubleArray &knots, float *&nu_knots)
nu_knots = static_cast<float *>(MEM_callocN(num_knots * sizeof(float), __func__));
for (size_t i = 0; i < num_knots; i++) {
- nu_knots[i] = (float)knots[i];
+ nu_knots[i] = float(knots[i]);
}
return true;
@@ -141,9 +141,9 @@ void USDNurbsReader::read_curve_sample(Curve *cu, const double motionSampleTime)
BPoint *bp = nu->bp;
for (int j = 0; j < nu->pntsu; j++, bp++, idx++) {
- bp->vec[0] = (float)usdPoints[idx][0];
- bp->vec[1] = (float)usdPoints[idx][1];
- bp->vec[2] = (float)usdPoints[idx][2];
+ bp->vec[0] = float(usdPoints[idx][0]);
+ bp->vec[1] = float(usdPoints[idx][1]);
+ bp->vec[2] = float(usdPoints[idx][2]);
bp->vec[3] = weight;
bp->f1 = SELECT;
bp->weight = weight;
diff --git a/source/blender/io/usd/intern/usd_writer_volume.cc b/source/blender/io/usd/intern/usd_writer_volume.cc
index 12db6d73901..8cc3c65ee70 100644
--- a/source/blender/io/usd/intern/usd_writer_volume.cc
+++ b/source/blender/io/usd/intern/usd_writer_volume.cc
@@ -145,7 +145,7 @@ std::optional<std::string> USDVolumeWriter::construct_vdb_file_path(const Volume
BLI_strncpy(vdb_file_name, volume->id.name + 2, FILE_MAXFILE);
const pxr::UsdTimeCode timecode = get_export_time_code();
if (!timecode.IsDefault()) {
- const int frame = (int)timecode.GetValue();
+ const int frame = int(timecode.GetValue());
const int num_frame_digits = frame == 0 ? 1 : integer_digits_i(abs(frame));
BLI_path_frame(vdb_file_name, frame, num_frame_digits);
}
diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc
index f2547e6fc14..95be927589e 100644
--- a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc
+++ b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc
@@ -503,7 +503,7 @@ static const char *tex_map_type_to_string[] = {
"map_d",
"map_Bump",
};
-BLI_STATIC_ASSERT(ARRAY_SIZE(tex_map_type_to_string) == (int)MTLTexMapType::Count,
+BLI_STATIC_ASSERT(ARRAY_SIZE(tex_map_type_to_string) == int(MTLTexMapType::Count),
"array size mismatch");
/**
@@ -641,7 +641,7 @@ void MTLWriter::write_texture_map(const MTLMaterial &mtl_material,
/* Always emit forward slashes for cross-platform compatibility. */
std::replace(path.begin(), path.end(), '\\', '/');
- fmt_handler_.write_mtl_map(tex_map_type_to_string[(int)texture_key], options, path);
+ fmt_handler_.write_mtl_map(tex_map_type_to_string[int(texture_key)], options, path);
}
static bool is_pbr_map(MTLTexMapType type)
@@ -677,7 +677,7 @@ void MTLWriter::write_materials(const char *blen_filepath,
fmt_handler_.write_string("");
fmt_handler_.write_mtl_newmtl(mtlmat.name);
write_bsdf_properties(mtlmat, write_pbr);
- for (int key = 0; key < (int)MTLTexMapType::Count; key++) {
+ for (int key = 0; key < int(MTLTexMapType::Count); key++) {
const MTLTexMap &tex = mtlmat.texture_maps[key];
if (!tex.is_valid()) {
continue;
diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc
index 851358f8762..0231bc79b89 100644
--- a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc
+++ b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc
@@ -33,7 +33,7 @@ const char *tex_map_type_to_socket_id[] = {
"Alpha",
"Normal",
};
-BLI_STATIC_ASSERT(ARRAY_SIZE(tex_map_type_to_socket_id) == (int)MTLTexMapType::Count,
+BLI_STATIC_ASSERT(ARRAY_SIZE(tex_map_type_to_socket_id) == int(MTLTexMapType::Count),
"array size mismatch");
/**
@@ -312,12 +312,12 @@ static void store_image_textures(const bNode *bsdf_node,
* - finding "Strength" property of the node for `-bm` option.
*/
- for (int key = 0; key < (int)MTLTexMapType::Count; ++key) {
+ for (int key = 0; key < int(MTLTexMapType::Count); ++key) {
MTLTexMap &value = r_mtl_mat.texture_maps[key];
Vector<const bNodeSocket *> linked_sockets;
const bNode *normal_map_node{nullptr};
- if (key == (int)MTLTexMapType::Normal) {
+ if (key == int(MTLTexMapType::Normal)) {
/* Find sockets linked to destination "Normal" socket in P-BSDF node. */
linked_sockets_to_dest_id(bsdf_node, *node_tree, "Normal", linked_sockets);
/* Among the linked sockets, find Normal Map shader node. */
@@ -328,7 +328,7 @@ static void store_image_textures(const bNode *bsdf_node,
}
else {
/* Skip emission map if emission strength is zero. */
- if (key == (int)MTLTexMapType::Emission) {
+ if (key == int(MTLTexMapType::Emission)) {
float emission_strength = 0.0f;
copy_property_from_node(
SOCK_FLOAT, bsdf_node, "Emission Strength", {&emission_strength, 1});
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
index a30dfda24d8..bd1c2d32a12 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
@@ -216,7 +216,7 @@ static void geom_add_polygon(Geometry *geom,
fprintf(stderr,
"Invalid vertex index %i (valid range [0, %zu)), ignoring face\n",
corner.vert_index,
- (size_t)global_vertices.vertices.size());
+ size_t(global_vertices.vertices.size()));
face_valid = false;
}
else {
@@ -228,7 +228,7 @@ static void geom_add_polygon(Geometry *geom,
fprintf(stderr,
"Invalid UV index %i (valid range [0, %zu)), ignoring face\n",
corner.uv_vert_index,
- (size_t)global_vertices.uv_vertices.size());
+ size_t(global_vertices.uv_vertices.size()));
face_valid = false;
}
}
@@ -244,7 +244,7 @@ static void geom_add_polygon(Geometry *geom,
fprintf(stderr,
"Invalid normal index %i (valid range [0, %zu)), ignoring face\n",
corner.vertex_normal_index,
- (size_t)global_vertices.vertex_normals.size());
+ size_t(global_vertices.vertex_normals.size()));
face_valid = false;
}
}
@@ -485,7 +485,7 @@ void OBJParser::parse(Vector<std::unique_ptr<Geometry>> &r_all_geometries,
/* Parse the buffer (until last newline) that we have so far,
* line by line. */
- StringRef buffer_str{buffer.data(), (int64_t)last_nl};
+ StringRef buffer_str{buffer.data(), int64_t(last_nl)};
while (!buffer_str.is_empty()) {
StringRef line = read_next_line(buffer_str);
const char *p = line.begin(), *end = line.end();
@@ -768,7 +768,7 @@ void MTLParser::parse_and_store(Map<string, std::unique_ptr<MTLMaterial>> &r_mat
MTLMaterial *material = nullptr;
- StringRef buffer_str{(const char *)buffer, (int64_t)buffer_len};
+ StringRef buffer_str{(const char *)buffer, int64_t(buffer_len)};
while (!buffer_str.is_empty()) {
const StringRef line = read_next_line(buffer_str);
const char *p = line.begin(), *end = line.end();
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
index ef05534928a..4a4d1eeadb6 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
@@ -166,7 +166,7 @@ void MeshFromGeometry::create_vertices(Mesh *mesh)
if (!mesh_geometry_.vertices_.contains(vi)) {
continue;
}
- int local_vi = (int)mesh_geometry_.global_to_local_vertices_.size();
+ int local_vi = int(mesh_geometry_.global_to_local_vertices_.size());
BLI_assert(local_vi >= 0 && local_vi < mesh->totvert);
copy_v3_v3(verts[local_vi].co, global_vertices_.vertices[vi]);
mesh_geometry_.global_to_local_vertices_.add_new(vi, local_vi);
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc b/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc
index 439a5fa8f05..787b1fc9730 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc
@@ -356,7 +356,7 @@ static void add_image_textures(Main *bmain,
bool relative_paths)
{
float node_locy = node_locy_top;
- for (int key = 0; key < (int)MTLTexMapType::Count; ++key) {
+ for (int key = 0; key < int(MTLTexMapType::Count); ++key) {
const MTLTexMap &value = mtl_mat.texture_maps[key];
if (!value.is_valid()) {
/* No Image texture node of this map type can be added to this material. */
@@ -375,7 +375,7 @@ static void add_image_textures(Main *bmain,
/* Add normal map node if needed. */
bNode *normal_map = nullptr;
- if (key == (int)MTLTexMapType::Normal) {
+ if (key == int(MTLTexMapType::Normal)) {
normal_map = add_node(ntree, SH_NODE_NORMAL_MAP, node_locx_normalmap, node_locy);
const float bump = std::max(0.0f, mtl_mat.normal_strength);
set_property_of_socket(SOCK_FLOAT, "Strength", {bump}, normal_map);
@@ -396,7 +396,7 @@ static void add_image_textures(Main *bmain,
link_sockets(ntree, image_node, "Color", normal_map, "Color");
link_sockets(ntree, normal_map, "Normal", bsdf, "Normal");
}
- else if (key == (int)MTLTexMapType::Alpha) {
+ else if (key == int(MTLTexMapType::Alpha)) {
link_sockets(ntree, image_node, "Alpha", bsdf, tex_map_type_to_socket_id[key]);
mat->blend_method = MA_BM_BLEND;
}
diff --git a/source/blender/io/wavefront_obj/tests/obj_mtl_parser_tests.cc b/source/blender/io/wavefront_obj/tests/obj_mtl_parser_tests.cc
index e473d629673..ce3c14a2939 100644
--- a/source/blender/io/wavefront_obj/tests/obj_mtl_parser_tests.cc
+++ b/source/blender/io/wavefront_obj/tests/obj_mtl_parser_tests.cc
@@ -67,7 +67,7 @@ class obj_mtl_parser_test : public testing::Test {
EXPECT_NEAR(exp.cc_roughness, got.cc_roughness, tol);
EXPECT_NEAR(exp.aniso, got.aniso, tol);
EXPECT_NEAR(exp.aniso_rot, got.aniso_rot, tol);
- for (int key = 0; key < (int)MTLTexMapType::Count; key++) {
+ for (int key = 0; key < int(MTLTexMapType::Count); key++) {
const MTLTexMap &exp_tex = exp.texture_maps[key];
const MTLTexMap &got_tex = got.texture_maps[key];
EXPECT_STREQ(exp_tex.image_path.c_str(), got_tex.image_path.c_str());