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/collada
parentc7b247a118e302a3afc6473797e53b6af28b69e2 (diff)
Cleanup: replace C-style casts with functional casts for numeric types
Diffstat (limited to 'source/blender/io/collada')
-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
11 files changed, 49 insertions, 49 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;