diff options
author | Campbell Barton <campbell@blender.org> | 2022-09-25 11:30:50 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-09-25 11:31:10 +0300 |
commit | c7b247a118e302a3afc6473797e53b6af28b69e2 (patch) | |
tree | d11149a165bfd8f3b3b791f24547499f041b133b | |
parent | 891949cbb47143420f4324cb60efc05ef5d70b39 (diff) |
Cleanup: replace static_casts with functional casts for numeric types
62 files changed, 148 insertions, 167 deletions
diff --git a/source/blender/blendthumb/src/blendthumb_extract.cc b/source/blender/blendthumb/src/blendthumb_extract.cc index fff1242f2ce..1429f26f82c 100644 --- a/source/blender/blendthumb/src/blendthumb_extract.cc +++ b/source/blender/blendthumb/src/blendthumb_extract.cc @@ -137,8 +137,7 @@ static eThumbStatus blendthumb_extract_from_file_impl(FileReader *file, /* Verify that image dimensions and data size make sense. */ size_t data_size = block_size - sizeof(shape); - const uint64_t expected_size = static_cast<uint64_t>(thumb->width) * - static_cast<uint64_t>(thumb->height) * 4; + const uint64_t expected_size = uint64_t(thumb->width) * uint64_t(thumb->height) * 4; if (thumb->width < 0 || thumb->height < 0 || data_size != expected_size) { return BT_INVALID_THUMB; } diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index bd3e452b7f2..c69a7b4b2c7 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -354,7 +354,7 @@ CustomDataLayer *BKE_id_attribute_search(ID *id, get_domains(id, info); for (eAttrDomain domain = ATTR_DOMAIN_POINT; domain < ATTR_DOMAIN_NUM; - domain = static_cast<eAttrDomain>((static_cast<int>(domain)) + 1)) { + domain = static_cast<eAttrDomain>((int(domain)) + 1)) { if (!(domain_mask & ATTR_DOMAIN_AS_MASK(domain))) { continue; } diff --git a/source/blender/blenkernel/intern/curve_bezier.cc b/source/blender/blenkernel/intern/curve_bezier.cc index 59b09384698..3aa87be3787 100644 --- a/source/blender/blenkernel/intern/curve_bezier.cc +++ b/source/blender/blenkernel/intern/curve_bezier.cc @@ -210,7 +210,7 @@ void evaluate_segment(const float3 &point_0, MutableSpan<float3> result) { BLI_assert(result.size() > 0); - const float inv_len = 1.0f / static_cast<float>(result.size()); + const float inv_len = 1.0f / float(result.size()); const float inv_len_squared = inv_len * inv_len; const float inv_len_cubed = inv_len_squared * inv_len; diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index 86be7ba8e7c..c07b4c7964e 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -520,7 +520,7 @@ static void layerInterp_propInt(const void **sources, const float src = *static_cast<const int *>(sources[i]); result += src * weight; } - const int rounded_result = static_cast<int>(round(result)); + const int rounded_result = int(round(result)); *static_cast<int *>(dest) = rounded_result; } diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index 64f6ceba32b..b06317fa511 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -867,8 +867,8 @@ void BKE_image_get_tile_uv(const Image *ima, const int tile_number, float r_uv[2 } else { const int tile_index = tile_number - 1001; - r_uv[0] = static_cast<float>(tile_index % 10); - r_uv[1] = static_cast<float>(tile_index / 10); + r_uv[0] = float(tile_index % 10); + r_uv[1] = float(tile_index / 10); } } diff --git a/source/blender/blenkernel/intern/mesh_boolean_convert.cc b/source/blender/blenkernel/intern/mesh_boolean_convert.cc index be6c27ee6f9..360c7da2ae2 100644 --- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc +++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc @@ -114,7 +114,7 @@ class MeshesToIMeshInfo { * input `Mesh` that contained the `MVert` that it came from. */ int MeshesToIMeshInfo::input_mesh_for_imesh_vert(int imesh_v) const { - int n = static_cast<int>(mesh_vert_offset.size()); + int n = int(mesh_vert_offset.size()); for (int i = 0; i < n - 1; ++i) { if (imesh_v < mesh_vert_offset[i + 1]) { return i; @@ -127,7 +127,7 @@ int MeshesToIMeshInfo::input_mesh_for_imesh_vert(int imesh_v) const * return the index of the input `Mesh` that contained the `MVert` that it came from. */ int MeshesToIMeshInfo::input_mesh_for_imesh_edge(int imesh_e) const { - int n = static_cast<int>(mesh_edge_offset.size()); + int n = int(mesh_edge_offset.size()); for (int i = 0; i < n - 1; ++i) { if (imesh_e < mesh_edge_offset[i + 1]) { return i; @@ -140,7 +140,7 @@ int MeshesToIMeshInfo::input_mesh_for_imesh_edge(int imesh_e) const * input `Mesh` that contained the `MPoly` that it came from. */ int MeshesToIMeshInfo::input_mesh_for_imesh_face(int imesh_f) const { - int n = static_cast<int>(mesh_poly_offset.size()); + int n = int(mesh_poly_offset.size()); for (int i = 0; i < n - 1; ++i) { if (imesh_f < mesh_poly_offset[i + 1]) { return i; @@ -831,7 +831,7 @@ Mesh *direct_mesh_boolean(Span<const Mesh *> meshes, return mi; } } - return static_cast<int>(mim.mesh_poly_offset.size()) - 1; + return int(mim.mesh_poly_offset.size()) - 1; }; IMesh m_out = boolean_mesh(m_in, static_cast<BoolOpType>(boolean_mode), diff --git a/source/blender/blenkernel/intern/mesh_calc_edges.cc b/source/blender/blenkernel/intern/mesh_calc_edges.cc index 038133c33ae..5e6babdf7b4 100644 --- a/source/blender/blenkernel/intern/mesh_calc_edges.cc +++ b/source/blender/blenkernel/intern/mesh_calc_edges.cc @@ -35,8 +35,7 @@ struct OrderedEdge { } } - OrderedEdge(const uint v1, const uint v2) - : OrderedEdge(static_cast<int>(v1), static_cast<int>(v2)) + OrderedEdge(const uint v1, const uint v2) : OrderedEdge(int(v1), int(v2)) { } @@ -217,7 +216,7 @@ void BKE_mesh_calc_edges(Mesh *mesh, bool keep_existing_edges, const bool select * Each edge is assigned to one of the hash maps based on the lower bits of a hash value. */ const int parallel_maps = get_parallel_maps_count(mesh); BLI_assert(is_power_of_2_i(parallel_maps)); - const uint32_t parallel_mask = static_cast<uint32_t>(parallel_maps) - 1; + const uint32_t parallel_mask = uint32_t(parallel_maps) - 1; Array<EdgeMap> edge_maps(parallel_maps); reserve_hash_maps(mesh, keep_existing_edges, edge_maps); diff --git a/source/blender/blenkernel/intern/subdiv_mesh.cc b/source/blender/blenkernel/intern/subdiv_mesh.cc index 6bc188fd1fc..d716a7228c0 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.cc +++ b/source/blender/blenkernel/intern/subdiv_mesh.cc @@ -267,14 +267,13 @@ static void vertex_interpolation_from_corner(const SubdivMeshContext *ctx, const int first_loop_index = loops_of_ptex.first_loop - coarse_mloop; const int last_loop_index = loops_of_ptex.last_loop - coarse_mloop; const int first_indices[2] = { - static_cast<int>(coarse_mloop[first_loop_index].v), - static_cast<int>( - coarse_mloop[coarse_poly->loopstart + + int(coarse_mloop[first_loop_index].v), + int(coarse_mloop[coarse_poly->loopstart + (first_loop_index - coarse_poly->loopstart + 1) % coarse_poly->totloop] .v)}; const int last_indices[2] = { - static_cast<int>(coarse_mloop[first_loop_index].v), - static_cast<int>(coarse_mloop[last_loop_index].v), + int(coarse_mloop[first_loop_index].v), + int(coarse_mloop[last_loop_index].v), }; CustomData_interp(vertex_data, &vertex_interpolation->vertex_data_storage, @@ -402,8 +401,8 @@ static void loop_interpolation_from_corner(const SubdivMeshContext *ctx, (first_loop_index - base_loop_index + 1) % coarse_poly->totloop; const int first_indices[2] = {first_loop_index, second_loop_index}; const int last_indices[2] = { - static_cast<int>(loops_of_ptex.last_loop - coarse_mloop), - static_cast<int>(loops_of_ptex.first_loop - coarse_mloop), + int(loops_of_ptex.last_loop - coarse_mloop), + int(loops_of_ptex.first_loop - coarse_mloop), }; CustomData_interp( loop_data, &loop_interpolation->loop_data_storage, first_indices, weights, nullptr, 2, 1); diff --git a/source/blender/blenkernel/intern/type_conversions.cc b/source/blender/blenkernel/intern/type_conversions.cc index a01f5d19088..852fe38c92f 100644 --- a/source/blender/blenkernel/intern/type_conversions.cc +++ b/source/blender/blenkernel/intern/type_conversions.cc @@ -163,7 +163,7 @@ static bool int8_to_bool(const int8_t &a) } static int int8_to_int(const int8_t &a) { - return static_cast<int>(a); + return int(a); } static float int8_to_float(const int8_t &a) { @@ -192,7 +192,7 @@ static float bool_to_float(const bool &a) } static int8_t bool_to_int8(const bool &a) { - return static_cast<int8_t>(a); + return int8_t(a); } static int32_t bool_to_int(const bool &a) { diff --git a/source/blender/blenkernel/intern/volume_render.cc b/source/blender/blenkernel/intern/volume_render.cc index e7620be6401..700bd63c9d4 100644 --- a/source/blender/blenkernel/intern/volume_render.cc +++ b/source/blender/blenkernel/intern/volume_render.cc @@ -102,9 +102,8 @@ bool BKE_volume_grid_dense_floats(const Volume *volume, } const openvdb::Vec3i resolution = bbox.dim().asVec3i(); - const int64_t num_voxels = static_cast<int64_t>(resolution[0]) * - static_cast<int64_t>(resolution[1]) * - static_cast<int64_t>(resolution[2]); + const int64_t num_voxels = int64_t(resolution[0]) * int64_t(resolution[1]) * + int64_t(resolution[2]); const int channels = BKE_volume_grid_channels(volume_grid); const int elem_size = sizeof(float) * channels; float *voxels = static_cast<float *>(MEM_malloc_arrayN(num_voxels, elem_size, __func__)); diff --git a/source/blender/blenlib/intern/delaunay_2d.cc b/source/blender/blenlib/intern/delaunay_2d.cc index db6cb0824dc..6280fe1010f 100644 --- a/source/blender/blenlib/intern/delaunay_2d.cc +++ b/source/blender/blenlib/intern/delaunay_2d.cc @@ -520,10 +520,10 @@ template<typename T> void cdt_draw(const std::string &label, const CDTArrangemen double height = maxy - miny; double aspect = height / width; int view_width = max_draw_width; - int view_height = static_cast<int>(view_width * aspect); + int view_height = int(view_width * aspect); if (view_height > max_draw_height) { view_height = max_draw_height; - view_width = static_cast<int>(view_height / aspect); + view_width = int(view_height / aspect); } double scale = view_width / width; @@ -2822,8 +2822,8 @@ extern "C" ::CDT_result *BLI_delaunay_2d_cdt_calc(const ::CDT_input *input, in.edge = blender::Array<std::pair<int, int>>(input->edges_len); in.face = blender::Array<blender::Vector<int>>(input->faces_len); for (int v = 0; v < input->verts_len; ++v) { - double x = static_cast<double>(input->vert_coords[v][0]); - double y = static_cast<double>(input->vert_coords[v][1]); + double x = double(input->vert_coords[v][0]); + double y = double(input->vert_coords[v][1]); in.vert[v] = blender::meshintersect::vec2<double>(x, y); } for (int e = 0; e < input->edges_len; ++e) { @@ -2836,7 +2836,7 @@ extern "C" ::CDT_result *BLI_delaunay_2d_cdt_calc(const ::CDT_input *input, in.face[f][j] = input->faces[fstart + j]; } } - in.epsilon = static_cast<double>(input->epsilon); + in.epsilon = double(input->epsilon); in.need_ids = input->need_ids; blender::meshintersect::CDT_result<double> res = blender::meshintersect::delaunay_2d_calc( @@ -2903,8 +2903,8 @@ extern "C" ::CDT_result *BLI_delaunay_2d_cdt_calc(const ::CDT_input *input, int v_orig_index = 0; for (int v = 0; v < nv; ++v) { - output->vert_coords[v][0] = static_cast<float>(res.vert[v][0]); - output->vert_coords[v][1] = static_cast<float>(res.vert[v][1]); + output->vert_coords[v][0] = float(res.vert[v][0]); + output->vert_coords[v][1] = float(res.vert[v][1]); if (input->need_ids) { int this_start = v_orig_index; output->verts_orig_start_table[v] = this_start; diff --git a/source/blender/blenlib/intern/math_vec.cc b/source/blender/blenlib/intern/math_vec.cc index 99c873299fe..8d1f850d8e5 100644 --- a/source/blender/blenlib/intern/math_vec.cc +++ b/source/blender/blenlib/intern/math_vec.cc @@ -108,7 +108,7 @@ isect_result<mpq2> isect_seg_seg(const mpq2 &v1, const mpq2 &v2, const mpq2 &v3, uint64_t hash_mpq_class(const mpq_class &value) { /* TODO: better/faster implementation of this. */ - return get_default_hash(static_cast<float>(value.get_d())); + return get_default_hash(float(value.get_d())); } #endif diff --git a/source/blender/blenlib/intern/mesh_intersect.cc b/source/blender/blenlib/intern/mesh_intersect.cc index a48df0aa977..7553898f5d3 100644 --- a/source/blender/blenlib/intern/mesh_intersect.cc +++ b/source/blender/blenlib/intern/mesh_intersect.cc @@ -2419,7 +2419,7 @@ class TriOverlaps { } } first_overlap_ = Array<int>(tm.face_size(), -1); - for (int i = 0; i < static_cast<int>(overlap_num_); ++i) { + for (int i = 0; i < int(overlap_num_); ++i) { int t = overlap_[i].indexA; if (first_overlap_[t] == -1) { first_overlap_[t] = i; diff --git a/source/blender/blenlib/intern/noise.cc b/source/blender/blenlib/intern/noise.cc index 8a073239b31..19c4b92a315 100644 --- a/source/blender/blenlib/intern/noise.cc +++ b/source/blender/blenlib/intern/noise.cc @@ -150,7 +150,7 @@ uint32_t hash_float(float4 k) BLI_INLINE float uint_to_float_01(uint32_t k) { - return static_cast<float>(k) / static_cast<float>(0xFFFFFFFFu); + return float(k) / float(0xFFFFFFFFu); } float hash_to_float(uint32_t kx) @@ -536,7 +536,7 @@ template<typename T> float perlin_fractal_template(T position, float octaves, fl float maxamp = 0.0f; float sum = 0.0f; octaves = CLAMPIS(octaves, 0.0f, 15.0f); - int n = static_cast<int>(octaves); + int n = int(octaves); for (int i = 0; i <= n; i++) { float t = perlin(fscale * position); sum += t * amp; diff --git a/source/blender/blenlib/intern/rand.cc b/source/blender/blenlib/intern/rand.cc index 40bbe14101b..b5db0d6b473 100644 --- a/source/blender/blenlib/intern/rand.cc +++ b/source/blender/blenlib/intern/rand.cc @@ -72,7 +72,7 @@ void BLI_rng_srandom(RNG *rng, uint seed) void BLI_rng_get_char_n(RNG *rng, char *bytes, size_t bytes_len) { - rng->rng.get_bytes(blender::MutableSpan(bytes, static_cast<int64_t>(bytes_len))); + rng->rng.get_bytes(blender::MutableSpan(bytes, int64_t(bytes_len))); } int BLI_rng_get_int(RNG *rng) @@ -441,7 +441,7 @@ float3 RandomNumberGenerator::get_triangle_sample_3d(float3 v1, float3 v2, float void RandomNumberGenerator::get_bytes(MutableSpan<char> r_bytes) { constexpr int64_t mask_bytes = 2; - constexpr int64_t rand_stride = static_cast<int64_t>(sizeof(x_)) - mask_bytes; + constexpr int64_t rand_stride = int64_t(sizeof(x_)) - mask_bytes; int64_t last_len = 0; int64_t trim_len = r_bytes.size(); diff --git a/source/blender/blenlib/intern/string_search.cc b/source/blender/blenlib/intern/string_search.cc index 96e2ad33619..6eeae307fc1 100644 --- a/source/blender/blenlib/intern/string_search.cc +++ b/source/blender/blenlib/intern/string_search.cc @@ -18,7 +18,7 @@ namespace blender::string_search { static int64_t count_utf8_code_points(StringRef str) { - return static_cast<int64_t>(BLI_strnlen_utf8(str.data(), static_cast<size_t>(str.size()))); + return int64_t(BLI_strnlen_utf8(str.data(), size_t(str.size()))); } int damerau_levenshtein_distance(StringRef a, StringRef b) @@ -205,7 +205,7 @@ static bool match_word_initials(StringRef query, StringRef word = words[word_index]; /* Try to match the current character with the current word. */ - if (static_cast<int>(char_index) < word.size()) { + if (int(char_index) < word.size()) { const uint32_t char_unicode = BLI_str_utf8_as_unicode_step( word.data(), word.size(), &char_index); if (query_unicode == char_unicode) { @@ -358,7 +358,7 @@ void extract_normalized_words(StringRef str, /* Make a copy of the string so that we can edit it. */ StringRef str_copy = allocator.copy_string(str); char *mutable_copy = const_cast<char *>(str_copy.data()); - const size_t str_size_in_bytes = static_cast<size_t>(str.size()); + const size_t str_size_in_bytes = size_t(str.size()); BLI_str_tolower_ascii(mutable_copy, str_size_in_bytes); /* Iterate over all unicode code points to split individual words. */ @@ -371,8 +371,7 @@ void extract_normalized_words(StringRef str, size -= offset; if (is_separator(unicode)) { if (is_in_word) { - r_words.append( - str_copy.substr(static_cast<int>(word_start), static_cast<int>(offset - word_start))); + r_words.append(str_copy.substr(int(word_start), int(offset - word_start))); is_in_word = false; } } @@ -386,7 +385,7 @@ void extract_normalized_words(StringRef str, } /* If the last word is not followed by a separator, it has to be handled separately. */ if (is_in_word) { - r_words.append(str_copy.drop_prefix(static_cast<int>(word_start))); + r_words.append(str_copy.drop_prefix(int(word_start))); } } @@ -472,7 +471,7 @@ int BLI_string_search_query(StringSearch *search, const char *query, void ***r_d } void **sorted_data = static_cast<void **>( - MEM_malloc_arrayN(static_cast<size_t>(sorted_result_indices.size()), sizeof(void *), AT)); + MEM_malloc_arrayN(size_t(sorted_result_indices.size()), sizeof(void *), AT)); for (const int i : sorted_result_indices.index_range()) { const int result_index = sorted_result_indices[i]; SearchItem &item = search->items[result_index]; diff --git a/source/blender/blenlib/intern/uuid.cc b/source/blender/blenlib/intern/uuid.cc index 890a721a9d1..023dd1ec409 100644 --- a/source/blender/blenlib/intern/uuid.cc +++ b/source/blender/blenlib/intern/uuid.cc @@ -136,10 +136,10 @@ bUUID::bUUID(const std::initializer_list<uint32_t> field_values) const auto *field_iter = field_values.begin(); this->time_low = *field_iter++; - this->time_mid = static_cast<uint16_t>(*field_iter++); - this->time_hi_and_version = static_cast<uint16_t>(*field_iter++); - this->clock_seq_hi_and_reserved = static_cast<uint8_t>(*field_iter++); - this->clock_seq_low = static_cast<uint8_t>(*field_iter++); + this->time_mid = uint16_t(*field_iter++); + this->time_hi_and_version = uint16_t(*field_iter++); + this->clock_seq_hi_and_reserved = uint8_t(*field_iter++); + this->clock_seq_low = uint8_t(*field_iter++); std::copy(field_iter, field_values.end(), this->node); } diff --git a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc index 25ee523ebc0..adcfe7f5d2d 100644 --- a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc +++ b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc @@ -99,7 +99,7 @@ template<typename T> CDT_input<T> fill_input_from_string(const char *spec) */ static int get_orig_index(const Array<Vector<int>> &out_to_orig, int orig_index) { - int n = static_cast<int>(out_to_orig.size()); + int n = int(out_to_orig.size()); for (int i = 0; i < n; ++i) { for (int orig : out_to_orig[i]) { if (orig == orig_index) { @@ -147,7 +147,7 @@ template<> double math_abs(const double v) */ template<typename T> int get_vertex_by_coord(const CDT_result<T> &out, double x, double y) { - int nv = static_cast<int>(out.vert.size()); + int nv = int(out.vert.size()); for (int i = 0; i < nv; ++i) { double vx = math_to_double(out.vert[i][0]); double vy = math_to_double(out.vert[i][1]); @@ -162,7 +162,7 @@ template<typename T> int get_vertex_by_coord(const CDT_result<T> &out, double x, template<typename T> int get_output_edge_index(const CDT_result<T> &out, int out_index_1, int out_index_2) { - int ne = static_cast<int>(out.edge.size()); + int ne = int(out.edge.size()); for (int i = 0; i < ne; ++i) { if ((out.edge[i].first == out_index_1 && out.edge[i].second == out_index_2) || (out.edge[i].first == out_index_2 && out.edge[i].second == out_index_1)) { @@ -175,7 +175,7 @@ int get_output_edge_index(const CDT_result<T> &out, int out_index_1, int out_ind template<typename T> bool output_edge_has_input_id(const CDT_result<T> &out, int out_edge_index, int in_edge_index) { - return out_edge_index < static_cast<int>(out.edge_orig.size()) && + return out_edge_index < int(out.edge_orig.size()) && out.edge_orig[out_edge_index].contains(in_edge_index); } @@ -184,8 +184,8 @@ bool output_edge_has_input_id(const CDT_result<T> &out, int out_edge_index, int */ template<typename T> int get_output_face_index(const CDT_result<T> &out, const Array<int> &poly) { - int nf = static_cast<int>(out.face.size()); - int npolyv = static_cast<int>(poly.size()); + int nf = int(out.face.size()); + int npolyv = int(poly.size()); for (int f = 0; f < nf; ++f) { if (out.face[f].size() != poly.size()) { continue; @@ -218,7 +218,7 @@ int get_output_tri_index(const CDT_result<T> &out, template<typename T> bool output_face_has_input_id(const CDT_result<T> &out, int out_face_index, int in_face_index) { - return out_face_index < static_cast<int>(out.face_orig.size()) && + return out_face_index < int(out.face_orig.size()) && out.face_orig[out_face_index].contains(in_face_index); } @@ -310,10 +310,10 @@ void graph_draw(const std::string &label, double height = maxy - miny; double aspect = height / width; int view_width = max_draw_width; - int view_height = static_cast<int>(view_width * aspect); + int view_height = int(view_width * aspect); if (view_height > max_draw_height) { view_height = max_draw_height; - view_width = static_cast<int>(view_height / aspect); + view_width = int(view_height / aspect); } double scale = view_width / width; diff --git a/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc b/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc index c155068b94a..67a5771593a 100644 --- a/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc +++ b/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc @@ -153,7 +153,7 @@ static int find_edge_pos_in_tri(const Vert *v0, const Vert *v1, const Face *f) for (int pos : f->index_range()) { int nextpos = f->next_pos(pos); if (((*f)[pos] == v0 && (*f)[nextpos] == v1) || ((*f)[pos] == v1 && (*f)[nextpos] == v0)) { - return static_cast<int>(pos); + return int(pos); } } return -1; diff --git a/source/blender/blenlib/tests/BLI_span_test.cc b/source/blender/blenlib/tests/BLI_span_test.cc index 0bd34250deb..0d974786a1a 100644 --- a/source/blender/blenlib/tests/BLI_span_test.cc +++ b/source/blender/blenlib/tests/BLI_span_test.cc @@ -237,7 +237,7 @@ TEST(span, SizeInBytes) { std::array<int, 10> a{}; Span<int> a_span(a); - EXPECT_EQ(a_span.size_in_bytes(), static_cast<int64_t>(sizeof(a))); + EXPECT_EQ(a_span.size_in_bytes(), int64_t(sizeof(a))); EXPECT_EQ(a_span.size_in_bytes(), 40); } diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc index 9e3d0b66556..dfbdd64ee7c 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc @@ -1069,10 +1069,10 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh if (need_material_index) { BM_mesh_elem_table_ensure(bm, BM_FACE); - write_fn_to_attribute<int>( - me->attributes_for_write(), "material_index", ATTR_DOMAIN_FACE, [&](const int i) { - return static_cast<int>(BM_face_at_index(bm, i)->mat_nr); - }); + write_fn_to_attribute<int>(me->attributes_for_write(), + "material_index", + ATTR_DOMAIN_FACE, + [&](const int i) { return int(BM_face_at_index(bm, i)->mat_nr); }); } /* Patch hook indices and vertex parents. */ diff --git a/source/blender/bmesh/tools/bmesh_boolean.cc b/source/blender/bmesh/tools/bmesh_boolean.cc index 216c73564c8..50a6812895f 100644 --- a/source/blender/bmesh/tools/bmesh_boolean.cc +++ b/source/blender/bmesh/tools/bmesh_boolean.cc @@ -187,7 +187,7 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, IMesh &m_out, bool keep_hidden float co[3]; const double3 &d_co = vertp->co; for (int i = 0; i < 3; ++i) { - co[i] = static_cast<float>(d_co[i]); + co[i] = float(d_co[i]); } BMVert *bmv = BM_vert_create(bm, co, nullptr, BM_CREATE_NOP); new_bmvs[v] = bmv; diff --git a/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc b/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc index ceb52feb9b4..11e3c1507d9 100644 --- a/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc +++ b/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc @@ -271,7 +271,7 @@ void FullFrameExecutionModel::update_progress_bar() { const bNodeTree *tree = context_.get_bnodetree(); if (tree) { - const float progress = num_operations_finished_ / static_cast<float>(operations_.size()); + const float progress = num_operations_finished_ / float(operations_.size()); tree->progress(tree->prh, progress); char buf[128]; diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cc b/source/blender/compositor/operations/COM_ReadBufferOperation.cc index 81f046af1b9..224d2ea0f41 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.cc +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cc @@ -31,8 +31,7 @@ void ReadBufferOperation::determine_canvas(const rcti &preferred_area, rcti &r_a /** \todo may not occur! But does with blur node. */ if (memory_proxy_->get_executor()) { - uint resolution[2] = {static_cast<uint>(BLI_rcti_size_x(&r_area)), - static_cast<uint>(BLI_rcti_size_y(&r_area))}; + uint resolution[2] = {uint(BLI_rcti_size_x(&r_area)), uint(BLI_rcti_size_y(&r_area))}; memory_proxy_->get_executor()->set_resolution(resolution); } diff --git a/source/blender/compositor/operations/COM_SMAAOperation.cc b/source/blender/compositor/operations/COM_SMAAOperation.cc index 261426b31e2..55983572ede 100644 --- a/source/blender/compositor/operations/COM_SMAAOperation.cc +++ b/source/blender/compositor/operations/COM_SMAAOperation.cc @@ -404,7 +404,7 @@ void SMAABlendingWeightCalculationOperation::init_execution() void SMAABlendingWeightCalculationOperation::set_corner_rounding(float rounding) { /* UI values are between 0 and 1 for simplicity but algorithm expects values between 0 and 100 */ - corner_rounding_ = static_cast<int>(scalenorm(0, 100, rounding)); + corner_rounding_ = int(scalenorm(0, 100, rounding)); } void SMAABlendingWeightCalculationOperation::execute_pixel(float output[4], diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc index 451c76bb36a..9a02bd70586 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc @@ -390,7 +390,7 @@ void VariableSizeBokehBlurOperation::update_memory_buffer_partial(MemoryBuffer * const float max_dim = MAX2(this->get_width(), this->get_height()); p.scalar = do_size_scale_ ? (max_dim / 100.0f) : 1.0f; - p.max_blur_scalar = static_cast<int>(max_size * p.scalar); + p.max_blur_scalar = int(max_size * p.scalar); CLAMP(p.max_blur_scalar, 1, max_blur_); for (BuffersIterator<float> it = output->iterate_with({p.image_input, p.size_input}, area); diff --git a/source/blender/compositor/realtime_compositor/intern/context.cc b/source/blender/compositor/realtime_compositor/intern/context.cc index 64ac29af3d1..924398f6747 100644 --- a/source/blender/compositor/realtime_compositor/intern/context.cc +++ b/source/blender/compositor/realtime_compositor/intern/context.cc @@ -17,9 +17,8 @@ int Context::get_frame_number() const float Context::get_time() const { - const float frame_number = static_cast<float>(get_frame_number()); - const float frame_rate = static_cast<float>(get_scene()->r.frs_sec) / - static_cast<float>(get_scene()->r.frs_sec_base); + const float frame_number = float(get_frame_number()); + const float frame_rate = float(get_scene()->r.frs_sec) / float(get_scene()->r.frs_sec_base); return frame_number / frame_rate; } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc index 129e0093d11..0a86cd62576 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc @@ -61,7 +61,7 @@ uint64_t AnimatedPropertyID::hash() const { uintptr_t ptr1 = (uintptr_t)data; uintptr_t ptr2 = (uintptr_t)property_rna; - return static_cast<uint64_t>(((ptr1 >> 4) * 33) ^ (ptr2 >> 4)); + return uint64_t(((ptr1 >> 4) * 33) ^ (ptr2 >> 4)); } namespace { diff --git a/source/blender/depsgraph/intern/node/deg_node_component.cc b/source/blender/depsgraph/intern/node/deg_node_component.cc index ebb4450579f..640f529f7fb 100644 --- a/source/blender/depsgraph/intern/node/deg_node_component.cc +++ b/source/blender/depsgraph/intern/node/deg_node_component.cc @@ -48,7 +48,7 @@ ComponentNode::OperationIDKey::OperationIDKey(OperationCode opcode, const char * string ComponentNode::OperationIDKey::identifier() const { - const string codebuf = to_string(static_cast<int>(opcode)); + const string codebuf = to_string(int(opcode)); return "OperationIDKey(" + codebuf + ", " + name + ")"; } @@ -59,7 +59,7 @@ bool ComponentNode::OperationIDKey::operator==(const OperationIDKey &other) cons uint64_t ComponentNode::OperationIDKey::hash() const { - const int opcode_as_int = static_cast<int>(opcode); + const int opcode_as_int = int(opcode); return BLI_ghashutil_combine_hash( name_tag, BLI_ghashutil_combine_hash(BLI_ghashutil_uinthash(opcode_as_int), diff --git a/source/blender/depsgraph/intern/node/deg_node_factory.cc b/source/blender/depsgraph/intern/node/deg_node_factory.cc index bcdfdbec604..4c08d4ee7bb 100644 --- a/source/blender/depsgraph/intern/node/deg_node_factory.cc +++ b/source/blender/depsgraph/intern/node/deg_node_factory.cc @@ -10,19 +10,19 @@ namespace blender::deg { /* Global type registry */ -static DepsNodeFactory *node_typeinfo_registry[static_cast<int>(NodeType::NUM_TYPES)] = {nullptr}; +static DepsNodeFactory *node_typeinfo_registry[int(NodeType::NUM_TYPES)] = {nullptr}; void register_node_typeinfo(DepsNodeFactory *factory) { BLI_assert(factory != nullptr); - const int type_as_int = static_cast<int>(factory->type()); + const int type_as_int = int(factory->type()); node_typeinfo_registry[type_as_int] = factory; } DepsNodeFactory *type_get_factory(const NodeType type) { /* Look up type - at worst, it doesn't exist in table yet, and we fail. */ - const int type_as_int = static_cast<int>(type); + const int type_as_int = int(type); return node_typeinfo_registry[type_as_int]; } diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc index 735d606ac9e..7cbee76e709 100644 --- a/source/blender/depsgraph/intern/node/deg_node_id.cc +++ b/source/blender/depsgraph/intern/node/deg_node_id.cc @@ -52,7 +52,7 @@ bool IDNode::ComponentIDKey::operator==(const ComponentIDKey &other) const uint64_t IDNode::ComponentIDKey::hash() const { - const int type_as_int = static_cast<int>(type); + const int type_as_int = int(type); return BLI_ghashutil_combine_hash(BLI_ghashutil_uinthash(type_as_int), BLI_ghashutil_strhash_p(name)); } @@ -190,7 +190,7 @@ IDComponentsMask IDNode::get_visible_components_mask() const IDComponentsMask result = 0; for (ComponentNode *comp_node : components.values()) { if (comp_node->possibly_affects_visible_id) { - const int component_type_as_int = static_cast<int>(comp_node->type); + const int component_type_as_int = int(comp_node->type); BLI_assert(component_type_as_int < 64); result |= (1ULL << component_type_as_int); } diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.cc b/source/blender/draw/engines/overlay/overlay_edit_uv.cc index 7425c577897..dd29a128255 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_uv.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_uv.cc @@ -335,9 +335,8 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) char text[16]; LISTBASE_FOREACH (ImageTile *, tile, &image->tiles) { BLI_snprintf(text, 5, "%d", tile->tile_number); - float tile_location[3] = {static_cast<float>((tile->tile_number - 1001) % 10), - static_cast<float>((tile->tile_number - 1001) / 10), - 0.0f}; + float tile_location[3] = { + float((tile->tile_number - 1001) % 10), float((tile->tile_number - 1001) / 10), 0.0f}; DRW_text_cache_add( dt, tile_location, text, strlen(text), 10, 10, DRW_TEXT_CACHE_GLOBALSPACE, color); } @@ -372,8 +371,7 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) float size_image[2]; BKE_image_get_size_fl(image, nullptr, size_image); - float size_stencil_image[2] = {static_cast<float>(stencil_ibuf->x), - static_cast<float>(stencil_ibuf->y)}; + float size_stencil_image[2] = {float(stencil_ibuf->x), float(stencil_ibuf->y)}; float obmat[4][4]; unit_m4(obmat); diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc b/source/blender/draw/intern/draw_cache_extract_mesh.cc index b1d1631cb6d..79f2982ab65 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc @@ -110,7 +110,7 @@ class ExtractorRunDatas : public Vector<ExtractorRunData> { uint iter_types_len() const { const eMRIterType iter_type = iter_types(); - uint bits = static_cast<uint>(iter_type); + uint bits = uint(iter_type); return count_bits_i(bits); } diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 8492804775e..c387a47f0a6 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -368,7 +368,7 @@ MINLINE CompressedPatchCoord make_patch_coord(int ptex_face_index, float u, floa { CompressedPatchCoord patch_coord = { ptex_face_index, - (static_cast<uint>(u * 65535.0f) << 16) | static_cast<uint>(v * 65535.0f), + (uint(u * 65535.0f) << 16) | uint(v * 65535.0f), }; return patch_coord; } @@ -1295,7 +1295,7 @@ static void drw_subdiv_compute_dispatch(const DRWSubdivCache *cache, uint total_dispatch_size, const bool has_sculpt_mask = false) { - const uint max_res_x = static_cast<uint>(GPU_max_work_group_count(0)); + const uint max_res_x = uint(GPU_max_work_group_count(0)); const uint dispatch_size = get_dispatch_size(total_dispatch_size); uint dispatch_rx = dispatch_size; @@ -2231,13 +2231,13 @@ void DRW_subdivide_loose_geom(DRWSubdivCache *subdiv_cache, MeshBufferCache *cac blender::Span<DRWSubdivLooseEdge> draw_subdiv_cache_get_loose_edges(const DRWSubdivCache *cache) { - return {cache->loose_geom.edges, static_cast<int64_t>(cache->loose_geom.edge_len)}; + return {cache->loose_geom.edges, int64_t(cache->loose_geom.edge_len)}; } blender::Span<DRWSubdivLooseVertex> draw_subdiv_cache_get_loose_verts(const DRWSubdivCache *cache) { return {cache->loose_geom.verts + cache->loose_geom.edge_len * 2, - static_cast<int64_t>(cache->loose_geom.vert_len)}; + int64_t(cache->loose_geom.vert_len)}; } static OpenSubdiv_EvaluatorCache *g_evaluator_cache = nullptr; diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc index 9c564c2cdda..6b7d42ec67c 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc @@ -231,8 +231,7 @@ static void extract_lines_loose_geom_subdiv(const DRWSubdivCache *subdiv_cache, } GPUIndexBuf *ibo = static_cast<GPUIndexBuf *>(buffer); - draw_subdiv_build_lines_loose_buffer( - subdiv_cache, ibo, flags, static_cast<uint>(loose_geom.edge_len)); + draw_subdiv_build_lines_loose_buffer(subdiv_cache, ibo, flags, uint(loose_geom.edge_len)); GPU_vertbuf_discard(flags); } diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc index 64ade020418..240e9b4fa60 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc @@ -285,7 +285,7 @@ static void extract_attr_init( GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf); - init_vbo_for_attribute(*mr, vbo, request, false, static_cast<uint32_t>(mr->loop_len)); + init_vbo_for_attribute(*mr, vbo, request, false, uint32_t(mr->loop_len)); /* TODO(@kevindietrich): float3 is used for scalar attributes as the implicit conversion done by * OpenGL to vec4 for a scalar `s` will produce a `vec4(s, 0, 0, 1)`. However, following the @@ -340,7 +340,7 @@ static void extract_attr_init_subdiv(const DRWSubdivCache *subdiv_cache, GPUVertFormat coarse_format = {0}; GPU_vertformat_attr_add(&coarse_format, "data", GPU_COMP_F32, dimensions, GPU_FETCH_FLOAT); GPU_vertbuf_init_with_format_ex(src_data, &coarse_format, GPU_USAGE_STATIC); - GPU_vertbuf_data_alloc(src_data, static_cast<uint32_t>(coarse_mesh->totloop)); + GPU_vertbuf_data_alloc(src_data, uint32_t(coarse_mesh->totloop)); switch (request.cd_type) { case CD_PROP_BOOL: @@ -379,7 +379,7 @@ static void extract_attr_init_subdiv(const DRWSubdivCache *subdiv_cache, draw_subdiv_interp_custom_data(subdiv_cache, src_data, dst_buffer, - static_cast<int>(dimensions), + int(dimensions), 0, ELEM(request.cd_type, CD_PROP_COLOR, CD_PROP_BYTE_COLOR)); diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index f52e11276e9..eb3e40f9f76 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -714,13 +714,13 @@ static void CURVES_OT_snap_curves_to_surface(wmOperatorType *ot) ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER; static const EnumPropertyItem attach_mode_items[] = { - {static_cast<int>(AttachMode::Nearest), + {int(AttachMode::Nearest), "NEAREST", 0, "Nearest", "Find the closest point on the surface for the root point of every curve and move the root " "there"}, - {static_cast<int>(AttachMode::Deform), + {int(AttachMode::Deform), "DEFORM", 0, "Deform", @@ -732,7 +732,7 @@ static void CURVES_OT_snap_curves_to_surface(wmOperatorType *ot) RNA_def_enum(ot->srna, "attach_mode", attach_mode_items, - static_cast<int>(AttachMode::Nearest), + int(AttachMode::Nearest), "Attach Mode", "How to find the point on the surface to attach to"); } diff --git a/source/blender/editors/geometry/geometry_attributes.cc b/source/blender/editors/geometry/geometry_attributes.cc index 14f2f8c6af5..673fb947c57 100644 --- a/source/blender/editors/geometry/geometry_attributes.cc +++ b/source/blender/editors/geometry/geometry_attributes.cc @@ -612,8 +612,7 @@ void GEOMETRY_OT_attribute_convert(wmOperatorType *ot) PropertyRNA *prop; - RNA_def_enum( - ot->srna, "mode", mode_items, static_cast<int>(ConvertAttributeMode::Generic), "Mode", ""); + RNA_def_enum(ot->srna, "mode", mode_items, int(ConvertAttributeMode::Generic), "Mode", ""); prop = RNA_def_enum(ot->srna, "domain", diff --git a/source/blender/editors/interface/interface_context_path.cc b/source/blender/editors/interface/interface_context_path.cc index 3b91ca79c00..e8f552e26a3 100644 --- a/source/blender/editors/interface/interface_context_path.cc +++ b/source/blender/editors/interface/interface_context_path.cc @@ -41,7 +41,7 @@ void context_path_add_generic(Vector<ContextPathItem> &path, static_cast<BIFIconID>(RNA_struct_ui_icon(rna_ptr.type)) : icon_override; - path.append({name, static_cast<int>(icon)}); + path.append({name, int(icon)}); } /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/interface/interface_region_tooltip.cc b/source/blender/editors/interface/interface_region_tooltip.cc index 2c4d13e0717..b1621f1a040 100644 --- a/source/blender/editors/interface/interface_region_tooltip.cc +++ b/source/blender/editors/interface/interface_region_tooltip.cc @@ -109,8 +109,7 @@ struct uiTooltipData { #define UI_TIP_LC_MAX 6 -BLI_STATIC_ASSERT(UI_TIP_LC_MAX == static_cast<int>(uiTooltipFormat::ColorID::Alert) + 1, - "invalid lc-max"); +BLI_STATIC_ASSERT(UI_TIP_LC_MAX == int(uiTooltipFormat::ColorID::Alert) + 1, "invalid lc-max"); BLI_STATIC_ASSERT(sizeof(uiTooltipFormat) <= sizeof(int), "oversize"); static uiTooltipField *text_field_add_only(uiTooltipData *data) @@ -168,12 +167,12 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region uchar drawcol[4] = {0, 0, 0, 255}; /* to store color in while drawing (alpha is always 255) */ /* The color from the theme. */ - float *main_color = tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Main)]; - float *value_color = tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Value)]; - float *active_color = tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Active)]; - float *normal_color = tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Normal)]; - float *python_color = tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Python)]; - float *alert_color = tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Alert)]; + float *main_color = tip_colors[int(uiTooltipFormat::ColorID::Main)]; + float *value_color = tip_colors[int(uiTooltipFormat::ColorID::Value)]; + float *active_color = tip_colors[int(uiTooltipFormat::ColorID::Active)]; + float *normal_color = tip_colors[int(uiTooltipFormat::ColorID::Normal)]; + float *python_color = tip_colors[int(uiTooltipFormat::ColorID::Python)]; + float *alert_color = tip_colors[int(uiTooltipFormat::ColorID::Alert)]; float background_color[3]; @@ -224,7 +223,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region fs_params.word_wrap = true; /* Draw header and active data (is done here to be able to change color). */ - rgb_float_to_uchar(drawcol, tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Main)]); + rgb_float_to_uchar(drawcol, tip_colors[int(uiTooltipFormat::ColorID::Main)]); UI_fontstyle_set(&data->fstyle); UI_fontstyle_draw(&data->fstyle, &bbox, field->text, UI_TIP_STR_MAX, drawcol, &fs_params); @@ -235,8 +234,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region bbox.xmin += xofs; bbox.ymax -= yofs; - rgb_float_to_uchar(drawcol, - tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Active)]); + rgb_float_to_uchar(drawcol, tip_colors[int(uiTooltipFormat::ColorID::Active)]); UI_fontstyle_draw( &data->fstyle, &bbox, field->text_suffix, UI_TIP_STR_MAX, drawcol, &fs_params); @@ -255,7 +253,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region UI_fontstyle_set(&fstyle_mono); /* XXX: needed because we don't have mono in 'U.uifonts'. */ BLF_size(fstyle_mono.uifont_id, fstyle_mono.points * U.dpi_fac); - rgb_float_to_uchar(drawcol, tip_colors[static_cast<int>(field->format.color_id)]); + rgb_float_to_uchar(drawcol, tip_colors[int(field->format.color_id)]); UI_fontstyle_draw(&fstyle_mono, &bbox, field->text, UI_TIP_STR_MAX, drawcol, &fs_params); } else { @@ -265,7 +263,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region fs_params.word_wrap = true; /* Draw remaining data. */ - rgb_float_to_uchar(drawcol, tip_colors[static_cast<int>(field->format.color_id)]); + rgb_float_to_uchar(drawcol, tip_colors[int(field->format.color_id)]); UI_fontstyle_set(&data->fstyle); UI_fontstyle_draw(&data->fstyle, &bbox, field->text, UI_TIP_STR_MAX, drawcol, &fs_params); } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index 423fd70e1e2..ee12afeb506 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -344,7 +344,7 @@ static int select_random_exec(bContext *C, wmOperator *op) VectorSet<Curves *> unique_curves = curves::get_unique_editable_curves(*C); const int seed = RNA_int_get(op->ptr, "seed"); - RandomNumberGenerator rng{static_cast<uint32_t>(seed)}; + RandomNumberGenerator rng{uint32_t(seed)}; const bool partial = RNA_boolean_get(op->ptr, "partial"); const bool constant_per_curve = RNA_boolean_get(op->ptr, "constant_per_curve"); diff --git a/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc b/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc index dc45a7ec51c..d3c61508726 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc +++ b/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc @@ -70,11 +70,11 @@ static void update_curve_mask(CurveMaskCache *curve_mask_cache, for (int y = 0; y < diameter; y++) { for (int x = 0; x < diameter; x++, m++) { float pixel_xy[2]; - pixel_xy[0] = static_cast<float>(x) + aa_offset; + pixel_xy[0] = float(x) + aa_offset; float total_weight = 0; for (int i = 0; i < aa_samples; i++) { - pixel_xy[1] = static_cast<float>(y) + aa_offset; + pixel_xy[1] = float(y) + aa_offset; for (int j = 0; j < aa_samples; j++) { const float len = len_v2v2(pixel_xy, bpos); const int sample_index = min_ii((len / clamped_radius) * CurveSamplesBaseLen, diff --git a/source/blender/geometry/intern/mesh_primitive_cuboid.cc b/source/blender/geometry/intern/mesh_primitive_cuboid.cc index 39571f2931e..a014c488a3b 100644 --- a/source/blender/geometry/intern/mesh_primitive_cuboid.cc +++ b/source/blender/geometry/intern/mesh_primitive_cuboid.cc @@ -328,9 +328,9 @@ static void calculate_uvs(const CuboidConfig &config, Mesh *mesh, const bke::Att int loop_index = 0; - const float x_delta = 0.25f / static_cast<float>(config.edges_x); - const float y_delta = 0.25f / static_cast<float>(config.edges_y); - const float z_delta = 0.25f / static_cast<float>(config.edges_z); + const float x_delta = 0.25f / float(config.edges_x); + const float y_delta = 0.25f / float(config.edges_y); + const float z_delta = 0.25f / float(config.edges_z); /* Calculate bottom face UVs. */ for (const int y : IndexRange(config.edges_y)) { diff --git a/source/blender/geometry/intern/mesh_to_volume.cc b/source/blender/geometry/intern/mesh_to_volume.cc index 580350bc547..4aa25317f90 100644 --- a/source/blender/geometry/intern/mesh_to_volume.cc +++ b/source/blender/geometry/intern/mesh_to_volume.cc @@ -36,12 +36,12 @@ OpenVDBMeshAdapter::OpenVDBMeshAdapter(const Mesh &mesh, float4x4 transform) size_t OpenVDBMeshAdapter::polygonCount() const { - return static_cast<size_t>(looptris_.size()); + return size_t(looptris_.size()); } size_t OpenVDBMeshAdapter::pointCount() const { - return static_cast<size_t>(verts_.size()); + return size_t(verts_.size()); } size_t OpenVDBMeshAdapter::vertexCount(size_t UNUSED(polygon_index)) const diff --git a/source/blender/gpu/opengl/gl_vertex_buffer.cc b/source/blender/gpu/opengl/gl_vertex_buffer.cc index 6942a220892..2515b7e8f19 100644 --- a/source/blender/gpu/opengl/gl_vertex_buffer.cc +++ b/source/blender/gpu/opengl/gl_vertex_buffer.cc @@ -144,7 +144,7 @@ void GLVertBuf::wrap_handle(uint64_t handle) BLI_assert(vbo_id_ == 0); BLI_assert(glIsBuffer(static_cast<uint>(handle))); is_wrapper_ = true; - vbo_id_ = static_cast<uint>(handle); + vbo_id_ = uint(handle); /* We assume the data is already on the device, so no need to allocate or send it. */ flag = GPU_VERTBUF_DATA_UPLOADED; } diff --git a/source/blender/io/usd/intern/usd_capi_export.cc b/source/blender/io/usd/intern/usd_capi_export.cc index 1033f85181c..3977daaca4a 100644 --- a/source/blender/io/usd/intern/usd_capi_export.cc +++ b/source/blender/io/usd/intern/usd_capi_export.cc @@ -96,8 +96,7 @@ static void export_startjob(void *customdata, } usd_stage->SetMetadata(pxr::UsdGeomTokens->upAxis, pxr::VtValue(pxr::UsdGeomTokens->z)); - usd_stage->SetMetadata(pxr::UsdGeomTokens->metersPerUnit, - static_cast<double>(scene->unit.scale_length)); + usd_stage->SetMetadata(pxr::UsdGeomTokens->metersPerUnit, double(scene->unit.scale_length)); usd_stage->GetRootLayer()->SetDocumentation(std::string("Blender v") + BKE_blender_version_string()); @@ -120,7 +119,7 @@ static void export_startjob(void *customdata, } /* Update the scene for the next frame to render. */ - scene->r.cfra = static_cast<int>(frame); + scene->r.cfra = int(frame); scene->r.subframe = frame - scene->r.cfra; BKE_scene_graph_update_for_newframe(data->depsgraph); diff --git a/source/blender/io/usd/intern/usd_capi_import.cc b/source/blender/io/usd/intern/usd_capi_import.cc index 54ad7ef5410..5808c6bc77a 100644 --- a/source/blender/io/usd/intern/usd_capi_import.cc +++ b/source/blender/io/usd/intern/usd_capi_import.cc @@ -230,7 +230,7 @@ static void import_startjob(void *customdata, short *stop, short *do_update, flo *data->do_update = true; *data->progress = 0.2f; - const float size = static_cast<float>(archive->readers().size()); + const float size = float(archive->readers().size()); size_t i = 0; /* Sort readers by name: when creating a lot of objects in Blender, diff --git a/source/blender/io/usd/intern/usd_reader_camera.cc b/source/blender/io/usd/intern/usd_reader_camera.cc index 7f1e9fef89d..da51787e437 100644 --- a/source/blender/io/usd/intern/usd_reader_camera.cc +++ b/source/blender/io/usd/intern/usd_reader_camera.cc @@ -71,7 +71,7 @@ void USDCameraReader::read_object_data(Main *bmain, const double motionSampleTim bcam->clip_end = clippingRangeVal.UncheckedGet<pxr::GfVec2f>()[1]; bcam->dof.focus_distance = focalDistanceVal.Get<float>(); - bcam->dof.aperture_fstop = static_cast<float>(fstopVal.Get<float>()); + bcam->dof.aperture_fstop = float(fstopVal.Get<float>()); if (bcam->type == CAM_ORTHO) { bcam->ortho_scale = max_ff(verAp.Get<float>(), horAp.Get<float>()); diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index e76b9d3283b..ea433bec139 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -275,7 +275,7 @@ void USDMeshReader::read_object_data(Main *bmain, const double motionSampleTime) bool USDMeshReader::valid() const { - return static_cast<bool>(mesh_prim_); + return bool(mesh_prim_); } bool USDMeshReader::topology_changed(const Mesh *existing_mesh, const double motionSampleTime) @@ -601,7 +601,7 @@ void USDMeshReader::process_normals_vertex_varying(Mesh *mesh) MutableSpan vert_normals{(float3 *)BKE_mesh_vertex_normals_for_write(mesh), mesh->totvert}; BLI_STATIC_ASSERT(sizeof(normals_[0]) == sizeof(float3), "Expected float3 normals size"); - vert_normals.copy_from({(float3 *)normals_.data(), static_cast<int64_t>(normals_.size())}); + vert_normals.copy_from({(float3 *)normals_.data(), int64_t(normals_.size())}); BKE_mesh_vertex_normals_clear_dirty(mesh); } diff --git a/source/blender/io/usd/intern/usd_reader_nurbs.cc b/source/blender/io/usd/intern/usd_reader_nurbs.cc index d0a5dc1c4b4..a838450a4c0 100644 --- a/source/blender/io/usd/intern/usd_reader_nurbs.cc +++ b/source/blender/io/usd/intern/usd_reader_nurbs.cc @@ -117,7 +117,7 @@ void USDNurbsReader::read_curve_sample(Curve *cu, const double motionSampleTime) nu->pntsv = 1; if (i < orders.size()) { - nu->orderu = static_cast<short>(orders[i]); + nu->orderu = short(orders[i]); } else { nu->orderu = 4; diff --git a/source/blender/io/usd/intern/usd_reader_volume.cc b/source/blender/io/usd/intern/usd_reader_volume.cc index 13044de5002..fc25dda53b9 100644 --- a/source/blender/io/usd/intern/usd_reader_volume.cc +++ b/source/blender/io/usd/intern/usd_reader_volume.cc @@ -65,10 +65,10 @@ void USDVolumeReader::read_object_data(Main *bmain, const double motionSampleTim filepathAttr.GetTimeSamples(&filePathTimes); if (!filePathTimes.empty()) { - int start = static_cast<int>(filePathTimes.front()); - int end = static_cast<int>(filePathTimes.back()); + int start = int(filePathTimes.front()); + int end = int(filePathTimes.back()); - volume->is_sequence = static_cast<char>(true); + volume->is_sequence = char(true); volume->frame_start = start; volume->frame_duration = (end - start) + 1; } diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc index 91b59059545..9f19a6390d3 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc @@ -511,7 +511,7 @@ std::optional<std::array<int, 2>> OBJMesh::calc_loose_edge_vert_indices(const in const Span<MEdge> edges = export_mesh_eval_->edges(); const MEdge &edge = edges[edge_index]; if (edge.flag & ME_LOOSEEDGE) { - return std::array<int, 2>{static_cast<int>(edge.v1), static_cast<int>(edge.v2)}; + return std::array<int, 2>{int(edge.v1), int(edge.v2)}; } return std::nullopt; } 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 56fe81181e3..a30dfda24d8 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 @@ -164,7 +164,7 @@ static void geom_add_edge(Geometry *geom, edge_v1 += edge_v1 < 0 ? r_global_vertices.vertices.size() : -1; edge_v2 += edge_v2 < 0 ? r_global_vertices.vertices.size() : -1; BLI_assert(edge_v1 >= 0 && edge_v2 >= 0); - geom->edges_.append({static_cast<uint>(edge_v1), static_cast<uint>(edge_v2)}); + geom->edges_.append({uint(edge_v1), uint(edge_v2)}); geom->track_vertex_index(edge_v1); geom->track_vertex_index(edge_v2); } diff --git a/source/blender/modifiers/intern/MOD_volume_displace.cc b/source/blender/modifiers/intern/MOD_volume_displace.cc index d9b94d79348..f5a4b98a53e 100644 --- a/source/blender/modifiers/intern/MOD_volume_displace.cc +++ b/source/blender/modifiers/intern/MOD_volume_displace.cc @@ -213,7 +213,7 @@ struct DisplaceGridOp { const float sample_radius = vdmd.texture_sample_radius * std::abs(vdmd.strength) / max_voxel_side_length / 2.0f; openvdb::tools::dilateActiveValues(temp_grid->tree(), - static_cast<int>(std::ceil(sample_radius)), + int(std::ceil(sample_radius)), openvdb::tools::NN_FACE_EDGE, openvdb::tools::EXPAND_TILES); diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.cc b/source/blender/nodes/composite/nodes/node_composite_blur.cc index 630f18361e3..af7dca32c0d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_blur.cc @@ -346,7 +346,7 @@ class BlurOperation : public NodeOperation { Domain domain = compute_domain(); if (get_extend_bounds()) { - domain.size.x += static_cast<int>(math::ceil(compute_blur_radius().x)) * 2; + domain.size.x += int(math::ceil(compute_blur_radius().x)) * 2; } /* We allocate an output image of a transposed size, that is, with a height equivalent to the diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.cc b/source/blender/nodes/composite/nodes/node_composite_curves.cc index bf45e219730..70bd4d17007 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.cc +++ b/source/blender/nodes/composite/nodes/node_composite_curves.cc @@ -80,8 +80,7 @@ class TimeCurveOperation : public NodeOperation { if (get_start_time() == get_end_time()) { return 0.0f; } - return static_cast<float>(frame_number - get_start_time()) / - static_cast<float>(get_end_time() - get_start_time()); + return float(frame_number - get_start_time()) / float(get_end_time() - get_start_time()); } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.cc b/source/blender/nodes/composite/nodes/node_composite_dilate.cc index 551dfacb276..0cf0c5cc80b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_dilate.cc +++ b/source/blender/nodes/composite/nodes/node_composite_dilate.cc @@ -393,7 +393,7 @@ class DilateErodeOperation : public NodeOperation { /* See the discussion in the implementation for more information. */ int get_morphological_distance_threshold_radius() { - return static_cast<int>(math::ceil(get_inset())) + math::abs(get_distance()); + return int(math::ceil(get_inset())) + math::abs(get_distance()); } /* ---------------------------------------- diff --git a/source/blender/nodes/composite/nodes/node_composite_scene_time.cc b/source/blender/nodes/composite/nodes/node_composite_scene_time.cc index 1f5317378bb..3a7e7dc78bd 100644 --- a/source/blender/nodes/composite/nodes/node_composite_scene_time.cc +++ b/source/blender/nodes/composite/nodes/node_composite_scene_time.cc @@ -38,7 +38,7 @@ class SceneTimeOperation : public NodeOperation { { Result &result = get_result("Frame"); result.allocate_single_value(); - result.set_float_value(static_cast<float>(context().get_frame_number())); + result.set_float_value(float(context().get_frame_number())); } }; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc index 801b3c78060..c69ea8635ca 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc @@ -115,7 +115,7 @@ static Mesh *create_circle_mesh(const float radius, MutableSpan<MLoop> loops = mesh->loops_for_write(); /* Assign vertex coordinates. */ - const float angle_delta = 2.0f * (M_PI / static_cast<float>(verts_num)); + const float angle_delta = 2.0f * (M_PI / float(verts_num)); for (const int i : IndexRange(verts_num)) { const float angle = i * angle_delta; copy_v3_v3(verts[i].co, float3(std::cos(angle) * radius, std::sin(angle) * radius, 0.0f)); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc index 1f9ad9f6ea2..9f01989fc02 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc @@ -258,7 +258,7 @@ int ConeConfig::calculate_total_corners() static void calculate_cone_verts(const MutableSpan<MVert> &verts, const ConeConfig &config) { Array<float2> circle(config.circle_segments); - const float angle_delta = 2.0f * (M_PI / static_cast<float>(config.circle_segments)); + const float angle_delta = 2.0f * (M_PI / float(config.circle_segments)); float angle = 0.0f; for (const int i : IndexRange(config.circle_segments)) { circle[i].x = std::cos(angle); @@ -275,8 +275,7 @@ static void calculate_cone_verts(const MutableSpan<MVert> &verts, const ConeConf /* Top fill including the outer edge of the fill. */ if (!config.top_is_point) { - const float top_fill_radius_delta = config.radius_top / - static_cast<float>(config.fill_segments); + const float top_fill_radius_delta = config.radius_top / float(config.fill_segments); for (const int i : IndexRange(config.fill_segments)) { const float top_fill_radius = top_fill_radius_delta * (i + 1); for (const int j : IndexRange(config.circle_segments)) { @@ -289,8 +288,8 @@ static void calculate_cone_verts(const MutableSpan<MVert> &verts, const ConeConf /* Rings along the side. */ const float side_radius_delta = (config.radius_bottom - config.radius_top) / - static_cast<float>(config.side_segments); - const float height_delta = 2.0f * config.height / static_cast<float>(config.side_segments); + float(config.side_segments); + const float height_delta = 2.0f * config.height / float(config.side_segments); for (const int i : IndexRange(config.side_segments - 1)) { const float ring_radius = config.radius_top + (side_radius_delta * (i + 1)); const float ring_height = config.height - (height_delta * (i + 1)); @@ -303,8 +302,7 @@ static void calculate_cone_verts(const MutableSpan<MVert> &verts, const ConeConf /* Bottom fill including the outer edge of the fill. */ if (!config.bottom_is_point) { - const float bottom_fill_radius_delta = config.radius_bottom / - static_cast<float>(config.fill_segments); + const float bottom_fill_radius_delta = config.radius_bottom / float(config.fill_segments); for (const int i : IndexRange(config.fill_segments)) { const float bottom_fill_radius = config.radius_bottom - (i * bottom_fill_radius_delta); for (const int j : IndexRange(config.circle_segments)) { @@ -544,7 +542,7 @@ static void calculate_cone_uvs(Mesh *mesh, const ConeConfig &config) Array<float2> circle(config.circle_segments); float angle = 0.0f; - const float angle_delta = 2.0f * M_PI / static_cast<float>(config.circle_segments); + const float angle_delta = 2.0f * M_PI / float(config.circle_segments); for (const int i : IndexRange(config.circle_segments)) { circle[i].x = std::cos(angle) * 0.225f; circle[i].y = std::sin(angle) * 0.225f; @@ -556,9 +554,8 @@ static void calculate_cone_uvs(Mesh *mesh, const ConeConfig &config) /* Left circle of the UV representing the top fill or top cone tip. */ if (config.top_is_point || config.fill_type != GEO_NODE_MESH_CIRCLE_FILL_NONE) { const float2 center_left(0.25f, 0.25f); - const float radius_factor_delta = 1.0f / (config.top_is_point ? - static_cast<float>(config.side_segments) : - static_cast<float>(config.fill_segments)); + const float radius_factor_delta = 1.0f / (config.top_is_point ? float(config.side_segments) : + float(config.fill_segments)); const int left_circle_segment_count = config.top_is_point ? config.side_segments : config.fill_segments; @@ -595,8 +592,8 @@ static void calculate_cone_uvs(Mesh *mesh, const ConeConfig &config) if (!config.top_is_point && !config.bottom_is_point) { /* Mesh is a truncated cone or cylinder. The sides are unwrapped into a rectangle. */ const float bottom = (config.fill_type == GEO_NODE_MESH_CIRCLE_FILL_NONE) ? 0.0f : 0.5f; - const float x_delta = 1.0f / static_cast<float>(config.circle_segments); - const float y_delta = (1.0f - bottom) / static_cast<float>(config.side_segments); + const float x_delta = 1.0f / float(config.circle_segments); + const float y_delta = (1.0f - bottom) / float(config.side_segments); for (const int i : IndexRange(config.side_segments)) { for (const int j : IndexRange(config.circle_segments)) { @@ -612,8 +609,8 @@ static void calculate_cone_uvs(Mesh *mesh, const ConeConfig &config) if (config.bottom_is_point || config.fill_type != GEO_NODE_MESH_CIRCLE_FILL_NONE) { const float2 center_right(0.75f, 0.25f); const float radius_factor_delta = 1.0f / (config.bottom_is_point ? - static_cast<float>(config.side_segments) : - static_cast<float>(config.fill_segments)); + float(config.side_segments) : + float(config.fill_segments)); const int right_circle_segment_count = config.bottom_is_point ? config.side_segments : config.fill_segments; @@ -679,7 +676,7 @@ Mesh *create_cylinder_or_cone_mesh(const float radius_top, if (config.height == 0.0f) { return create_vertex_mesh(); } - const float z_delta = -2.0f * config.height / static_cast<float>(config.side_segments); + const float z_delta = -2.0f * config.height / float(config.side_segments); const float3 start(0.0f, 0.0f, config.height); const float3 delta(0.0f, 0.0f, z_delta); return create_line_mesh(start, delta, config.tot_verts); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc index d39e72b7f0a..1c8e7eec6c0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc @@ -266,16 +266,16 @@ BLI_NOINLINE static void calculate_sphere_uvs(Mesh *mesh, const float segments, const float segments_inv = 1.0f / segments; for (const int i_segment : IndexRange(segments)) { - const float segment = static_cast<float>(i_segment); + const float segment = float(i_segment); uvs[loop_index++] = float2((segment + 0.5f) * segments_inv, 0.0f); uvs[loop_index++] = float2(segment * segments_inv, dy); uvs[loop_index++] = float2((segment + 1.0f) * segments_inv, dy); } for (const int i_ring : IndexRange(1, rings - 2)) { - const float ring = static_cast<float>(i_ring); + const float ring = float(i_ring); for (const int i_segment : IndexRange(segments)) { - const float segment = static_cast<float>(i_segment); + const float segment = float(i_segment); uvs[loop_index++] = float2(segment * segments_inv, ring / rings); uvs[loop_index++] = float2(segment * segments_inv, (ring + 1.0f) / rings); uvs[loop_index++] = float2((segment + 1.0f) * segments_inv, (ring + 1.0f) / rings); @@ -284,7 +284,7 @@ BLI_NOINLINE static void calculate_sphere_uvs(Mesh *mesh, const float segments, } for (const int i_segment : IndexRange(segments)) { - const float segment = static_cast<float>(i_segment); + const float segment = float(i_segment); uvs[loop_index++] = float2((segment + 0.5f) * segments_inv, 1.0f); uvs[loop_index++] = float2((segment + 1.0f) * segments_inv, 1.0f - dy); uvs[loop_index++] = float2(segment * segments_inv, 1.0f - dy); diff --git a/source/blender/nodes/geometry/nodes/node_geo_volume_cube.cc b/source/blender/nodes/geometry/nodes/node_geo_volume_cube.cc index c102b91acb1..274c243909d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_volume_cube.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_volume_cube.cc @@ -75,8 +75,7 @@ class Grid3DFieldContext : public FieldContext { int64_t points_num() const { - return static_cast<int64_t>(resolution_.x) * static_cast<int64_t>(resolution_.y) * - static_cast<int64_t>(resolution_.z); + return int64_t(resolution_.x) * int64_t(resolution_.y) * int64_t(resolution_.z); } GVArray get_varray_for_input(const FieldInput &field_input, |