33[[nodiscard]]
inline std::optional<Bounds<T>>
merge(
const std::optional<
Bounds<T>> &a,
36 if (a.has_value() &&
b.has_value()) {
49[[nodiscard]]
inline std::optional<Bounds<T>>
merge(
const std::optional<
Bounds<T>> &a,
56[[nodiscard]]
inline std::optional<Bounds<T>>
min_max(
const std::optional<
Bounds<T>> &a,
80 for (
int64_t lane = 0; lane < lanes; lane++) {
81 lo[lane] = hi[lane] = values[0];
83 for (
int64_t i = 0; i < full; i += lanes) {
84 for (
int64_t lane = 0; lane < lanes; lane++) {
85 const T &value = values[i + lane];
91 Bounds<T>
result{lo[0], hi[0]};
92 for (
int64_t lane = 1; lane < lanes; lane++) {
104template<
typename T,
typename RadiusT>
110 const int64_t full = size & ~(lanes - 1);
114 for (
int64_t lane = 0; lane < lanes; lane++) {
115 lo[lane] = values[0] - radii[0];
116 hi[lane] = values[0] + radii[0];
118 for (
int64_t i = 0; i < full; i += lanes) {
119 for (
int64_t lane = 0; lane < lanes; lane++) {
120 lo[lane] =
math::min(lo[lane], values[i + lane] - radii[i + lane]);
121 hi[lane] =
math::max(hi[lane], values[i + lane] + radii[i + lane]);
126 for (
int64_t lane = 1; lane < lanes; lane++) {
130 for (
int64_t i = full; i < size; i++) {
142template<
typename T> [[nodiscard]]
inline std::optional<Bounds<T>>
min_max(
const Span<T> values)
154 return merge(init, detail::min_max_lanes(values.slice(range)));
172 mask.index_range().drop_front(1),
176 Bounds<T> result = init;
177 mask.slice(range).foreach_index_optimized<int64_t>(
178 [&](const int i) { math::min_max(values[i], result.min, result.max); });
188template<
typename T,
typename RadiusT>
204 detail::min_max_lanes_with_radii(values.slice(range), radii.slice(range)));
212template<
typename T> [[nodiscard]]
inline std::optional<Bounds<T>>
min_max(
const VArray<T> &varray)
233 Bounds<T> result = init;
234 for (const int i : range) {
235 math::min_max(varray[i], result.min, result.max);
259 if (!a.has_value() || !
b.has_value()) {
268template<
typename T>
inline std::optional<T>
max(
const VArray<T> &values)
281 std::numeric_limits<T>::min(),
282 [&](
const IndexRange range,
int current_max) {
283 for (const int value : values_span.slice(range)) {
284 current_max = std::max(current_max, value);
288 [](
const int a,
const int b) {
return std::max(a,
b); });
363template<
typename T,
int D>
379template<
typename T,
int D>
392template<
typename T,
int Size>
395 for (
int i = 0; i < Size; i++) {
403template<
typename T,
int Size>
406 for (
int i = 0; i < Size; i++) {
414template<
typename T,
int Size>
418 for (
int i = 0; i < Size; i++) {
428 if constexpr (std::is_integral_v<T> || std::is_floating_point_v<T>) {
438 if constexpr (std::is_integral_v<T> || std::is_floating_point_v<T>) {
448 if constexpr (std::is_integral_v<T> || std::is_floating_point_v<T>) {
468 return p1 * q2 > p2 * q1;
475 return p1 * q2 < p2 * q1;
479template<
typename T,
int Size>
491 for (
int i = 0; i < Size; i++) {
492 const T di = end[i] - start[i];
495 if (start[i] <
bounds.min[i] || start[i] >
bounds.max[i]) {
503 const T p_low = (di >
T(0)) ?
bounds.min[i] - start[i] : -(
bounds.max[i] - start[i]);
504 const T p_high = (di >
T(0)) ?
bounds.max[i] - start[i] : -(
bounds.min[i] - start[i]);
505 const T di_abs = (di >
T(0)) ? di : -di;
527 return p_exit >=
T(0) && p_enter <= q_enter;
556 const T center = this->center();
557 const T new_half_size = this->size() /
T(2) *
scale;
564 this->
min = this->
center() - (new_size /
T(2));
565 this->
max = this->
min + new_size;
570 const T offset = new_center - this->
center();
575template<
typename PaddingT>
607 if constexpr (std::is_integral_v<T> || std::is_floating_point_v<T>) {
#define PRF_scope_with_name(ui_name, category)
constexpr const T & first() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
std::optional< T > get_if_single() const
IndexRange index_range() const
CommonVArrayInfo common_info() const
constexpr IndexRange index_range() const
float3x3 scale(float3x3 mat, float2 scale)
OrientationBounds merge(const OrientationBounds &cone_a, const OrientationBounds &cone_b)
Bounds< T > segment_bounds(const T &start, const T &end)
bool any_greater_than_v(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
bool any_less_or_equal_than_v(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
bool segment_enter_exit_bounds(const Bounds< VecBase< T, Size > > &bounds, const VecBase< T, Size > &start, const VecBase< T, Size > &end)
bool any_less_than_v(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
bool any_less_than(const T &a, const T &b)
Bounds< T > min_max_lanes(const Span< T > values)
bool rational_greater_than(const T &p1, const T &q1, const T &p2, const T &q2)
Bounds< T > min_max_lanes_with_radii(const Span< T > values, const Span< RadiusT > radii)
bool any_less_or_equal_than(const T &a, const T &b)
bool rational_less_than(const T &p1, const T &q1, const T &p2, const T &q2)
bool any_greater_than(const T &a, const T &b)
Bounds< VecBase< T, 3 > > transform_bounds(const MatBase< T, D, D > &matrix, const Bounds< VecBase< T, 3 > > &bounds)
Bounds< T > merge(const Bounds< T > &a, const Bounds< T > &b)
std::array< VecBase< T, 3 >, 8 > corners(const Bounds< VecBase< T, 3 > > &bounds)
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)
std::optional< T > max(const VArray< T > &values)
std::optional< Bounds< T > > intersect(const Bounds< T > &a, const Bounds< T > &b)
int size(const AssetLibraryReference *library_reference)
T min(const T &a, const T &b)
T midpoint(const T &a, const T &b)
void min_max(const T &value, T &min, T &max)
T max(const T &a, const T &b)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
Value parallel_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
uint padding(uint offset, uint alignment)
void scale_from_center(const T &scale)
bool contains(const T &point) const
void recenter(const T &new_center)
void resize(const T &new_size)
void pad(const PaddingT &padding)
void translate(const T &offset)
blender::VecBase< float, 3 > size() const
bool intersects_segment(const T &start, const T &end) const
bool intersects(const Bounds< T > &other) const