diff options
author | Jacques Lucke <jacques@blender.org> | 2022-09-25 18:39:45 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-09-25 18:39:45 +0300 |
commit | c6e70e7bacf82b38ca7125d6821713a711489c0b (patch) | |
tree | 3679590f6254b7fbbd6623080edafe217f20c7b6 | |
parent | 0419ee871ff960f62e28a2a9fed764f66c616d71 (diff) |
Cleanup: follow C++ type cast style guide in some files
https://wiki.blender.org/wiki/Style_Guide/C_Cpp#C.2B.2B_Type_Cast
This was discussed in https://devtalk.blender.org/t/rfc-style-guide-for-type-casts-in-c-code/25907.
77 files changed, 247 insertions, 275 deletions
diff --git a/source/blender/blenlib/BLI_allocator.hh b/source/blender/blenlib/BLI_allocator.hh index f19292fffd8..149dda5a50e 100644 --- a/source/blender/blenlib/BLI_allocator.hh +++ b/source/blender/blenlib/BLI_allocator.hh @@ -65,13 +65,12 @@ class RawAllocator { public: void *allocate(size_t size, size_t alignment, const char *UNUSED(name)) { - BLI_assert(is_power_of_2_i(static_cast<int>(alignment))); + BLI_assert(is_power_of_2_i(int(alignment))); void *ptr = malloc(size + alignment + sizeof(MemHead)); void *used_ptr = reinterpret_cast<void *>( - reinterpret_cast<uintptr_t>(POINTER_OFFSET(ptr, alignment + sizeof(MemHead))) & - ~(static_cast<uintptr_t>(alignment) - 1)); - int offset = static_cast<int>((intptr_t)used_ptr - (intptr_t)ptr); - BLI_assert(offset >= static_cast<int>(sizeof(MemHead))); + uintptr_t(POINTER_OFFSET(ptr, alignment + sizeof(MemHead))) & ~(uintptr_t(alignment) - 1)); + int offset = int(intptr_t(used_ptr) - intptr_t(ptr)); + BLI_assert(offset >= int(sizeof(MemHead))); (static_cast<MemHead *>(used_ptr) - 1)->offset = offset; return used_ptr; } diff --git a/source/blender/blenlib/BLI_any.hh b/source/blender/blenlib/BLI_any.hh index f9b53436763..df67a090e92 100644 --- a/source/blender/blenlib/BLI_any.hh +++ b/source/blender/blenlib/BLI_any.hh @@ -42,12 +42,13 @@ template<typename ExtraInfo, typename T> inline constexpr AnyTypeInfo<ExtraInfo> info_for_inline = { is_trivially_copy_constructible_extended_v<T> ? nullptr : - +[](void *dst, const void *src) { new (dst) T(*(const T *)src); }, + +[](void *dst, const void *src) { new (dst) T(*static_cast<const T *>(src)); }, is_trivially_move_constructible_extended_v<T> ? nullptr : - +[](void *dst, void *src) { new (dst) T(std::move(*(T *)src)); }, - is_trivially_destructible_extended_v<T> ? nullptr : - +[](void *src) { std::destroy_at(((T *)src)); }, + +[](void *dst, void *src) { new (dst) T(std::move(*static_cast<T *>(src))); }, + is_trivially_destructible_extended_v<T> ? + nullptr : + +[](void *src) { std::destroy_at((static_cast<T *>(src))); }, nullptr, ExtraInfo::template get<T>()}; diff --git a/source/blender/blenlib/BLI_array.hh b/source/blender/blenlib/BLI_array.hh index 813277d9968..200381048c9 100644 --- a/source/blender/blenlib/BLI_array.hh +++ b/source/blender/blenlib/BLI_array.hh @@ -424,8 +424,7 @@ class Array { T *allocate(int64_t size) { - return static_cast<T *>( - allocator_.allocate(static_cast<size_t>(size) * sizeof(T), alignof(T), AT)); + return static_cast<T *>(allocator_.allocate(size_t(size) * sizeof(T), alignof(T), AT)); } void deallocate_if_not_inline(T *ptr) diff --git a/source/blender/blenlib/BLI_bit_vector.hh b/source/blender/blenlib/BLI_bit_vector.hh index 2cec190f84a..ca6c6b2cd2a 100644 --- a/source/blender/blenlib/BLI_bit_vector.hh +++ b/source/blender/blenlib/BLI_bit_vector.hh @@ -106,7 +106,7 @@ class MutableBitRef { MutableBitRef(uint8_t *byte_ptr, const int64_t bit_index) { byte_ptr_ = byte_ptr + (bit_index >> 3); - mask_ = 1 << static_cast<uint8_t>(bit_index & 7); + mask_ = 1 << uint8_t(bit_index & 7); } /** @@ -211,7 +211,7 @@ class BitVector { data_ = inline_buffer_; size_in_bits_ = 0; capacity_in_bits_ = BitsInInlineBuffer; - uninitialized_fill_n(data_, BytesInInlineBuffer, static_cast<uint8_t>(0)); + uninitialized_fill_n(data_, BytesInInlineBuffer, uint8_t(0)); } BitVector(NoExceptConstructor, Allocator allocator = {}) noexcept : BitVector(allocator) @@ -447,7 +447,7 @@ class BitVector { /* Fill entire bytes at once. */ const int64_t start_fill_byte_index = aligned_ranges.aligned.start() / BitsPerByte; const int64_t bytes_to_fill = aligned_ranges.aligned.size() / BitsPerByte; - const uint8_t fill_value = value ? (uint8_t)0xff : (uint8_t)0x00; + const uint8_t fill_value = value ? uint8_t(0xff) : uint8_t(0x00); initialized_fill_n(data_ + start_fill_byte_index, bytes_to_fill, fill_value); /* Fill bits in the end that don't cover a full byte. */ @@ -505,7 +505,7 @@ class BitVector { * uninitialized byte. */ uninitialized_fill_n(new_data + bytes_to_copy, new_capacity_in_bytes - bytes_to_copy, - (uint8_t)initial_value_for_new_bytes); + uint8_t(initial_value_for_new_bytes)); if (!this->is_inline()) { allocator_.deallocate(data_); diff --git a/source/blender/blenlib/BLI_cpp_type_make.hh b/source/blender/blenlib/BLI_cpp_type_make.hh index b0dbbff7ca8..3acef4b0f09 100644 --- a/source/blender/blenlib/BLI_cpp_type_make.hh +++ b/source/blender/blenlib/BLI_cpp_type_make.hh @@ -211,8 +211,8 @@ CPPType::CPPType(CPPTypeParam<T, Flags> /* unused */, StringRef debug_name) using namespace cpp_type_util; debug_name_ = debug_name; - size_ = (int64_t)sizeof(T); - alignment_ = (int64_t)alignof(T); + size_ = int64_t(sizeof(T)); + alignment_ = int64_t(alignof(T)); is_trivial_ = std::is_trivial_v<T>; is_trivially_destructible_ = std::is_trivially_destructible_v<T>; if constexpr (std::is_default_constructible_v<T>) { @@ -221,7 +221,7 @@ CPPType::CPPType(CPPTypeParam<T, Flags> /* unused */, StringRef debug_name) value_initialize_ = value_initialize_cb<T>; value_initialize_indices_ = value_initialize_indices_cb<T>; static T default_value; - default_value_ = (void *)&default_value; + default_value_ = &default_value; } if constexpr (std::is_destructible_v<T>) { destruct_ = destruct_cb<T>; diff --git a/source/blender/blenlib/BLI_function_ref.hh b/source/blender/blenlib/BLI_function_ref.hh index 9a38176c988..bc386322c5d 100644 --- a/source/blender/blenlib/BLI_function_ref.hh +++ b/source/blender/blenlib/BLI_function_ref.hh @@ -116,7 +116,7 @@ template<typename Ret, typename... Params> class FunctionRef<Ret(Params...)> { !std::is_same_v<std::remove_cv_t<std::remove_reference_t<Callable>>, FunctionRef>))> FunctionRef(Callable &&callable) : callback_(callback_fn<typename std::remove_reference_t<Callable>>), - callable_(reinterpret_cast<intptr_t>(&callable)) + callable_(intptr_t(&callable)) { } diff --git a/source/blender/blenlib/BLI_generic_array.hh b/source/blender/blenlib/BLI_generic_array.hh index 4b917434264..f0eddd30419 100644 --- a/source/blender/blenlib/BLI_generic_array.hh +++ b/source/blender/blenlib/BLI_generic_array.hh @@ -243,7 +243,7 @@ class GArray { { const int64_t item_size = type_->size(); const int64_t alignment = type_->alignment(); - return allocator_.allocate(static_cast<size_t>(size) * item_size, alignment, AT); + return allocator_.allocate(size_t(size) * item_size, alignment, AT); } void deallocate(void *ptr) diff --git a/source/blender/blenlib/BLI_generic_virtual_array.hh b/source/blender/blenlib/BLI_generic_virtual_array.hh index 21549896f45..9545eaf9622 100644 --- a/source/blender/blenlib/BLI_generic_virtual_array.hh +++ b/source/blender/blenlib/BLI_generic_virtual_array.hh @@ -315,7 +315,7 @@ template<typename T> class GVArrayImpl_For_VArray : public GVArrayImpl { protected: void get(const int64_t index, void *r_value) const override { - *(T *)r_value = varray_[index]; + *static_cast<T *>(r_value) = varray_[index]; } void get_to_uninitialized(const int64_t index, void *r_value) const override @@ -325,22 +325,24 @@ template<typename T> class GVArrayImpl_For_VArray : public GVArrayImpl { void materialize(const IndexMask mask, void *dst) const override { - varray_.materialize(mask, MutableSpan((T *)dst, mask.min_array_size())); + varray_.materialize(mask, MutableSpan(static_cast<T *>(dst), mask.min_array_size())); } void materialize_to_uninitialized(const IndexMask mask, void *dst) const override { - varray_.materialize_to_uninitialized(mask, MutableSpan((T *)dst, mask.min_array_size())); + varray_.materialize_to_uninitialized( + mask, MutableSpan(static_cast<T *>(dst), mask.min_array_size())); } void materialize_compressed(const IndexMask mask, void *dst) const override { - varray_.materialize_compressed(mask, MutableSpan((T *)dst, mask.size())); + varray_.materialize_compressed(mask, MutableSpan(static_cast<T *>(dst), mask.size())); } void materialize_compressed_to_uninitialized(const IndexMask mask, void *dst) const override { - varray_.materialize_compressed_to_uninitialized(mask, MutableSpan((T *)dst, mask.size())); + varray_.materialize_compressed_to_uninitialized( + mask, MutableSpan(static_cast<T *>(dst), mask.size())); } bool try_assign_VArray(void *varray) const override @@ -422,7 +424,7 @@ template<typename T> class GVMutableArrayImpl_For_VMutableArray : public GVMutab protected: void get(const int64_t index, void *r_value) const override { - *(T *)r_value = varray_[index]; + *static_cast<T *>(r_value) = varray_[index]; } void get_to_uninitialized(const int64_t index, void *r_value) const override @@ -443,40 +445,42 @@ template<typename T> class GVMutableArrayImpl_For_VMutableArray : public GVMutab void set_by_relocate(const int64_t index, void *value) override { - T &value_ = *(T *)value; + T &value_ = *static_cast<T *>(value); varray_.set(index, std::move(value_)); value_.~T(); } void set_by_move(const int64_t index, void *value) override { - T &value_ = *(T *)value; + T &value_ = *static_cast<T *>(value); varray_.set(index, std::move(value_)); } void set_all(const void *src) override { - varray_.set_all(Span((T *)src, size_)); + varray_.set_all(Span(static_cast<const T *>(src), size_)); } void materialize(const IndexMask mask, void *dst) const override { - varray_.materialize(mask, MutableSpan((T *)dst, mask.min_array_size())); + varray_.materialize(mask, MutableSpan(static_cast<T *>(dst), mask.min_array_size())); } void materialize_to_uninitialized(const IndexMask mask, void *dst) const override { - varray_.materialize_to_uninitialized(mask, MutableSpan((T *)dst, mask.min_array_size())); + varray_.materialize_to_uninitialized( + mask, MutableSpan(static_cast<T *>(dst), mask.min_array_size())); } void materialize_compressed(const IndexMask mask, void *dst) const override { - varray_.materialize_compressed(mask, MutableSpan((T *)dst, mask.size())); + varray_.materialize_compressed(mask, MutableSpan(static_cast<T *>(dst), mask.size())); } void materialize_compressed_to_uninitialized(const IndexMask mask, void *dst) const override { - varray_.materialize_compressed_to_uninitialized(mask, MutableSpan((T *)dst, mask.size())); + varray_.materialize_compressed_to_uninitialized( + mask, MutableSpan(static_cast<T *>(dst), mask.size())); } bool try_assign_VArray(void *varray) const override @@ -709,7 +713,7 @@ inline bool GVMutableArray::try_assign_VMutableArray(VMutableArray<T> &varray) c inline GVMutableArrayImpl *GVMutableArray::get_impl() const { - return (GVMutableArrayImpl *)impl_; + return const_cast<GVMutableArrayImpl *>(static_cast<const GVMutableArrayImpl *>(impl_)); } /** \} */ diff --git a/source/blender/blenlib/BLI_hash.hh b/source/blender/blenlib/BLI_hash.hh index 25d7cd6aaf8..693d4a8a71c 100644 --- a/source/blender/blenlib/BLI_hash.hh +++ b/source/blender/blenlib/BLI_hash.hh @@ -85,7 +85,7 @@ template<typename T> struct DefaultHash { { if constexpr (std::is_enum_v<T>) { /* For enums use the value as hash directly. */ - return (uint64_t)value; + return uint64_t(value); } else { /* Try to call the `hash()` function on the value. */ @@ -119,7 +119,7 @@ template<typename T> struct DefaultHash<const T> { template<> struct DefaultHash<TYPE> { \ uint64_t operator()(TYPE value) const \ { \ - return static_cast<uint64_t>(value); \ + return uint64_t(value); \ } \ } @@ -158,7 +158,7 @@ template<> struct DefaultHash<double> { template<> struct DefaultHash<bool> { uint64_t operator()(bool value) const { - return static_cast<uint64_t>((value != false) * 1298191); + return uint64_t((value != false) * 1298191); } }; @@ -209,8 +209,8 @@ template<> struct DefaultHash<std::string_view> { template<typename T> struct DefaultHash<T *> { uint64_t operator()(const T *value) const { - uintptr_t ptr = reinterpret_cast<uintptr_t>(value); - uint64_t hash = static_cast<uint64_t>(ptr >> 4); + uintptr_t ptr = uintptr_t(value); + uint64_t hash = uint64_t(ptr >> 4); return hash; } }; diff --git a/source/blender/blenlib/BLI_hash_tables.hh b/source/blender/blenlib/BLI_hash_tables.hh index 156fe481828..85a8fd5d385 100644 --- a/source/blender/blenlib/BLI_hash_tables.hh +++ b/source/blender/blenlib/BLI_hash_tables.hh @@ -43,8 +43,7 @@ inline constexpr int64_t log2_floor_constexpr(const int64_t x) inline constexpr int64_t log2_ceil_constexpr(const int64_t x) { BLI_assert(x >= 0); - return (is_power_of_2_constexpr(static_cast<int>(x))) ? log2_floor_constexpr(x) : - log2_floor_constexpr(x) + 1; + return (is_power_of_2_constexpr(int(x))) ? log2_floor_constexpr(x) : log2_floor_constexpr(x) + 1; } inline constexpr int64_t power_of_2_max_constexpr(const int64_t x) @@ -71,17 +70,14 @@ inline constexpr int64_t ceil_division_by_fraction(const int64_t x, const int64_t numerator, const int64_t denominator) { - return static_cast<int64_t>( - ceil_division(static_cast<uint64_t>(x) * static_cast<uint64_t>(denominator), - static_cast<uint64_t>(numerator))); + return int64_t(ceil_division(uint64_t(x) * uint64_t(denominator), uint64_t(numerator))); } inline constexpr int64_t floor_multiplication_with_fraction(const int64_t x, const int64_t numerator, const int64_t denominator) { - return static_cast<int64_t>((static_cast<uint64_t>(x) * static_cast<uint64_t>(numerator) / - static_cast<uint64_t>(denominator))); + return int64_t((uint64_t(x) * uint64_t(numerator) / uint64_t(denominator))); } inline constexpr int64_t total_slot_amount_for_usable_slots( @@ -121,7 +117,7 @@ class LoadFactor { int64_t *r_total_slots, int64_t *r_usable_slots) const { - BLI_assert(is_power_of_2_i(static_cast<int>(min_total_slots))); + BLI_assert(is_power_of_2_i(int(min_total_slots))); int64_t total_slots = this->compute_total_slots(min_usable_slots, numerator_, denominator_); total_slots = std::max(total_slots, min_total_slots); diff --git a/source/blender/blenlib/BLI_linear_allocator.hh b/source/blender/blenlib/BLI_linear_allocator.hh index deb6ea3b5fd..07211de3aed 100644 --- a/source/blender/blenlib/BLI_linear_allocator.hh +++ b/source/blender/blenlib/BLI_linear_allocator.hh @@ -161,7 +161,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya void *pointer_buffer = this->allocate(element_amount * sizeof(void *), alignof(void *)); void *elements_buffer = this->allocate(element_amount * element_size, element_alignment); - MutableSpan<void *> pointers((void **)pointer_buffer, element_amount); + MutableSpan<void *> pointers(static_cast<void **>(pointer_buffer), element_amount); void *next_element_buffer = elements_buffer; for (int64_t i : IndexRange(element_amount)) { pointers[i] = next_element_buffer; diff --git a/source/blender/blenlib/BLI_map.hh b/source/blender/blenlib/BLI_map.hh index 95d1e344894..4322e3c0f2d 100644 --- a/source/blender/blenlib/BLI_map.hh +++ b/source/blender/blenlib/BLI_map.hh @@ -943,7 +943,7 @@ class Map { */ int64_t size_in_bytes() const { - return static_cast<int64_t>(sizeof(Slot) * slots_.size()); + return int64_t(sizeof(Slot) * slots_.size()); } /** @@ -987,7 +987,7 @@ class Map { max_load_factor_.compute_total_and_usable_slots( SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots); BLI_assert(total_slots >= 1); - const uint64_t new_slot_mask = static_cast<uint64_t>(total_slots) - 1; + const uint64_t new_slot_mask = uint64_t(total_slots) - 1; /** * Optimize the case when the map was empty beforehand. We can avoid some copies here. @@ -1261,7 +1261,7 @@ template<typename Key, typename Value> class StdUnorderedMapWrapper { public: int64_t size() const { - return static_cast<int64_t>(map_.size()); + return int64_t(map_.size()); } bool is_empty() const diff --git a/source/blender/blenlib/BLI_math_vec_types.hh b/source/blender/blenlib/BLI_math_vec_types.hh index 7f20881dfa3..c19317867a9 100644 --- a/source/blender/blenlib/BLI_math_vec_types.hh +++ b/source/blender/blenlib/BLI_math_vec_types.hh @@ -74,28 +74,28 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size> explicit vec_base(uint value) { for (int i = 0; i < Size; i++) { - (*this)[i] = static_cast<T>(value); + (*this)[i] = T(value); } } explicit vec_base(int value) { for (int i = 0; i < Size; i++) { - (*this)[i] = static_cast<T>(value); + (*this)[i] = T(value); } } explicit vec_base(float value) { for (int i = 0; i < Size; i++) { - (*this)[i] = static_cast<T>(value); + (*this)[i] = T(value); } } explicit vec_base(double value) { for (int i = 0; i < Size; i++) { - (*this)[i] = static_cast<T>(value); + (*this)[i] = T(value); } } @@ -126,53 +126,42 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size> /** Mixed scalar-vector constructors. */ template<typename U, BLI_ENABLE_IF_VEC(Size, == 3)> - constexpr vec_base(const vec_base<U, 2> &xy, T z) - : vec_base(static_cast<T>(xy.x), static_cast<T>(xy.y), z) + constexpr vec_base(const vec_base<U, 2> &xy, T z) : vec_base(T(xy.x), T(xy.y), z) { } template<typename U, BLI_ENABLE_IF_VEC(Size, == 3)> - constexpr vec_base(T x, const vec_base<U, 2> &yz) - : vec_base(x, static_cast<T>(yz.x), static_cast<T>(yz.y)) + constexpr vec_base(T x, const vec_base<U, 2> &yz) : vec_base(x, T(yz.x), T(yz.y)) { } template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)> - vec_base(vec_base<U, 3> xyz, T w) - : vec_base( - static_cast<T>(xyz.x), static_cast<T>(xyz.y), static_cast<T>(xyz.z), static_cast<T>(w)) + vec_base(vec_base<U, 3> xyz, T w) : vec_base(T(xyz.x), T(xyz.y), T(xyz.z), T(w)) { } template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)> - vec_base(T x, vec_base<U, 3> yzw) - : vec_base( - static_cast<T>(x), static_cast<T>(yzw.x), static_cast<T>(yzw.y), static_cast<T>(yzw.z)) + vec_base(T x, vec_base<U, 3> yzw) : vec_base(T(x), T(yzw.x), T(yzw.y), T(yzw.z)) { } template<typename U, typename V, BLI_ENABLE_IF_VEC(Size, == 4)> - vec_base(vec_base<U, 2> xy, vec_base<V, 2> zw) - : vec_base( - static_cast<T>(xy.x), static_cast<T>(xy.y), static_cast<T>(zw.x), static_cast<T>(zw.y)) + vec_base(vec_base<U, 2> xy, vec_base<V, 2> zw) : vec_base(T(xy.x), T(xy.y), T(zw.x), T(zw.y)) { } template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)> - vec_base(vec_base<U, 2> xy, T z, T w) - : vec_base(static_cast<T>(xy.x), static_cast<T>(xy.y), static_cast<T>(z), static_cast<T>(w)) + vec_base(vec_base<U, 2> xy, T z, T w) : vec_base(T(xy.x), T(xy.y), T(z), T(w)) { } template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)> - vec_base(T x, vec_base<U, 2> yz, T w) - : vec_base(static_cast<T>(x), static_cast<T>(yz.x), static_cast<T>(yz.y), static_cast<T>(w)) + vec_base(T x, vec_base<U, 2> yz, T w) : vec_base(T(x), T(yz.x), T(yz.y), T(w)) { } template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)> - vec_base(T x, T y, vec_base<U, 2> zw) - : vec_base(static_cast<T>(x), static_cast<T>(y), static_cast<T>(zw.x), static_cast<T>(zw.y)) + vec_base(T x, T y, vec_base<U, 2> zw) : vec_base(T(x), T(y), T(zw.x), T(zw.y)) { } @@ -182,7 +171,7 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size> explicit vec_base(const vec_base<U, OtherSize> &other) { for (int i = 0; i < Size; i++) { - (*this)[i] = static_cast<T>(other[i]); + (*this)[i] = T(other[i]); } } @@ -214,7 +203,7 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size> template<typename U> explicit vec_base(const vec_base<U, Size> &vec) { for (int i = 0; i < Size; i++) { - (*this)[i] = static_cast<T>(vec[i]); + (*this)[i] = T(vec[i]); } } diff --git a/source/blender/blenlib/BLI_math_vector.hh b/source/blender/blenlib/BLI_math_vector.hh index 384c4b49070..3067232e8ea 100644 --- a/source/blender/blenlib/BLI_math_vector.hh +++ b/source/blender/blenlib/BLI_math_vector.hh @@ -357,9 +357,9 @@ inline vec_base<T, 3> cross(const vec_base<T, 3> &a, const vec_base<T, 3> &b) inline vec_base<float, 3> cross_high_precision(const vec_base<float, 3> &a, const vec_base<float, 3> &b) { - return {(float)((double)a.y * b.z - (double)a.z * b.y), - (float)((double)a.z * b.x - (double)a.x * b.z), - (float)((double)a.x * b.y - (double)a.y * b.x)}; + return {float(double(a.y) * double(b.z) - double(a.z) * double(b.y)), + float(double(a.z) * double(b.x) - double(a.x) * double(b.z)), + float(double(a.x) * double(b.y) - double(a.y) * double(b.x))}; } template<typename T, BLI_ENABLE_IF((is_math_float_type<T>))> diff --git a/source/blender/blenlib/BLI_memory_utils.hh b/source/blender/blenlib/BLI_memory_utils.hh index c2ad3ea761a..0809f372b25 100644 --- a/source/blender/blenlib/BLI_memory_utils.hh +++ b/source/blender/blenlib/BLI_memory_utils.hh @@ -516,7 +516,7 @@ inline constexpr bool is_same_any_v = (std::is_same_v<T, Args> || ...); */ inline constexpr int64_t default_inline_buffer_capacity(size_t element_size) { - return (static_cast<int64_t>(element_size) < 100) ? 4 : 0; + return (int64_t(element_size) < 100) ? 4 : 0; } /** diff --git a/source/blender/blenlib/BLI_mesh_intersect.hh b/source/blender/blenlib/BLI_mesh_intersect.hh index 22ea83760aa..4ed1fe5f513 100644 --- a/source/blender/blenlib/BLI_mesh_intersect.hh +++ b/source/blender/blenlib/BLI_mesh_intersect.hh @@ -354,12 +354,12 @@ struct BoundingBox { void combine(const double3 &p) { - min.x = min_ff(min.x, static_cast<float>(p.x)); - min.y = min_ff(min.y, static_cast<float>(p.y)); - min.z = min_ff(min.z, static_cast<float>(p.z)); - max.x = max_ff(max.x, static_cast<float>(p.x)); - max.y = max_ff(max.y, static_cast<float>(p.y)); - max.z = max_ff(max.z, static_cast<float>(p.z)); + min.x = min_ff(min.x, float(p.x)); + min.y = min_ff(min.y, float(p.y)); + min.z = min_ff(min.z, float(p.z)); + max.x = max_ff(max.x, float(p.x)); + max.y = max_ff(max.y, float(p.y)); + max.z = max_ff(max.z, float(p.z)); } void combine(const BoundingBox &bb) diff --git a/source/blender/blenlib/BLI_probing_strategies.hh b/source/blender/blenlib/BLI_probing_strategies.hh index 2c001270495..d11bed9208e 100644 --- a/source/blender/blenlib/BLI_probing_strategies.hh +++ b/source/blender/blenlib/BLI_probing_strategies.hh @@ -223,7 +223,7 @@ using DefaultProbingStrategy = PythonProbingStrategy<>; int64_t linear_offset = 0; \ uint64_t current_hash = probing_strategy.get(); \ do { \ - int64_t R_SLOT_INDEX = static_cast<int64_t>((current_hash + static_cast<uint64_t>(linear_offset)) & MASK); + int64_t R_SLOT_INDEX = int64_t((current_hash + uint64_t(linear_offset)) & MASK); #define SLOT_PROBING_END() \ } while (++linear_offset < probing_strategy.linear_steps()); \ diff --git a/source/blender/blenlib/BLI_rand.hh b/source/blender/blenlib/BLI_rand.hh index 2c4484bd63f..e4f35bef217 100644 --- a/source/blender/blenlib/BLI_rand.hh +++ b/source/blender/blenlib/BLI_rand.hh @@ -29,7 +29,7 @@ class RandomNumberGenerator { void seed(uint32_t seed) { constexpr uint64_t lowseed = 0x330E; - x_ = (static_cast<uint64_t>(seed) << 16) | lowseed; + x_ = (uint64_t(seed) << 16) | lowseed; } /** @@ -40,13 +40,13 @@ class RandomNumberGenerator { uint32_t get_uint32() { this->step(); - return static_cast<uint32_t>(x_ >> 17); + return uint32_t(x_ >> 17); } int32_t get_int32() { this->step(); - return static_cast<int32_t>(x_ >> 17); + return int32_t(x_ >> 17); } /** @@ -63,7 +63,7 @@ class RandomNumberGenerator { */ double get_double() { - return (double)this->get_int32() / 0x80000000; + return double(this->get_int32()) / 0x80000000; } /** diff --git a/source/blender/blenlib/BLI_resource_scope.hh b/source/blender/blenlib/BLI_resource_scope.hh index 9826b694e16..d3f6d5e3f13 100644 --- a/source/blender/blenlib/BLI_resource_scope.hh +++ b/source/blender/blenlib/BLI_resource_scope.hh @@ -128,7 +128,7 @@ template<typename Func> inline void ResourceScope::add_destruct_call(Func func) { void *buffer = allocator_.allocate(sizeof(Func), alignof(Func)); new (buffer) Func(std::move(func)); - this->add(buffer, [](void *data) { (*(Func *)data)(); }); + this->add(buffer, [](void *data) { (*static_cast<Func *>(data))(); }); } /** diff --git a/source/blender/blenlib/BLI_set.hh b/source/blender/blenlib/BLI_set.hh index a1b6ad9754e..a5f62001798 100644 --- a/source/blender/blenlib/BLI_set.hh +++ b/source/blender/blenlib/BLI_set.hh @@ -626,7 +626,7 @@ class Set { max_load_factor_.compute_total_and_usable_slots( SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots); BLI_assert(total_slots >= 1); - const uint64_t new_slot_mask = static_cast<uint64_t>(total_slots) - 1; + const uint64_t new_slot_mask = uint64_t(total_slots) - 1; /** * Optimize the case when the set was empty beforehand. We can avoid some copies here. @@ -854,7 +854,7 @@ template<typename Key> class StdUnorderedSetWrapper { public: int64_t size() const { - return static_cast<int64_t>(set_.size()); + return int64_t(set_.size()); } bool is_empty() const diff --git a/source/blender/blenlib/BLI_span.hh b/source/blender/blenlib/BLI_span.hh index 0f3fcea1270..adfccd8d6fe 100644 --- a/source/blender/blenlib/BLI_span.hh +++ b/source/blender/blenlib/BLI_span.hh @@ -112,13 +112,11 @@ template<typename T> class Span { * Span<int> span = {1, 2, 3, 4}; * call_function_with_array(span); */ - constexpr Span(const std::initializer_list<T> &list) - : Span(list.begin(), static_cast<int64_t>(list.size())) + constexpr Span(const std::initializer_list<T> &list) : Span(list.begin(), int64_t(list.size())) { } - constexpr Span(const std::vector<T> &vector) - : Span(vector.data(), static_cast<int64_t>(vector.size())) + constexpr Span(const std::vector<T> &vector) : Span(vector.data(), int64_t(vector.size())) { } @@ -718,7 +716,7 @@ template<typename T> class MutableSpan { { BLI_assert((size_ * sizeof(T)) % sizeof(NewT) == 0); int64_t new_size = size_ * sizeof(T) / sizeof(NewT); - return MutableSpan<NewT>((NewT *)data_, new_size); + return MutableSpan<NewT>(reinterpret_cast<NewT *>(data_), new_size); } }; diff --git a/source/blender/blenlib/BLI_string_ref.hh b/source/blender/blenlib/BLI_string_ref.hh index 3823bd02630..b202769e3c3 100644 --- a/source/blender/blenlib/BLI_string_ref.hh +++ b/source/blender/blenlib/BLI_string_ref.hh @@ -178,12 +178,12 @@ constexpr StringRefBase::operator Span<char>() const */ inline StringRefBase::operator std::string() const { - return std::string(data_, static_cast<size_t>(size_)); + return std::string(data_, size_t(size_)); } constexpr StringRefBase::operator std::string_view() const { - return std::string_view(data_, static_cast<size_t>(size_)); + return std::string_view(data_, size_t(size_)); } constexpr const char *StringRefBase::begin() const @@ -209,7 +209,7 @@ constexpr IndexRange StringRefBase::index_range() const inline void StringRefBase::unsafe_copy(char *dst) const { if (size_ > 0) { - memcpy(dst, data_, static_cast<size_t>(size_)); + memcpy(dst, data_, size_t(size_)); } dst[size_] = '\0'; } @@ -308,86 +308,79 @@ constexpr int64_t index_or_npos_to_int64(size_t index) if (index == std::string_view::npos) { return StringRef::not_found; } - return static_cast<int64_t>(index); + return int64_t(index); } constexpr int64_t StringRefBase::find(char c, int64_t pos) const { BLI_assert(pos >= 0); - return index_or_npos_to_int64(std::string_view(*this).find(c, static_cast<size_t>(pos))); + return index_or_npos_to_int64(std::string_view(*this).find(c, size_t(pos))); } constexpr int64_t StringRefBase::find(StringRef str, int64_t pos) const { BLI_assert(pos >= 0); - return index_or_npos_to_int64(std::string_view(*this).find(str, static_cast<size_t>(pos))); + return index_or_npos_to_int64(std::string_view(*this).find(str, size_t(pos))); } constexpr int64_t StringRefBase::rfind(char c, int64_t pos) const { BLI_assert(pos >= 0); - return index_or_npos_to_int64(std::string_view(*this).rfind(c, static_cast<size_t>(pos))); + return index_or_npos_to_int64(std::string_view(*this).rfind(c, size_t(pos))); } constexpr int64_t StringRefBase::rfind(StringRef str, int64_t pos) const { BLI_assert(pos >= 0); - return index_or_npos_to_int64(std::string_view(*this).rfind(str, static_cast<size_t>(pos))); + return index_or_npos_to_int64(std::string_view(*this).rfind(str, size_t(pos))); } constexpr int64_t StringRefBase::find_first_of(StringRef chars, int64_t pos) const { BLI_assert(pos >= 0); - return index_or_npos_to_int64( - std::string_view(*this).find_first_of(chars, static_cast<size_t>(pos))); + return index_or_npos_to_int64(std::string_view(*this).find_first_of(chars, size_t(pos))); } constexpr int64_t StringRefBase::find_first_of(char c, int64_t pos) const { BLI_assert(pos >= 0); - return index_or_npos_to_int64( - std::string_view(*this).find_first_of(c, static_cast<size_t>(pos))); + return index_or_npos_to_int64(std::string_view(*this).find_first_of(c, size_t(pos))); } constexpr int64_t StringRefBase::find_last_of(StringRef chars, int64_t pos) const { BLI_assert(pos >= 0); - return index_or_npos_to_int64( - std::string_view(*this).find_last_of(chars, static_cast<size_t>(pos))); + return index_or_npos_to_int64(std::string_view(*this).find_last_of(chars, size_t(pos))); } constexpr int64_t StringRefBase::find_last_of(char c, int64_t pos) const { BLI_assert(pos >= 0); - return index_or_npos_to_int64(std::string_view(*this).find_last_of(c, static_cast<size_t>(pos))); + return index_or_npos_to_int64(std::string_view(*this).find_last_of(c, size_t(pos))); } constexpr int64_t StringRefBase::find_first_not_of(StringRef chars, int64_t pos) const { BLI_assert(pos >= 0); - return index_or_npos_to_int64( - std::string_view(*this).find_first_not_of(chars, static_cast<size_t>(pos))); + return index_or_npos_to_int64(std::string_view(*this).find_first_not_of(chars, size_t(pos))); } constexpr int64_t StringRefBase::find_first_not_of(char c, int64_t pos) const { BLI_assert(pos >= 0); - return index_or_npos_to_int64( - std::string_view(*this).find_first_not_of(c, static_cast<size_t>(pos))); + return index_or_npos_to_int64(std::string_view(*this).find_first_not_of(c, size_t(pos))); } constexpr int64_t StringRefBase::find_last_not_of(StringRef chars, int64_t pos) const { BLI_assert(pos >= 0); - return index_or_npos_to_int64( - std::string_view(*this).find_last_not_of(chars, static_cast<size_t>(pos))); + return index_or_npos_to_int64(std::string_view(*this).find_last_not_of(chars, size_t(pos))); } constexpr int64_t StringRefBase::find_last_not_of(char c, int64_t pos) const { BLI_assert(pos >= 0); - return index_or_npos_to_int64( - std::string_view(*this).find_last_not_of(c, static_cast<size_t>(pos))); + return index_or_npos_to_int64(std::string_view(*this).find_last_not_of(c, size_t(pos))); } constexpr StringRef StringRefBase::trim() const @@ -440,15 +433,14 @@ constexpr StringRefNull::StringRefNull() : StringRefBase("", 0) constexpr StringRefNull::StringRefNull(const char *str, const int64_t size) : StringRefBase(str, size) { - BLI_assert(static_cast<int64_t>(strlen(str)) == size); + BLI_assert(int64_t(strlen(str)) == size); } /** * Construct a StringRefNull from a null terminated c-string. The pointer must not point to * NULL. */ -inline StringRefNull::StringRefNull(const char *str) - : StringRefBase(str, static_cast<int64_t>(strlen(str))) +inline StringRefNull::StringRefNull(const char *str) : StringRefBase(str, int64_t(strlen(str))) { BLI_assert(str != nullptr); BLI_assert(data_[size_] == '\0'); @@ -504,7 +496,7 @@ constexpr StringRef::StringRef(StringRefNull other) : StringRefBase(other.data() * Create a StringRef from a null-terminated c-string. */ constexpr StringRef::StringRef(const char *str) - : StringRefBase(str, str ? static_cast<int64_t>(std::char_traits<char>::length(str)) : 0) + : StringRefBase(str, str ? int64_t(std::char_traits<char>::length(str)) : 0) { } @@ -560,7 +552,7 @@ constexpr char StringRef::operator[](int64_t index) const * second point points to a smaller address than the first one. */ constexpr StringRef::StringRef(const char *begin, const char *one_after_end) - : StringRefBase(begin, static_cast<int64_t>(one_after_end - begin)) + : StringRefBase(begin, int64_t(one_after_end - begin)) { BLI_assert(begin <= one_after_end); } @@ -570,12 +562,12 @@ constexpr StringRef::StringRef(const char *begin, const char *one_after_end) * will point to uninitialized memory. */ inline StringRef::StringRef(const std::string &str) - : StringRefBase(str.data(), static_cast<int64_t>(str.size())) + : StringRefBase(str.data(), int64_t(str.size())) { } constexpr StringRef::StringRef(std::string_view view) - : StringRefBase(view.data(), static_cast<int64_t>(view.size())) + : StringRefBase(view.data(), int64_t(view.size())) { } diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 9f68795a4a2..98177876f87 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -786,24 +786,23 @@ extern bool BLI_memory_is_zero(const void *arr, size_t arr_size); extern "C++" { \ inline constexpr _enum_type operator|(_enum_type a, _enum_type b) \ { \ - return static_cast<_enum_type>(static_cast<uint64_t>(a) | static_cast<uint64_t>(b)); \ + return (_enum_type)(uint64_t(a) | uint64_t(b)); \ } \ inline constexpr _enum_type operator&(_enum_type a, _enum_type b) \ { \ - return static_cast<_enum_type>(static_cast<uint64_t>(a) & static_cast<uint64_t>(b)); \ + return (_enum_type)(uint64_t(a) & uint64_t(b)); \ } \ inline constexpr _enum_type operator~(_enum_type a) \ { \ - return static_cast<_enum_type>(~static_cast<uint64_t>(a) & \ - (2 * static_cast<uint64_t>(_max_enum_value) - 1)); \ + return (_enum_type)(~uint64_t(a) & (2 * uint64_t(_max_enum_value) - 1)); \ } \ inline _enum_type &operator|=(_enum_type &a, _enum_type b) \ { \ - return a = static_cast<_enum_type>(static_cast<uint64_t>(a) | static_cast<uint64_t>(b)); \ + return a = (_enum_type)(uint64_t(a) | uint64_t(b)); \ } \ inline _enum_type &operator&=(_enum_type &a, _enum_type b) \ { \ - return a = static_cast<_enum_type>(static_cast<uint64_t>(a) & static_cast<uint64_t>(b)); \ + return a = (_enum_type)(uint64_t(a) & uint64_t(b)); \ } \ } /* extern "C++" */ diff --git a/source/blender/blenlib/BLI_vector.hh b/source/blender/blenlib/BLI_vector.hh index 1f5f97d754d..d07c9aeeb3d 100644 --- a/source/blender/blenlib/BLI_vector.hh +++ b/source/blender/blenlib/BLI_vector.hh @@ -96,8 +96,7 @@ class Vector { */ #ifndef NDEBUG int64_t debug_size_; -# define UPDATE_VECTOR_SIZE(ptr) \ - (ptr)->debug_size_ = static_cast<int64_t>((ptr)->end_ - (ptr)->begin_) +# define UPDATE_VECTOR_SIZE(ptr) (ptr)->debug_size_ = int64_t((ptr)->end_ - (ptr)->begin_) #else # define UPDATE_VECTOR_SIZE(ptr) ((void)0) #endif @@ -244,7 +243,7 @@ class Vector { /* Copy from inline buffer to newly allocated buffer. */ const int64_t capacity = size; begin_ = static_cast<T *>( - allocator_.allocate(sizeof(T) * static_cast<size_t>(capacity), alignof(T), AT)); + allocator_.allocate(sizeof(T) * size_t(capacity), alignof(T), AT)); capacity_end_ = begin_ + capacity; uninitialized_relocate_n(other.begin_, size, begin_); end_ = begin_ + size; @@ -693,7 +692,7 @@ class Vector { */ int64_t size() const { - const int64_t current_size = static_cast<int64_t>(end_ - begin_); + const int64_t current_size = int64_t(end_ - begin_); BLI_assert(debug_size_ == current_size); return current_size; } @@ -813,7 +812,7 @@ class Vector { { for (const T *current = begin_; current != end_; current++) { if (*current == value) { - return static_cast<int64_t>(current - begin_); + return int64_t(current - begin_); } } return -1; @@ -905,7 +904,7 @@ class Vector { */ int64_t capacity() const { - return static_cast<int64_t>(capacity_end_ - begin_); + return int64_t(capacity_end_ - begin_); } /** @@ -975,7 +974,7 @@ class Vector { const int64_t size = this->size(); T *new_array = static_cast<T *>( - allocator_.allocate(static_cast<size_t>(new_capacity) * sizeof(T), alignof(T), AT)); + allocator_.allocate(size_t(new_capacity) * sizeof(T), alignof(T), AT)); try { uninitialized_relocate_n(begin_, size, new_array); } diff --git a/source/blender/blenlib/BLI_vector_set.hh b/source/blender/blenlib/BLI_vector_set.hh index 1a42e776d3d..9e8cf5af59f 100644 --- a/source/blender/blenlib/BLI_vector_set.hh +++ b/source/blender/blenlib/BLI_vector_set.hh @@ -513,7 +513,7 @@ class VectorSet { */ int64_t size_in_bytes() const { - return static_cast<int64_t>(sizeof(Slot) * slots_.size() + sizeof(Key) * usable_slots_); + return int64_t(sizeof(Slot) * slots_.size() + sizeof(Key) * usable_slots_); } /** @@ -557,7 +557,7 @@ class VectorSet { max_load_factor_.compute_total_and_usable_slots( SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots); BLI_assert(total_slots >= 1); - const uint64_t new_slot_mask = static_cast<uint64_t>(total_slots) - 1; + const uint64_t new_slot_mask = uint64_t(total_slots) - 1; /* Optimize the case when the set was empty beforehand. We can avoid some copies here. */ if (this->size() == 0) { @@ -839,7 +839,7 @@ class VectorSet { Key *allocate_keys_array(const int64_t size) { return static_cast<Key *>( - slots_.allocator().allocate(sizeof(Key) * static_cast<size_t>(size), alignof(Key), AT)); + slots_.allocator().allocate(sizeof(Key) * size_t(size), alignof(Key), AT)); } void deallocate_keys_array(Key *keys) diff --git a/source/blender/blenlib/BLI_virtual_array.hh b/source/blender/blenlib/BLI_virtual_array.hh index 19ee2334bd9..217c8c00d66 100644 --- a/source/blender/blenlib/BLI_virtual_array.hh +++ b/source/blender/blenlib/BLI_virtual_array.hh @@ -324,7 +324,7 @@ class VArrayImpl_For_ArrayContainer : public VArrayImpl_For_Span<T> { public: VArrayImpl_For_ArrayContainer(Container container) - : VArrayImpl_For_Span<T>((int64_t)container.size()), container_(std::move(container)) + : VArrayImpl_For_Span<T>(int64_t(container.size())), container_(std::move(container)) { this->data_ = const_cast<T *>(container_.data()); } diff --git a/source/blender/blenlib/tests/BLI_linear_allocator_test.cc b/source/blender/blenlib/tests/BLI_linear_allocator_test.cc index 8f707789954..778f048a8e7 100644 --- a/source/blender/blenlib/tests/BLI_linear_allocator_test.cc +++ b/source/blender/blenlib/tests/BLI_linear_allocator_test.cc @@ -9,7 +9,7 @@ namespace blender::tests { static bool is_aligned(void *ptr, uint alignment) { - BLI_assert(is_power_of_2_i(static_cast<int>(alignment))); + BLI_assert(is_power_of_2_i(int(alignment))); return (POINTER_AS_UINT(ptr) & (alignment - 1)) == 0; } diff --git a/source/blender/blenlib/tests/BLI_span_test.cc b/source/blender/blenlib/tests/BLI_span_test.cc index 0d974786a1a..2dec84c4206 100644 --- a/source/blender/blenlib/tests/BLI_span_test.cc +++ b/source/blender/blenlib/tests/BLI_span_test.cc @@ -280,7 +280,7 @@ TEST(span, ContainsPtr) EXPECT_TRUE(a_span.contains_ptr(&a[0] + 1)); EXPECT_TRUE(a_span.contains_ptr(&a[0] + 2)); EXPECT_FALSE(a_span.contains_ptr(&a[0] + 3)); - int *ptr_before = reinterpret_cast<int *>(reinterpret_cast<uintptr_t>(a.data()) - 1); + int *ptr_before = reinterpret_cast<int *>(uintptr_t(a.data()) - 1); EXPECT_FALSE(a_span.contains_ptr(ptr_before)); EXPECT_FALSE(a_span.contains_ptr(&other)); } diff --git a/source/blender/blenlib/tests/BLI_stack_cxx_test.cc b/source/blender/blenlib/tests/BLI_stack_cxx_test.cc index 5c7f1106993..768d7199f68 100644 --- a/source/blender/blenlib/tests/BLI_stack_cxx_test.cc +++ b/source/blender/blenlib/tests/BLI_stack_cxx_test.cc @@ -118,19 +118,19 @@ TEST(stack, PushPopMany) Stack<int> stack; for (int i = 0; i < 1000; i++) { stack.push(i); - EXPECT_EQ(stack.size(), static_cast<uint>(i + 1)); + EXPECT_EQ(stack.size(), uint(i + 1)); } for (int i = 999; i > 50; i--) { EXPECT_EQ(stack.pop(), i); - EXPECT_EQ(stack.size(), static_cast<uint>(i)); + EXPECT_EQ(stack.size(), uint(i)); } for (int i = 51; i < 5000; i++) { stack.push(i); - EXPECT_EQ(stack.size(), static_cast<uint>(i + 1)); + EXPECT_EQ(stack.size(), uint(i + 1)); } for (int i = 4999; i >= 0; i--) { EXPECT_EQ(stack.pop(), i); - EXPECT_EQ(stack.size(), static_cast<uint>(i)); + EXPECT_EQ(stack.size(), uint(i)); } } diff --git a/source/blender/blenlib/tests/BLI_string_ref_test.cc b/source/blender/blenlib/tests/BLI_string_ref_test.cc index c3bb53f39d5..478b68a005e 100644 --- a/source/blender/blenlib/tests/BLI_string_ref_test.cc +++ b/source/blender/blenlib/tests/BLI_string_ref_test.cc @@ -357,7 +357,7 @@ TEST(string_ref, Constexpr) constexpr StringRef sref("World"); BLI_STATIC_ASSERT(sref[2] == 'r', ""); BLI_STATIC_ASSERT(sref.size() == 5, ""); - std::array<int, static_cast<std::size_t>(sref.find_first_of('o'))> compiles = {1}; + std::array<int, std::size_t(sref.find_first_of('o'))> compiles = {1}; EXPECT_EQ(compiles[0], 1); } } // namespace blender::tests diff --git a/source/blender/functions/intern/field.cc b/source/blender/functions/intern/field.cc index 8fb56d7aa11..dca12859b72 100644 --- a/source/blender/functions/intern/field.cc +++ b/source/blender/functions/intern/field.cc @@ -744,7 +744,7 @@ int FieldEvaluator::add(GField field, GVArray *varray_ptr) dst_varrays_.append(nullptr); output_pointer_infos_.append(OutputPointerInfo{ varray_ptr, [](void *dst, const GVArray &varray, ResourceScope &UNUSED(scope)) { - *(GVArray *)dst = varray; + *static_cast<GVArray *>(dst) = varray; }}); return field_index; } diff --git a/source/blender/functions/intern/multi_function_builder.cc b/source/blender/functions/intern/multi_function_builder.cc index f21de46b74e..8a09ed37e19 100644 --- a/source/blender/functions/intern/multi_function_builder.cc +++ b/source/blender/functions/intern/multi_function_builder.cc @@ -27,8 +27,8 @@ CustomMF_GenericConstant::CustomMF_GenericConstant(const CPPType &type, CustomMF_GenericConstant::~CustomMF_GenericConstant() { if (owns_value_) { - signature_.param_types[0].data_type().single_type().destruct((void *)value_); - MEM_freeN((void *)value_); + signature_.param_types[0].data_type().single_type().destruct(const_cast<void *>(value_)); + MEM_freeN(const_cast<void *>(value_)); } } diff --git a/source/blender/functions/intern/multi_function_procedure_executor.cc b/source/blender/functions/intern/multi_function_procedure_executor.cc index 554395b91d7..4fe3c27ea27 100644 --- a/source/blender/functions/intern/multi_function_procedure_executor.cc +++ b/source/blender/functions/intern/multi_function_procedure_executor.cc @@ -449,7 +449,7 @@ class VariableState : NonCopyable, NonMovable { } else { new_value = value_allocator.obtain_GVectorArray_not_owned( - *(GVectorArray *)caller_provided_storage_); + *static_cast<GVectorArray *>(caller_provided_storage_)); } if (value_ != nullptr) { if (value_->type == ValueType::GVVectorArray) { @@ -780,8 +780,9 @@ class VariableState : NonCopyable, NonMovable { break; } case ValueType::Span: { - const Span<bool> span((bool *)this->value_as<VariableValue_Span>()->data, - mask.min_array_size()); + const Span<bool> span( + static_cast<const bool *>(this->value_as<VariableValue_Span>()->data), + mask.min_array_size()); for (const int i : mask) { r_indices[span[i]].append(i); } @@ -790,7 +791,7 @@ class VariableState : NonCopyable, NonMovable { case ValueType::OneSingle: { auto *value_typed = this->value_as<VariableValue_OneSingle>(); BLI_assert(value_typed->is_initialized); - const bool condition = *(bool *)value_typed->data; + const bool condition = *static_cast<const bool *>(value_typed->data); r_indices[condition].extend(mask); break; } diff --git a/source/blender/nodes/geometry/node_geometry_tree.cc b/source/blender/nodes/geometry/node_geometry_tree.cc index 1a12d2c49e6..61a416765a3 100644 --- a/source/blender/nodes/geometry/node_geometry_tree.cc +++ b/source/blender/nodes/geometry/node_geometry_tree.cc @@ -48,7 +48,7 @@ static void geometry_node_tree_get_from_context(const bContext *C, } if (md->type == eModifierType_Nodes) { - NodesModifierData *nmd = (NodesModifierData *)md; + const NodesModifierData *nmd = reinterpret_cast<const NodesModifierData *>(md); if (nmd->node_group != nullptr) { *r_from = &ob->id; *r_id = &ob->id; diff --git a/source/blender/nodes/geometry/node_geometry_util.cc b/source/blender/nodes/geometry/node_geometry_util.cc index 8f673d2264e..3192459b8b5 100644 --- a/source/blender/nodes/geometry/node_geometry_util.cc +++ b/source/blender/nodes/geometry/node_geometry_util.cc @@ -36,7 +36,7 @@ std::optional<eCustomDataType> node_data_type_to_custom_data_type(const eNodeSoc std::optional<eCustomDataType> node_socket_to_custom_data_type(const bNodeSocket &socket) { - return node_data_type_to_custom_data_type(static_cast<eNodeSocketDatatype>(socket.type)); + return node_data_type_to_custom_data_type(eNodeSocketDatatype(socket.type)); } } // namespace blender::nodes diff --git a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc index 13a9cdc8600..4ad6efebfa8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc @@ -87,13 +87,13 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) static void node_update(bNodeTree *ntree, bNode *node) { const NodeAccumulateField &storage = node_storage(*node); - const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); + const eCustomDataType data_type = eCustomDataType(storage.data_type); - bNodeSocket *sock_in_vector = (bNodeSocket *)node->inputs.first; + bNodeSocket *sock_in_vector = static_cast<bNodeSocket *>(node->inputs.first); bNodeSocket *sock_in_float = sock_in_vector->next; bNodeSocket *sock_in_int = sock_in_float->next; - bNodeSocket *sock_out_vector = (bNodeSocket *)node->outputs.first; + bNodeSocket *sock_out_vector = static_cast<bNodeSocket *>(node->outputs.first); bNodeSocket *sock_out_float = sock_out_vector->next; bNodeSocket *sock_out_int = sock_out_float->next; @@ -373,8 +373,8 @@ template<typename T> std::string identifier_suffix() static void node_geo_exec(GeoNodeExecParams params) { const NodeAccumulateField &storage = node_storage(params.node()); - const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); - const eAttrDomain source_domain = static_cast<eAttrDomain>(storage.domain); + const eCustomDataType data_type = eCustomDataType(storage.data_type); + const eAttrDomain source_domain = eAttrDomain(storage.domain); Field<int> group_index_field = params.extract_input<Field<int>>("Group Index"); attribute_math::convert_to_static_type(data_type, [&](auto dummy) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc index 8c11288efdd..c9df66f1eea 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc @@ -50,9 +50,9 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) static void node_update(bNodeTree *ntree, bNode *node) { const NodeGeometryAttributeCapture &storage = node_storage(*node); - const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); + const eCustomDataType data_type = eCustomDataType(storage.data_type); - bNodeSocket *socket_value_geometry = (bNodeSocket *)node->inputs.first; + bNodeSocket *socket_value_geometry = static_cast<bNodeSocket *>(node->inputs.first); bNodeSocket *socket_value_vector = socket_value_geometry->next; bNodeSocket *socket_value_float = socket_value_vector->next; bNodeSocket *socket_value_color4f = socket_value_float->next; @@ -65,7 +65,7 @@ static void node_update(bNodeTree *ntree, bNode *node) nodeSetSocketAvailability(ntree, socket_value_boolean, data_type == CD_PROP_BOOL); nodeSetSocketAvailability(ntree, socket_value_int32, data_type == CD_PROP_INT32); - bNodeSocket *out_socket_value_geometry = (bNodeSocket *)node->outputs.first; + bNodeSocket *out_socket_value_geometry = static_cast<bNodeSocket *>(node->outputs.first); bNodeSocket *out_socket_value_vector = out_socket_value_geometry->next; bNodeSocket *out_socket_value_float = out_socket_value_vector->next; bNodeSocket *out_socket_value_color4f = out_socket_value_float->next; @@ -165,8 +165,8 @@ static void node_geo_exec(GeoNodeExecParams params) } const NodeGeometryAttributeCapture &storage = node_storage(params.node()); - const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); - const eAttrDomain domain = static_cast<eAttrDomain>(storage.domain); + const eCustomDataType data_type = eCustomDataType(storage.data_type); + const eAttrDomain domain = eAttrDomain(storage.domain); const std::string output_identifier = "Attribute" + identifier_suffix(data_type); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc index f6ea6073459..a59236235a5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc @@ -42,7 +42,7 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) static void node_update(bNodeTree *ntree, bNode *node) { - bNodeSocket *point_socket = (bNodeSocket *)node->outputs.first; + bNodeSocket *point_socket = static_cast<bNodeSocket *>(node->outputs.first); bNodeSocket *edge_socket = point_socket->next; bNodeSocket *face_socket = edge_socket->next; bNodeSocket *face_corner_socket = face_socket->next; diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc index af0007c2fa4..0ab0081b9cf 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc @@ -54,12 +54,12 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) static void node_update(bNodeTree *ntree, bNode *node) { - bNodeSocket *socket_geo = (bNodeSocket *)node->inputs.first; + bNodeSocket *socket_geo = static_cast<bNodeSocket *>(node->inputs.first); bNodeSocket *socket_selection = socket_geo->next; bNodeSocket *socket_float_attr = socket_selection->next; bNodeSocket *socket_float3_attr = socket_float_attr->next; - bNodeSocket *socket_float_mean = (bNodeSocket *)node->outputs.first; + bNodeSocket *socket_float_mean = static_cast<bNodeSocket *>(node->outputs.first); bNodeSocket *socket_float_median = socket_float_mean->next; bNodeSocket *socket_float_sum = socket_float_median->next; bNodeSocket *socket_float_min = socket_float_sum->next; @@ -77,7 +77,7 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *socket_vector_std = socket_vector_range->next; bNodeSocket *socket_vector_variance = socket_vector_std->next; - const eCustomDataType data_type = static_cast<eCustomDataType>(node->custom1); + const eCustomDataType data_type = eCustomDataType(node->custom1); nodeSetSocketAvailability(ntree, socket_float_attr, data_type == CD_PROP_FLOAT); nodeSetSocketAvailability(ntree, socket_float_mean, data_type == CD_PROP_FLOAT); @@ -184,8 +184,8 @@ static void node_geo_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.get_input<GeometrySet>("Geometry"); const bNode &node = params.node(); - const eCustomDataType data_type = static_cast<eCustomDataType>(node.custom1); - const eAttrDomain domain = static_cast<eAttrDomain>(node.custom2); + const eCustomDataType data_type = eCustomDataType(node.custom1); + const eAttrDomain domain = eAttrDomain(node.custom2); Vector<const GeometryComponent *> components = geometry_set.get_components_for_read(); const Field<bool> selection_field = params.get_input<Field<bool>>("Selection"); diff --git a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc index c8c58945bce..341f58f176b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc @@ -37,7 +37,7 @@ static void node_update(bNodeTree *ntree, bNode *node) { GeometryNodeBooleanOperation operation = (GeometryNodeBooleanOperation)node->custom1; - bNodeSocket *geometry_1_socket = (bNodeSocket *)node->inputs.first; + bNodeSocket *geometry_1_socket = static_cast<bNodeSocket *>(node->inputs.first); bNodeSocket *geometry_2_socket = geometry_1_socket->next; switch (operation) { @@ -148,7 +148,8 @@ static void node_geo_exec(GeoNodeExecParams params) } MEM_SAFE_FREE(result->mat); - result->mat = (Material **)MEM_malloc_arrayN(materials.size(), sizeof(Material *), __func__); + result->mat = static_cast<Material **>( + MEM_malloc_arrayN(materials.size(), sizeof(Material *), __func__)); result->totcol = materials.size(); MutableSpan(result->mat, result->totcol).copy_from(materials); diff --git a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc index 54a061993a3..f4e8788cb8d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc @@ -57,8 +57,8 @@ static void node_geo_exec(GeoNodeExecParams params) return; } const Object *self_object = params.self_object(); - const bool is_recursive = BKE_collection_has_object_recursive_instanced(collection, - (Object *)self_object); + const bool is_recursive = BKE_collection_has_object_recursive_instanced( + collection, const_cast<Object *>(self_object)); if (is_recursive) { params.error_message_add(NodeWarningType::Error, "Collection contains current object"); params.set_default_remaining_outputs(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc index 4586bb24464..50863b2031a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc @@ -48,7 +48,7 @@ static void node_update(bNodeTree *ntree, bNode *node) { const NodeGeometryCurveFillet &storage = node_storage(*node); const GeometryNodeCurveFilletMode mode = (GeometryNodeCurveFilletMode)storage.mode; - bNodeSocket *poly_socket = ((bNodeSocket *)node->inputs.first)->next; + bNodeSocket *poly_socket = static_cast<bNodeSocket *>(node->inputs.first)->next; nodeSetSocketAvailability(ntree, poly_socket, mode == GEO_NODE_CURVE_FILLET_POLY); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc index abf9135bce8..85a8ccc3192 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc @@ -106,7 +106,7 @@ static void node_update(bNodeTree *ntree, bNode *node) const NodeGeometryCurvePrimitiveArc &storage = node_storage(*node); const GeometryNodeCurvePrimitiveArcMode mode = (GeometryNodeCurvePrimitiveArcMode)storage.mode; - bNodeSocket *start_socket = ((bNodeSocket *)node->inputs.first)->next; + bNodeSocket *start_socket = static_cast<bNodeSocket *>(node->inputs.first)->next; bNodeSocket *middle_socket = start_socket->next; bNodeSocket *end_socket = middle_socket->next; @@ -116,7 +116,7 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *offset_angle_socket = sweep_angle_socket->next; - bNodeSocket *center_out_socket = ((bNodeSocket *)node->outputs.first)->next; + bNodeSocket *center_out_socket = static_cast<bNodeSocket *>(node->outputs.first)->next; bNodeSocket *normal_out_socket = center_out_socket->next; bNodeSocket *radius_out_socket = normal_out_socket->next; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc index 4c5a8faa4b2..12df6f76a28 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc @@ -75,12 +75,12 @@ static void node_update(bNodeTree *ntree, bNode *node) const GeometryNodeCurvePrimitiveCircleMode mode = (GeometryNodeCurvePrimitiveCircleMode) storage.mode; - bNodeSocket *start_socket = ((bNodeSocket *)node->inputs.first)->next; + bNodeSocket *start_socket = static_cast<bNodeSocket *>(node->inputs.first)->next; bNodeSocket *middle_socket = start_socket->next; bNodeSocket *end_socket = middle_socket->next; bNodeSocket *radius_socket = end_socket->next; - bNodeSocket *center_socket = ((bNodeSocket *)node->outputs.first)->next; + bNodeSocket *center_socket = static_cast<bNodeSocket *>(node->outputs.first)->next; nodeSetSocketAvailability( ntree, start_socket, mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc index 4cfa606d8eb..9f098674fe5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc @@ -57,7 +57,7 @@ static void node_update(bNodeTree *ntree, bNode *node) const NodeGeometryCurvePrimitiveLine &storage = node_storage(*node); const GeometryNodeCurvePrimitiveLineMode mode = (GeometryNodeCurvePrimitiveLineMode)storage.mode; - bNodeSocket *p2_socket = ((bNodeSocket *)node->inputs.first)->next; + bNodeSocket *p2_socket = static_cast<bNodeSocket *>(node->inputs.first)->next; bNodeSocket *direction_socket = p2_socket->next; bNodeSocket *length_socket = direction_socket->next; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc index fec4e31701f..9536917077e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc @@ -83,10 +83,9 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) static void node_update(bNodeTree *ntree, bNode *node) { const NodeGeometryCurvePrimitiveQuad &storage = node_storage(*node); - GeometryNodeCurvePrimitiveQuadMode mode = static_cast<GeometryNodeCurvePrimitiveQuadMode>( - storage.mode); + GeometryNodeCurvePrimitiveQuadMode mode = GeometryNodeCurvePrimitiveQuadMode(storage.mode); - bNodeSocket *width = ((bNodeSocket *)node->inputs.first); + bNodeSocket *width = static_cast<bNodeSocket *>(node->inputs.first); bNodeSocket *height = width->next; bNodeSocket *bottom = height->next; bNodeSocket *top = bottom->next; @@ -140,7 +139,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) search_link_ops_for_declarations(params, declaration.outputs()); } else if (params.node_tree().typeinfo->validate_link( - static_cast<eNodeSocketDatatype>(params.other_socket().type), SOCK_FLOAT)) { + eNodeSocketDatatype(params.other_socket().type), SOCK_FLOAT)) { params.add_item(IFACE_("Width"), SocketSearchOp{"Width", GEO_NODE_CURVE_PRIMITIVE_QUAD_MODE_RECTANGLE}); params.add_item(IFACE_("Height"), diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc index 41eafe2a741..db71371d464 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc @@ -44,7 +44,7 @@ static void node_update(bNodeTree *ntree, bNode *node) const NodeGeometryCurveResample &storage = node_storage(*node); const GeometryNodeCurveResampleMode mode = (GeometryNodeCurveResampleMode)storage.mode; - bNodeSocket *count_socket = ((bNodeSocket *)node->inputs.first)->next->next; + bNodeSocket *count_socket = static_cast<bNodeSocket *>(node->inputs.first)->next->next; bNodeSocket *length_socket = count_socket->next; nodeSetSocketAvailability(ntree, count_socket, mode == GEO_NODE_CURVE_RESAMPLE_COUNT); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc index e80b600a740..186c00ddda0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc @@ -52,7 +52,7 @@ static void node_update(bNodeTree *ntree, bNode *node) const NodeGeometryCurveSample &storage = node_storage(*node); const GeometryNodeCurveSampleMode mode = (GeometryNodeCurveSampleMode)storage.mode; - bNodeSocket *factor = ((bNodeSocket *)node->inputs.first)->next; + bNodeSocket *factor = static_cast<bNodeSocket *>(node->inputs.first)->next; bNodeSocket *length = factor->next; nodeSetSocketAvailability(ntree, factor, mode == GEO_NODE_CURVE_SAMPLE_FACTOR); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index 799a65ec3d1..e05d80bd722 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -58,7 +58,7 @@ static void node_update(bNodeTree *ntree, bNode *node) const NodeGeometryCurveToPoints &storage = node_storage(*node); const GeometryNodeCurveResampleMode mode = (GeometryNodeCurveResampleMode)storage.mode; - bNodeSocket *count_socket = ((bNodeSocket *)node->inputs.first)->next; + bNodeSocket *count_socket = static_cast<bNodeSocket *>(node->inputs.first)->next; bNodeSocket *length_socket = count_socket->next; nodeSetSocketAvailability(ntree, count_socket, mode == GEO_NODE_CURVE_RESAMPLE_COUNT); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc index 1576b573058..a5a82557a4f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc @@ -64,7 +64,7 @@ static void node_update(bNodeTree *ntree, bNode *node) const NodeGeometryCurveTrim &storage = node_storage(*node); const GeometryNodeCurveSampleMode mode = (GeometryNodeCurveSampleMode)storage.mode; - bNodeSocket *start_fac = ((bNodeSocket *)node->inputs.first)->next; + bNodeSocket *start_fac = static_cast<bNodeSocket *>(node->inputs.first)->next; bNodeSocket *end_fac = start_fac->next; bNodeSocket *start_len = end_fac->next; bNodeSocket *end_len = start_len->next; @@ -95,8 +95,8 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) search_link_ops_for_declarations(params, declaration.inputs().take_front(1)); if (params.in_out() == SOCK_IN) { - if (params.node_tree().typeinfo->validate_link( - static_cast<eNodeSocketDatatype>(params.other_socket().type), SOCK_FLOAT)) { + if (params.node_tree().typeinfo->validate_link(eNodeSocketDatatype(params.other_socket().type), + SOCK_FLOAT)) { params.add_item(IFACE_("Start (Factor)"), SocketSearchOp{"Start", GEO_NODE_CURVE_SAMPLE_FACTOR}); params.add_item(IFACE_("End (Factor)"), SocketSearchOp{"End", GEO_NODE_CURVE_SAMPLE_FACTOR}); diff --git a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc index 851ca622d6b..07226772447 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc @@ -1163,7 +1163,7 @@ static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { const bNode *node = static_cast<bNode *>(ptr->data); const NodeGeometryDeleteGeometry &storage = node_storage(*node); - const eAttrDomain domain = static_cast<eAttrDomain>(storage.domain); + const eAttrDomain domain = eAttrDomain(storage.domain); uiItemR(layout, ptr, "domain", 0, "", ICON_NONE); /* Only show the mode when it is relevant. */ @@ -1192,7 +1192,7 @@ static void node_geo_exec(GeoNodeExecParams params) params.extract_input<Field<bool>>("Selection")); const NodeGeometryDeleteGeometry &storage = node_storage(params.node()); - const eAttrDomain domain = static_cast<eAttrDomain>(storage.domain); + const eAttrDomain domain = eAttrDomain(storage.domain); const GeometryNodeDeleteGeometryMode mode = (GeometryNodeDeleteGeometryMode)storage.mode; if (domain == ATTR_DOMAIN_INSTANCE) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc index 83bff91c4b3..9910ccb84fa 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc @@ -65,10 +65,10 @@ static void node_distribute_points_in_volume_init(bNodeTree *UNUSED(ntree), bNod static void node_distribute_points_in_volume_update(bNodeTree *ntree, bNode *node) { const NodeGeometryDistributePointsInVolume &storage = node_storage(*node); - GeometryNodeDistributePointsInVolumeMode mode = - static_cast<GeometryNodeDistributePointsInVolumeMode>(storage.mode); + GeometryNodeDistributePointsInVolumeMode mode = GeometryNodeDistributePointsInVolumeMode( + storage.mode); - bNodeSocket *sock_density = ((bNodeSocket *)(node->inputs.first))->next; + bNodeSocket *sock_density = static_cast<bNodeSocket *>(node->inputs.first)->next; bNodeSocket *sock_seed = sock_density->next; bNodeSocket *sock_spacing = sock_seed->next; bNodeSocket *sock_threshold = sock_spacing->next; @@ -185,8 +185,8 @@ static void geo_node_distribute_points_in_volume_exec(GeoNodeExecParams params) GeometrySet geometry_set = params.extract_input<GeometrySet>("Volume"); const NodeGeometryDistributePointsInVolume &storage = node_storage(params.node()); - const GeometryNodeDistributePointsInVolumeMode mode = - static_cast<GeometryNodeDistributePointsInVolumeMode>(storage.mode); + const GeometryNodeDistributePointsInVolumeMode mode = GeometryNodeDistributePointsInVolumeMode( + storage.mode); float density; int seed; diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc index 2ea9958bbd8..b3575332745 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc @@ -69,8 +69,8 @@ static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) static void node_point_distribute_points_on_faces_update(bNodeTree *ntree, bNode *node) { - bNodeSocket *sock_distance_min = (bNodeSocket *)BLI_findlink(&node->inputs, 2); - bNodeSocket *sock_density_max = (bNodeSocket *)sock_distance_min->next; + bNodeSocket *sock_distance_min = static_cast<bNodeSocket *>(BLI_findlink(&node->inputs, 2)); + bNodeSocket *sock_density_max = static_cast<bNodeSocket *>(sock_distance_min->next); bNodeSocket *sock_density = sock_density_max->next; bNodeSocket *sock_density_factor = sock_density->next; nodeSetSocketAvailability(ntree, @@ -511,8 +511,8 @@ static void node_geo_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input<GeometrySet>("Mesh"); - const GeometryNodeDistributePointsOnFacesMode method = - static_cast<GeometryNodeDistributePointsOnFacesMode>(params.node().custom1); + const GeometryNodeDistributePointsOnFacesMode method = GeometryNodeDistributePointsOnFacesMode( + params.node().custom1); const int seed = params.get_input<int>("Seed") * 5383843; const Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"); diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc index 5614d5b66dc..c8095c7362b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc @@ -49,9 +49,9 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) static void node_update(bNodeTree *ntree, bNode *node) { const NodeGeometryExtrudeMesh &storage = node_storage(*node); - const GeometryNodeExtrudeMeshMode mode = static_cast<GeometryNodeExtrudeMeshMode>(storage.mode); + const GeometryNodeExtrudeMeshMode mode = GeometryNodeExtrudeMeshMode(storage.mode); - bNodeSocket *individual_socket = (bNodeSocket *)node->inputs.last; + bNodeSocket *individual_socket = static_cast<bNodeSocket *>(node->inputs.last); nodeSetSocketAvailability(ntree, individual_socket, mode == GEO_NODE_EXTRUDE_MESH_FACES); } @@ -1313,7 +1313,7 @@ static void node_geo_exec(GeoNodeExecParams params) Field<float3> offset_field = params.extract_input<Field<float3>>("Offset"); Field<float> scale_field = params.extract_input<Field<float>>("Offset Scale"); const NodeGeometryExtrudeMesh &storage = node_storage(params.node()); - GeometryNodeExtrudeMeshMode mode = static_cast<GeometryNodeExtrudeMeshMode>(storage.mode); + GeometryNodeExtrudeMeshMode mode = GeometryNodeExtrudeMeshMode(storage.mode); /* Create a combined field from the offset and the scale so the field evaluator * can take care of the multiplication and to simplify each extrude function. */ diff --git a/source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc b/source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc index 3c9889b664b..4d7e4b00c5a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc @@ -44,7 +44,7 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) static void node_update(bNodeTree *ntree, bNode *node) { - const eCustomDataType data_type = static_cast<eCustomDataType>(node->custom2); + const eCustomDataType data_type = eCustomDataType(node->custom2); bNodeSocket *sock_index = static_cast<bNodeSocket *>(node->inputs.first); bNodeSocket *sock_in_float = sock_index->next; @@ -165,8 +165,8 @@ static StringRefNull identifier_suffix(eCustomDataType data_type) static void node_geo_exec(GeoNodeExecParams params) { const bNode &node = params.node(); - const eAttrDomain domain = static_cast<eAttrDomain>(node.custom1); - const eCustomDataType data_type = static_cast<eCustomDataType>(node.custom2); + const eAttrDomain domain = eAttrDomain(node.custom1); + const eCustomDataType data_type = eCustomDataType(node.custom2); Field<int> index_field = params.extract_input<Field<int>>("Index"); attribute_math::convert_to_static_type(data_type, [&](auto dummy) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc index 725fc6d6db7..62d0fe3f9fa 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc @@ -292,7 +292,7 @@ class ImageFieldsFunction : public fn::MultiFunction { 1, "Color"); MutableSpan<float> r_alpha = params.uninitialized_single_output_if_required<float>(2, "Alpha"); - MutableSpan<float4> color_data{(float4 *)r_color.data(), r_color.size()}; + MutableSpan<float4> color_data{reinterpret_cast<float4 *>(r_color.data()), r_color.size()}; /* Sample image texture. */ switch (interpolation_) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_material.cc b/source/blender/nodes/geometry/nodes/node_geo_input_material.cc index 19882c4966d..6f3c6d23bd2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_material.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_material.cc @@ -19,7 +19,7 @@ static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) static void node_geo_exec(GeoNodeExecParams params) { - Material *material = (Material *)params.node().id; + Material *material = reinterpret_cast<Material *>(params.node().id); params.set_output("Material", material); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc index 72c45de7b0f..90fa47c8217 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc @@ -40,7 +40,8 @@ class PlanarFieldInput final : public bke::MeshFieldInput { const Span<MVert> verts = mesh.verts(); const Span<MPoly> polys = mesh.polys(); const Span<MLoop> loops = mesh.loops(); - const Span<float3> poly_normals{(float3 *)BKE_mesh_poly_normals_ensure(&mesh), mesh.totpoly}; + const Span<float3> poly_normals{ + reinterpret_cast<const float3 *>(BKE_mesh_poly_normals_ensure(&mesh)), mesh.totpoly}; bke::MeshFieldContext context{mesh, ATTR_DOMAIN_FACE}; fn::FieldEvaluator evaluator{context, polys.size()}; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc index da09d3650e3..8973c1db319 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc @@ -37,9 +37,9 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) static void node_update(bNodeTree *ntree, bNode *node) { const NodeGeometryInputNamedAttribute &storage = node_storage(*node); - const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); + const eCustomDataType data_type = eCustomDataType(storage.data_type); - bNodeSocket *socket_vector = (bNodeSocket *)node->outputs.first; + bNodeSocket *socket_vector = static_cast<bNodeSocket *>(node->outputs.first); bNodeSocket *socket_float = socket_vector->next; bNodeSocket *socket_color4f = socket_float->next; bNodeSocket *socket_boolean = socket_color4f->next; @@ -59,7 +59,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) if (params.in_out() == SOCK_OUT) { const std::optional<eCustomDataType> type = node_data_type_to_custom_data_type( - static_cast<eNodeSocketDatatype>(params.other_socket().type)); + eNodeSocketDatatype(params.other_socket().type)); if (type && *type != CD_PROP_STRING) { /* The input and output sockets have the same name. */ params.add_item(IFACE_("Attribute"), [type](LinkSearchOpParams ¶ms) { @@ -74,7 +74,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) static void node_geo_exec(GeoNodeExecParams params) { const NodeGeometryInputNamedAttribute &storage = node_storage(params.node()); - const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); + const eCustomDataType data_type = eCustomDataType(storage.data_type); const std::string name = params.extract_input<std::string>("Name"); diff --git a/source/blender/nodes/geometry/nodes/node_geo_interpolate_domain.cc b/source/blender/nodes/geometry/nodes/node_geo_interpolate_domain.cc index 8e38ef14aba..df1427ac5b9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_interpolate_domain.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_interpolate_domain.cc @@ -42,7 +42,7 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) static void node_update(bNodeTree *ntree, bNode *node) { - const eCustomDataType data_type = static_cast<eCustomDataType>(node->custom2); + const eCustomDataType data_type = eCustomDataType(node->custom2); bNodeSocket *sock_in_float = static_cast<bNodeSocket *>(node->inputs.first); bNodeSocket *sock_in_int = sock_in_float->next; @@ -135,8 +135,8 @@ static StringRefNull identifier_suffix(eCustomDataType data_type) static void node_geo_exec(GeoNodeExecParams params) { const bNode &node = params.node(); - const eAttrDomain domain = static_cast<eAttrDomain>(node.custom1); - const eCustomDataType data_type = static_cast<eCustomDataType>(node.custom2); + const eAttrDomain domain = eAttrDomain(node.custom1); + const eCustomDataType data_type = eCustomDataType(node.custom2); attribute_math::convert_to_static_type(data_type, [&](auto dummy) { using T = decltype(dummy); 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 9f01989fc02..bd36b85180f 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 @@ -754,7 +754,7 @@ static void node_init(bNodeTree *UNUSED(ntree), bNode *node) static void node_update(bNodeTree *ntree, bNode *node) { - bNodeSocket *vertices_socket = (bNodeSocket *)node->inputs.first; + bNodeSocket *vertices_socket = static_cast<bNodeSocket *>(node->inputs.first); bNodeSocket *rings_socket = vertices_socket->next; bNodeSocket *fill_subdiv_socket = rings_socket->next; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc index 301d46e586f..587999f3d00 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc @@ -66,7 +66,7 @@ static void node_init(bNodeTree *UNUSED(ntree), bNode *node) static void node_update(bNodeTree *ntree, bNode *node) { - bNodeSocket *vertices_socket = (bNodeSocket *)node->inputs.first; + bNodeSocket *vertices_socket = static_cast<bNodeSocket *>(node->inputs.first); bNodeSocket *rings_socket = vertices_socket->next; bNodeSocket *fill_subdiv_socket = rings_socket->next; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc index aa9a2e9013f..8287c6a6714 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc @@ -47,7 +47,7 @@ static Mesh *create_ico_sphere_mesh(const int subdivisions, const float radius) BMeshToMeshParams params{}; params.calc_object_remap = false; - Mesh *mesh = (Mesh *)BKE_id_new_nomain(ID_ME, nullptr); + Mesh *mesh = reinterpret_cast<Mesh *>(BKE_id_new_nomain(ID_ME, nullptr)); BKE_id_material_eval_ensure_default_slot(&mesh->id); BM_mesh_bm_to_me(nullptr, bm, mesh, ¶ms); BM_mesh_free(bm); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc index fcc76fcdc1e..a755fd1a75d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc @@ -65,7 +65,7 @@ static void node_init(bNodeTree *UNUSED(ntree), bNode *node) static void node_update(bNodeTree *ntree, bNode *node) { - bNodeSocket *count_socket = (bNodeSocket *)node->inputs.first; + bNodeSocket *count_socket = static_cast<bNodeSocket *>(node->inputs.first); bNodeSocket *resolution_socket = count_socket->next; bNodeSocket *start_socket = resolution_socket->next; bNodeSocket *end_and_offset_socket = start_socket->next; @@ -97,7 +97,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) return; } else if (params.node_tree().typeinfo->validate_link( - static_cast<eNodeSocketDatatype>(params.other_socket().type), SOCK_FLOAT)) { + eNodeSocketDatatype(params.other_socket().type), SOCK_FLOAT)) { params.add_item(IFACE_("Count"), [](LinkSearchOpParams ¶ms) { bNode &node = params.add_node("GeometryNodeMeshLine"); node_storage(node).mode = GEO_NODE_MESH_LINE_MODE_OFFSET; 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 1c8e7eec6c0..4b43693f0f6 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 @@ -309,7 +309,8 @@ static Mesh *create_uv_sphere_mesh(const float radius, const int segments, const threading::parallel_invoke( 1024 < segments * rings, [&]() { - MutableSpan vert_normals{(float3 *)BKE_mesh_vertex_normals_for_write(mesh), mesh->totvert}; + MutableSpan vert_normals{ + reinterpret_cast<float3 *>(BKE_mesh_vertex_normals_for_write(mesh)), mesh->totvert}; calculate_sphere_vertex_data(verts, vert_normals, radius, segments, rings); BKE_mesh_vertex_normals_clear_dirty(mesh); }, diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc index f6fa5c99013..de04f0561e5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc @@ -59,24 +59,22 @@ static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) static void node_init(bNodeTree *UNUSED(tree), bNode *node) { - NodeGeometryMeshToVolume *data = (NodeGeometryMeshToVolume *)MEM_callocN( - sizeof(NodeGeometryMeshToVolume), __func__); + NodeGeometryMeshToVolume *data = MEM_cnew<NodeGeometryMeshToVolume>(__func__); data->resolution_mode = MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT; node->storage = data; } static void node_update(bNodeTree *ntree, bNode *node) { - NodeGeometryMeshToVolume *data = (NodeGeometryMeshToVolume *)node->storage; + NodeGeometryMeshToVolume &data = node_storage(*node); bNodeSocket *voxel_size_socket = nodeFindSocket(node, SOCK_IN, "Voxel Size"); bNodeSocket *voxel_amount_socket = nodeFindSocket(node, SOCK_IN, "Voxel Amount"); nodeSetSocketAvailability(ntree, voxel_amount_socket, - data->resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT); - nodeSetSocketAvailability(ntree, - voxel_size_socket, - data->resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_SIZE); + data.resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT); + nodeSetSocketAvailability( + ntree, voxel_size_socket, data.resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_SIZE); } #ifdef WITH_OPENVDB @@ -126,7 +124,7 @@ static Volume *create_volume_from_mesh(const Mesh &mesh, GeoNodeExecParams ¶ exterior_band_width, mesh_to_volume_space_transform); - Volume *volume = (Volume *)BKE_id_new_nomain(ID_VO, nullptr); + Volume *volume = reinterpret_cast<Volume *>(BKE_id_new_nomain(ID_VO, nullptr)); BKE_volume_init_grids(volume); /* Convert mesh to grid and add to volume. */ diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc index 5181b23f51a..ec9a40f8cf8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc @@ -215,7 +215,7 @@ static void initialize_volume_component_from_points(GeoNodeExecParams ¶ms, return; } - Volume *volume = (Volume *)BKE_id_new_nomain(ID_VO, nullptr); + Volume *volume = reinterpret_cast<Volume *>(BKE_id_new_nomain(ID_VO, nullptr)); BKE_volume_init_grids(volume); const float density = params.get_input<float>("Density"); diff --git a/source/blender/nodes/geometry/nodes/node_geo_proximity.cc b/source/blender/nodes/geometry/nodes/node_geo_proximity.cc index d5233ee35a4..1b906823d04 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_proximity.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_proximity.cc @@ -211,8 +211,7 @@ static void node_geo_exec(GeoNodeExecParams params) Field<float3> position_field = params.extract_input<Field<float3>>("Source Position"); auto proximity_fn = std::make_unique<ProximityFunction>( - std::move(geometry_set_target), - static_cast<GeometryNodeProximityTargetType>(storage.target_element)); + std::move(geometry_set_target), GeometryNodeProximityTargetType(storage.target_element)); auto proximity_op = std::make_shared<FieldOperation>( FieldOperation(std::move(proximity_fn), {std::move(position_field)})); diff --git a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc index f657b128c51..a49b2c70ce2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc @@ -70,9 +70,9 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) static void node_update(bNodeTree *ntree, bNode *node) { const NodeGeometryRaycast &storage = node_storage(*node); - const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); + const eCustomDataType data_type = eCustomDataType(storage.data_type); - bNodeSocket *socket_vector = (bNodeSocket *)BLI_findlink(&node->inputs, 1); + bNodeSocket *socket_vector = static_cast<bNodeSocket *>(BLI_findlink(&node->inputs, 1)); bNodeSocket *socket_float = socket_vector->next; bNodeSocket *socket_color4f = socket_float->next; bNodeSocket *socket_boolean = socket_color4f->next; @@ -84,7 +84,7 @@ static void node_update(bNodeTree *ntree, bNode *node) nodeSetSocketAvailability(ntree, socket_boolean, data_type == CD_PROP_BOOL); nodeSetSocketAvailability(ntree, socket_int32, data_type == CD_PROP_INT32); - bNodeSocket *out_socket_vector = (bNodeSocket *)BLI_findlink(&node->outputs, 4); + bNodeSocket *out_socket_vector = static_cast<bNodeSocket *>(BLI_findlink(&node->outputs, 4)); bNodeSocket *out_socket_float = out_socket_vector->next; bNodeSocket *out_socket_color4f = out_socket_float->next; bNodeSocket *out_socket_boolean = out_socket_color4f->next; @@ -386,8 +386,8 @@ static void node_geo_exec(GeoNodeExecParams params) { GeometrySet target = params.extract_input<GeometrySet>("Target Geometry"); const NodeGeometryRaycast &storage = node_storage(params.node()); - const GeometryNodeRaycastMapMode mapping = (GeometryNodeRaycastMapMode)storage.mapping; - const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); + const GeometryNodeRaycastMapMode mapping = GeometryNodeRaycastMapMode(storage.mapping); + const eCustomDataType data_type = eCustomDataType(storage.data_type); if (target.is_empty()) { params.set_default_remaining_outputs(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc index 2ebbf88b8ad..c70e9c42848 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc @@ -56,8 +56,7 @@ static void node_update(bNodeTree *ntree, bNode *node) bNodeSocket *center_socket = scale_float_socket->next; bNodeSocket *axis_socket = center_socket->next; - const GeometryNodeScaleElementsMode mode = static_cast<GeometryNodeScaleElementsMode>( - node->custom2); + const GeometryNodeScaleElementsMode mode = GeometryNodeScaleElementsMode(node->custom2); const bool use_single_axis = mode == GEO_NODE_SCALE_ELEMENTS_SINGLE_AXIS; nodeSetSocketAvailability(ntree, axis_socket, use_single_axis); @@ -405,9 +404,8 @@ static void scale_edges_on_axis(Mesh &mesh, const AxisScaleFields &fields) static void node_geo_exec(GeoNodeExecParams params) { const bNode &node = params.node(); - const eAttrDomain domain = static_cast<eAttrDomain>(node.custom1); - const GeometryNodeScaleElementsMode scale_mode = static_cast<GeometryNodeScaleElementsMode>( - node.custom2); + const eAttrDomain domain = eAttrDomain(node.custom1); + const GeometryNodeScaleElementsMode scale_mode = GeometryNodeScaleElementsMode(node.custom2); GeometrySet geometry = params.extract_input<GeometrySet>("Geometry"); diff --git a/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc index d785694f253..f40ad62a5e4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc @@ -43,7 +43,7 @@ static void node_geo_exec(GeoNodeExecParams params) const Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"); const NodeGeometrySeparateGeometry &storage = node_storage(params.node()); - const eAttrDomain domain = static_cast<eAttrDomain>(storage.domain); + const eAttrDomain domain = eAttrDomain(storage.domain); auto separate_geometry_maybe_recursively = [&](GeometrySet &geometry_set, const Field<bool> &selection) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc index 37e55602fb0..d0b770aadad 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc @@ -49,9 +49,9 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node) static void node_update(bNodeTree *ntree, bNode *node) { const NodeGeometryStoreNamedAttribute &storage = node_storage(*node); - const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); + const eCustomDataType data_type = eCustomDataType(storage.data_type); - bNodeSocket *socket_geometry = (bNodeSocket *)node->inputs.first; + bNodeSocket *socket_geometry = static_cast<bNodeSocket *>(node->inputs.first); bNodeSocket *socket_name = socket_geometry->next; bNodeSocket *socket_vector = socket_name->next; bNodeSocket *socket_float = socket_vector->next; @@ -75,7 +75,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) if (params.in_out() == SOCK_IN) { const std::optional<eCustomDataType> type = node_data_type_to_custom_data_type( - static_cast<eNodeSocketDatatype>(params.other_socket().type)); + eNodeSocketDatatype(params.other_socket().type)); if (type && *type != CD_PROP_STRING) { /* The input and output sockets have the same name. */ params.add_item(IFACE_("Value"), [type](LinkSearchOpParams ¶ms) { @@ -155,8 +155,8 @@ static void node_geo_exec(GeoNodeExecParams params) params.used_named_attribute(name, NamedAttributeUsage::Write); const NodeGeometryStoreNamedAttribute &storage = node_storage(params.node()); - const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); - const eAttrDomain domain = static_cast<eAttrDomain>(storage.domain); + const eCustomDataType data_type = eCustomDataType(storage.data_type); + const eAttrDomain domain = eAttrDomain(storage.domain); GField field; switch (data_type) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc index afd7db6604d..e8913f80916 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc @@ -85,7 +85,7 @@ static void node_init(bNodeTree *UNUSED(ntree), bNode *node) data->align_y = GEO_NODE_STRING_TO_CURVES_ALIGN_Y_TOP_BASELINE; data->pivot_mode = GEO_NODE_STRING_TO_CURVES_PIVOT_MODE_BOTTOM_LEFT; node->storage = data; - node->id = (ID *)BKE_vfont_builtin_get(); + node->id = reinterpret_cast<ID *>(BKE_vfont_builtin_get()); } static void node_update(bNodeTree *ntree, bNode *node) @@ -93,11 +93,11 @@ static void node_update(bNodeTree *ntree, bNode *node) const NodeGeometryStringToCurves &storage = node_storage(*node); const GeometryNodeStringToCurvesOverflowMode overflow = (GeometryNodeStringToCurvesOverflowMode) storage.overflow; - bNodeSocket *socket_remainder = ((bNodeSocket *)node->outputs.first)->next; + bNodeSocket *socket_remainder = static_cast<bNodeSocket *>(node->outputs.first)->next; nodeSetSocketAvailability( ntree, socket_remainder, overflow == GEO_NODE_STRING_TO_CURVES_MODE_TRUNCATE); - bNodeSocket *height_socket = (bNodeSocket *)node->inputs.last; + bNodeSocket *height_socket = static_cast<bNodeSocket *>(node->inputs.last); nodeSetSocketAvailability( ntree, height_socket, overflow != GEO_NODE_STRING_TO_CURVES_MODE_OVERFLOW); } @@ -203,7 +203,7 @@ static std::optional<TextLayout> get_text_layout(GeoNodeExecParams ¶ms) cu.linedist = line_spacing; cu.vfont = vfont; cu.overflow = overflow; - cu.tb = (TextBox *)MEM_calloc_arrayN(MAXTEXTBOX, sizeof(TextBox), __func__); + cu.tb = static_cast<TextBox *>(MEM_calloc_arrayN(MAXTEXTBOX, sizeof(TextBox), __func__)); cu.tb->w = textbox_w; cu.tb->h = textbox_h; cu.totbox = 1; @@ -213,8 +213,8 @@ static std::optional<TextLayout> get_text_layout(GeoNodeExecParams ¶ms) cu.len = len_bytes; cu.pos = len_chars; /* The reason for the additional character here is unknown, but reflects other code elsewhere. */ - cu.str = (char *)MEM_mallocN(len_bytes + sizeof(char32_t), __func__); - cu.strinfo = (CharInfo *)MEM_callocN((len_chars + 1) * sizeof(CharInfo), __func__); + cu.str = static_cast<char *>(MEM_mallocN(len_bytes + sizeof(char32_t), __func__)); + cu.strinfo = static_cast<CharInfo *>(MEM_callocN((len_chars + 1) * sizeof(CharInfo), __func__)); BLI_strncpy(cu.str, layout.text.c_str(), len_bytes + 1); struct CharTrans *chartransdata = nullptr; @@ -226,7 +226,7 @@ static std::optional<TextLayout> get_text_layout(GeoNodeExecParams ¶ms) nullptr, &cu, FO_DUPLI, nullptr, &r_text, &text_len, &text_free, &chartransdata); if (text_free) { - MEM_freeN((void *)r_text); + MEM_freeN(const_cast<char32_t *>(r_text)); } Span<CharInfo> info{cu.strinfo, text_len}; @@ -272,7 +272,7 @@ static Map<int, int> create_curve_instances(GeoNodeExecParams ¶ms, TextLayout &layout, InstancesComponent &instances) { - VFont *vfont = (VFont *)params.node().id; + VFont *vfont = reinterpret_cast<VFont *>(params.node().id); Map<int, int> handles; bool pivot_required = params.output_is_required("Pivot Point"); diff --git a/source/blender/nodes/geometry/nodes/node_geo_switch.cc b/source/blender/nodes/geometry/nodes/node_geo_switch.cc index ddc87e3dac4..6dc30af4fb6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_switch.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_switch.cc @@ -89,8 +89,8 @@ static void node_update(bNodeTree *ntree, bNode *node) { const NodeSwitch &storage = node_storage(*node); int index = 0; - bNodeSocket *field_switch = (bNodeSocket *)node->inputs.first; - bNodeSocket *non_field_switch = (bNodeSocket *)field_switch->next; + bNodeSocket *field_switch = static_cast<bNodeSocket *>(node->inputs.first); + bNodeSocket *non_field_switch = static_cast<bNodeSocket *>(field_switch->next); const bool fields_type = ELEM( storage.input_type, SOCK_FLOAT, SOCK_INT, SOCK_BOOLEAN, SOCK_VECTOR, SOCK_RGBA, SOCK_STRING); @@ -222,7 +222,7 @@ template<typename T> void switch_no_fields(GeoNodeExecParams ¶ms, const Stri static void node_geo_exec(GeoNodeExecParams params) { const NodeSwitch &storage = node_storage(params.node()); - const eNodeSocketDatatype data_type = static_cast<eNodeSocketDatatype>(storage.input_type); + const eNodeSocketDatatype data_type = eNodeSocketDatatype(storage.input_type); switch (data_type) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc b/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc index 57487059437..04fe7641899 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc @@ -68,10 +68,8 @@ static void node_geo_exec(GeoNodeExecParams params) Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"); const int min_vertices = std::max(params.extract_input<int>("Minimum Vertices"), 4); - GeometryNodeTriangulateQuads quad_method = static_cast<GeometryNodeTriangulateQuads>( - params.node().custom1); - GeometryNodeTriangulateNGons ngon_method = static_cast<GeometryNodeTriangulateNGons>( - params.node().custom2); + GeometryNodeTriangulateQuads quad_method = GeometryNodeTriangulateQuads(params.node().custom1); + GeometryNodeTriangulateNGons ngon_method = GeometryNodeTriangulateNGons(params.node().custom2); geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (!geometry_set.has_mesh()) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_viewer.cc b/source/blender/nodes/geometry/nodes/node_geo_viewer.cc index 6979693e215..2c8a70901f8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_viewer.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_viewer.cc @@ -61,7 +61,7 @@ static eNodeSocketDatatype custom_data_type_to_socket_type(const eCustomDataType static void node_update(bNodeTree *ntree, bNode *node) { const NodeGeometryViewer &storage = node_storage(*node); - const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); + const eCustomDataType data_type = eCustomDataType(storage.data_type); const eNodeSocketDatatype socket_type = custom_data_type_to_socket_type(data_type); LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) { 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 274c243909d..4018f85fc94 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_volume_cube.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_volume_cube.cc @@ -168,7 +168,7 @@ static void node_geo_exec(GeoNodeExecParams params) grid->transform().postTranslate( openvdb::math::Vec3<float>(bounds_min.x, bounds_min.y, bounds_min.z)); - Volume *volume = (Volume *)BKE_id_new_nomain(ID_VO, nullptr); + Volume *volume = reinterpret_cast<Volume *>(BKE_id_new_nomain(ID_VO, nullptr)); BKE_volume_init_grids(volume); BKE_volume_grid_add_vdb(*volume, "density", std::move(grid)); |