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-26 10:38:25 +0300
committerCampbell Barton <campbell@blender.org>2022-09-26 10:58:36 +0300
commit333e41eac6daf60c6aa9df0496a39c57d74b9c87 (patch)
tree5986e980fd64bc4ef1c3dda125a0f9dca4bab2c8 /source/blender/blenkernel
parent0210c4df1793799a09a35e44be286dfca88769dc (diff)
Cleanup: replace C-style casts with functional casts for numeric types
Use function style casts in C++ headers & source.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_attribute_math.hh30
-rw-r--r--source/blender/blenkernel/BKE_cryptomatte.hh4
-rw-r--r--source/blender/blenkernel/BKE_curves.hh2
-rw-r--r--source/blender/blenkernel/intern/subdiv_mesh.cc3
4 files changed, 16 insertions, 23 deletions
diff --git a/source/blender/blenkernel/BKE_attribute_math.hh b/source/blender/blenkernel/BKE_attribute_math.hh
index abd8b33b260..5c0e5f428a4 100644
--- a/source/blender/blenkernel/BKE_attribute_math.hh
+++ b/source/blender/blenkernel/BKE_attribute_math.hh
@@ -60,12 +60,12 @@ template<> inline bool mix2(const float factor, const bool &a, const bool &b)
template<> inline int8_t mix2(const float factor, const int8_t &a, const int8_t &b)
{
- return static_cast<int8_t>(std::round((1.0f - factor) * a + factor * b));
+ return int8_t(std::round((1.0f - factor) * a + factor * b));
}
template<> inline int mix2(const float factor, const int &a, const int &b)
{
- return static_cast<int>(std::round((1.0f - factor) * a + factor * b));
+ return int(std::round((1.0f - factor) * a + factor * b));
}
template<> inline float mix2(const float factor, const float &a, const float &b)
@@ -108,7 +108,7 @@ template<typename T> T mix3(const float3 &weights, const T &v0, const T &v1, con
template<>
inline int8_t mix3(const float3 &weights, const int8_t &v0, const int8_t &v1, const int8_t &v2)
{
- return static_cast<int8_t>(std::round(weights.x * v0 + weights.y * v1 + weights.z * v2));
+ return int8_t(std::round(weights.x * v0 + weights.y * v1 + weights.z * v2));
}
template<> inline bool mix3(const float3 &weights, const bool &v0, const bool &v1, const bool &v2)
@@ -118,7 +118,7 @@ template<> inline bool mix3(const float3 &weights, const bool &v0, const bool &v
template<> inline int mix3(const float3 &weights, const int &v0, const int &v1, const int &v2)
{
- return static_cast<int>(std::round(weights.x * v0 + weights.y * v1 + weights.z * v2));
+ return int(std::round(weights.x * v0 + weights.y * v1 + weights.z * v2));
}
template<>
@@ -160,10 +160,8 @@ inline ColorGeometry4b mix3(const float3 &weights,
const float4 v1_f{&v1.r};
const float4 v2_f{&v2.r};
const float4 mixed = v0_f * weights[0] + v1_f * weights[1] + v2_f * weights[2];
- return ColorGeometry4b{static_cast<uint8_t>(mixed[0]),
- static_cast<uint8_t>(mixed[1]),
- static_cast<uint8_t>(mixed[2]),
- static_cast<uint8_t>(mixed[3])};
+ return ColorGeometry4b{
+ uint8_t(mixed[0]), uint8_t(mixed[1]), uint8_t(mixed[2]), uint8_t(mixed[3])};
}
/** \} */
@@ -180,8 +178,7 @@ template<>
inline int8_t mix4(
const float4 &weights, const int8_t &v0, const int8_t &v1, const int8_t &v2, const int8_t &v3)
{
- return static_cast<int8_t>(
- std::round(weights.x * v0 + weights.y * v1 + weights.z * v2 + weights.w * v3));
+ return int8_t(std::round(weights.x * v0 + weights.y * v1 + weights.z * v2 + weights.w * v3));
}
template<>
@@ -194,8 +191,7 @@ inline bool mix4(
template<>
inline int mix4(const float4 &weights, const int &v0, const int &v1, const int &v2, const int &v3)
{
- return static_cast<int>(
- std::round(weights.x * v0 + weights.y * v1 + weights.z * v2 + weights.w * v3));
+ return int(std::round(weights.x * v0 + weights.y * v1 + weights.z * v2 + weights.w * v3));
}
template<>
@@ -244,10 +240,8 @@ inline ColorGeometry4b mix4(const float4 &weights,
const float4 v3_f{&v3.r};
float4 mixed;
interp_v4_v4v4v4v4(mixed, v0_f, v1_f, v2_f, v3_f, weights);
- return ColorGeometry4b{static_cast<uint8_t>(mixed[0]),
- static_cast<uint8_t>(mixed[1]),
- static_cast<uint8_t>(mixed[2]),
- static_cast<uint8_t>(mixed[3])};
+ return ColorGeometry4b{
+ uint8_t(mixed[0]), uint8_t(mixed[1]), uint8_t(mixed[2]), uint8_t(mixed[3])};
}
/** \} */
@@ -523,7 +517,7 @@ template<> struct DefaultMixerStruct<ColorGeometry4b> {
template<> struct DefaultMixerStruct<int> {
static int double_to_int(const double &value)
{
- return static_cast<int>(std::round(value));
+ return int(std::round(value));
}
/* Store interpolated ints in a double temporarily, so that weights are handled correctly. It
* uses double instead of float so that it is accurate for all 32 bit integers. */
@@ -542,7 +536,7 @@ template<> struct DefaultMixerStruct<bool> {
template<> struct DefaultMixerStruct<int8_t> {
static int8_t float_to_int8_t(const float &value)
{
- return static_cast<int8_t>(std::round(value));
+ return int8_t(std::round(value));
}
/* Store interpolated 8 bit integers in a float temporarily to increase accuracy. */
using type = SimpleMixerWithAccumulationType<int8_t, float, float_to_int8_t>;
diff --git a/source/blender/blenkernel/BKE_cryptomatte.hh b/source/blender/blenkernel/BKE_cryptomatte.hh
index dd08f7b5c4f..b24968c5c70 100644
--- a/source/blender/blenkernel/BKE_cryptomatte.hh
+++ b/source/blender/blenkernel/BKE_cryptomatte.hh
@@ -79,8 +79,8 @@ struct CryptomatteHash {
{
uint32_t mantissa = hash & ((1 << 23) - 1);
uint32_t exponent = (hash >> 23) & ((1 << 8) - 1);
- exponent = MAX2(exponent, (uint32_t)1);
- exponent = MIN2(exponent, (uint32_t)254);
+ exponent = MAX2(exponent, uint32_t(1));
+ exponent = MIN2(exponent, uint32_t(254));
exponent = exponent << 23;
uint32_t sign = (hash >> 31);
sign = sign << 31;
diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh
index 0d67152dec8..371f6052a76 100644
--- a/source/blender/blenkernel/BKE_curves.hh
+++ b/source/blender/blenkernel/BKE_curves.hh
@@ -986,7 +986,7 @@ inline bool has_vector_handles(const int num_curve_points,
const bool cyclic,
const int resolution)
{
- return evaluated_size - !cyclic != (int64_t)segments_num(num_curve_points, cyclic) * resolution;
+ return evaluated_size - !cyclic != int64_t(segments_num(num_curve_points, cyclic)) * resolution;
}
inline float3 calculate_vector_handle(const float3 &point, const float3 &next_point)
diff --git a/source/blender/blenkernel/intern/subdiv_mesh.cc b/source/blender/blenkernel/intern/subdiv_mesh.cc
index 651e58d9ca4..14695718804 100644
--- a/source/blender/blenkernel/intern/subdiv_mesh.cc
+++ b/source/blender/blenkernel/intern/subdiv_mesh.cc
@@ -1084,8 +1084,7 @@ static void subdiv_mesh_vertex_of_loose_edge_interpolate(SubdivMeshContext *ctx,
BLI_assert(u > 0.0f);
BLI_assert(u < 1.0f);
const float interpolation_weights[2] = {1.0f - u, u};
- const int coarse_vertex_indices[2] = {static_cast<int>(coarse_edge->v1),
- static_cast<int>(coarse_edge->v2)};
+ const int coarse_vertex_indices[2] = {int(coarse_edge->v1), int(coarse_edge->v2)};
CustomData_interp(&coarse_mesh->vdata,
&subdiv_mesh->vdata,
coarse_vertex_indices,