LeviLamina
Loading...
Searching...
No Matches
BoundingBox.h
1#pragma once
2
3#include "ll/api/coro/Generator.h"
4#include "mc/_HeaderOutputPredefine.h"
5
6// auto generated inclusion list
7#include "mc/util/Rotation.h"
8#include "mc/world/level/BlockPos.h"
9
10
11class AABB;
12
13class BoundingBox : public ll::math::CommutativeGroup<BoundingBox, BlockPos, BlockPos> {
14public:
15 union {
16 BlockPos min, x, r, s;
17 };
18 union {
19 BlockPos max, y, g, t, z, b, p;
20 };
21
22 [[nodiscard]] constexpr BoundingBox() noexcept : min(0), max(0) {}
23 [[nodiscard]] constexpr BoundingBox(class BoundingBox const& k) noexcept = default;
24 constexpr BoundingBox& operator=(class BoundingBox const& k) noexcept = default;
25 [[nodiscard]] constexpr BoundingBox(BlockPos const& min, BlockPos const& max) noexcept : min(min), max(max) {}
26
27 ll::coro::Generator<BlockPos> forEachPos() const {
28 for (int dy = min.y; dy <= max.y; ++dy)
29 for (int dx = min.x; dx <= max.x; ++dx)
30 for (int dz = min.z; dz <= max.z; ++dz) {
31 co_yield BlockPos{dx, dy, dz};
32 }
33 }
34
35 constexpr BoundingBox& merge(BoundingBox const& a) noexcept {
36 *this = BoundingBox{ll::math::min(a.min, min), ll::math::max(a.max, max)};
37 return *this;
38 }
39
40 constexpr BoundingBox& merge(BlockPos const& a) noexcept {
41 *this = BoundingBox{ll::math::min(a, min), ll::math::max(a, max)};
42 return *this;
43 }
44
45 template <typename T, size_t N>
46 [[nodiscard]] constexpr T& get() noexcept {
47 if constexpr (N == 0) {
48 return x;
49 } else if constexpr (N == 1) {
50 return y;
51 } else {
52 static_assert(ll::traits::always_false<T>);
53 }
54 }
55
56 template <typename T, size_t N>
57 [[nodiscard]] constexpr T const& get() const noexcept {
58 if constexpr (N == 0) {
59 return x;
60 } else if constexpr (N == 1) {
61 return y;
62 } else {
63 static_assert(ll::traits::always_false<T>);
64 }
65 }
66
67 [[nodiscard]] bool contains(BlockPos const& a) const noexcept { return a.ge(min).all() && a.le(max).all(); }
68
69 [[nodiscard]] bool contains(BoundingBox const& a) const noexcept {
70 return a.min.ge(min).all() && a.max.le(max).all();
71 }
72
73 [[nodiscard]] BlockPos getSideLength() const noexcept { return max - min + 1; }
74
75 LLNDAPI operator class AABB() const;
76
77public:
78 // member functions
79 // NOLINTBEGIN
80 MCAPI BoundingBox(int _x0, int _y0, int _z0, int _x1, int _y1, int _z1);
81
82 MCNAPI void applyTransformation(::BlockPos const& pivot, ::Rotation rotationXZ, bool mirrorX, bool mirrorZ);
83
84 MCNAPI bool isValid() const;
85 // NOLINTEND
86
87public:
88 // static functions
89 // NOLINTBEGIN
90 MCNAPI static ::std::optional<::BoundingBox> intersect(::BoundingBox const& lhs, ::BoundingBox const& rhs);
91
92 MCNAPI static ::BoundingBox orientBox(
93 int footX,
94 int footY,
95 int footZ,
96 int offX,
97 int offY,
98 int offZ,
99 int width,
100 int height,
101 int depth,
102 int orientation
103 );
104 // NOLINTEND
105
106public:
107 // constructor thunks
108 // NOLINTBEGIN
109 MCNAPI void* $ctor();
110
111 MCNAPI void* $ctor(int _x0, int _y0, int _z0, int _x1, int _y1, int _z1);
112 // NOLINTEND
113};
Definition AABB.h:18
Definition BlockPos.h:18
Definition BoundingBox.h:13
static MCAPI ::BoundingBox orientBox(int footX, int footY, int footZ, int offX, int offY, int offZ, int width, int height, int depth, int orientation)
MCAPI void applyTransformation(::BlockPos const &pivot, ::Rotation rotationXZ, bool mirrorX, bool mirrorZ)
MCAPI void * $ctor()
static MCAPI ::std::optional<::BoundingBox > intersect(::BoundingBox const &lhs, ::BoundingBox const &rhs)
MCAPI bool isValid() const
MCAPI void * $ctor(int _x0, int _y0, int _z0, int _x1, int _y1, int _z1)
Definition Generator.h:13
Definition CommutativeGroup.h:17