30[[nodiscard]]
inline std::optional<Bounds<T>>
merge(
const std::optional<
Bounds<T>> &a,
33 if (a.has_value() &&
b.has_value()) {
46[[nodiscard]]
inline std::optional<Bounds<T>>
min_max(
const std::optional<
Bounds<T>> &a,
58template<
typename T> [[nodiscard]]
inline std::optional<Bounds<T>>
min_max(
const Span<T> values)
60 if (values.is_empty()) {
69 Bounds<T> result = init;
70 for (const int i : range) {
71 math::min_max(values[i], result.min, result.max);
81 if (values.is_empty() || mask.is_empty()) {
84 if (mask.size() == values.size()) {
94 Bounds<T> result = init;
95 mask.slice(range).foreach_index_optimized<int64_t>(
96 [&](const int i) { math::min_max(values[i], result.min, result.max); });
106template<
typename T,
typename RadiusT>
111 if (values.is_empty()) {
115 return threading::parallel_reduce(
116 values.index_range(),
120 Bounds<T> result = init;
121 for (const int i : range) {
122 result.min = math::min(values[i] - radii[i], result.min);
123 result.max = math::max(values[i] + radii[i], result.max);
138 if (!a.has_value() || !
b.has_value()) {
143 if (result.is_empty()) {
153template<
typename T,
int Size>
157 for (
int i = 0; i < Size; i++) {
169 if constexpr (std::is_integral<T>::value || std::is_floating_point<T>::value) {
170 return this->max <= this->
min;
173 return detail::any_less_or_equal_than(this->max, this->
min);
195 const T center = this->center();
196 const T new_half_size = this->
size() /
T(2) * scale;
197 this->
min = center - new_half_size;
198 this->max = center + new_half_size;
203 this->
min = this->center() - (new_size /
T(2));
204 this->max = this->
min + new_size;
209 const T offset = new_center - this->center();
210 this->translate(offset);
214template<
typename PaddingT>
218 this->max = this->max +
padding;
__forceinline BoundBox intersect(const BoundBox &a, const BoundBox &b)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
local_group_size(16, 16) .push_constant(Type b
OrientationBounds merge(const OrientationBounds &cone_a, const OrientationBounds &cone_b)
Bounds< T > merge(const Bounds< T > &a, const Bounds< T > &b)
std::optional< Bounds< T > > min_max_with_radii(const Span< T > values, const Span< RadiusT > radii)
std::optional< Bounds< T > > min_max(const std::optional< Bounds< T > > &a, const T &b)
bool any_less_or_equal_than(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
T min(const T &a, const T &b)
T midpoint(const T &a, const T &b)
T max(const T &a, const T &b)
Value parallel_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)