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.
This commit is contained in:
@@ -65,13 +65,12 @@ class RawAllocator {
|
|||||||
public:
|
public:
|
||||||
void *allocate(size_t size, size_t alignment, const char *UNUSED(name))
|
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 *ptr = malloc(size + alignment + sizeof(MemHead));
|
||||||
void *used_ptr = reinterpret_cast<void *>(
|
void *used_ptr = reinterpret_cast<void *>(
|
||||||
reinterpret_cast<uintptr_t>(POINTER_OFFSET(ptr, alignment + sizeof(MemHead))) &
|
uintptr_t(POINTER_OFFSET(ptr, alignment + sizeof(MemHead))) & ~(uintptr_t(alignment) - 1));
|
||||||
~(static_cast<uintptr_t>(alignment) - 1));
|
int offset = int(intptr_t(used_ptr) - intptr_t(ptr));
|
||||||
int offset = static_cast<int>((intptr_t)used_ptr - (intptr_t)ptr);
|
BLI_assert(offset >= int(sizeof(MemHead)));
|
||||||
BLI_assert(offset >= static_cast<int>(sizeof(MemHead)));
|
|
||||||
(static_cast<MemHead *>(used_ptr) - 1)->offset = offset;
|
(static_cast<MemHead *>(used_ptr) - 1)->offset = offset;
|
||||||
return used_ptr;
|
return used_ptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,13 @@ template<typename ExtraInfo, typename T>
|
|||||||
inline constexpr AnyTypeInfo<ExtraInfo> info_for_inline = {
|
inline constexpr AnyTypeInfo<ExtraInfo> info_for_inline = {
|
||||||
is_trivially_copy_constructible_extended_v<T> ?
|
is_trivially_copy_constructible_extended_v<T> ?
|
||||||
nullptr :
|
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> ?
|
is_trivially_move_constructible_extended_v<T> ?
|
||||||
nullptr :
|
nullptr :
|
||||||
+[](void *dst, void *src) { new (dst) T(std::move(*(T *)src)); },
|
+[](void *dst, void *src) { new (dst) T(std::move(*static_cast<T *>(src))); },
|
||||||
is_trivially_destructible_extended_v<T> ? nullptr :
|
is_trivially_destructible_extended_v<T> ?
|
||||||
+[](void *src) { std::destroy_at(((T *)src)); },
|
nullptr :
|
||||||
|
+[](void *src) { std::destroy_at((static_cast<T *>(src))); },
|
||||||
nullptr,
|
nullptr,
|
||||||
ExtraInfo::template get<T>()};
|
ExtraInfo::template get<T>()};
|
||||||
|
|
||||||
|
|||||||
@@ -424,8 +424,7 @@ class Array {
|
|||||||
|
|
||||||
T *allocate(int64_t size)
|
T *allocate(int64_t size)
|
||||||
{
|
{
|
||||||
return static_cast<T *>(
|
return static_cast<T *>(allocator_.allocate(size_t(size) * sizeof(T), alignof(T), AT));
|
||||||
allocator_.allocate(static_cast<size_t>(size) * sizeof(T), alignof(T), AT));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void deallocate_if_not_inline(T *ptr)
|
void deallocate_if_not_inline(T *ptr)
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class MutableBitRef {
|
|||||||
MutableBitRef(uint8_t *byte_ptr, const int64_t bit_index)
|
MutableBitRef(uint8_t *byte_ptr, const int64_t bit_index)
|
||||||
{
|
{
|
||||||
byte_ptr_ = byte_ptr + (bit_index >> 3);
|
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_;
|
data_ = inline_buffer_;
|
||||||
size_in_bits_ = 0;
|
size_in_bits_ = 0;
|
||||||
capacity_in_bits_ = BitsInInlineBuffer;
|
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)
|
BitVector(NoExceptConstructor, Allocator allocator = {}) noexcept : BitVector(allocator)
|
||||||
@@ -447,7 +447,7 @@ class BitVector {
|
|||||||
/* Fill entire bytes at once. */
|
/* Fill entire bytes at once. */
|
||||||
const int64_t start_fill_byte_index = aligned_ranges.aligned.start() / BitsPerByte;
|
const int64_t start_fill_byte_index = aligned_ranges.aligned.start() / BitsPerByte;
|
||||||
const int64_t bytes_to_fill = aligned_ranges.aligned.size() / 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);
|
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. */
|
/* Fill bits in the end that don't cover a full byte. */
|
||||||
@@ -505,7 +505,7 @@ class BitVector {
|
|||||||
* uninitialized byte. */
|
* uninitialized byte. */
|
||||||
uninitialized_fill_n(new_data + bytes_to_copy,
|
uninitialized_fill_n(new_data + bytes_to_copy,
|
||||||
new_capacity_in_bytes - 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()) {
|
if (!this->is_inline()) {
|
||||||
allocator_.deallocate(data_);
|
allocator_.deallocate(data_);
|
||||||
|
|||||||
@@ -211,8 +211,8 @@ CPPType::CPPType(CPPTypeParam<T, Flags> /* unused */, StringRef debug_name)
|
|||||||
using namespace cpp_type_util;
|
using namespace cpp_type_util;
|
||||||
|
|
||||||
debug_name_ = debug_name;
|
debug_name_ = debug_name;
|
||||||
size_ = (int64_t)sizeof(T);
|
size_ = int64_t(sizeof(T));
|
||||||
alignment_ = (int64_t)alignof(T);
|
alignment_ = int64_t(alignof(T));
|
||||||
is_trivial_ = std::is_trivial_v<T>;
|
is_trivial_ = std::is_trivial_v<T>;
|
||||||
is_trivially_destructible_ = std::is_trivially_destructible_v<T>;
|
is_trivially_destructible_ = std::is_trivially_destructible_v<T>;
|
||||||
if constexpr (std::is_default_constructible_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_ = value_initialize_cb<T>;
|
||||||
value_initialize_indices_ = value_initialize_indices_cb<T>;
|
value_initialize_indices_ = value_initialize_indices_cb<T>;
|
||||||
static T default_value;
|
static T default_value;
|
||||||
default_value_ = (void *)&default_value;
|
default_value_ = &default_value;
|
||||||
}
|
}
|
||||||
if constexpr (std::is_destructible_v<T>) {
|
if constexpr (std::is_destructible_v<T>) {
|
||||||
destruct_ = destruct_cb<T>;
|
destruct_ = destruct_cb<T>;
|
||||||
|
|||||||
@@ -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>))>
|
!std::is_same_v<std::remove_cv_t<std::remove_reference_t<Callable>>, FunctionRef>))>
|
||||||
FunctionRef(Callable &&callable)
|
FunctionRef(Callable &&callable)
|
||||||
: callback_(callback_fn<typename std::remove_reference_t<Callable>>),
|
: callback_(callback_fn<typename std::remove_reference_t<Callable>>),
|
||||||
callable_(reinterpret_cast<intptr_t>(&callable))
|
callable_(intptr_t(&callable))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ class GArray {
|
|||||||
{
|
{
|
||||||
const int64_t item_size = type_->size();
|
const int64_t item_size = type_->size();
|
||||||
const int64_t alignment = type_->alignment();
|
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)
|
void deallocate(void *ptr)
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ template<typename T> class GVArrayImpl_For_VArray : public GVArrayImpl {
|
|||||||
protected:
|
protected:
|
||||||
void get(const int64_t index, void *r_value) const override
|
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
|
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
|
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
|
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
|
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
|
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
|
bool try_assign_VArray(void *varray) const override
|
||||||
@@ -422,7 +424,7 @@ template<typename T> class GVMutableArrayImpl_For_VMutableArray : public GVMutab
|
|||||||
protected:
|
protected:
|
||||||
void get(const int64_t index, void *r_value) const override
|
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
|
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
|
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_));
|
varray_.set(index, std::move(value_));
|
||||||
value_.~T();
|
value_.~T();
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_by_move(const int64_t index, void *value) override
|
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_));
|
varray_.set(index, std::move(value_));
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_all(const void *src) override
|
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
|
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
|
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
|
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
|
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
|
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
|
inline GVMutableArrayImpl *GVMutableArray::get_impl() const
|
||||||
{
|
{
|
||||||
return (GVMutableArrayImpl *)impl_;
|
return const_cast<GVMutableArrayImpl *>(static_cast<const GVMutableArrayImpl *>(impl_));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ template<typename T> struct DefaultHash {
|
|||||||
{
|
{
|
||||||
if constexpr (std::is_enum_v<T>) {
|
if constexpr (std::is_enum_v<T>) {
|
||||||
/* For enums use the value as hash directly. */
|
/* For enums use the value as hash directly. */
|
||||||
return (uint64_t)value;
|
return uint64_t(value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Try to call the `hash()` function on the value. */
|
/* Try to call the `hash()` function on the value. */
|
||||||
@@ -119,7 +119,7 @@ template<typename T> struct DefaultHash<const T> {
|
|||||||
template<> struct DefaultHash<TYPE> { \
|
template<> struct DefaultHash<TYPE> { \
|
||||||
uint64_t operator()(TYPE value) const \
|
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> {
|
template<> struct DefaultHash<bool> {
|
||||||
uint64_t operator()(bool value) const
|
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 *> {
|
template<typename T> struct DefaultHash<T *> {
|
||||||
uint64_t operator()(const T *value) const
|
uint64_t operator()(const T *value) const
|
||||||
{
|
{
|
||||||
uintptr_t ptr = reinterpret_cast<uintptr_t>(value);
|
uintptr_t ptr = uintptr_t(value);
|
||||||
uint64_t hash = static_cast<uint64_t>(ptr >> 4);
|
uint64_t hash = uint64_t(ptr >> 4);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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)
|
inline constexpr int64_t log2_ceil_constexpr(const int64_t x)
|
||||||
{
|
{
|
||||||
BLI_assert(x >= 0);
|
BLI_assert(x >= 0);
|
||||||
return (is_power_of_2_constexpr(static_cast<int>(x))) ? log2_floor_constexpr(x) :
|
return (is_power_of_2_constexpr(int(x))) ? log2_floor_constexpr(x) : log2_floor_constexpr(x) + 1;
|
||||||
log2_floor_constexpr(x) + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr int64_t power_of_2_max_constexpr(const int64_t x)
|
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 numerator,
|
||||||
const int64_t denominator)
|
const int64_t denominator)
|
||||||
{
|
{
|
||||||
return static_cast<int64_t>(
|
return int64_t(ceil_division(uint64_t(x) * uint64_t(denominator), uint64_t(numerator)));
|
||||||
ceil_division(static_cast<uint64_t>(x) * static_cast<uint64_t>(denominator),
|
|
||||||
static_cast<uint64_t>(numerator)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr int64_t floor_multiplication_with_fraction(const int64_t x,
|
inline constexpr int64_t floor_multiplication_with_fraction(const int64_t x,
|
||||||
const int64_t numerator,
|
const int64_t numerator,
|
||||||
const int64_t denominator)
|
const int64_t denominator)
|
||||||
{
|
{
|
||||||
return static_cast<int64_t>((static_cast<uint64_t>(x) * static_cast<uint64_t>(numerator) /
|
return int64_t((uint64_t(x) * uint64_t(numerator) / uint64_t(denominator)));
|
||||||
static_cast<uint64_t>(denominator)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr int64_t total_slot_amount_for_usable_slots(
|
inline constexpr int64_t total_slot_amount_for_usable_slots(
|
||||||
@@ -121,7 +117,7 @@ class LoadFactor {
|
|||||||
int64_t *r_total_slots,
|
int64_t *r_total_slots,
|
||||||
int64_t *r_usable_slots) const
|
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_);
|
int64_t total_slots = this->compute_total_slots(min_usable_slots, numerator_, denominator_);
|
||||||
total_slots = std::max(total_slots, min_total_slots);
|
total_slots = std::max(total_slots, min_total_slots);
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya
|
|||||||
void *pointer_buffer = this->allocate(element_amount * sizeof(void *), alignof(void *));
|
void *pointer_buffer = this->allocate(element_amount * sizeof(void *), alignof(void *));
|
||||||
void *elements_buffer = this->allocate(element_amount * element_size, element_alignment);
|
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;
|
void *next_element_buffer = elements_buffer;
|
||||||
for (int64_t i : IndexRange(element_amount)) {
|
for (int64_t i : IndexRange(element_amount)) {
|
||||||
pointers[i] = next_element_buffer;
|
pointers[i] = next_element_buffer;
|
||||||
|
|||||||
@@ -943,7 +943,7 @@ class Map {
|
|||||||
*/
|
*/
|
||||||
int64_t size_in_bytes() const
|
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(
|
max_load_factor_.compute_total_and_usable_slots(
|
||||||
SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots);
|
SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots);
|
||||||
BLI_assert(total_slots >= 1);
|
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.
|
* 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:
|
public:
|
||||||
int64_t size() const
|
int64_t size() const
|
||||||
{
|
{
|
||||||
return static_cast<int64_t>(map_.size());
|
return int64_t(map_.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_empty() const
|
bool is_empty() const
|
||||||
|
|||||||
@@ -74,28 +74,28 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size>
|
|||||||
explicit vec_base(uint value)
|
explicit vec_base(uint value)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
(*this)[i] = static_cast<T>(value);
|
(*this)[i] = T(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit vec_base(int value)
|
explicit vec_base(int value)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
(*this)[i] = static_cast<T>(value);
|
(*this)[i] = T(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit vec_base(float value)
|
explicit vec_base(float value)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
(*this)[i] = static_cast<T>(value);
|
(*this)[i] = T(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit vec_base(double value)
|
explicit vec_base(double value)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Size; i++) {
|
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. */
|
/** Mixed scalar-vector constructors. */
|
||||||
|
|
||||||
template<typename U, BLI_ENABLE_IF_VEC(Size, == 3)>
|
template<typename U, BLI_ENABLE_IF_VEC(Size, == 3)>
|
||||||
constexpr vec_base(const vec_base<U, 2> &xy, T z)
|
constexpr vec_base(const vec_base<U, 2> &xy, T z) : vec_base(T(xy.x), T(xy.y), z)
|
||||||
: vec_base(static_cast<T>(xy.x), static_cast<T>(xy.y), z)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U, BLI_ENABLE_IF_VEC(Size, == 3)>
|
template<typename U, BLI_ENABLE_IF_VEC(Size, == 3)>
|
||||||
constexpr vec_base(T x, const vec_base<U, 2> &yz)
|
constexpr vec_base(T x, const vec_base<U, 2> &yz) : vec_base(x, T(yz.x), T(yz.y))
|
||||||
: vec_base(x, static_cast<T>(yz.x), static_cast<T>(yz.y))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
|
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
|
||||||
vec_base(vec_base<U, 3> xyz, T w)
|
vec_base(vec_base<U, 3> xyz, T w) : vec_base(T(xyz.x), T(xyz.y), T(xyz.z), T(w))
|
||||||
: vec_base(
|
|
||||||
static_cast<T>(xyz.x), static_cast<T>(xyz.y), static_cast<T>(xyz.z), static_cast<T>(w))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
|
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
|
||||||
vec_base(T x, vec_base<U, 3> yzw)
|
vec_base(T x, vec_base<U, 3> yzw) : vec_base(T(x), T(yzw.x), T(yzw.y), T(yzw.z))
|
||||||
: vec_base(
|
|
||||||
static_cast<T>(x), static_cast<T>(yzw.x), static_cast<T>(yzw.y), static_cast<T>(yzw.z))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U, typename V, BLI_ENABLE_IF_VEC(Size, == 4)>
|
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(vec_base<U, 2> xy, vec_base<V, 2> zw) : vec_base(T(xy.x), T(xy.y), T(zw.x), T(zw.y))
|
||||||
: vec_base(
|
|
||||||
static_cast<T>(xy.x), static_cast<T>(xy.y), static_cast<T>(zw.x), static_cast<T>(zw.y))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
|
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
|
||||||
vec_base(vec_base<U, 2> xy, T z, 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))
|
||||||
: vec_base(static_cast<T>(xy.x), static_cast<T>(xy.y), static_cast<T>(z), static_cast<T>(w))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
|
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
|
||||||
vec_base(T x, vec_base<U, 2> yz, 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))
|
||||||
: vec_base(static_cast<T>(x), static_cast<T>(yz.x), static_cast<T>(yz.y), static_cast<T>(w))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
|
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
|
||||||
vec_base(T x, T y, vec_base<U, 2> zw)
|
vec_base(T x, T y, vec_base<U, 2> zw) : vec_base(T(x), T(y), T(zw.x), T(zw.y))
|
||||||
: vec_base(static_cast<T>(x), static_cast<T>(y), static_cast<T>(zw.x), static_cast<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)
|
explicit vec_base(const vec_base<U, OtherSize> &other)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Size; i++) {
|
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)
|
template<typename U> explicit vec_base(const vec_base<U, Size> &vec)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
(*this)[i] = static_cast<T>(vec[i]);
|
(*this)[i] = T(vec[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
inline vec_base<float, 3> cross_high_precision(const vec_base<float, 3> &a,
|
||||||
const vec_base<float, 3> &b)
|
const vec_base<float, 3> &b)
|
||||||
{
|
{
|
||||||
return {(float)((double)a.y * b.z - (double)a.z * b.y),
|
return {float(double(a.y) * double(b.z) - double(a.z) * double(b.y)),
|
||||||
(float)((double)a.z * b.x - (double)a.x * b.z),
|
float(double(a.z) * double(b.x) - double(a.x) * double(b.z)),
|
||||||
(float)((double)a.x * b.y - (double)a.y * b.x)};
|
float(double(a.x) * double(b.y) - double(a.y) * double(b.x))};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, BLI_ENABLE_IF((is_math_float_type<T>))>
|
template<typename T, BLI_ENABLE_IF((is_math_float_type<T>))>
|
||||||
|
|||||||
@@ -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)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -354,12 +354,12 @@ struct BoundingBox {
|
|||||||
|
|
||||||
void combine(const double3 &p)
|
void combine(const double3 &p)
|
||||||
{
|
{
|
||||||
min.x = min_ff(min.x, static_cast<float>(p.x));
|
min.x = min_ff(min.x, float(p.x));
|
||||||
min.y = min_ff(min.y, static_cast<float>(p.y));
|
min.y = min_ff(min.y, float(p.y));
|
||||||
min.z = min_ff(min.z, static_cast<float>(p.z));
|
min.z = min_ff(min.z, float(p.z));
|
||||||
max.x = max_ff(max.x, static_cast<float>(p.x));
|
max.x = max_ff(max.x, float(p.x));
|
||||||
max.y = max_ff(max.y, static_cast<float>(p.y));
|
max.y = max_ff(max.y, float(p.y));
|
||||||
max.z = max_ff(max.z, static_cast<float>(p.z));
|
max.z = max_ff(max.z, float(p.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
void combine(const BoundingBox &bb)
|
void combine(const BoundingBox &bb)
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ using DefaultProbingStrategy = PythonProbingStrategy<>;
|
|||||||
int64_t linear_offset = 0; \
|
int64_t linear_offset = 0; \
|
||||||
uint64_t current_hash = probing_strategy.get(); \
|
uint64_t current_hash = probing_strategy.get(); \
|
||||||
do { \
|
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() \
|
#define SLOT_PROBING_END() \
|
||||||
} while (++linear_offset < probing_strategy.linear_steps()); \
|
} while (++linear_offset < probing_strategy.linear_steps()); \
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class RandomNumberGenerator {
|
|||||||
void seed(uint32_t seed)
|
void seed(uint32_t seed)
|
||||||
{
|
{
|
||||||
constexpr uint64_t lowseed = 0x330E;
|
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()
|
uint32_t get_uint32()
|
||||||
{
|
{
|
||||||
this->step();
|
this->step();
|
||||||
return static_cast<uint32_t>(x_ >> 17);
|
return uint32_t(x_ >> 17);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t get_int32()
|
int32_t get_int32()
|
||||||
{
|
{
|
||||||
this->step();
|
this->step();
|
||||||
return static_cast<int32_t>(x_ >> 17);
|
return int32_t(x_ >> 17);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,7 +63,7 @@ class RandomNumberGenerator {
|
|||||||
*/
|
*/
|
||||||
double get_double()
|
double get_double()
|
||||||
{
|
{
|
||||||
return (double)this->get_int32() / 0x80000000;
|
return double(this->get_int32()) / 0x80000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ template<typename Func> inline void ResourceScope::add_destruct_call(Func func)
|
|||||||
{
|
{
|
||||||
void *buffer = allocator_.allocate(sizeof(Func), alignof(Func));
|
void *buffer = allocator_.allocate(sizeof(Func), alignof(Func));
|
||||||
new (buffer) Func(std::move(func));
|
new (buffer) Func(std::move(func));
|
||||||
this->add(buffer, [](void *data) { (*(Func *)data)(); });
|
this->add(buffer, [](void *data) { (*static_cast<Func *>(data))(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ class Set {
|
|||||||
max_load_factor_.compute_total_and_usable_slots(
|
max_load_factor_.compute_total_and_usable_slots(
|
||||||
SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots);
|
SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots);
|
||||||
BLI_assert(total_slots >= 1);
|
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.
|
* 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:
|
public:
|
||||||
int64_t size() const
|
int64_t size() const
|
||||||
{
|
{
|
||||||
return static_cast<int64_t>(set_.size());
|
return int64_t(set_.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_empty() const
|
bool is_empty() const
|
||||||
|
|||||||
@@ -112,13 +112,11 @@ template<typename T> class Span {
|
|||||||
* Span<int> span = {1, 2, 3, 4};
|
* Span<int> span = {1, 2, 3, 4};
|
||||||
* call_function_with_array(span);
|
* call_function_with_array(span);
|
||||||
*/
|
*/
|
||||||
constexpr Span(const std::initializer_list<T> &list)
|
constexpr Span(const std::initializer_list<T> &list) : Span(list.begin(), int64_t(list.size()))
|
||||||
: Span(list.begin(), static_cast<int64_t>(list.size()))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Span(const std::vector<T> &vector)
|
constexpr Span(const std::vector<T> &vector) : Span(vector.data(), int64_t(vector.size()))
|
||||||
: Span(vector.data(), static_cast<int64_t>(vector.size()))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -718,7 +716,7 @@ template<typename T> class MutableSpan {
|
|||||||
{
|
{
|
||||||
BLI_assert((size_ * sizeof(T)) % sizeof(NewT) == 0);
|
BLI_assert((size_ * sizeof(T)) % sizeof(NewT) == 0);
|
||||||
int64_t new_size = size_ * sizeof(T) / sizeof(NewT);
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -178,12 +178,12 @@ constexpr StringRefBase::operator Span<char>() const
|
|||||||
*/
|
*/
|
||||||
inline StringRefBase::operator std::string() 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
|
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
|
constexpr const char *StringRefBase::begin() const
|
||||||
@@ -209,7 +209,7 @@ constexpr IndexRange StringRefBase::index_range() const
|
|||||||
inline void StringRefBase::unsafe_copy(char *dst) const
|
inline void StringRefBase::unsafe_copy(char *dst) const
|
||||||
{
|
{
|
||||||
if (size_ > 0) {
|
if (size_ > 0) {
|
||||||
memcpy(dst, data_, static_cast<size_t>(size_));
|
memcpy(dst, data_, size_t(size_));
|
||||||
}
|
}
|
||||||
dst[size_] = '\0';
|
dst[size_] = '\0';
|
||||||
}
|
}
|
||||||
@@ -308,86 +308,79 @@ constexpr int64_t index_or_npos_to_int64(size_t index)
|
|||||||
if (index == std::string_view::npos) {
|
if (index == std::string_view::npos) {
|
||||||
return StringRef::not_found;
|
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
|
constexpr int64_t StringRefBase::find(char c, int64_t pos) const
|
||||||
{
|
{
|
||||||
BLI_assert(pos >= 0);
|
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
|
constexpr int64_t StringRefBase::find(StringRef str, int64_t pos) const
|
||||||
{
|
{
|
||||||
BLI_assert(pos >= 0);
|
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
|
constexpr int64_t StringRefBase::rfind(char c, int64_t pos) const
|
||||||
{
|
{
|
||||||
BLI_assert(pos >= 0);
|
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
|
constexpr int64_t StringRefBase::rfind(StringRef str, int64_t pos) const
|
||||||
{
|
{
|
||||||
BLI_assert(pos >= 0);
|
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
|
constexpr int64_t StringRefBase::find_first_of(StringRef chars, int64_t pos) const
|
||||||
{
|
{
|
||||||
BLI_assert(pos >= 0);
|
BLI_assert(pos >= 0);
|
||||||
return index_or_npos_to_int64(
|
return index_or_npos_to_int64(std::string_view(*this).find_first_of(chars, size_t(pos)));
|
||||||
std::string_view(*this).find_first_of(chars, static_cast<size_t>(pos)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int64_t StringRefBase::find_first_of(char c, int64_t pos) const
|
constexpr int64_t StringRefBase::find_first_of(char c, int64_t pos) const
|
||||||
{
|
{
|
||||||
BLI_assert(pos >= 0);
|
BLI_assert(pos >= 0);
|
||||||
return index_or_npos_to_int64(
|
return index_or_npos_to_int64(std::string_view(*this).find_first_of(c, size_t(pos)));
|
||||||
std::string_view(*this).find_first_of(c, static_cast<size_t>(pos)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int64_t StringRefBase::find_last_of(StringRef chars, int64_t pos) const
|
constexpr int64_t StringRefBase::find_last_of(StringRef chars, int64_t pos) const
|
||||||
{
|
{
|
||||||
BLI_assert(pos >= 0);
|
BLI_assert(pos >= 0);
|
||||||
return index_or_npos_to_int64(
|
return index_or_npos_to_int64(std::string_view(*this).find_last_of(chars, size_t(pos)));
|
||||||
std::string_view(*this).find_last_of(chars, static_cast<size_t>(pos)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int64_t StringRefBase::find_last_of(char c, int64_t pos) const
|
constexpr int64_t StringRefBase::find_last_of(char c, int64_t pos) const
|
||||||
{
|
{
|
||||||
BLI_assert(pos >= 0);
|
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
|
constexpr int64_t StringRefBase::find_first_not_of(StringRef chars, int64_t pos) const
|
||||||
{
|
{
|
||||||
BLI_assert(pos >= 0);
|
BLI_assert(pos >= 0);
|
||||||
return index_or_npos_to_int64(
|
return index_or_npos_to_int64(std::string_view(*this).find_first_not_of(chars, size_t(pos)));
|
||||||
std::string_view(*this).find_first_not_of(chars, static_cast<size_t>(pos)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int64_t StringRefBase::find_first_not_of(char c, int64_t pos) const
|
constexpr int64_t StringRefBase::find_first_not_of(char c, int64_t pos) const
|
||||||
{
|
{
|
||||||
BLI_assert(pos >= 0);
|
BLI_assert(pos >= 0);
|
||||||
return index_or_npos_to_int64(
|
return index_or_npos_to_int64(std::string_view(*this).find_first_not_of(c, size_t(pos)));
|
||||||
std::string_view(*this).find_first_not_of(c, static_cast<size_t>(pos)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int64_t StringRefBase::find_last_not_of(StringRef chars, int64_t pos) const
|
constexpr int64_t StringRefBase::find_last_not_of(StringRef chars, int64_t pos) const
|
||||||
{
|
{
|
||||||
BLI_assert(pos >= 0);
|
BLI_assert(pos >= 0);
|
||||||
return index_or_npos_to_int64(
|
return index_or_npos_to_int64(std::string_view(*this).find_last_not_of(chars, size_t(pos)));
|
||||||
std::string_view(*this).find_last_not_of(chars, static_cast<size_t>(pos)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int64_t StringRefBase::find_last_not_of(char c, int64_t pos) const
|
constexpr int64_t StringRefBase::find_last_not_of(char c, int64_t pos) const
|
||||||
{
|
{
|
||||||
BLI_assert(pos >= 0);
|
BLI_assert(pos >= 0);
|
||||||
return index_or_npos_to_int64(
|
return index_or_npos_to_int64(std::string_view(*this).find_last_not_of(c, size_t(pos)));
|
||||||
std::string_view(*this).find_last_not_of(c, static_cast<size_t>(pos)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr StringRef StringRefBase::trim() const
|
constexpr StringRef StringRefBase::trim() const
|
||||||
@@ -440,15 +433,14 @@ constexpr StringRefNull::StringRefNull() : StringRefBase("", 0)
|
|||||||
constexpr StringRefNull::StringRefNull(const char *str, const int64_t size)
|
constexpr StringRefNull::StringRefNull(const char *str, const int64_t size)
|
||||||
: StringRefBase(str, 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
|
* Construct a StringRefNull from a null terminated c-string. The pointer must not point to
|
||||||
* NULL.
|
* NULL.
|
||||||
*/
|
*/
|
||||||
inline StringRefNull::StringRefNull(const char *str)
|
inline StringRefNull::StringRefNull(const char *str) : StringRefBase(str, int64_t(strlen(str)))
|
||||||
: StringRefBase(str, static_cast<int64_t>(strlen(str)))
|
|
||||||
{
|
{
|
||||||
BLI_assert(str != nullptr);
|
BLI_assert(str != nullptr);
|
||||||
BLI_assert(data_[size_] == '\0');
|
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.
|
* Create a StringRef from a null-terminated c-string.
|
||||||
*/
|
*/
|
||||||
constexpr StringRef::StringRef(const char *str)
|
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.
|
* second point points to a smaller address than the first one.
|
||||||
*/
|
*/
|
||||||
constexpr StringRef::StringRef(const char *begin, const char *one_after_end)
|
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);
|
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.
|
* will point to uninitialized memory.
|
||||||
*/
|
*/
|
||||||
inline StringRef::StringRef(const std::string &str)
|
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)
|
constexpr StringRef::StringRef(std::string_view view)
|
||||||
: StringRefBase(view.data(), static_cast<int64_t>(view.size()))
|
: StringRefBase(view.data(), int64_t(view.size()))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -786,24 +786,23 @@ extern bool BLI_memory_is_zero(const void *arr, size_t arr_size);
|
|||||||
extern "C++" { \
|
extern "C++" { \
|
||||||
inline constexpr _enum_type operator|(_enum_type a, _enum_type 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, _enum_type 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) \
|
inline constexpr _enum_type operator~(_enum_type a) \
|
||||||
{ \
|
{ \
|
||||||
return static_cast<_enum_type>(~static_cast<uint64_t>(a) & \
|
return (_enum_type)(~uint64_t(a) & (2 * uint64_t(_max_enum_value) - 1)); \
|
||||||
(2 * static_cast<uint64_t>(_max_enum_value) - 1)); \
|
|
||||||
} \
|
} \
|
||||||
inline _enum_type &operator|=(_enum_type &a, _enum_type 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)); \
|
||||||
} \
|
} \
|
||||||
inline _enum_type &operator&=(_enum_type &a, _enum_type 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++" */
|
} /* extern "C++" */
|
||||||
|
|
||||||
|
|||||||
@@ -96,8 +96,7 @@ class Vector {
|
|||||||
*/
|
*/
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
int64_t debug_size_;
|
int64_t debug_size_;
|
||||||
# define UPDATE_VECTOR_SIZE(ptr) \
|
# define UPDATE_VECTOR_SIZE(ptr) (ptr)->debug_size_ = int64_t((ptr)->end_ - (ptr)->begin_)
|
||||||
(ptr)->debug_size_ = static_cast<int64_t>((ptr)->end_ - (ptr)->begin_)
|
|
||||||
#else
|
#else
|
||||||
# define UPDATE_VECTOR_SIZE(ptr) ((void)0)
|
# define UPDATE_VECTOR_SIZE(ptr) ((void)0)
|
||||||
#endif
|
#endif
|
||||||
@@ -244,7 +243,7 @@ class Vector {
|
|||||||
/* Copy from inline buffer to newly allocated buffer. */
|
/* Copy from inline buffer to newly allocated buffer. */
|
||||||
const int64_t capacity = size;
|
const int64_t capacity = size;
|
||||||
begin_ = static_cast<T *>(
|
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;
|
capacity_end_ = begin_ + capacity;
|
||||||
uninitialized_relocate_n(other.begin_, size, begin_);
|
uninitialized_relocate_n(other.begin_, size, begin_);
|
||||||
end_ = begin_ + size;
|
end_ = begin_ + size;
|
||||||
@@ -693,7 +692,7 @@ class Vector {
|
|||||||
*/
|
*/
|
||||||
int64_t size() const
|
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);
|
BLI_assert(debug_size_ == current_size);
|
||||||
return current_size;
|
return current_size;
|
||||||
}
|
}
|
||||||
@@ -813,7 +812,7 @@ class Vector {
|
|||||||
{
|
{
|
||||||
for (const T *current = begin_; current != end_; current++) {
|
for (const T *current = begin_; current != end_; current++) {
|
||||||
if (*current == value) {
|
if (*current == value) {
|
||||||
return static_cast<int64_t>(current - begin_);
|
return int64_t(current - begin_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@@ -905,7 +904,7 @@ class Vector {
|
|||||||
*/
|
*/
|
||||||
int64_t capacity() const
|
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();
|
const int64_t size = this->size();
|
||||||
|
|
||||||
T *new_array = static_cast<T *>(
|
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 {
|
try {
|
||||||
uninitialized_relocate_n(begin_, size, new_array);
|
uninitialized_relocate_n(begin_, size, new_array);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ class VectorSet {
|
|||||||
*/
|
*/
|
||||||
int64_t size_in_bytes() const
|
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(
|
max_load_factor_.compute_total_and_usable_slots(
|
||||||
SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots);
|
SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots);
|
||||||
BLI_assert(total_slots >= 1);
|
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. */
|
/* Optimize the case when the set was empty beforehand. We can avoid some copies here. */
|
||||||
if (this->size() == 0) {
|
if (this->size() == 0) {
|
||||||
@@ -839,7 +839,7 @@ class VectorSet {
|
|||||||
Key *allocate_keys_array(const int64_t size)
|
Key *allocate_keys_array(const int64_t size)
|
||||||
{
|
{
|
||||||
return static_cast<Key *>(
|
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)
|
void deallocate_keys_array(Key *keys)
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ class VArrayImpl_For_ArrayContainer : public VArrayImpl_For_Span<T> {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
VArrayImpl_For_ArrayContainer(Container container)
|
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());
|
this->data_ = const_cast<T *>(container_.data());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace blender::tests {
|
|||||||
|
|
||||||
static bool is_aligned(void *ptr, uint alignment)
|
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;
|
return (POINTER_AS_UINT(ptr) & (alignment - 1)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ TEST(span, ContainsPtr)
|
|||||||
EXPECT_TRUE(a_span.contains_ptr(&a[0] + 1));
|
EXPECT_TRUE(a_span.contains_ptr(&a[0] + 1));
|
||||||
EXPECT_TRUE(a_span.contains_ptr(&a[0] + 2));
|
EXPECT_TRUE(a_span.contains_ptr(&a[0] + 2));
|
||||||
EXPECT_FALSE(a_span.contains_ptr(&a[0] + 3));
|
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(ptr_before));
|
||||||
EXPECT_FALSE(a_span.contains_ptr(&other));
|
EXPECT_FALSE(a_span.contains_ptr(&other));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,19 +118,19 @@ TEST(stack, PushPopMany)
|
|||||||
Stack<int> stack;
|
Stack<int> stack;
|
||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
stack.push(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--) {
|
for (int i = 999; i > 50; i--) {
|
||||||
EXPECT_EQ(stack.pop(), 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++) {
|
for (int i = 51; i < 5000; i++) {
|
||||||
stack.push(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--) {
|
for (int i = 4999; i >= 0; i--) {
|
||||||
EXPECT_EQ(stack.pop(), i);
|
EXPECT_EQ(stack.pop(), i);
|
||||||
EXPECT_EQ(stack.size(), static_cast<uint>(i));
|
EXPECT_EQ(stack.size(), uint(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ TEST(string_ref, Constexpr)
|
|||||||
constexpr StringRef sref("World");
|
constexpr StringRef sref("World");
|
||||||
BLI_STATIC_ASSERT(sref[2] == 'r', "");
|
BLI_STATIC_ASSERT(sref[2] == 'r', "");
|
||||||
BLI_STATIC_ASSERT(sref.size() == 5, "");
|
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);
|
EXPECT_EQ(compiles[0], 1);
|
||||||
}
|
}
|
||||||
} // namespace blender::tests
|
} // namespace blender::tests
|
||||||
|
|||||||
@@ -744,7 +744,7 @@ int FieldEvaluator::add(GField field, GVArray *varray_ptr)
|
|||||||
dst_varrays_.append(nullptr);
|
dst_varrays_.append(nullptr);
|
||||||
output_pointer_infos_.append(OutputPointerInfo{
|
output_pointer_infos_.append(OutputPointerInfo{
|
||||||
varray_ptr, [](void *dst, const GVArray &varray, ResourceScope &UNUSED(scope)) {
|
varray_ptr, [](void *dst, const GVArray &varray, ResourceScope &UNUSED(scope)) {
|
||||||
*(GVArray *)dst = varray;
|
*static_cast<GVArray *>(dst) = varray;
|
||||||
}});
|
}});
|
||||||
return field_index;
|
return field_index;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ CustomMF_GenericConstant::CustomMF_GenericConstant(const CPPType &type,
|
|||||||
CustomMF_GenericConstant::~CustomMF_GenericConstant()
|
CustomMF_GenericConstant::~CustomMF_GenericConstant()
|
||||||
{
|
{
|
||||||
if (owns_value_) {
|
if (owns_value_) {
|
||||||
signature_.param_types[0].data_type().single_type().destruct((void *)value_);
|
signature_.param_types[0].data_type().single_type().destruct(const_cast<void *>(value_));
|
||||||
MEM_freeN((void *)value_);
|
MEM_freeN(const_cast<void *>(value_));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -449,7 +449,7 @@ class VariableState : NonCopyable, NonMovable {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
new_value = value_allocator.obtain_GVectorArray_not_owned(
|
new_value = value_allocator.obtain_GVectorArray_not_owned(
|
||||||
*(GVectorArray *)caller_provided_storage_);
|
*static_cast<GVectorArray *>(caller_provided_storage_));
|
||||||
}
|
}
|
||||||
if (value_ != nullptr) {
|
if (value_ != nullptr) {
|
||||||
if (value_->type == ValueType::GVVectorArray) {
|
if (value_->type == ValueType::GVVectorArray) {
|
||||||
@@ -780,7 +780,8 @@ class VariableState : NonCopyable, NonMovable {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ValueType::Span: {
|
case ValueType::Span: {
|
||||||
const Span<bool> span((bool *)this->value_as<VariableValue_Span>()->data,
|
const Span<bool> span(
|
||||||
|
static_cast<const bool *>(this->value_as<VariableValue_Span>()->data),
|
||||||
mask.min_array_size());
|
mask.min_array_size());
|
||||||
for (const int i : mask) {
|
for (const int i : mask) {
|
||||||
r_indices[span[i]].append(i);
|
r_indices[span[i]].append(i);
|
||||||
@@ -790,7 +791,7 @@ class VariableState : NonCopyable, NonMovable {
|
|||||||
case ValueType::OneSingle: {
|
case ValueType::OneSingle: {
|
||||||
auto *value_typed = this->value_as<VariableValue_OneSingle>();
|
auto *value_typed = this->value_as<VariableValue_OneSingle>();
|
||||||
BLI_assert(value_typed->is_initialized);
|
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);
|
r_indices[condition].extend(mask);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ static void geometry_node_tree_get_from_context(const bContext *C,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (md->type == eModifierType_Nodes) {
|
if (md->type == eModifierType_Nodes) {
|
||||||
NodesModifierData *nmd = (NodesModifierData *)md;
|
const NodesModifierData *nmd = reinterpret_cast<const NodesModifierData *>(md);
|
||||||
if (nmd->node_group != nullptr) {
|
if (nmd->node_group != nullptr) {
|
||||||
*r_from = &ob->id;
|
*r_from = &ob->id;
|
||||||
*r_id = &ob->id;
|
*r_id = &ob->id;
|
||||||
|
|||||||
@@ -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)
|
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
|
} // namespace blender::nodes
|
||||||
|
|||||||
@@ -87,13 +87,13 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node)
|
|||||||
static void node_update(bNodeTree *ntree, bNode *node)
|
static void node_update(bNodeTree *ntree, bNode *node)
|
||||||
{
|
{
|
||||||
const NodeAccumulateField &storage = node_storage(*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_float = sock_in_vector->next;
|
||||||
bNodeSocket *sock_in_int = sock_in_float->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_float = sock_out_vector->next;
|
||||||
bNodeSocket *sock_out_int = sock_out_float->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)
|
static void node_geo_exec(GeoNodeExecParams params)
|
||||||
{
|
{
|
||||||
const NodeAccumulateField &storage = node_storage(params.node());
|
const NodeAccumulateField &storage = node_storage(params.node());
|
||||||
const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type);
|
const eCustomDataType data_type = eCustomDataType(storage.data_type);
|
||||||
const eAttrDomain source_domain = static_cast<eAttrDomain>(storage.domain);
|
const eAttrDomain source_domain = eAttrDomain(storage.domain);
|
||||||
|
|
||||||
Field<int> group_index_field = params.extract_input<Field<int>>("Group Index");
|
Field<int> group_index_field = params.extract_input<Field<int>>("Group Index");
|
||||||
attribute_math::convert_to_static_type(data_type, [&](auto dummy) {
|
attribute_math::convert_to_static_type(data_type, [&](auto dummy) {
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node)
|
|||||||
static void node_update(bNodeTree *ntree, bNode *node)
|
static void node_update(bNodeTree *ntree, bNode *node)
|
||||||
{
|
{
|
||||||
const NodeGeometryAttributeCapture &storage = node_storage(*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_vector = socket_value_geometry->next;
|
||||||
bNodeSocket *socket_value_float = socket_value_vector->next;
|
bNodeSocket *socket_value_float = socket_value_vector->next;
|
||||||
bNodeSocket *socket_value_color4f = socket_value_float->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_boolean, data_type == CD_PROP_BOOL);
|
||||||
nodeSetSocketAvailability(ntree, socket_value_int32, data_type == CD_PROP_INT32);
|
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_vector = out_socket_value_geometry->next;
|
||||||
bNodeSocket *out_socket_value_float = out_socket_value_vector->next;
|
bNodeSocket *out_socket_value_float = out_socket_value_vector->next;
|
||||||
bNodeSocket *out_socket_value_color4f = out_socket_value_float->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 NodeGeometryAttributeCapture &storage = node_storage(params.node());
|
||||||
const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type);
|
const eCustomDataType data_type = eCustomDataType(storage.data_type);
|
||||||
const eAttrDomain domain = static_cast<eAttrDomain>(storage.domain);
|
const eAttrDomain domain = eAttrDomain(storage.domain);
|
||||||
|
|
||||||
const std::string output_identifier = "Attribute" + identifier_suffix(data_type);
|
const std::string output_identifier = "Attribute" + identifier_suffix(data_type);
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node)
|
|||||||
|
|
||||||
static void node_update(bNodeTree *ntree, 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 *edge_socket = point_socket->next;
|
||||||
bNodeSocket *face_socket = edge_socket->next;
|
bNodeSocket *face_socket = edge_socket->next;
|
||||||
bNodeSocket *face_corner_socket = face_socket->next;
|
bNodeSocket *face_corner_socket = face_socket->next;
|
||||||
|
|||||||
@@ -54,12 +54,12 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node)
|
|||||||
|
|
||||||
static void node_update(bNodeTree *ntree, 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_selection = socket_geo->next;
|
||||||
bNodeSocket *socket_float_attr = socket_selection->next;
|
bNodeSocket *socket_float_attr = socket_selection->next;
|
||||||
bNodeSocket *socket_float3_attr = socket_float_attr->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_median = socket_float_mean->next;
|
||||||
bNodeSocket *socket_float_sum = socket_float_median->next;
|
bNodeSocket *socket_float_sum = socket_float_median->next;
|
||||||
bNodeSocket *socket_float_min = socket_float_sum->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_std = socket_vector_range->next;
|
||||||
bNodeSocket *socket_vector_variance = socket_vector_std->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_attr, data_type == CD_PROP_FLOAT);
|
||||||
nodeSetSocketAvailability(ntree, socket_float_mean, 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");
|
GeometrySet geometry_set = params.get_input<GeometrySet>("Geometry");
|
||||||
const bNode &node = params.node();
|
const bNode &node = params.node();
|
||||||
const eCustomDataType data_type = static_cast<eCustomDataType>(node.custom1);
|
const eCustomDataType data_type = eCustomDataType(node.custom1);
|
||||||
const eAttrDomain domain = static_cast<eAttrDomain>(node.custom2);
|
const eAttrDomain domain = eAttrDomain(node.custom2);
|
||||||
Vector<const GeometryComponent *> components = geometry_set.get_components_for_read();
|
Vector<const GeometryComponent *> components = geometry_set.get_components_for_read();
|
||||||
|
|
||||||
const Field<bool> selection_field = params.get_input<Field<bool>>("Selection");
|
const Field<bool> selection_field = params.get_input<Field<bool>>("Selection");
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ static void node_update(bNodeTree *ntree, bNode *node)
|
|||||||
{
|
{
|
||||||
GeometryNodeBooleanOperation operation = (GeometryNodeBooleanOperation)node->custom1;
|
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;
|
bNodeSocket *geometry_2_socket = geometry_1_socket->next;
|
||||||
|
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
@@ -148,7 +148,8 @@ static void node_geo_exec(GeoNodeExecParams params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MEM_SAFE_FREE(result->mat);
|
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();
|
result->totcol = materials.size();
|
||||||
MutableSpan(result->mat, result->totcol).copy_from(materials);
|
MutableSpan(result->mat, result->totcol).copy_from(materials);
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ static void node_geo_exec(GeoNodeExecParams params)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const Object *self_object = params.self_object();
|
const Object *self_object = params.self_object();
|
||||||
const bool is_recursive = BKE_collection_has_object_recursive_instanced(collection,
|
const bool is_recursive = BKE_collection_has_object_recursive_instanced(
|
||||||
(Object *)self_object);
|
collection, const_cast<Object *>(self_object));
|
||||||
if (is_recursive) {
|
if (is_recursive) {
|
||||||
params.error_message_add(NodeWarningType::Error, "Collection contains current object");
|
params.error_message_add(NodeWarningType::Error, "Collection contains current object");
|
||||||
params.set_default_remaining_outputs();
|
params.set_default_remaining_outputs();
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ static void node_update(bNodeTree *ntree, bNode *node)
|
|||||||
{
|
{
|
||||||
const NodeGeometryCurveFillet &storage = node_storage(*node);
|
const NodeGeometryCurveFillet &storage = node_storage(*node);
|
||||||
const GeometryNodeCurveFilletMode mode = (GeometryNodeCurveFilletMode)storage.mode;
|
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);
|
nodeSetSocketAvailability(ntree, poly_socket, mode == GEO_NODE_CURVE_FILLET_POLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ static void node_update(bNodeTree *ntree, bNode *node)
|
|||||||
const NodeGeometryCurvePrimitiveArc &storage = node_storage(*node);
|
const NodeGeometryCurvePrimitiveArc &storage = node_storage(*node);
|
||||||
const GeometryNodeCurvePrimitiveArcMode mode = (GeometryNodeCurvePrimitiveArcMode)storage.mode;
|
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 *middle_socket = start_socket->next;
|
||||||
bNodeSocket *end_socket = middle_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 *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 *normal_out_socket = center_out_socket->next;
|
||||||
bNodeSocket *radius_out_socket = normal_out_socket->next;
|
bNodeSocket *radius_out_socket = normal_out_socket->next;
|
||||||
|
|
||||||
|
|||||||
@@ -75,12 +75,12 @@ static void node_update(bNodeTree *ntree, bNode *node)
|
|||||||
const GeometryNodeCurvePrimitiveCircleMode mode = (GeometryNodeCurvePrimitiveCircleMode)
|
const GeometryNodeCurvePrimitiveCircleMode mode = (GeometryNodeCurvePrimitiveCircleMode)
|
||||||
storage.mode;
|
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 *middle_socket = start_socket->next;
|
||||||
bNodeSocket *end_socket = middle_socket->next;
|
bNodeSocket *end_socket = middle_socket->next;
|
||||||
bNodeSocket *radius_socket = end_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(
|
nodeSetSocketAvailability(
|
||||||
ntree, start_socket, mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS);
|
ntree, start_socket, mode == GEO_NODE_CURVE_PRIMITIVE_CIRCLE_TYPE_POINTS);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ static void node_update(bNodeTree *ntree, bNode *node)
|
|||||||
const NodeGeometryCurvePrimitiveLine &storage = node_storage(*node);
|
const NodeGeometryCurvePrimitiveLine &storage = node_storage(*node);
|
||||||
const GeometryNodeCurvePrimitiveLineMode mode = (GeometryNodeCurvePrimitiveLineMode)storage.mode;
|
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 *direction_socket = p2_socket->next;
|
||||||
bNodeSocket *length_socket = direction_socket->next;
|
bNodeSocket *length_socket = direction_socket->next;
|
||||||
|
|
||||||
|
|||||||
@@ -83,10 +83,9 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node)
|
|||||||
static void node_update(bNodeTree *ntree, bNode *node)
|
static void node_update(bNodeTree *ntree, bNode *node)
|
||||||
{
|
{
|
||||||
const NodeGeometryCurvePrimitiveQuad &storage = node_storage(*node);
|
const NodeGeometryCurvePrimitiveQuad &storage = node_storage(*node);
|
||||||
GeometryNodeCurvePrimitiveQuadMode mode = static_cast<GeometryNodeCurvePrimitiveQuadMode>(
|
GeometryNodeCurvePrimitiveQuadMode mode = GeometryNodeCurvePrimitiveQuadMode(storage.mode);
|
||||||
storage.mode);
|
|
||||||
|
|
||||||
bNodeSocket *width = ((bNodeSocket *)node->inputs.first);
|
bNodeSocket *width = static_cast<bNodeSocket *>(node->inputs.first);
|
||||||
bNodeSocket *height = width->next;
|
bNodeSocket *height = width->next;
|
||||||
bNodeSocket *bottom = height->next;
|
bNodeSocket *bottom = height->next;
|
||||||
bNodeSocket *top = bottom->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());
|
search_link_ops_for_declarations(params, declaration.outputs());
|
||||||
}
|
}
|
||||||
else if (params.node_tree().typeinfo->validate_link(
|
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"),
|
params.add_item(IFACE_("Width"),
|
||||||
SocketSearchOp{"Width", GEO_NODE_CURVE_PRIMITIVE_QUAD_MODE_RECTANGLE});
|
SocketSearchOp{"Width", GEO_NODE_CURVE_PRIMITIVE_QUAD_MODE_RECTANGLE});
|
||||||
params.add_item(IFACE_("Height"),
|
params.add_item(IFACE_("Height"),
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ static void node_update(bNodeTree *ntree, bNode *node)
|
|||||||
const NodeGeometryCurveResample &storage = node_storage(*node);
|
const NodeGeometryCurveResample &storage = node_storage(*node);
|
||||||
const GeometryNodeCurveResampleMode mode = (GeometryNodeCurveResampleMode)storage.mode;
|
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;
|
bNodeSocket *length_socket = count_socket->next;
|
||||||
|
|
||||||
nodeSetSocketAvailability(ntree, count_socket, mode == GEO_NODE_CURVE_RESAMPLE_COUNT);
|
nodeSetSocketAvailability(ntree, count_socket, mode == GEO_NODE_CURVE_RESAMPLE_COUNT);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ static void node_update(bNodeTree *ntree, bNode *node)
|
|||||||
const NodeGeometryCurveSample &storage = node_storage(*node);
|
const NodeGeometryCurveSample &storage = node_storage(*node);
|
||||||
const GeometryNodeCurveSampleMode mode = (GeometryNodeCurveSampleMode)storage.mode;
|
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;
|
bNodeSocket *length = factor->next;
|
||||||
|
|
||||||
nodeSetSocketAvailability(ntree, factor, mode == GEO_NODE_CURVE_SAMPLE_FACTOR);
|
nodeSetSocketAvailability(ntree, factor, mode == GEO_NODE_CURVE_SAMPLE_FACTOR);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ static void node_update(bNodeTree *ntree, bNode *node)
|
|||||||
const NodeGeometryCurveToPoints &storage = node_storage(*node);
|
const NodeGeometryCurveToPoints &storage = node_storage(*node);
|
||||||
const GeometryNodeCurveResampleMode mode = (GeometryNodeCurveResampleMode)storage.mode;
|
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;
|
bNodeSocket *length_socket = count_socket->next;
|
||||||
|
|
||||||
nodeSetSocketAvailability(ntree, count_socket, mode == GEO_NODE_CURVE_RESAMPLE_COUNT);
|
nodeSetSocketAvailability(ntree, count_socket, mode == GEO_NODE_CURVE_RESAMPLE_COUNT);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ static void node_update(bNodeTree *ntree, bNode *node)
|
|||||||
const NodeGeometryCurveTrim &storage = node_storage(*node);
|
const NodeGeometryCurveTrim &storage = node_storage(*node);
|
||||||
const GeometryNodeCurveSampleMode mode = (GeometryNodeCurveSampleMode)storage.mode;
|
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 *end_fac = start_fac->next;
|
||||||
bNodeSocket *start_len = end_fac->next;
|
bNodeSocket *start_len = end_fac->next;
|
||||||
bNodeSocket *end_len = start_len->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));
|
search_link_ops_for_declarations(params, declaration.inputs().take_front(1));
|
||||||
|
|
||||||
if (params.in_out() == SOCK_IN) {
|
if (params.in_out() == SOCK_IN) {
|
||||||
if (params.node_tree().typeinfo->validate_link(
|
if (params.node_tree().typeinfo->validate_link(eNodeSocketDatatype(params.other_socket().type),
|
||||||
static_cast<eNodeSocketDatatype>(params.other_socket().type), SOCK_FLOAT)) {
|
SOCK_FLOAT)) {
|
||||||
params.add_item(IFACE_("Start (Factor)"),
|
params.add_item(IFACE_("Start (Factor)"),
|
||||||
SocketSearchOp{"Start", GEO_NODE_CURVE_SAMPLE_FACTOR});
|
SocketSearchOp{"Start", GEO_NODE_CURVE_SAMPLE_FACTOR});
|
||||||
params.add_item(IFACE_("End (Factor)"), SocketSearchOp{"End", GEO_NODE_CURVE_SAMPLE_FACTOR});
|
params.add_item(IFACE_("End (Factor)"), SocketSearchOp{"End", GEO_NODE_CURVE_SAMPLE_FACTOR});
|
||||||
|
|||||||
@@ -1163,7 +1163,7 @@ static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|||||||
{
|
{
|
||||||
const bNode *node = static_cast<bNode *>(ptr->data);
|
const bNode *node = static_cast<bNode *>(ptr->data);
|
||||||
const NodeGeometryDeleteGeometry &storage = node_storage(*node);
|
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);
|
uiItemR(layout, ptr, "domain", 0, "", ICON_NONE);
|
||||||
/* Only show the mode when it is relevant. */
|
/* 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"));
|
params.extract_input<Field<bool>>("Selection"));
|
||||||
|
|
||||||
const NodeGeometryDeleteGeometry &storage = node_storage(params.node());
|
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;
|
const GeometryNodeDeleteGeometryMode mode = (GeometryNodeDeleteGeometryMode)storage.mode;
|
||||||
|
|
||||||
if (domain == ATTR_DOMAIN_INSTANCE) {
|
if (domain == ATTR_DOMAIN_INSTANCE) {
|
||||||
|
|||||||
@@ -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)
|
static void node_distribute_points_in_volume_update(bNodeTree *ntree, bNode *node)
|
||||||
{
|
{
|
||||||
const NodeGeometryDistributePointsInVolume &storage = node_storage(*node);
|
const NodeGeometryDistributePointsInVolume &storage = node_storage(*node);
|
||||||
GeometryNodeDistributePointsInVolumeMode mode =
|
GeometryNodeDistributePointsInVolumeMode mode = GeometryNodeDistributePointsInVolumeMode(
|
||||||
static_cast<GeometryNodeDistributePointsInVolumeMode>(storage.mode);
|
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_seed = sock_density->next;
|
||||||
bNodeSocket *sock_spacing = sock_seed->next;
|
bNodeSocket *sock_spacing = sock_seed->next;
|
||||||
bNodeSocket *sock_threshold = sock_spacing->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");
|
GeometrySet geometry_set = params.extract_input<GeometrySet>("Volume");
|
||||||
|
|
||||||
const NodeGeometryDistributePointsInVolume &storage = node_storage(params.node());
|
const NodeGeometryDistributePointsInVolume &storage = node_storage(params.node());
|
||||||
const GeometryNodeDistributePointsInVolumeMode mode =
|
const GeometryNodeDistributePointsInVolumeMode mode = GeometryNodeDistributePointsInVolumeMode(
|
||||||
static_cast<GeometryNodeDistributePointsInVolumeMode>(storage.mode);
|
storage.mode);
|
||||||
|
|
||||||
float density;
|
float density;
|
||||||
int seed;
|
int seed;
|
||||||
|
|||||||
@@ -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)
|
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_distance_min = static_cast<bNodeSocket *>(BLI_findlink(&node->inputs, 2));
|
||||||
bNodeSocket *sock_density_max = (bNodeSocket *)sock_distance_min->next;
|
bNodeSocket *sock_density_max = static_cast<bNodeSocket *>(sock_distance_min->next);
|
||||||
bNodeSocket *sock_density = sock_density_max->next;
|
bNodeSocket *sock_density = sock_density_max->next;
|
||||||
bNodeSocket *sock_density_factor = sock_density->next;
|
bNodeSocket *sock_density_factor = sock_density->next;
|
||||||
nodeSetSocketAvailability(ntree,
|
nodeSetSocketAvailability(ntree,
|
||||||
@@ -511,8 +511,8 @@ static void node_geo_exec(GeoNodeExecParams params)
|
|||||||
{
|
{
|
||||||
GeometrySet geometry_set = params.extract_input<GeometrySet>("Mesh");
|
GeometrySet geometry_set = params.extract_input<GeometrySet>("Mesh");
|
||||||
|
|
||||||
const GeometryNodeDistributePointsOnFacesMode method =
|
const GeometryNodeDistributePointsOnFacesMode method = GeometryNodeDistributePointsOnFacesMode(
|
||||||
static_cast<GeometryNodeDistributePointsOnFacesMode>(params.node().custom1);
|
params.node().custom1);
|
||||||
|
|
||||||
const int seed = params.get_input<int>("Seed") * 5383843;
|
const int seed = params.get_input<int>("Seed") * 5383843;
|
||||||
const Field<bool> selection_field = params.extract_input<Field<bool>>("Selection");
|
const Field<bool> selection_field = params.extract_input<Field<bool>>("Selection");
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node)
|
|||||||
static void node_update(bNodeTree *ntree, bNode *node)
|
static void node_update(bNodeTree *ntree, bNode *node)
|
||||||
{
|
{
|
||||||
const NodeGeometryExtrudeMesh &storage = node_storage(*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);
|
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<float3> offset_field = params.extract_input<Field<float3>>("Offset");
|
||||||
Field<float> scale_field = params.extract_input<Field<float>>("Offset Scale");
|
Field<float> scale_field = params.extract_input<Field<float>>("Offset Scale");
|
||||||
const NodeGeometryExtrudeMesh &storage = node_storage(params.node());
|
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
|
/* 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. */
|
* can take care of the multiplication and to simplify each extrude function. */
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node)
|
|||||||
|
|
||||||
static void node_update(bNodeTree *ntree, 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_index = static_cast<bNodeSocket *>(node->inputs.first);
|
||||||
bNodeSocket *sock_in_float = sock_index->next;
|
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)
|
static void node_geo_exec(GeoNodeExecParams params)
|
||||||
{
|
{
|
||||||
const bNode &node = params.node();
|
const bNode &node = params.node();
|
||||||
const eAttrDomain domain = static_cast<eAttrDomain>(node.custom1);
|
const eAttrDomain domain = eAttrDomain(node.custom1);
|
||||||
const eCustomDataType data_type = static_cast<eCustomDataType>(node.custom2);
|
const eCustomDataType data_type = eCustomDataType(node.custom2);
|
||||||
|
|
||||||
Field<int> index_field = params.extract_input<Field<int>>("Index");
|
Field<int> index_field = params.extract_input<Field<int>>("Index");
|
||||||
attribute_math::convert_to_static_type(data_type, [&](auto dummy) {
|
attribute_math::convert_to_static_type(data_type, [&](auto dummy) {
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ class ImageFieldsFunction : public fn::MultiFunction {
|
|||||||
1, "Color");
|
1, "Color");
|
||||||
MutableSpan<float> r_alpha = params.uninitialized_single_output_if_required<float>(2, "Alpha");
|
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. */
|
/* Sample image texture. */
|
||||||
switch (interpolation_) {
|
switch (interpolation_) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|||||||
|
|
||||||
static void node_geo_exec(GeoNodeExecParams params)
|
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);
|
params.set_output("Material", material);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ class PlanarFieldInput final : public bke::MeshFieldInput {
|
|||||||
const Span<MVert> verts = mesh.verts();
|
const Span<MVert> verts = mesh.verts();
|
||||||
const Span<MPoly> polys = mesh.polys();
|
const Span<MPoly> polys = mesh.polys();
|
||||||
const Span<MLoop> loops = mesh.loops();
|
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};
|
bke::MeshFieldContext context{mesh, ATTR_DOMAIN_FACE};
|
||||||
fn::FieldEvaluator evaluator{context, polys.size()};
|
fn::FieldEvaluator evaluator{context, polys.size()};
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node)
|
|||||||
static void node_update(bNodeTree *ntree, bNode *node)
|
static void node_update(bNodeTree *ntree, bNode *node)
|
||||||
{
|
{
|
||||||
const NodeGeometryInputNamedAttribute &storage = node_storage(*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_float = socket_vector->next;
|
||||||
bNodeSocket *socket_color4f = socket_float->next;
|
bNodeSocket *socket_color4f = socket_float->next;
|
||||||
bNodeSocket *socket_boolean = socket_color4f->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) {
|
if (params.in_out() == SOCK_OUT) {
|
||||||
const std::optional<eCustomDataType> type = node_data_type_to_custom_data_type(
|
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) {
|
if (type && *type != CD_PROP_STRING) {
|
||||||
/* The input and output sockets have the same name. */
|
/* The input and output sockets have the same name. */
|
||||||
params.add_item(IFACE_("Attribute"), [type](LinkSearchOpParams ¶ms) {
|
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)
|
static void node_geo_exec(GeoNodeExecParams params)
|
||||||
{
|
{
|
||||||
const NodeGeometryInputNamedAttribute &storage = node_storage(params.node());
|
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");
|
const std::string name = params.extract_input<std::string>("Name");
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node)
|
|||||||
|
|
||||||
static void node_update(bNodeTree *ntree, 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_float = static_cast<bNodeSocket *>(node->inputs.first);
|
||||||
bNodeSocket *sock_in_int = sock_in_float->next;
|
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)
|
static void node_geo_exec(GeoNodeExecParams params)
|
||||||
{
|
{
|
||||||
const bNode &node = params.node();
|
const bNode &node = params.node();
|
||||||
const eAttrDomain domain = static_cast<eAttrDomain>(node.custom1);
|
const eAttrDomain domain = eAttrDomain(node.custom1);
|
||||||
const eCustomDataType data_type = static_cast<eCustomDataType>(node.custom2);
|
const eCustomDataType data_type = eCustomDataType(node.custom2);
|
||||||
|
|
||||||
attribute_math::convert_to_static_type(data_type, [&](auto dummy) {
|
attribute_math::convert_to_static_type(data_type, [&](auto dummy) {
|
||||||
using T = decltype(dummy);
|
using T = decltype(dummy);
|
||||||
|
|||||||
@@ -754,7 +754,7 @@ static void node_init(bNodeTree *UNUSED(ntree), bNode *node)
|
|||||||
|
|
||||||
static void node_update(bNodeTree *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 *rings_socket = vertices_socket->next;
|
||||||
bNodeSocket *fill_subdiv_socket = rings_socket->next;
|
bNodeSocket *fill_subdiv_socket = rings_socket->next;
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ static void node_init(bNodeTree *UNUSED(ntree), bNode *node)
|
|||||||
|
|
||||||
static void node_update(bNodeTree *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 *rings_socket = vertices_socket->next;
|
||||||
bNodeSocket *fill_subdiv_socket = rings_socket->next;
|
bNodeSocket *fill_subdiv_socket = rings_socket->next;
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ static Mesh *create_ico_sphere_mesh(const int subdivisions, const float radius)
|
|||||||
|
|
||||||
BMeshToMeshParams params{};
|
BMeshToMeshParams params{};
|
||||||
params.calc_object_remap = false;
|
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);
|
BKE_id_material_eval_ensure_default_slot(&mesh->id);
|
||||||
BM_mesh_bm_to_me(nullptr, bm, mesh, ¶ms);
|
BM_mesh_bm_to_me(nullptr, bm, mesh, ¶ms);
|
||||||
BM_mesh_free(bm);
|
BM_mesh_free(bm);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ static void node_init(bNodeTree *UNUSED(ntree), bNode *node)
|
|||||||
|
|
||||||
static void node_update(bNodeTree *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 *resolution_socket = count_socket->next;
|
||||||
bNodeSocket *start_socket = resolution_socket->next;
|
bNodeSocket *start_socket = resolution_socket->next;
|
||||||
bNodeSocket *end_and_offset_socket = start_socket->next;
|
bNodeSocket *end_and_offset_socket = start_socket->next;
|
||||||
@@ -97,7 +97,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (params.node_tree().typeinfo->validate_link(
|
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) {
|
params.add_item(IFACE_("Count"), [](LinkSearchOpParams ¶ms) {
|
||||||
bNode &node = params.add_node("GeometryNodeMeshLine");
|
bNode &node = params.add_node("GeometryNodeMeshLine");
|
||||||
node_storage(node).mode = GEO_NODE_MESH_LINE_MODE_OFFSET;
|
node_storage(node).mode = GEO_NODE_MESH_LINE_MODE_OFFSET;
|
||||||
|
|||||||
@@ -309,7 +309,8 @@ static Mesh *create_uv_sphere_mesh(const float radius, const int segments, const
|
|||||||
threading::parallel_invoke(
|
threading::parallel_invoke(
|
||||||
1024 < segments * rings,
|
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);
|
calculate_sphere_vertex_data(verts, vert_normals, radius, segments, rings);
|
||||||
BKE_mesh_vertex_normals_clear_dirty(mesh);
|
BKE_mesh_vertex_normals_clear_dirty(mesh);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -59,24 +59,22 @@ static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|||||||
|
|
||||||
static void node_init(bNodeTree *UNUSED(tree), bNode *node)
|
static void node_init(bNodeTree *UNUSED(tree), bNode *node)
|
||||||
{
|
{
|
||||||
NodeGeometryMeshToVolume *data = (NodeGeometryMeshToVolume *)MEM_callocN(
|
NodeGeometryMeshToVolume *data = MEM_cnew<NodeGeometryMeshToVolume>(__func__);
|
||||||
sizeof(NodeGeometryMeshToVolume), __func__);
|
|
||||||
data->resolution_mode = MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT;
|
data->resolution_mode = MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT;
|
||||||
node->storage = data;
|
node->storage = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void node_update(bNodeTree *ntree, bNode *node)
|
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_size_socket = nodeFindSocket(node, SOCK_IN, "Voxel Size");
|
||||||
bNodeSocket *voxel_amount_socket = nodeFindSocket(node, SOCK_IN, "Voxel Amount");
|
bNodeSocket *voxel_amount_socket = nodeFindSocket(node, SOCK_IN, "Voxel Amount");
|
||||||
nodeSetSocketAvailability(ntree,
|
nodeSetSocketAvailability(ntree,
|
||||||
voxel_amount_socket,
|
voxel_amount_socket,
|
||||||
data->resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT);
|
data.resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT);
|
||||||
nodeSetSocketAvailability(ntree,
|
nodeSetSocketAvailability(
|
||||||
voxel_size_socket,
|
ntree, voxel_size_socket, data.resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_SIZE);
|
||||||
data->resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_OPENVDB
|
#ifdef WITH_OPENVDB
|
||||||
@@ -126,7 +124,7 @@ static Volume *create_volume_from_mesh(const Mesh &mesh, GeoNodeExecParams ¶
|
|||||||
exterior_band_width,
|
exterior_band_width,
|
||||||
mesh_to_volume_space_transform);
|
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);
|
BKE_volume_init_grids(volume);
|
||||||
|
|
||||||
/* Convert mesh to grid and add to volume. */
|
/* Convert mesh to grid and add to volume. */
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ static void initialize_volume_component_from_points(GeoNodeExecParams ¶ms,
|
|||||||
return;
|
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);
|
BKE_volume_init_grids(volume);
|
||||||
|
|
||||||
const float density = params.get_input<float>("Density");
|
const float density = params.get_input<float>("Density");
|
||||||
|
|||||||
@@ -211,8 +211,7 @@ static void node_geo_exec(GeoNodeExecParams params)
|
|||||||
Field<float3> position_field = params.extract_input<Field<float3>>("Source Position");
|
Field<float3> position_field = params.extract_input<Field<float3>>("Source Position");
|
||||||
|
|
||||||
auto proximity_fn = std::make_unique<ProximityFunction>(
|
auto proximity_fn = std::make_unique<ProximityFunction>(
|
||||||
std::move(geometry_set_target),
|
std::move(geometry_set_target), GeometryNodeProximityTargetType(storage.target_element));
|
||||||
static_cast<GeometryNodeProximityTargetType>(storage.target_element));
|
|
||||||
auto proximity_op = std::make_shared<FieldOperation>(
|
auto proximity_op = std::make_shared<FieldOperation>(
|
||||||
FieldOperation(std::move(proximity_fn), {std::move(position_field)}));
|
FieldOperation(std::move(proximity_fn), {std::move(position_field)}));
|
||||||
|
|
||||||
|
|||||||
@@ -70,9 +70,9 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node)
|
|||||||
static void node_update(bNodeTree *ntree, bNode *node)
|
static void node_update(bNodeTree *ntree, bNode *node)
|
||||||
{
|
{
|
||||||
const NodeGeometryRaycast &storage = node_storage(*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_float = socket_vector->next;
|
||||||
bNodeSocket *socket_color4f = socket_float->next;
|
bNodeSocket *socket_color4f = socket_float->next;
|
||||||
bNodeSocket *socket_boolean = socket_color4f->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_boolean, data_type == CD_PROP_BOOL);
|
||||||
nodeSetSocketAvailability(ntree, socket_int32, data_type == CD_PROP_INT32);
|
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_float = out_socket_vector->next;
|
||||||
bNodeSocket *out_socket_color4f = out_socket_float->next;
|
bNodeSocket *out_socket_color4f = out_socket_float->next;
|
||||||
bNodeSocket *out_socket_boolean = out_socket_color4f->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");
|
GeometrySet target = params.extract_input<GeometrySet>("Target Geometry");
|
||||||
const NodeGeometryRaycast &storage = node_storage(params.node());
|
const NodeGeometryRaycast &storage = node_storage(params.node());
|
||||||
const GeometryNodeRaycastMapMode mapping = (GeometryNodeRaycastMapMode)storage.mapping;
|
const GeometryNodeRaycastMapMode mapping = GeometryNodeRaycastMapMode(storage.mapping);
|
||||||
const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type);
|
const eCustomDataType data_type = eCustomDataType(storage.data_type);
|
||||||
|
|
||||||
if (target.is_empty()) {
|
if (target.is_empty()) {
|
||||||
params.set_default_remaining_outputs();
|
params.set_default_remaining_outputs();
|
||||||
|
|||||||
@@ -56,8 +56,7 @@ static void node_update(bNodeTree *ntree, bNode *node)
|
|||||||
bNodeSocket *center_socket = scale_float_socket->next;
|
bNodeSocket *center_socket = scale_float_socket->next;
|
||||||
bNodeSocket *axis_socket = center_socket->next;
|
bNodeSocket *axis_socket = center_socket->next;
|
||||||
|
|
||||||
const GeometryNodeScaleElementsMode mode = static_cast<GeometryNodeScaleElementsMode>(
|
const GeometryNodeScaleElementsMode mode = GeometryNodeScaleElementsMode(node->custom2);
|
||||||
node->custom2);
|
|
||||||
const bool use_single_axis = mode == GEO_NODE_SCALE_ELEMENTS_SINGLE_AXIS;
|
const bool use_single_axis = mode == GEO_NODE_SCALE_ELEMENTS_SINGLE_AXIS;
|
||||||
|
|
||||||
nodeSetSocketAvailability(ntree, axis_socket, use_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)
|
static void node_geo_exec(GeoNodeExecParams params)
|
||||||
{
|
{
|
||||||
const bNode &node = params.node();
|
const bNode &node = params.node();
|
||||||
const eAttrDomain domain = static_cast<eAttrDomain>(node.custom1);
|
const eAttrDomain domain = eAttrDomain(node.custom1);
|
||||||
const GeometryNodeScaleElementsMode scale_mode = static_cast<GeometryNodeScaleElementsMode>(
|
const GeometryNodeScaleElementsMode scale_mode = GeometryNodeScaleElementsMode(node.custom2);
|
||||||
node.custom2);
|
|
||||||
|
|
||||||
GeometrySet geometry = params.extract_input<GeometrySet>("Geometry");
|
GeometrySet geometry = params.extract_input<GeometrySet>("Geometry");
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ static void node_geo_exec(GeoNodeExecParams params)
|
|||||||
const Field<bool> selection_field = params.extract_input<Field<bool>>("Selection");
|
const Field<bool> selection_field = params.extract_input<Field<bool>>("Selection");
|
||||||
|
|
||||||
const NodeGeometrySeparateGeometry &storage = node_storage(params.node());
|
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,
|
auto separate_geometry_maybe_recursively = [&](GeometrySet &geometry_set,
|
||||||
const Field<bool> &selection) {
|
const Field<bool> &selection) {
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node)
|
|||||||
static void node_update(bNodeTree *ntree, bNode *node)
|
static void node_update(bNodeTree *ntree, bNode *node)
|
||||||
{
|
{
|
||||||
const NodeGeometryStoreNamedAttribute &storage = node_storage(*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_name = socket_geometry->next;
|
||||||
bNodeSocket *socket_vector = socket_name->next;
|
bNodeSocket *socket_vector = socket_name->next;
|
||||||
bNodeSocket *socket_float = socket_vector->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) {
|
if (params.in_out() == SOCK_IN) {
|
||||||
const std::optional<eCustomDataType> type = node_data_type_to_custom_data_type(
|
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) {
|
if (type && *type != CD_PROP_STRING) {
|
||||||
/* The input and output sockets have the same name. */
|
/* The input and output sockets have the same name. */
|
||||||
params.add_item(IFACE_("Value"), [type](LinkSearchOpParams ¶ms) {
|
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);
|
params.used_named_attribute(name, NamedAttributeUsage::Write);
|
||||||
|
|
||||||
const NodeGeometryStoreNamedAttribute &storage = node_storage(params.node());
|
const NodeGeometryStoreNamedAttribute &storage = node_storage(params.node());
|
||||||
const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type);
|
const eCustomDataType data_type = eCustomDataType(storage.data_type);
|
||||||
const eAttrDomain domain = static_cast<eAttrDomain>(storage.domain);
|
const eAttrDomain domain = eAttrDomain(storage.domain);
|
||||||
|
|
||||||
GField field;
|
GField field;
|
||||||
switch (data_type) {
|
switch (data_type) {
|
||||||
|
|||||||
@@ -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->align_y = GEO_NODE_STRING_TO_CURVES_ALIGN_Y_TOP_BASELINE;
|
||||||
data->pivot_mode = GEO_NODE_STRING_TO_CURVES_PIVOT_MODE_BOTTOM_LEFT;
|
data->pivot_mode = GEO_NODE_STRING_TO_CURVES_PIVOT_MODE_BOTTOM_LEFT;
|
||||||
node->storage = data;
|
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)
|
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 NodeGeometryStringToCurves &storage = node_storage(*node);
|
||||||
const GeometryNodeStringToCurvesOverflowMode overflow = (GeometryNodeStringToCurvesOverflowMode)
|
const GeometryNodeStringToCurvesOverflowMode overflow = (GeometryNodeStringToCurvesOverflowMode)
|
||||||
storage.overflow;
|
storage.overflow;
|
||||||
bNodeSocket *socket_remainder = ((bNodeSocket *)node->outputs.first)->next;
|
bNodeSocket *socket_remainder = static_cast<bNodeSocket *>(node->outputs.first)->next;
|
||||||
nodeSetSocketAvailability(
|
nodeSetSocketAvailability(
|
||||||
ntree, socket_remainder, overflow == GEO_NODE_STRING_TO_CURVES_MODE_TRUNCATE);
|
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(
|
nodeSetSocketAvailability(
|
||||||
ntree, height_socket, overflow != GEO_NODE_STRING_TO_CURVES_MODE_OVERFLOW);
|
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.linedist = line_spacing;
|
||||||
cu.vfont = vfont;
|
cu.vfont = vfont;
|
||||||
cu.overflow = overflow;
|
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->w = textbox_w;
|
||||||
cu.tb->h = textbox_h;
|
cu.tb->h = textbox_h;
|
||||||
cu.totbox = 1;
|
cu.totbox = 1;
|
||||||
@@ -213,8 +213,8 @@ static std::optional<TextLayout> get_text_layout(GeoNodeExecParams ¶ms)
|
|||||||
cu.len = len_bytes;
|
cu.len = len_bytes;
|
||||||
cu.pos = len_chars;
|
cu.pos = len_chars;
|
||||||
/* The reason for the additional character here is unknown, but reflects other code elsewhere. */
|
/* 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.str = static_cast<char *>(MEM_mallocN(len_bytes + sizeof(char32_t), __func__));
|
||||||
cu.strinfo = (CharInfo *)MEM_callocN((len_chars + 1) * sizeof(CharInfo), __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);
|
BLI_strncpy(cu.str, layout.text.c_str(), len_bytes + 1);
|
||||||
|
|
||||||
struct CharTrans *chartransdata = nullptr;
|
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);
|
nullptr, &cu, FO_DUPLI, nullptr, &r_text, &text_len, &text_free, &chartransdata);
|
||||||
|
|
||||||
if (text_free) {
|
if (text_free) {
|
||||||
MEM_freeN((void *)r_text);
|
MEM_freeN(const_cast<char32_t *>(r_text));
|
||||||
}
|
}
|
||||||
|
|
||||||
Span<CharInfo> info{cu.strinfo, text_len};
|
Span<CharInfo> info{cu.strinfo, text_len};
|
||||||
@@ -272,7 +272,7 @@ static Map<int, int> create_curve_instances(GeoNodeExecParams ¶ms,
|
|||||||
TextLayout &layout,
|
TextLayout &layout,
|
||||||
InstancesComponent &instances)
|
InstancesComponent &instances)
|
||||||
{
|
{
|
||||||
VFont *vfont = (VFont *)params.node().id;
|
VFont *vfont = reinterpret_cast<VFont *>(params.node().id);
|
||||||
Map<int, int> handles;
|
Map<int, int> handles;
|
||||||
bool pivot_required = params.output_is_required("Pivot Point");
|
bool pivot_required = params.output_is_required("Pivot Point");
|
||||||
|
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ static void node_update(bNodeTree *ntree, bNode *node)
|
|||||||
{
|
{
|
||||||
const NodeSwitch &storage = node_storage(*node);
|
const NodeSwitch &storage = node_storage(*node);
|
||||||
int index = 0;
|
int index = 0;
|
||||||
bNodeSocket *field_switch = (bNodeSocket *)node->inputs.first;
|
bNodeSocket *field_switch = static_cast<bNodeSocket *>(node->inputs.first);
|
||||||
bNodeSocket *non_field_switch = (bNodeSocket *)field_switch->next;
|
bNodeSocket *non_field_switch = static_cast<bNodeSocket *>(field_switch->next);
|
||||||
|
|
||||||
const bool fields_type = ELEM(
|
const bool fields_type = ELEM(
|
||||||
storage.input_type, SOCK_FLOAT, SOCK_INT, SOCK_BOOLEAN, SOCK_VECTOR, SOCK_RGBA, SOCK_STRING);
|
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)
|
static void node_geo_exec(GeoNodeExecParams params)
|
||||||
{
|
{
|
||||||
const NodeSwitch &storage = node_storage(params.node());
|
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) {
|
switch (data_type) {
|
||||||
|
|
||||||
|
|||||||
@@ -68,10 +68,8 @@ static void node_geo_exec(GeoNodeExecParams params)
|
|||||||
Field<bool> selection_field = params.extract_input<Field<bool>>("Selection");
|
Field<bool> selection_field = params.extract_input<Field<bool>>("Selection");
|
||||||
const int min_vertices = std::max(params.extract_input<int>("Minimum Vertices"), 4);
|
const int min_vertices = std::max(params.extract_input<int>("Minimum Vertices"), 4);
|
||||||
|
|
||||||
GeometryNodeTriangulateQuads quad_method = static_cast<GeometryNodeTriangulateQuads>(
|
GeometryNodeTriangulateQuads quad_method = GeometryNodeTriangulateQuads(params.node().custom1);
|
||||||
params.node().custom1);
|
GeometryNodeTriangulateNGons ngon_method = GeometryNodeTriangulateNGons(params.node().custom2);
|
||||||
GeometryNodeTriangulateNGons ngon_method = static_cast<GeometryNodeTriangulateNGons>(
|
|
||||||
params.node().custom2);
|
|
||||||
|
|
||||||
geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) {
|
geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) {
|
||||||
if (!geometry_set.has_mesh()) {
|
if (!geometry_set.has_mesh()) {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ static eNodeSocketDatatype custom_data_type_to_socket_type(const eCustomDataType
|
|||||||
static void node_update(bNodeTree *ntree, bNode *node)
|
static void node_update(bNodeTree *ntree, bNode *node)
|
||||||
{
|
{
|
||||||
const NodeGeometryViewer &storage = node_storage(*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);
|
const eNodeSocketDatatype socket_type = custom_data_type_to_socket_type(data_type);
|
||||||
|
|
||||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
|
LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ static void node_geo_exec(GeoNodeExecParams params)
|
|||||||
grid->transform().postTranslate(
|
grid->transform().postTranslate(
|
||||||
openvdb::math::Vec3<float>(bounds_min.x, bounds_min.y, bounds_min.z));
|
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_init_grids(volume);
|
||||||
|
|
||||||
BKE_volume_grid_add_vdb(*volume, "density", std::move(grid));
|
BKE_volume_grid_add_vdb(*volume, "density", std::move(grid));
|
||||||
|
|||||||
Reference in New Issue
Block a user