24 Vec3 max, y, g, t, z, b, p;
27 [[nodiscard]]
constexpr AABB() noexcept : min(0), max(0) {}
28 [[nodiscard]]
constexpr AABB(
class AABB
const& k) noexcept : min(k.min), max(k.max) {}
29 [[nodiscard]]
constexpr AABB(
class Vec3 const& min,
class Vec3 const& max) noexcept : min(min), max(max) {}
30 constexpr AABB& operator=(
const AABB&)
noexcept =
default;
32 inline AABB& merge(AABB
const& a)
noexcept {
33 *
this = AABB{ll::math::min(a.min, min), ll::math::max(a.max, max)};
37 inline AABB& merge(
Vec3 const& a)
noexcept {
38 *
this = AABB{ll::math::min(a, min), ll::math::max(a, max)};
42 template <
typename T,
size_t N>
43 [[nodiscard]]
constexpr T& get()
noexcept {
44 if constexpr (N == 0) {
46 }
else if constexpr (N == 1) {
49 static_assert(ll::traits::always_false<T>);
53 template <
typename T,
size_t N>
54 [[nodiscard]]
constexpr T
const& get()
const noexcept {
55 if constexpr (N == 0) {
57 }
else if constexpr (N == 1) {
60 static_assert(ll::traits::always_false<T>);
64 [[nodiscard]]
constexpr bool contains(
Vec3 const& a)
const noexcept {
return a.ge(min).all() && a.le(max).all(); }
66 [[nodiscard]]
constexpr bool contains(AABB
const& a)
const noexcept {
67 return a.min.ge(min).all() && a.max.le(max).all();
72 LLAPI
bool intersects(::AABB
const& c)
const;
74 [[nodiscard]]
constexpr Vec3 center()
const noexcept {
return (min + max) * 0.5f; }
76 [[nodiscard]]
constexpr AABB& shrink(
float f)
noexcept {
82 [[nodiscard]]
constexpr AABB& shrink(
Vec3 const& offset)
noexcept {
86 Vec3::forEachComponent([&]<
typename axis_type,
size_t iter> {
87 auto& newMin = min.get<axis_type, iter>();
88 auto& newMax = max.get<axis_type, iter>();
90 if (newMin > newMax) {
91 auto mid = (newMin + newMax) * 0.5f;
103 MCAPI ::AABBHitResult clip(
::Vec3 const& a,
::Vec3 const& b)
const;
105 MCAPI ::AABB cloneAndFloor(
float offsetMin,
float offsetMax)
const;
107 MCAPI ::AABB cloneAndGrow(
::Vec3 const& distance)
const;
109 MCAPI ::AABB cloneAndGrow(
float radius)
const;
111 MCAPI ::AABB cloneAndShrink(
::Vec3 const& offset)
const;
113 MCAPI ::AABB cloneAndTransformByMatrix(
::Matrix const& transform)
const;
115 MCAPI ::AABB cloneAndTranslate(
::Vec3 const& offset)
const;
117 MCAPI
float distanceTo(::AABB
const& aabb)
const;
119 MCAPI
bool intersectSegment(
120 ::Vec3 const& segmentBegin,
126 MCAPI
bool intersects(
::Vec3 const& segmentBegin,
::Vec3 const& segmentEnd)
const;
129 MCAPI
bool operator!=(::AABB
const& rhs)
const;
136 MCAPI static ::AABB aroundRadius(
::Vec3 const& point,
float radius);
138 MCAPI static ::ClipCollideResult
139 clipCollide(::AABB
const& stationary, ::AABB
const& moving,
::Vec3 const& velocity);
145 MCAPI static ::AABB
const& BLOCK_SHAPE();
147 MCAPI static ::AABB
const& BOX_AT_ORIGIN_WITH_NO_VOLUME();
153 MCAPI
void* $ctor(
::Vec3 const& min,
::Vec3 const& max);