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) {}
31 inline AABB& merge(AABB
const& a)
noexcept {
32 *
this = AABB{ll::math::min(a.min, min), ll::math::max(a.max, max)};
36 inline AABB& merge(
Vec3 const& a)
noexcept {
37 *
this = AABB{ll::math::min(a, min), ll::math::max(a, max)};
41 template <
typename T,
size_t N>
42 [[nodiscard]]
constexpr T& get()
noexcept {
43 if constexpr (N == 0) {
45 }
else if constexpr (N == 1) {
48 static_assert(ll::traits::always_false<T>);
52 template <
typename T,
size_t N>
53 [[nodiscard]]
constexpr T
const& get()
const noexcept {
54 if constexpr (N == 0) {
56 }
else if constexpr (N == 1) {
59 static_assert(ll::traits::always_false<T>);
63 [[nodiscard]]
constexpr bool contains(
Vec3 const& a)
const noexcept {
return a.ge(min).all() && a.le(max).all(); }
65 [[nodiscard]]
constexpr bool contains(AABB
const& a)
const noexcept {
66 return a.min.ge(min).all() && a.max.le(max).all();
71 LLAPI
bool intersects(::AABB
const& c)
const;
73 [[nodiscard]]
constexpr Vec3 center()
const noexcept {
return (min + max) * 0.5f; }
75 [[nodiscard]]
constexpr AABB& shrink(
float f)
noexcept {
81 [[nodiscard]]
constexpr AABB& shrink(
Vec3 const& offset)
noexcept {
85 Vec3::forEachComponent([&]<
typename axis_type,
size_t iter> {
86 auto& newMin = min.get<axis_type, iter>();
87 auto& newMax = max.get<axis_type, iter>();
89 if (newMin > newMax) {
90 auto mid = (newMin + newMax) * 0.5f;
103 MCAPI
float _clipAxisCollide(::AABB
const& c,
float vAxis,
int axisIndex,
bool oneway)
const;
106 MCAPI ::AABBHitResult clip(
::Vec3 const& a,
::Vec3 const& b)
const;
108 MCAPI ::AABB cloneAndFloor(
float offsetMin,
float offsetMax)
const;
110 MCAPI ::AABB cloneAndFloorMinAndCeilingMax()
const;
112 MCAPI ::AABB cloneAndGrow(
::Vec3 const& distance)
const;
114 MCAPI ::AABB cloneAndShrink(
::Vec3 const& offset)
const;
116 MCAPI ::AABB cloneAndTransformByMatrix(
::Matrix const& transform)
const;
118 MCAPI
float distanceTo(
::Vec3 const& pos)
const;
120 MCAPI
float distanceToSqr(::AABB
const& aabb)
const;
123 MCAPI ::std::array<::Vec3, 8> getCorners()
const;
126 MCAPI
bool intersectSegment(
127 ::Vec3 const& segmentBegin,
133 MCAPI
bool intersects(
::Vec3 const& segmentBegin,
::Vec3 const& segmentEnd)
const;
139 MCAPI static ::ClipCollideResult
140 clipCollide(::AABB
const& stationary, ::AABB
const& moving,
::Vec3 const& velocity);
146 MCAPI static ::AABB
const& BLOCK_SHAPE();
148 MCAPI static ::AABB
const& BOX_AT_ORIGIN_WITH_NO_VOLUME();