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 AABB(
::Vec3 const& min,
float side);
105 MCAPI AABB(
float minX,
float minY,
float minZ,
float maxX,
float maxY,
float maxZ);
107 MCAPI ::Vec3 axisInside(::AABB
const& other,
::Vec3 axis)
const;
109 MCAPI ::AABBHitResult clip(
::Vec3 const& a,
::Vec3 const& b)
const;
111 MCAPI ::Vec3 clipCollide(::AABB
const& c,
::Vec3 const& velocity,
bool oneWay,
float* penetration)
const;
114 MCAPI
float clipXCollide(::AABB
const& c,
float ya,
bool oneway)
const;
116 MCAPI
float clipYCollide(::AABB
const& c,
float ya,
bool oneway)
const;
118 MCAPI
float clipZCollide(::AABB
const& c,
float ya,
bool oneway)
const;
121 MCAPI ::AABB cloneAndExpandAlongDirection(
::Vec3 const& direction)
const;
123 MCAPI ::AABB cloneAndFloor(
float offsetMin,
float offsetMax)
const;
125 MCAPI ::AABB cloneAndFloorMinAndCeilingMax()
const;
127 MCAPI ::AABB cloneAndGrow(
::Vec3 const& distance)
const;
129 MCAPI ::AABB cloneAndGrow(
float radius)
const;
131 MCAPI ::AABB cloneAndShrink(
::Vec3 const& offset)
const;
133 MCAPI ::AABB cloneAndTransformByMatrix(
::Matrix const& transform)
const;
135 MCAPI ::AABB cloneAndTranslate(
::Vec3 const& offset)
const;
137 MCAPI
float distanceTo(::AABB
const& aabb)
const;
139 MCAPI
float distanceTo(
::Vec3 const& pos)
const;
141 MCAPI
float distanceToSqr(
::Vec3 const& pos)
const;
143 MCAPI ::Vec3 getBottomCenter()
const;
145 MCAPI ::Vec3 getBounds()
const;
147 MCAPI ::Vec3 getCenter()
const;
150 MCAPI ::std::array<::Vec3, 8> getCorners()
const;
153 MCAPI
float getSize()
const;
155 MCAPI ::Vec3 getTopCenter()
const;
157 MCAPI
float getVolume()
const;
159 MCAPI
bool intersectSegment(
160 ::Vec3 const& segmentBegin,
166 MCAPI
bool intersects(
::Vec3 const& segmentBegin,
::Vec3 const& segmentEnd)
const;
168 MCAPI
bool intersectsInner(::AABB
const& c)
const;
170 MCAPI
bool isNan()
const;
172 MCAPI
bool isValid()
const;
174 MCAPI
bool operator!=(::AABB
const& rhs)
const;
176 MCAPI
bool operator==(::AABB
const& rhs)
const;
178 MCAPI ::AABB& set(::AABB
const& b);
180 MCFOLD ::AABB& set(
::Vec3 const& min,
::Vec3 const& max);
182 MCFOLD ::AABB& set(
float minX,
float minY,
float minZ,
float maxX,
float maxY,
float maxZ);
185 MCAPI ::AABB& translateCenterTo(
::Vec3 const& center);
192 MCAPI static ::AABB aroundRadius(
::Vec3 const& point,
float radius);
194 MCAPI static ::ClipCollideResult
195 clipCollide(::AABB
const& stationary, ::AABB
const& moving,
::Vec3 const& velocity);
201 MCAPI static ::AABB
const& BLOCK_SHAPE();
203 MCAPI static ::AABB
const& BOX_AT_ORIGIN_WITH_NO_VOLUME();
209 MCFOLD
void* $ctor(
::Vec3 const& min,
::Vec3 const& max);
211 MCAPI
void* $ctor(
::Vec3 const& min,
float side);
213 MCFOLD
void* $ctor(
float minX,
float minY,
float minZ,
float maxX,
float maxY,
float maxZ);