diff options
author | Campbell Barton <campbell@blender.org> | 2022-09-26 10:38:25 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-09-26 10:58:36 +0300 |
commit | 333e41eac6daf60c6aa9df0496a39c57d74b9c87 (patch) | |
tree | 5986e980fd64bc4ef1c3dda125a0f9dca4bab2c8 | |
parent | 0210c4df1793799a09a35e44be286dfca88769dc (diff) |
Cleanup: replace C-style casts with functional casts for numeric types
Use function style casts in C++ headers & source.
54 files changed, 138 insertions, 153 deletions
diff --git a/intern/ghost/intern/GHOST_ContextGLX.cpp b/intern/ghost/intern/GHOST_ContextGLX.cpp index e5f2e707f32..4c1e2705b50 100644 --- a/intern/ghost/intern/GHOST_ContextGLX.cpp +++ b/intern/ghost/intern/GHOST_ContextGLX.cpp @@ -320,7 +320,7 @@ GHOST_TSuccess GHOST_ContextGLX::getSwapInterval(int &intervalOut) ::glXQueryDrawable(m_display, m_window, GLX_SWAP_INTERVAL_EXT, &interval); - intervalOut = static_cast<int>(interval); + intervalOut = int(interval); return GHOST_kSuccess; } diff --git a/intern/ghost/intern/GHOST_XrAction.cpp b/intern/ghost/intern/GHOST_XrAction.cpp index 0e725bf4075..9fbe033ade9 100644 --- a/intern/ghost/intern/GHOST_XrAction.cpp +++ b/intern/ghost/intern/GHOST_XrAction.cpp @@ -528,7 +528,7 @@ void *GHOST_XrActionSet::getCustomdata() uint32_t GHOST_XrActionSet::getActionCount() const { - return (uint32_t)m_actions.size(); + return uint32_t(m_actions.size()); } void GHOST_XrActionSet::getActionCustomdataArray(void **r_customdata_array) diff --git a/intern/mikktspace/mikktspace.hh b/intern/mikktspace/mikktspace.hh index 93e22658a56..2e5b0b065a8 100644 --- a/intern/mikktspace/mikktspace.hh +++ b/intern/mikktspace/mikktspace.hh @@ -151,7 +151,7 @@ template<typename Mesh> class Mikktspace { void genTangSpace() { - nrFaces = (uint)mesh.GetNumFaces(); + nrFaces = uint(mesh.GetNumFaces()); #ifdef WITH_TBB nrThreads = tbb::this_task_arena::max_concurrency(); @@ -276,7 +276,7 @@ template<typename Mesh> class Mikktspace { if (verts != 3 && verts != 4) continue; - uint tA = (uint)triangles.size(); + uint tA = uint(triangles.size()); triangles.emplace_back(f, nrTSpaces); Triangle &triA = triangles[tA]; @@ -284,7 +284,7 @@ template<typename Mesh> class Mikktspace { triA.setVertices(0, 1, 2); } else { - uint tB = (uint)triangles.size(); + uint tB = uint(triangles.size()); triangles.emplace_back(f, nrTSpaces); Triangle &triB = triangles[tB]; @@ -731,7 +731,7 @@ template<typename Mesh> class Mikktspace { continue; } - const uint newGroupId = (uint)groups.size(); + const uint newGroupId = uint(groups.size()); triangle.group[i] = newGroupId; groups.emplace_back(triangle.vertices[i], bool(triangle.orientPreserving)); diff --git a/intern/sky/source/sky_nishita.cpp b/intern/sky/source/sky_nishita.cpp index f1eab181189..d00ef51e152 100644 --- a/intern/sky/source/sky_nishita.cpp +++ b/intern/sky/source/sky_nishita.cpp @@ -316,7 +316,7 @@ void SKY_nishita_skymodel_precompute_texture(float *pixels, for (int y = start_y; y < end_y; y++) { /* sample more pixels toward the horizon */ - float latitude = (M_PI_2_F + half_lat_step) * sqr((float)y / height); + float latitude = (M_PI_2_F + half_lat_step) * sqr(float(y) / height); float *pixel_row = pixels + (y * width * stride); for (int x = 0; x < half_width; x++) { 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, diff --git a/source/blender/blenlib/BLI_cpp_type.hh b/source/blender/blenlib/BLI_cpp_type.hh index 8cf5ead1c7b..568ccbb5a64 100644 --- a/source/blender/blenlib/BLI_cpp_type.hh +++ b/source/blender/blenlib/BLI_cpp_type.hh @@ -297,7 +297,7 @@ class CPPType : NonCopyable, NonMovable { */ bool pointer_has_valid_alignment(const void *ptr) const { - return ((uintptr_t)ptr & alignment_mask_) == 0; + return (uintptr_t(ptr) & alignment_mask_) == 0; } bool pointer_can_point_to_instance(const void *ptr) const diff --git a/source/blender/blenlib/BLI_cpp_type_make.hh b/source/blender/blenlib/BLI_cpp_type_make.hh index 3acef4b0f09..1f494624821 100644 --- a/source/blender/blenlib/BLI_cpp_type_make.hh +++ b/source/blender/blenlib/BLI_cpp_type_make.hh @@ -271,7 +271,7 @@ CPPType::CPPType(CPPTypeParam<T, Flags> /* unused */, StringRef debug_name) is_equal_ = is_equal_cb<T>; } - alignment_mask_ = (uintptr_t)alignment_ - (uintptr_t)1; + alignment_mask_ = uintptr_t(alignment_) - uintptr_t(1); has_special_member_functions_ = (default_construct_ && copy_construct_ && copy_assign_ && move_construct_ && move_assign_ && destruct_); } diff --git a/source/blender/blenlib/BLI_dot_export.hh b/source/blender/blenlib/BLI_dot_export.hh index b6decca0720..454f3c8412c 100644 --- a/source/blender/blenlib/BLI_dot_export.hh +++ b/source/blender/blenlib/BLI_dot_export.hh @@ -98,7 +98,7 @@ class Cluster { std::string name() const { - return "cluster_" + std::to_string((uintptr_t)this); + return "cluster_" + std::to_string(uintptr_t(this)); } void set_parent_cluster(Cluster *new_parent); diff --git a/source/blender/blenlib/BLI_hash_tables.hh b/source/blender/blenlib/BLI_hash_tables.hh index 85a8fd5d385..de65c58d4db 100644 --- a/source/blender/blenlib/BLI_hash_tables.hh +++ b/source/blender/blenlib/BLI_hash_tables.hh @@ -225,17 +225,17 @@ template<typename Pointer> struct PointerKeyInfo { static bool is_empty(Pointer pointer) { - return (uintptr_t)pointer == UINTPTR_MAX; + return uintptr_t(pointer) == UINTPTR_MAX; } static bool is_removed(Pointer pointer) { - return (uintptr_t)pointer == UINTPTR_MAX - 1; + return uintptr_t(pointer) == UINTPTR_MAX - 1; } static bool is_not_empty_or_removed(Pointer pointer) { - return (uintptr_t)pointer < UINTPTR_MAX - 1; + return uintptr_t(pointer) < UINTPTR_MAX - 1; } }; diff --git a/source/blender/blenlib/BLI_linear_allocator.hh b/source/blender/blenlib/BLI_linear_allocator.hh index 07211de3aed..a897845db45 100644 --- a/source/blender/blenlib/BLI_linear_allocator.hh +++ b/source/blender/blenlib/BLI_linear_allocator.hh @@ -207,8 +207,8 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya Span<char> buffer = unused_borrowed_buffers_[i]; if (buffer.size() >= min_allocation_size) { unused_borrowed_buffers_.remove_and_reorder(i); - current_begin_ = (uintptr_t)buffer.begin(); - current_end_ = (uintptr_t)buffer.end(); + current_begin_ = uintptr_t(buffer.begin()); + current_end_ = uintptr_t(buffer.end()); return; } } @@ -226,7 +226,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya void *buffer = allocator_.allocate(size_in_bytes, min_alignment, __func__); owned_buffers_.append(buffer); - current_begin_ = (uintptr_t)buffer; + current_begin_ = uintptr_t(buffer); current_end_ = current_begin_ + size_in_bytes; } diff --git a/source/blender/blenlib/BLI_map.hh b/source/blender/blenlib/BLI_map.hh index d5bc53c4d6c..9fc5614c189 100644 --- a/source/blender/blenlib/BLI_map.hh +++ b/source/blender/blenlib/BLI_map.hh @@ -1314,7 +1314,7 @@ template<typename Key, typename Value> class StdUnorderedMapWrapper { bool remove(const Key &key) { - return (bool)map_.erase(key); + return bool(map_.erase(key)); } Value &lookup(const Key &key) diff --git a/source/blender/blenlib/BLI_math_vector.hh b/source/blender/blenlib/BLI_math_vector.hh index 3067232e8ea..e8303aa858b 100644 --- a/source/blender/blenlib/BLI_math_vector.hh +++ b/source/blender/blenlib/BLI_math_vector.hh @@ -366,7 +366,7 @@ template<typename T, BLI_ENABLE_IF((is_math_float_type<T>))> inline vec_base<T, 3> cross_poly(Span<vec_base<T, 3>> poly) { /* Newell's Method. */ - int nv = static_cast<int>(poly.size()); + int nv = int(poly.size()); if (nv < 3) { return vec_base<T, 3>(0, 0, 0); } diff --git a/source/blender/blenlib/BLI_memory_utils.hh b/source/blender/blenlib/BLI_memory_utils.hh index 0809f372b25..b6ffa6d8b4a 100644 --- a/source/blender/blenlib/BLI_memory_utils.hh +++ b/source/blender/blenlib/BLI_memory_utils.hh @@ -372,7 +372,7 @@ template<size_t Size, size_t Alignment> class AlignedBuffer { */ template<typename T, int64_t Size = 1> class TypedBuffer { private: - BLI_NO_UNIQUE_ADDRESS AlignedBuffer<sizeof(T) * (size_t)Size, alignof(T)> buffer_; + BLI_NO_UNIQUE_ADDRESS AlignedBuffer<sizeof(T) * size_t(Size), alignof(T)> buffer_; public: operator T *() diff --git a/source/blender/blenlib/BLI_set.hh b/source/blender/blenlib/BLI_set.hh index afe18529762..8fb618edeb6 100644 --- a/source/blender/blenlib/BLI_set.hh +++ b/source/blender/blenlib/BLI_set.hh @@ -917,7 +917,7 @@ template<typename Key> class StdUnorderedSetWrapper { bool remove(const Key &key) { - return (bool)set_.erase(key); + return bool(set_.erase(key)); } void remove_contained(const Key &key) diff --git a/source/blender/blenlib/BLI_string_ref.hh b/source/blender/blenlib/BLI_string_ref.hh index b202769e3c3..14dee54d730 100644 --- a/source/blender/blenlib/BLI_string_ref.hh +++ b/source/blender/blenlib/BLI_string_ref.hh @@ -585,7 +585,7 @@ inline std::ostream &operator<<(std::ostream &stream, StringRef ref) inline std::ostream &operator<<(std::ostream &stream, StringRefNull ref) { - stream << std::string(ref.data(), (size_t)ref.size()); + stream << std::string(ref.data(), size_t(ref.size())); return stream; } @@ -611,7 +611,7 @@ constexpr bool operator==(StringRef a, StringRef b) /* This also avoids passing null to the call below, which would results in an ASAN warning. */ return true; } - return STREQLEN(a.data(), b.data(), (size_t)a.size()); + return STREQLEN(a.data(), b.data(), size_t(a.size())); } constexpr bool operator!=(StringRef a, StringRef b) diff --git a/source/blender/blenlib/tests/BLI_exception_safety_test_utils.hh b/source/blender/blenlib/tests/BLI_exception_safety_test_utils.hh index 63943e48f0e..367d8508a20 100644 --- a/source/blender/blenlib/tests/BLI_exception_safety_test_utils.hh +++ b/source/blender/blenlib/tests/BLI_exception_safety_test_utils.hh @@ -87,7 +87,7 @@ class ExceptionThrower { uint64_t hash() const { - return static_cast<uint64_t>(value); + return uint64_t(value); } friend bool operator==(const ExceptionThrower &a, const ExceptionThrower &b) diff --git a/source/blender/blenlib/tests/BLI_vector_test.cc b/source/blender/blenlib/tests/BLI_vector_test.cc index 2dd220f562b..c603f5dff27 100644 --- a/source/blender/blenlib/tests/BLI_vector_test.cc +++ b/source/blender/blenlib/tests/BLI_vector_test.cc @@ -317,7 +317,7 @@ TEST(vector, BecomeLarge) } EXPECT_EQ(vec.size(), 100); for (int i = 0; i < 100; i++) { - EXPECT_EQ(vec[i], static_cast<int>(i * 5)); + EXPECT_EQ(vec[i], int(i * 5)); } } diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc index 863171f105e..28c0b44ac2f 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc @@ -1130,7 +1130,7 @@ static void do_fillGradientBuffer(uint rw, dmin = ud; /* Set a new minimum equal to the new lower value. */ } } - odist = (float)(dmin); /* Cast outer min to a float. */ + odist = float(dmin); /* Cast outer min to a float. */ rsf = odist * 0.5f; rsl = *(uint *)&odist; /* Use some peculiar properties of the way bits are stored. */ rsl = 0x5f3759df - (rsl >> 1); /* In floats vs. uints to compute an approximate. */ @@ -1151,7 +1151,7 @@ static void do_fillGradientBuffer(uint rw, } /* Cast inner min to a float. */ - idist = (float)(dmin); + idist = float(dmin); rsf = idist * 0.5f; rsl = *(uint *)&idist; diff --git a/source/blender/draw/engines/eevee_next/eevee_material.hh b/source/blender/draw/engines/eevee_next/eevee_material.hh index ad0c293926b..f4b1f60b456 100644 --- a/source/blender/draw/engines/eevee_next/eevee_material.hh +++ b/source/blender/draw/engines/eevee_next/eevee_material.hh @@ -120,7 +120,7 @@ struct MaterialKey { uint64_t hash() const { BLI_assert(options < sizeof(*mat)); - return (uint64_t)mat + options; + return uint64_t(mat) + options; } bool operator<(const MaterialKey &k) const @@ -154,7 +154,7 @@ struct ShaderKey { uint64_t hash() const { - return (uint64_t)shader + options; + return uint64_t(shader) + options; } bool operator<(const ShaderKey &k) const diff --git a/source/blender/draw/engines/image/image_drawing_mode.hh b/source/blender/draw/engines/image/image_drawing_mode.hh index a1cd110e1d8..21dac8009f6 100644 --- a/source/blender/draw/engines/image/image_drawing_mode.hh +++ b/source/blender/draw/engines/image/image_drawing_mode.hh @@ -243,8 +243,8 @@ template<typename TextureMethod> class ScreenSpaceDrawingMode : public AbstractD do_partial_update_float_buffer(tile_buffer, iterator); } - const float tile_width = static_cast<float>(iterator.tile_data.tile_buffer->x); - const float tile_height = static_cast<float>(iterator.tile_data.tile_buffer->y); + const float tile_width = float(iterator.tile_data.tile_buffer->x); + const float tile_height = float(iterator.tile_data.tile_buffer->y); for (int i = 0; i < SCREEN_SPACE_DRAWING_MODE_TEXTURE_LEN; i++) { const TextureInfo &info = instance_data.texture_infos[i]; @@ -260,23 +260,20 @@ template<typename TextureMethod> class ScreenSpaceDrawingMode : public AbstractD const float texture_height = GPU_texture_height(texture); /* TODO: early bound check. */ ImageTileWrapper tile_accessor(iterator.tile_data.tile); - float tile_offset_x = static_cast<float>(tile_accessor.get_tile_x_offset()); - float tile_offset_y = static_cast<float>(tile_accessor.get_tile_y_offset()); + float tile_offset_x = float(tile_accessor.get_tile_x_offset()); + float tile_offset_y = float(tile_accessor.get_tile_y_offset()); rcti *changed_region_in_texel_space = &iterator.changed_region.region; rctf changed_region_in_uv_space; - BLI_rctf_init(&changed_region_in_uv_space, - static_cast<float>(changed_region_in_texel_space->xmin) / - static_cast<float>(iterator.tile_data.tile_buffer->x) + - tile_offset_x, - static_cast<float>(changed_region_in_texel_space->xmax) / - static_cast<float>(iterator.tile_data.tile_buffer->x) + - tile_offset_x, - static_cast<float>(changed_region_in_texel_space->ymin) / - static_cast<float>(iterator.tile_data.tile_buffer->y) + - tile_offset_y, - static_cast<float>(changed_region_in_texel_space->ymax) / - static_cast<float>(iterator.tile_data.tile_buffer->y) + - tile_offset_y); + BLI_rctf_init( + &changed_region_in_uv_space, + float(changed_region_in_texel_space->xmin) / float(iterator.tile_data.tile_buffer->x) + + tile_offset_x, + float(changed_region_in_texel_space->xmax) / float(iterator.tile_data.tile_buffer->x) + + tile_offset_x, + float(changed_region_in_texel_space->ymin) / float(iterator.tile_data.tile_buffer->y) + + tile_offset_y, + float(changed_region_in_texel_space->ymax) / float(iterator.tile_data.tile_buffer->y) + + tile_offset_y); rctf changed_overlapping_region_in_uv_space; const bool region_overlap = BLI_rctf_isect(&info.clipping_uv_bounds, &changed_region_in_uv_space, @@ -423,8 +420,8 @@ template<typename TextureMethod> class ScreenSpaceDrawingMode : public AbstractD * transformation. */ float uv_to_texel[4][4]; copy_m4_m4(uv_to_texel, instance_data.ss_to_texture); - float scale[3] = {static_cast<float>(texture_width) / static_cast<float>(tile_buffer.x), - static_cast<float>(texture_height) / static_cast<float>(tile_buffer.y), + float scale[3] = {float(texture_width) / float(tile_buffer.x), + float(texture_height) / float(tile_buffer.y), 1.0f}; rescale_m4(uv_to_texel, scale); uv_to_texel[3][0] += image_tile.get_tile_x_offset() / diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 97cec585979..e494f9f4632 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -1318,7 +1318,7 @@ static void drw_subdiv_compute_dispatch(const DRWSubdivCache *cache, /* X and Y dimensions may have different limits so the above computation may not be right, but * even with the standard 64k minimum on all dimensions we still have a lot of room. Therefore, * we presume it all fits. */ - BLI_assert(dispatch_ry < static_cast<uint>(GPU_max_work_group_count(1))); + BLI_assert(dispatch_ry < uint(GPU_max_work_group_count(1))); draw_subdiv_ubo_update_and_bind( cache, shader, src_offset, dst_offset, total_dispatch_size, has_sculpt_mask); diff --git a/source/blender/draw/intern/draw_command.hh b/source/blender/draw/intern/draw_command.hh index 46a9199a267..5307a242e39 100644 --- a/source/blender/draw/intern/draw_command.hh +++ b/source/blender/draw/intern/draw_command.hh @@ -387,7 +387,7 @@ class DrawCommandBuf { instance_len = instance_len != -1 ? instance_len : 1; int64_t index = commands.append_and_get_index({}); - headers.append({Type::Draw, static_cast<uint>(index)}); + headers.append({Type::Draw, uint(index)}); commands[index].draw = {batch, instance_len, vertex_len, vertex_first, handle}; } @@ -489,11 +489,11 @@ class DrawMultiBuf { DrawMulti &cmd = commands.last().draw_multi; - uint &group_id = group_ids_.lookup_or_add(DrawGroupKey(cmd.uuid, batch), (uint)-1); + uint &group_id = group_ids_.lookup_or_add(DrawGroupKey(cmd.uuid, batch), uint(-1)); bool inverted = handle.has_inverted_handedness(); - if (group_id == (uint)-1) { + if (group_id == uint(-1)) { uint new_group_id = group_count_++; DrawGroup &group = group_buf_.get_or_resize(new_group_id); diff --git a/source/blender/draw/intern/draw_pass.hh b/source/blender/draw/intern/draw_pass.hh index e1a0a6652ac..ee2180712d1 100644 --- a/source/blender/draw/intern/draw_pass.hh +++ b/source/blender/draw/intern/draw_pass.hh @@ -403,7 +403,7 @@ class PassSortable : public PassMain { { int64_t index = sub_passes_.append_and_get_index( PassBase(name, draw_commands_buf_, sub_passes_, shader_)); - headers_.append({Type::SubPass, static_cast<uint>(index)}); + headers_.append({Type::SubPass, uint(index)}); sorting_values_.append(sorting_value); return sub_passes_[index]; } @@ -442,7 +442,7 @@ namespace detail { template<class T> inline command::Undetermined &PassBase<T>::create_command(command::Type type) { int64_t index = commands_.append_and_get_index({}); - headers_.append({type, static_cast<uint>(index)}); + headers_.append({type, uint(index)}); return commands_[index]; } @@ -452,7 +452,7 @@ inline void PassBase<T>::clear(eGPUFrameBufferBits planes, float depth, uint8_t stencil) { - create_command(command::Type::Clear).clear = {(uint8_t)planes, stencil, depth, color}; + create_command(command::Type::Clear).clear = {uint8_t(planes), stencil, depth, color}; } template<class T> inline GPUBatch *PassBase<T>::procedural_batch_get(GPUPrimType primitive) @@ -477,7 +477,7 @@ template<class T> inline PassBase<T> &PassBase<T>::sub(const char *name) { int64_t index = sub_passes_.append_and_get_index( PassBase(name, draw_commands_buf_, sub_passes_, shader_)); - headers_.append({command::Type::SubPass, static_cast<uint>(index)}); + headers_.append({command::Type::SubPass, uint(index)}); return sub_passes_[index]; } diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc index 12e3d4afd5d..097e45ad3ee 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc @@ -300,7 +300,7 @@ static void extract_edit_data_iter_subdiv_mesh(const DRWSubdivCache *subdiv_cach uint subdiv_quad_index, const MPoly *coarse_quad) { - const int coarse_quad_index = static_cast<int>(coarse_quad - mr->mpoly); + const int coarse_quad_index = int(coarse_quad - mr->mpoly); BMFace *coarse_quad_bm = bm_original_face_get(mr, coarse_quad_index); extract_edit_data_iter_subdiv_bm(subdiv_cache, mr, _data, subdiv_quad_index, coarse_quad_bm); } diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc index 0b9043e3289..504d4a6956a 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc @@ -174,7 +174,7 @@ static void extract_edituv_data_iter_subdiv_mesh(const DRWSubdivCache *subdiv_ca uint subdiv_quad_index, const MPoly *coarse_quad) { - const int coarse_quad_index = static_cast<int>(coarse_quad - mr->mpoly); + const int coarse_quad_index = int(coarse_quad - mr->mpoly); BMFace *coarse_quad_bm = bm_original_face_get(mr, coarse_quad_index); extract_edituv_data_iter_subdiv_bm(subdiv_cache, mr, _data, subdiv_quad_index, coarse_quad_bm); } diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 7e5556adcc9..403cb0116d2 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -3659,10 +3659,10 @@ static void ui_but_build_drawstr_float(uiBut *but, double value) /* Change negative zero to regular zero, without altering anything else. */ value += +0.0f; - if (value == (double)FLT_MAX) { + if (value == double(FLT_MAX)) { STR_CONCAT(but->drawstr, slen, "inf"); } - else if (value == (double)-FLT_MAX) { + else if (value == double(-FLT_MAX)) { STR_CONCAT(but->drawstr, slen, "-inf"); } else if (subtype == PROP_PERCENTAGE) { diff --git a/source/blender/editors/interface/interface_region_tooltip.cc b/source/blender/editors/interface/interface_region_tooltip.cc index 74985c50cc1..3ded613c6f3 100644 --- a/source/blender/editors/interface/interface_region_tooltip.cc +++ b/source/blender/editors/interface/interface_region_tooltip.cc @@ -1396,8 +1396,7 @@ ARegion *UI_tooltip_create_from_gizmo(bContext *C, wmGizmo *gz) { wmWindow *win = CTX_wm_window(C); const float aspect = 1.0f; - float init_position[2] = {static_cast<float>(win->eventstate->xy[0]), - static_cast<float>(win->eventstate->xy[1])}; + float init_position[2] = {float(win->eventstate->xy[0]), float(win->eventstate->xy[1])}; uiTooltipData *data = ui_tooltip_data_from_gizmo(C, gz); if (data == nullptr) { diff --git a/source/blender/editors/object/object_transform.cc b/source/blender/editors/object/object_transform.cc index 680cf1c94cd..8ba460b1c6d 100644 --- a/source/blender/editors/object/object_transform.cc +++ b/source/blender/editors/object/object_transform.cc @@ -1866,7 +1866,7 @@ struct XFormAxisData { static void object_transform_axis_target_calc_depth_init(XFormAxisData *xfd, const int mval[2]) { float view_co_a[3], view_co_b[3]; - const float2 mval_fl = {static_cast<float>(mval[0]), static_cast<float>(mval[1])}; + const float2 mval_fl = {float(mval[0]), float(mval[1])}; ED_view3d_win_to_ray(xfd->vc.region, mval_fl, view_co_a, view_co_b); add_v3_v3(view_co_b, view_co_a); float center[3] = {0.0f}; diff --git a/source/blender/editors/sculpt_paint/paint_image.cc b/source/blender/editors/sculpt_paint/paint_image.cc index e849fd95084..619002a1bea 100644 --- a/source/blender/editors/sculpt_paint/paint_image.cc +++ b/source/blender/editors/sculpt_paint/paint_image.cc @@ -980,7 +980,7 @@ void ED_imapaint_bucket_fill(struct bContext *C, ED_image_undo_push_begin(op->type->name, PAINT_MODE_TEXTURE_2D); - const float mouse_init[2] = {static_cast<float>(mouse[0]), static_cast<float>(mouse[1])}; + const float mouse_init[2] = {float(mouse[0]), float(mouse[1])}; paint_2d_bucket_fill(C, color, nullptr, mouse_init, nullptr, nullptr); ED_image_undo_push_end(); diff --git a/source/blender/editors/space_view3d/view3d_select.cc b/source/blender/editors/space_view3d/view3d_select.cc index f38b22fce4d..687c2b7d591 100644 --- a/source/blender/editors/space_view3d/view3d_select.cc +++ b/source/blender/editors/space_view3d/view3d_select.cc @@ -4667,7 +4667,7 @@ static bool object_circle_select(ViewContext *vc, View3D *v3d = vc->v3d; const float radius_squared = rad * rad; - const float mval_fl[2] = {static_cast<float>(mval[0]), static_cast<float>(mval[1])}; + const float mval_fl[2] = {float(mval[0]), float(mval[1])}; bool changed = false; if (SEL_OP_USE_PRE_DESELECT(sel_op)) { diff --git a/source/blender/functions/FN_field.hh b/source/blender/functions/FN_field.hh index ca12f407e49..bf2fbfa3f3c 100644 --- a/source/blender/functions/FN_field.hh +++ b/source/blender/functions/FN_field.hh @@ -546,7 +546,7 @@ template<typename T> struct ValueOrField { bool is_field() const { - return (bool)this->field; + return bool(this->field); } Field<T> as_field() const diff --git a/source/blender/gpu/intern/gpu_framebuffer_private.hh b/source/blender/gpu/intern/gpu_framebuffer_private.hh index 6e5d9518bfc..76e816e7f65 100644 --- a/source/blender/gpu/intern/gpu_framebuffer_private.hh +++ b/source/blender/gpu/intern/gpu_framebuffer_private.hh @@ -40,12 +40,12 @@ typedef enum GPUAttachmentType : int { inline constexpr GPUAttachmentType operator-(GPUAttachmentType a, int b) { - return static_cast<GPUAttachmentType>(static_cast<int>(a) - b); + return static_cast<GPUAttachmentType>(int(a) - b); } inline constexpr GPUAttachmentType operator+(GPUAttachmentType a, int b) { - return static_cast<GPUAttachmentType>(static_cast<int>(a) + b); + return static_cast<GPUAttachmentType>(int(a) + b); } inline GPUAttachmentType &operator++(GPUAttachmentType &a) diff --git a/source/blender/gpu/metal/mtl_context.hh b/source/blender/gpu/metal/mtl_context.hh index 3ba33ebfa46..6229afcef79 100644 --- a/source/blender/gpu/metal/mtl_context.hh +++ b/source/blender/gpu/metal/mtl_context.hh @@ -352,7 +352,7 @@ struct MTLSamplerArray { { uint32_t hash = this->num_samplers; for (int i = 0; i < this->num_samplers; i++) { - hash ^= (uint32_t)this->mtl_sampler_flags[i] << (i % 3); + hash ^= uint32_t(this->mtl_sampler_flags[i]) << (i % 3); } return hash; } diff --git a/source/blender/gpu/metal/mtl_pso_descriptor_state.hh b/source/blender/gpu/metal/mtl_pso_descriptor_state.hh index 1906350679a..198d309874b 100644 --- a/source/blender/gpu/metal/mtl_pso_descriptor_state.hh +++ b/source/blender/gpu/metal/mtl_pso_descriptor_state.hh @@ -28,8 +28,8 @@ struct MTLVertexAttributeDescriptorPSO { uint64_t hash() const { - return (uint64_t)((uint64_t)this->format ^ (this->offset << 4) ^ (this->buffer_index << 8) ^ - (this->format_conversion_mode << 12)); + return uint64_t((uint64_t(this->format) ^ (this->offset << 4) ^ (this->buffer_index << 8) ^ + (this->format_conversion_mode << 12))); } }; @@ -46,8 +46,7 @@ struct MTLVertexBufferLayoutDescriptorPSO { uint64_t hash() const { - return (uint64_t)((uint64_t)this->step_function ^ (this->step_rate << 4) ^ - (this->stride << 8)); + return uint64_t(uint64_t(this->step_function) ^ (this->step_rate << 4) ^ (this->stride << 8)); } }; @@ -217,31 +216,30 @@ struct MTLRenderPipelineStateDescriptor { * has collisions. */ uint64_t hash = this->vertex_descriptor.hash(); - hash ^= (uint64_t)this->num_color_attachments << 16; /* up to 6 (3 bits). */ - hash ^= (uint64_t)this->depth_attachment_format << 18; /* up to 555 (9 bits). */ - hash ^= (uint64_t)this->stencil_attachment_format << 20; /* up to 555 (9 bits). */ - hash ^= (uint64_t)(*( - (uint64_t *)&this->vertex_descriptor.prim_topology_class)); /* Up to 3 (2 bits). */ + hash ^= uint64_t(this->num_color_attachments) << 16; /* up to 6 (3 bits). */ + hash ^= uint64_t(this->depth_attachment_format) << 18; /* up to 555 (9 bits). */ + hash ^= uint64_t(this->stencil_attachment_format) << 20; /* up to 555 (9 bits). */ + hash ^= uint64_t( + *((uint64_t *)&this->vertex_descriptor.prim_topology_class)); /* Up to 3 (2 bits). */ /* Only include elements in Hash if they are needed - avoids variable null assignments * influencing hash. */ if (this->num_color_attachments > 0) { - hash ^= (uint64_t)this->color_write_mask << 22; /* 4 bit bit-mask. */ - hash ^= (uint64_t)this->alpha_blend_op << 26; /* Up to 4 (3 bits). */ - hash ^= (uint64_t)this->rgb_blend_op << 29; /* Up to 4 (3 bits). */ - hash ^= (uint64_t)this->dest_alpha_blend_factor << 32; /* Up to 18 (5 bits). */ - hash ^= (uint64_t)this->dest_rgb_blend_factor << 37; /* Up to 18 (5 bits). */ - hash ^= (uint64_t)this->src_alpha_blend_factor << 42; /* Up to 18 (5 bits). */ - hash ^= (uint64_t)this->src_rgb_blend_factor << 47; /* Up to 18 (5 bits). */ + hash ^= uint64_t(this->color_write_mask) << 22; /* 4 bit bit-mask. */ + hash ^= uint64_t(this->alpha_blend_op) << 26; /* Up to 4 (3 bits). */ + hash ^= uint64_t(this->rgb_blend_op) << 29; /* Up to 4 (3 bits). */ + hash ^= uint64_t(this->dest_alpha_blend_factor) << 32; /* Up to 18 (5 bits). */ + hash ^= uint64_t(this->dest_rgb_blend_factor) << 37; /* Up to 18 (5 bits). */ + hash ^= uint64_t(this->src_alpha_blend_factor) << 42; /* Up to 18 (5 bits). */ + hash ^= uint64_t(this->src_rgb_blend_factor) << 47; /* Up to 18 (5 bits). */ } for (const uint c : IndexRange(GPU_FB_MAX_COLOR_ATTACHMENT)) { - hash ^= (uint64_t)this->color_attachment_format[c] << (c + 52); // up to 555 (9 bits) + hash ^= uint64_t(this->color_attachment_format[c]) << (c + 52); /* Up to 555 (9 bits). */ } - hash |= (uint64_t)((this->blending_enabled && (this->num_color_attachments > 0)) ? 1 : 0) - << 62; - hash ^= (uint64_t)this->point_size; + hash |= uint64_t((this->blending_enabled && (this->num_color_attachments > 0)) ? 1 : 0) << 62; + hash ^= uint64_t(this->point_size); return hash; } diff --git a/source/blender/gpu/metal/mtl_texture.hh b/source/blender/gpu/metal/mtl_texture.hh index 88d09e4e133..ebc9eb2e00e 100644 --- a/source/blender/gpu/metal/mtl_texture.hh +++ b/source/blender/gpu/metal/mtl_texture.hh @@ -51,9 +51,9 @@ struct TextureUpdateRoutineSpecialisation { uint64_t hash() const { blender::DefaultHash<std::string> string_hasher; - return (uint64_t)string_hasher( + return uint64_t(string_hasher( this->input_data_type + this->output_data_type + - std::to_string((this->component_count_input << 8) + this->component_count_output)); + std::to_string((this->component_count_input << 8) + this->component_count_output))); } }; @@ -108,10 +108,10 @@ struct TextureReadRoutineSpecialisation { uint64_t hash() const { blender::DefaultHash<std::string> string_hasher; - return (uint64_t)string_hasher(this->input_data_type + this->output_data_type + - std::to_string((this->component_count_input << 8) + - this->component_count_output + - (this->depth_format_mode << 28))); + return uint64_t(string_hasher(this->input_data_type + this->output_data_type + + std::to_string((this->component_count_input << 8) + + this->component_count_output + + (this->depth_format_mode << 28)))); } }; @@ -138,12 +138,12 @@ struct MTLSamplerState { operator uint() const { - return (uint)state; + return uint(state); } operator uint64_t() const { - return (uint64_t)state; + return uint64_t(state); } }; diff --git a/source/blender/gpu/opengl/gl_index_buffer.hh b/source/blender/gpu/opengl/gl_index_buffer.hh index 974c01d2b65..78159db764c 100644 --- a/source/blender/gpu/opengl/gl_index_buffer.hh +++ b/source/blender/gpu/opengl/gl_index_buffer.hh @@ -35,11 +35,9 @@ class GLIndexBuf : public IndexBuf { { additional_vertex_offset += index_start_; if (index_type_ == GPU_INDEX_U32) { - return reinterpret_cast<void *>(static_cast<intptr_t>(additional_vertex_offset) * - sizeof(GLuint)); + return reinterpret_cast<void *>(intptr_t(additional_vertex_offset) * sizeof(GLuint)); } - return reinterpret_cast<void *>(static_cast<intptr_t>(additional_vertex_offset) * - sizeof(GLushort)); + return reinterpret_cast<void *>(intptr_t(additional_vertex_offset) * sizeof(GLushort)); } GLuint restart_index() const diff --git a/source/blender/gpu/opengl/gl_vertex_buffer.cc b/source/blender/gpu/opengl/gl_vertex_buffer.cc index 2515b7e8f19..d186c2025b3 100644 --- a/source/blender/gpu/opengl/gl_vertex_buffer.cc +++ b/source/blender/gpu/opengl/gl_vertex_buffer.cc @@ -142,7 +142,7 @@ void *GLVertBuf::unmap(const void *mapped_data) const void GLVertBuf::wrap_handle(uint64_t handle) { BLI_assert(vbo_id_ == 0); - BLI_assert(glIsBuffer(static_cast<uint>(handle))); + BLI_assert(glIsBuffer(uint(handle))); is_wrapper_ = true; vbo_id_ = uint(handle); /* We assume the data is already on the device, so no need to allocate or send it. */ diff --git a/source/blender/io/alembic/exporter/abc_archive.cc b/source/blender/io/alembic/exporter/abc_archive.cc index c4a4f129ecf..55e172db241 100644 --- a/source/blender/io/alembic/exporter/abc_archive.cc +++ b/source/blender/io/alembic/exporter/abc_archive.cc @@ -130,7 +130,7 @@ static TimeSamplingPtr create_time_sampling(double scene_fps, get_shutter_samples(scene_fps, params, nr_of_samples, true, samples); - TimeSamplingType ts(static_cast<uint32_t>(samples.size()), 1.0 / scene_fps); + TimeSamplingType ts(uint32_t(samples.size()), 1.0 / scene_fps); return TimeSamplingPtr(new TimeSampling(ts, samples)); // NOLINT: modernize-make-shared } diff --git a/source/blender/io/alembic/exporter/abc_export_capi.cc b/source/blender/io/alembic/exporter/abc_export_capi.cc index dfca89e2c6d..546bc9d49cc 100644 --- a/source/blender/io/alembic/exporter/abc_export_capi.cc +++ b/source/blender/io/alembic/exporter/abc_export_capi.cc @@ -144,8 +144,8 @@ static void export_startjob(void *customdata, } /* Update the scene for the next frame to render. */ - scene->r.cfra = static_cast<int>(frame); - scene->r.subframe = static_cast<float>(frame - scene->r.cfra); + scene->r.cfra = int(frame); + scene->r.subframe = float(frame - scene->r.cfra); BKE_scene_graph_update_for_newframe(data->depsgraph); CLOG_INFO(&LOG, 2, "Exporting frame %.2f", frame); diff --git a/source/blender/io/alembic/exporter/abc_writer_curves.cc b/source/blender/io/alembic/exporter/abc_writer_curves.cc index 4717d3ec26e..e5e8053d7d3 100644 --- a/source/blender/io/alembic/exporter/abc_writer_curves.cc +++ b/source/blender/io/alembic/exporter/abc_writer_curves.cc @@ -142,7 +142,7 @@ void ABCCurveWriter::do_write(HierarchyContext &context) } } - orders.push_back(static_cast<uint8_t>(nurbs->orderu)); + orders.push_back(uint8_t(nurbs->orderu)); vert_counts.push_back(verts.size() - current_point_count); } diff --git a/source/blender/io/alembic/intern/abc_reader_camera.cc b/source/blender/io/alembic/intern/abc_reader_camera.cc index 830526a11ac..e7a319730b6 100644 --- a/source/blender/io/alembic/intern/abc_reader_camera.cc +++ b/source/blender/io/alembic/intern/abc_reader_camera.cc @@ -77,11 +77,11 @@ void AbcCameraReader::readObjectData(Main *bmain, const ISampleSelector &sample_ bcam->stereo.convergence_distance = convergence_plane.getValue(sample_sel); } - const float lens = static_cast<float>(cam_sample.getFocalLength()); - const float apperture_x = static_cast<float>(cam_sample.getHorizontalAperture()); - const float apperture_y = static_cast<float>(cam_sample.getVerticalAperture()); - const float h_film_offset = static_cast<float>(cam_sample.getHorizontalFilmOffset()); - const float v_film_offset = static_cast<float>(cam_sample.getVerticalFilmOffset()); + const float lens = float(cam_sample.getFocalLength()); + const float apperture_x = float(cam_sample.getHorizontalAperture()); + const float apperture_y = float(cam_sample.getVerticalAperture()); + const float h_film_offset = float(cam_sample.getHorizontalFilmOffset()); + const float v_film_offset = float(cam_sample.getVerticalFilmOffset()); const float film_aspect = apperture_x / apperture_y; bcam->lens = lens; @@ -89,10 +89,10 @@ void AbcCameraReader::readObjectData(Main *bmain, const ISampleSelector &sample_ bcam->sensor_y = apperture_y * 10; bcam->shiftx = h_film_offset / apperture_x; bcam->shifty = v_film_offset / apperture_y / film_aspect; - bcam->clip_start = max_ff(0.1f, static_cast<float>(cam_sample.getNearClippingPlane())); - bcam->clip_end = static_cast<float>(cam_sample.getFarClippingPlane()); - bcam->dof.focus_distance = static_cast<float>(cam_sample.getFocusDistance()); - bcam->dof.aperture_fstop = static_cast<float>(cam_sample.getFStop()); + bcam->clip_start = max_ff(0.1f, float(cam_sample.getNearClippingPlane())); + bcam->clip_end = float(cam_sample.getFarClippingPlane()); + bcam->dof.focus_distance = float(cam_sample.getFocusDistance()); + bcam->dof.aperture_fstop = float(cam_sample.getFStop()); m_object = BKE_object_add_only_object(bmain, OB_CAMERA, m_object_name.c_str()); m_object->data = bcam; diff --git a/source/blender/io/alembic/intern/abc_reader_curves.cc b/source/blender/io/alembic/intern/abc_reader_curves.cc index d8859acdf5f..24bdae3ac50 100644 --- a/source/blender/io/alembic/intern/abc_reader_curves.cc +++ b/source/blender/io/alembic/intern/abc_reader_curves.cc @@ -152,7 +152,7 @@ void AbcCurveReader::read_curve_sample(Curve *cu, break; case Alembic::AbcGeom::kVariableOrder: if (orders && orders->size() > i) { - nu->orderu = static_cast<short>((*orders)[i]); + nu->orderu = short((*orders)[i]); break; } ATTR_FALLTHROUGH; diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc index 6ddf55109ab..f08514dc45c 100644 --- a/source/blender/io/alembic/intern/abc_reader_mesh.cc +++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc @@ -133,7 +133,7 @@ static void read_mverts_interp(MVert *mverts, const Imath::V3f &floor_pos = (*positions)[i]; const Imath::V3f &ceil_pos = (*ceil_positions)[i]; - interp_v3_v3v3(tmp, floor_pos.getValue(), ceil_pos.getValue(), static_cast<float>(weight)); + interp_v3_v3v3(tmp, floor_pos.getValue(), ceil_pos.getValue(), float(weight)); copy_zup_from_yup(mvert.co, tmp); } } @@ -448,7 +448,7 @@ static void read_velocity(const V3fArraySamplePtr &velocities, const CDStreamConfig &config, const float velocity_scale) { - const int num_velocity_vectors = static_cast<int>(velocities->size()); + const int num_velocity_vectors = int(velocities->size()); if (num_velocity_vectors != config.mesh->totvert) { /* Files containing videogrammetry data may be malformed and export velocity data on missing * frames (most likely by copying the last valid data). */ diff --git a/source/blender/io/alembic/intern/abc_reader_object.cc b/source/blender/io/alembic/intern/abc_reader_object.cc index db056c0eef6..5cf1fda0db2 100644 --- a/source/blender/io/alembic/intern/abc_reader_object.cc +++ b/source/blender/io/alembic/intern/abc_reader_object.cc @@ -110,7 +110,7 @@ static Imath::M44d blend_matrices(const Imath::M44d &m0, convert_matrix_datatype(m0, mat0); convert_matrix_datatype(m1, mat1); - interp_m4_m4m4(ret, mat0, mat1, static_cast<float>(weight)); + interp_m4_m4m4(ret, mat0, mat1, float(weight)); return convert_matrix_datatype(ret); } diff --git a/source/blender/io/alembic/intern/abc_util.cc b/source/blender/io/alembic/intern/abc_util.cc index 90f73d25c22..846a3622d62 100644 --- a/source/blender/io/alembic/intern/abc_util.cc +++ b/source/blender/io/alembic/intern/abc_util.cc @@ -73,7 +73,7 @@ Imath::M44d convert_matrix_datatype(float mat[4][4]) for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { - m[i][j] = static_cast<double>(mat[i][j]); + m[i][j] = double(mat[i][j]); } } @@ -84,7 +84,7 @@ void convert_matrix_datatype(const Imath::M44d &xform, float r_mat[4][4]) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { - r_mat[i][j] = static_cast<float>(xform[i][j]); + r_mat[i][j] = float(xform[i][j]); } } } diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc index 11c26fd2f72..39595089109 100644 --- a/source/blender/io/alembic/intern/alembic_capi.cc +++ b/source/blender/io/alembic/intern/alembic_capi.cc @@ -502,7 +502,7 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa /* Create objects and set scene frame range. */ - const float size = static_cast<float>(data->readers.size()); + const float size = float(data->readers.size()); size_t i = 0; chrono_t min_time = std::numeric_limits<chrono_t>::max(); @@ -542,8 +542,8 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa scene->r.cfra = scene->r.sfra; } else if (min_time < max_time) { - scene->r.sfra = static_cast<int>(round(min_time * FPS)); - scene->r.efra = static_cast<int>(round(max_time * FPS)); + scene->r.sfra = int(round(min_time * FPS)); + scene->r.efra = int(round(max_time * FPS)); scene->r.cfra = scene->r.sfra; } } diff --git a/source/blender/io/usd/intern/usd_reader_curve.h b/source/blender/io/usd/intern/usd_reader_curve.h index 1e9330b81f1..48fb2c5e2d1 100644 --- a/source/blender/io/usd/intern/usd_reader_curve.h +++ b/source/blender/io/usd/intern/usd_reader_curve.h @@ -27,7 +27,7 @@ class USDCurvesReader : public USDGeomReader { bool valid() const override { - return static_cast<bool>(curve_prim_); + return bool(curve_prim_); } void create_object(Main *bmain, double motionSampleTime) override; diff --git a/source/blender/io/usd/intern/usd_reader_nurbs.h b/source/blender/io/usd/intern/usd_reader_nurbs.h index a5441aad3cf..aa3940dc540 100644 --- a/source/blender/io/usd/intern/usd_reader_nurbs.h +++ b/source/blender/io/usd/intern/usd_reader_nurbs.h @@ -27,7 +27,7 @@ class USDNurbsReader : public USDGeomReader { bool valid() const override { - return static_cast<bool>(curve_prim_); + return bool(curve_prim_); } void create_object(Main *bmain, double motionSampleTime) override; diff --git a/source/blender/io/usd/intern/usd_reader_volume.h b/source/blender/io/usd/intern/usd_reader_volume.h index 350fae6ada0..923c3d140c9 100644 --- a/source/blender/io/usd/intern/usd_reader_volume.h +++ b/source/blender/io/usd/intern/usd_reader_volume.h @@ -23,7 +23,7 @@ class USDVolumeReader : public USDXformReader { bool valid() const override { - return static_cast<bool>(volume_); + return bool(volume_); } void create_object(Main *bmain, double motionSampleTime) override; diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.hh b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.hh index 9c1bc2f0f8f..2d4edd8979d 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.hh +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.hh @@ -49,11 +49,11 @@ struct MTLTexMap { struct MTLMaterial { const MTLTexMap &tex_map_of_type(MTLTexMapType key) const { - return texture_maps[(int)key]; + return texture_maps[int(key)]; } MTLTexMap &tex_map_of_type(MTLTexMapType key) { - return texture_maps[(int)key]; + return texture_maps[int(key)]; } std::string name; @@ -76,7 +76,7 @@ struct MTLMaterial { float aniso_rot{-1.0f}; /* `anisor` */ int illum_mode{-1}; - MTLTexMap texture_maps[(int)MTLTexMapType::Count]; + MTLTexMap texture_maps[int(MTLTexMapType::Count)]; /* Only used for Normal Map node: `map_Bump`. */ float normal_strength{-1.0f}; }; diff --git a/source/blender/io/wavefront_obj/importer/obj_import_objects.hh b/source/blender/io/wavefront_obj/importer/obj_import_objects.hh index 04d9a665588..91f09d9e188 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_objects.hh +++ b/source/blender/io/wavefront_obj/importer/obj_import_objects.hh @@ -110,7 +110,7 @@ struct Geometry { int get_vertex_count() const { - return (int)vertices_.size(); + return int(vertices_.size()); } void track_vertex_index(int index) { |