4#ifndef GREM_CORE_DATA_LOOSE_ORTHTREE_HPP
5#define GREM_CORE_DATA_LOOSE_ORTHTREE_HPP
26template <
size_t N,
typename Scalar,
typename T>
36 [[nodiscard]] constexpr
bool operator==(const
LooseOrthtreeID&) const noexcept = default;
38 constexpr operator
bool() const noexcept {
39 return elementIndex != INVALID_ELEMENT;
43 using ElementIndex = uint32_t;
47 template <
size_t N,
typename Scalar,
typename T>
51 : elementIndex(elementIndex) {}
53 ElementIndex elementIndex = INVALID_ELEMENT;
64template <
size_t N,
typename Scalar,
typename T>
67 static_assert(N == 2 || N == 3);
78 using NodeIndex = uint32_t;
79 using ElementIndex = LooseOrthtreeID::ElementIndex;
81 static constexpr ElementIndex INVALID_ELEMENT = LooseOrthtreeID::INVALID_ELEMENT;
84 using SubOrthantNodeIndices =
Array<NodeIndex, (N == 2) ? 4 : 8>;
86 SubOrthantNodeIndices subOrthantNodeIndices{};
87 NodeIndex parentNodeIndex = 0;
88 ElementIndex firstElementIndex = INVALID_ELEMENT;
92 ElementIndex previousElementIndex = INVALID_ELEMENT;
93 ElementIndex nextElementIndex = INVALID_ELEMENT;
95 NodeIndex nodeIndex = 0;
101 using reference = std::conditional_t<Const, typename LooseOrthtree::const_reference, typename LooseOrthtree::reference>;
102 using pointer = std::conditional_t<Const, typename LooseOrthtree::const_pointer, typename LooseOrthtree::pointer>;
106 constexpr Iterator() noexcept = default;
108 constexpr operator Iterator<true>() const noexcept requires(!Const) {
109 return Iterator<true>{container, elementIndex};
112 constexpr operator LooseOrthtreeID() const noexcept {
113 return LooseOrthtreeID{elementIndex};
116 [[nodiscard]]
constexpr reference operator*()
const {
118 return *container->elements[elementIndex].value;
121 [[nodiscard]]
constexpr pointer operator->()
const {
125 [[nodiscard]]
constexpr bool operator==(
const Iterator& other)
const {
127 return elementIndex == other.elementIndex;
130 constexpr Iterator& operator++() {
132 GREM_ASSERT(elementIndex < container->elements.size());
135 }
while (elementIndex < container->elements.size() && !container->elements[elementIndex].value);
139 constexpr Iterator operator++(
int) {
140 Iterator old = *
this;
146 friend LooseOrthtree;
148 constexpr Iterator(std::conditional_t<Const, const LooseOrthtree, LooseOrthtree>* container, ElementIndex elementIndex) noexcept
149 : container(container)
150 , elementIndex(elementIndex) {}
152 std::conditional_t<Const, const LooseOrthtree, LooseOrthtree>* container =
nullptr;
153 ElementIndex elementIndex = 0;
156 template <
bool Const>
157 class LocalIterator {
159 using reference = std::conditional_t<Const, typename LooseOrthtree::const_reference, typename LooseOrthtree::reference>;
160 using pointer = std::conditional_t<Const, typename LooseOrthtree::const_pointer, typename LooseOrthtree::pointer>;
164 constexpr LocalIterator() noexcept = default;
166 constexpr operator Iterator<true>() const noexcept requires(!Const) {
167 return Iterator<true>{container, elementIndex};
170 constexpr operator LooseOrthtreeID() const noexcept {
171 return LooseOrthtreeID{elementIndex};
174 [[nodiscard]]
constexpr reference operator*()
const {
176 return *container->elements[elementIndex].value;
179 [[nodiscard]]
constexpr pointer operator->()
const {
183 [[nodiscard]]
constexpr bool operator==(
const LocalIterator& other)
const {
185 return elementIndex == other.elementIndex;
188 constexpr LocalIterator& operator++() {
190 elementIndex = container->elements[elementIndex].nextElementIndex;
194 constexpr LocalIterator operator++(
int) {
195 Iterator old = *
this;
201 friend LooseOrthtree;
203 constexpr LocalIterator(std::conditional_t<Const, const LooseOrthtree, LooseOrthtree>* container, ElementIndex elementIndex) noexcept
204 : container(container)
205 , elementIndex(elementIndex) {}
207 std::conditional_t<Const, const LooseOrthtree, LooseOrthtree>* container =
nullptr;
208 ElementIndex elementIndex = 0;
235 reset(worldBoundingBox, minOrthantSize);
252 minOrthantSize = newMinOrthantSize;
253 rootCenter = (newWorldBoundingBox.min + newWorldBoundingBox.max) * Scalar{0.5};
254 const Length<N, Scalar> worldMaxExtents =
max(newWorldBoundingBox.max - rootCenter, rootCenter - newWorldBoundingBox.min);
255 const Scalar worldMaxExtent =
maxComponent(worldMaxExtents);
257 halfRootSize = newMinOrthantSize;
258 while (halfRootSize < worldMaxExtent) {
259 halfRootSize *= Scalar{2};
273 firstFreeNodeIndex = 0;
274 firstFreeElementIndex = INVALID_ELEMENT;
283 return minOrthantSize;
293 return Box<N, Scalar>{.min = rootCenter - rootHalfExtents, .max = rootCenter + rootHalfExtents};
304 ElementIndex elementIndex = 0;
305 while (elementIndex < elements.size() && !elements[elementIndex].value) {
308 return iterator{
this, elementIndex};
319 ElementIndex elementIndex = 0;
320 while (elementIndex < elements.size() && !elements[elementIndex].value) {
345 return iterator{
this,
static_cast<ElementIndex
>(elements.size())};
356 return const_iterator{
this,
static_cast<ElementIndex
>(elements.size())};
384 [[nodiscard]]
bool empty() const noexcept {
403 template <
typename... Args>
415 const Scalar aabbSize = [&] {
416 if constexpr (N == 2) {
417 return max(aabbDiagonal.x, aabbDiagonal.y);
419 return max(
max(aabbDiagonal.x, aabbDiagonal.y), aabbDiagonal.z);
428 Scalar orthantSize = halfRootSize;
430 NodeIndex nodeIndex = 0;
431 while (orthantSize >= aabbSize && orthantSize >= minOrthantSize) {
432 orthantSize *= Scalar{0.5};
436 const size_t subOrthantArrayIndex = getSubOrthantArrayIndex(difference);
442 const NodeIndex parentNodeIndex = nodeIndex;
443 if (
const NodeIndex orthantNodeIndex = tree[parentNodeIndex].subOrthantNodeIndices[subOrthantArrayIndex]) {
445 nodeIndex = orthantNodeIndex;
448 if (firstFreeNodeIndex != 0) {
451 nodeIndex = std::exchange(firstFreeNodeIndex, std::exchange(tree[firstFreeNodeIndex].subOrthantNodeIndices.front(), NodeIndex{0}));
454 if (tree.size() >=
size_t{Limits<NodeIndex>::MAX}) {
455 throw std::length_error{
"Maximum node count exceeded."};
457 nodeIndex =
static_cast<NodeIndex
>(tree.size());
461 tree[nodeIndex].parentNodeIndex = parentNodeIndex;
463 tree[parentNodeIndex].subOrthantNodeIndices[subOrthantArrayIndex] = nodeIndex;
468 ElementIndex elementIndex = INVALID_ELEMENT;
470 if (firstFreeElementIndex != INVALID_ELEMENT) {
473 elementIndex = std::exchange(firstFreeElementIndex, std::exchange(elements[firstFreeElementIndex].nextElementIndex, INVALID_ELEMENT));
476 if (elements.size() >=
size_t{Limits<ElementIndex>::MAX}) {
477 throw std::length_error{
"Maximum element count exceeded."};
479 elementIndex =
static_cast<ElementIndex
>(elements.size());
480 elements.emplace_back();
484 elements[elementIndex].value.emplace(std::forward<Args>(args)...);
486 cleanupElement(elementIndex);
490 cleanupNode(nodeIndex);
495 elements[elementIndex].nodeIndex = nodeIndex;
496 ElementIndex& firstElementIndex = tree[nodeIndex].firstElementIndex;
498 if (firstElementIndex != INVALID_ELEMENT) {
499 elements[firstElementIndex].previousElementIndex = elementIndex;
501 GREM_ASSERT(elements[elementIndex].previousElementIndex == INVALID_ELEMENT);
502 elements[elementIndex].nextElementIndex = std::exchange(firstElementIndex, elementIndex);
503 GREM_ASSERT(elements[elementIndex].nextElementIndex != elementIndex);
506 return iterator{
this, elementIndex};
525 return emplace(elementBoundingBox, value);
544 return emplace(elementBoundingBox, std::move(value));
558 iterator result{
this, pos.elementIndex};
572 eraseAtIndex(
id.elementIndex);
584 return *elements[
id.elementIndex].value;
596 return *elements[
id.elementIndex].value;
643 template <
typename Callback,
typename Predicate>
645 return traverseNodesImplementation(
646 [
this, callback = std::forward<Callback>(callback)](
const Box<N, Scalar>& looseBounds, NodeIndex nodeIndex)
mutable {
649 constexpr bool CALLBACK_RETURNS_BOOL = std::is_convertible_v<
decltype(callback(looseBounds, first, last)),
bool>;
650 if constexpr (CALLBACK_RETURNS_BOOL) {
651 return callback(looseBounds, first, last);
653 callback(looseBounds, first, last);
656 std::forward<Predicate>(predicate));
694 template <
typename Callback>
736 template <
typename Callback,
typename Predicate>
738 return traverseNodesImplementation(
739 [
this, callback = std::forward<Callback>(callback)](
const Box<N, Scalar>&, NodeIndex nodeIndex)
mutable {
742 constexpr bool CALLBACK_RETURNS_BOOL = std::is_convertible_v<
decltype(callback(*first)),
bool>;
744 if constexpr (CALLBACK_RETURNS_BOOL) {
752 if constexpr (CALLBACK_RETURNS_BOOL) {
756 std::forward<Predicate>(predicate));
787 template <
typename Callback>
822 template <
typename Callback>
843 return traverseElements([](
const T&) ->
bool {
return true; }, [&point](
const Box<N, Scalar>& boundingBox) ->
bool {
return boundingBox.contains(point); });
876 template <
typename Callback>
901 template <
typename U>
906 template <
typename Predicate>
909 for (ElementIndex elementIndex = 0; elementIndex < c.elements.
size(); ++elementIndex) {
911 if (predicate(*value)) {
912 c.eraseAtIndex(elementIndex);
921 [[nodiscard]]
static constexpr size_t getSubOrthantArrayIndex(
Length<N, Scalar> difference) {
923 for (
size_t i = 0; i < N; ++i) {
924 result |=
static_cast<size_t>(!
signbit(difference[i])) << (N - 1 - i);
929 template <
typename Callback>
930 static constexpr void forEachActiveOrthant(
const Node::SubOrthantNodeIndices& subOrthantNodeIndices,
Point<N, Scalar> center, Scalar halfOrthantSize,
931 Callback&& callback) {
932 if constexpr (
N == 2) {
933 if (
const NodeIndex orthantNodeIndex = subOrthantNodeIndices[0b00]) {
934 callback(orthantNodeIndex,
Point<2, Scalar>{center.x - halfOrthantSize, center.y - halfOrthantSize});
936 if (
const NodeIndex orthantNodeIndex = subOrthantNodeIndices[0b01]) {
937 callback(orthantNodeIndex,
Point<2, Scalar>{center.x - halfOrthantSize, center.y + halfOrthantSize});
939 if (
const NodeIndex orthantNodeIndex = subOrthantNodeIndices[0b10]) {
940 callback(orthantNodeIndex,
Point<2, Scalar>{center.x + halfOrthantSize, center.y - halfOrthantSize});
942 if (
const NodeIndex orthantNodeIndex = subOrthantNodeIndices[0b11]) {
943 callback(orthantNodeIndex,
Point<2, Scalar>{center.x + halfOrthantSize, center.y + halfOrthantSize});
946 if (
const NodeIndex orthantNodeIndex = subOrthantNodeIndices[0b000]) {
947 callback(orthantNodeIndex,
Point<3, Scalar>{center.x - halfOrthantSize, center.y - halfOrthantSize, center.z - halfOrthantSize});
949 if (
const NodeIndex orthantNodeIndex = subOrthantNodeIndices[0b001]) {
950 callback(orthantNodeIndex,
Point<3, Scalar>{center.x - halfOrthantSize, center.y - halfOrthantSize, center.z + halfOrthantSize});
952 if (
const NodeIndex orthantNodeIndex = subOrthantNodeIndices[0b010]) {
953 callback(orthantNodeIndex,
Point<3, Scalar>{center.x - halfOrthantSize, center.y + halfOrthantSize, center.z - halfOrthantSize});
955 if (
const NodeIndex orthantNodeIndex = subOrthantNodeIndices[0b011]) {
956 callback(orthantNodeIndex,
Point<3, Scalar>{center.x - halfOrthantSize, center.y + halfOrthantSize, center.z + halfOrthantSize});
958 if (
const NodeIndex orthantNodeIndex = subOrthantNodeIndices[0b100]) {
959 callback(orthantNodeIndex,
Point<3, Scalar>{center.x + halfOrthantSize, center.y - halfOrthantSize, center.z - halfOrthantSize});
961 if (
const NodeIndex orthantNodeIndex = subOrthantNodeIndices[0b101]) {
962 callback(orthantNodeIndex,
Point<3, Scalar>{center.x + halfOrthantSize, center.y - halfOrthantSize, center.z + halfOrthantSize});
964 if (
const NodeIndex orthantNodeIndex = subOrthantNodeIndices[0b110]) {
965 callback(orthantNodeIndex,
Point<3, Scalar>{center.x + halfOrthantSize, center.y + halfOrthantSize, center.z - halfOrthantSize});
967 if (
const NodeIndex orthantNodeIndex = subOrthantNodeIndices[0b111]) {
968 callback(orthantNodeIndex,
Point<3, Scalar>{center.x + halfOrthantSize, center.y + halfOrthantSize, center.z + halfOrthantSize});
973 template <
typename Callback,
typename Predicate>
974 auto traverseNodesImplementation(Callback&& callback, Predicate&& predicate)
const {
975 constexpr bool CALLBACK_RETURNS_BOOL = std::is_convertible_v<
decltype(callback(std::declval<
const Box<N, Scalar>&>(), std::declval<const NodeIndex&>())),
bool>;
978 struct IterationState {
979 Point<N, Scalar> center;
983 SmallBuffer<IterationState, 24> iterationStack{};
985 iterationStack.push_back(IterationState{
986 .center = rootCenter,
987 .orthantSize = halfRootSize,
991 const IterationState iterationState = iterationStack.back();
992 iterationStack.pop_back();
995 const Scalar orthantSize = iterationState.orthantSize;
996 const NodeIndex nodeIndex = iterationState.nodeIndex;
998 const Box<N, Scalar> looseBounds{center - looseBoundsHalfSize, center + looseBoundsHalfSize};
999 if constexpr (CALLBACK_RETURNS_BOOL) {
1000 if (callback(looseBounds, nodeIndex)) {
1004 callback(looseBounds, nodeIndex);
1007 const Scalar halfOrthantSize = orthantSize *
Scalar{0.5};
1008 forEachActiveOrthant(tree[nodeIndex].subOrthantNodeIndices, center, halfOrthantSize,
1009 [&iterationStack, &predicate, orthantSize, halfOrthantSize](NodeIndex orthantNodeIndex,
Point<N, Scalar> orthantCenter) {
1011 if (predicate(looseBounds)) {
1012 iterationStack.push_back(IterationState{
1013 .center = orthantCenter,
1014 .orthantSize = halfOrthantSize,
1015 .nodeIndex = orthantNodeIndex,
1019 }
while (!iterationStack.empty());
1022 if constexpr (CALLBACK_RETURNS_BOOL) {
1027 [[nodiscard]]
static bool isNodeEmpty(
const Node& node) {
1028 return node.firstElementIndex == INVALID_ELEMENT &&
allOf(node.subOrthantNodeIndices, [](NodeIndex orthantNodeIndex) ->
bool { return orthantNodeIndex == 0; });
1031 void cleanupNode(NodeIndex nodeIndex)
noexcept {
1032 Node* node = &tree[nodeIndex];
1033 while (isNodeEmpty(*node)) {
1034 if (nodeIndex == 0) {
1038 node->subOrthantNodeIndices.front() = std::exchange(firstFreeNodeIndex, std::exchange(nodeIndex, node->parentNodeIndex));
1039 node = &tree[nodeIndex];
1040 for (NodeIndex& orthantNodeIndex : node->subOrthantNodeIndices) {
1041 if (orthantNodeIndex == firstFreeNodeIndex) {
1042 orthantNodeIndex = 0;
1049 void cleanupElement(ElementIndex elementIndex)
noexcept {
1050 Element& element = elements[elementIndex];
1051 const ElementIndex previousElementIndex = std::exchange(element.previousElementIndex, INVALID_ELEMENT);
1052 if (element.nextElementIndex != INVALID_ELEMENT) {
1053 elements[element.nextElementIndex].previousElementIndex = previousElementIndex;
1055 ElementIndex& previousNextElementIndex =
1056 (previousElementIndex == INVALID_ELEMENT) ? tree[element.nodeIndex].firstElementIndex : elements[previousElementIndex].nextElementIndex;
1057 previousNextElementIndex = std::exchange(element.nextElementIndex, std::exchange(firstFreeElementIndex, elementIndex));
1058 GREM_ASSERT(elements[elementIndex].nextElementIndex != elementIndex);
1059 if (element.nodeIndex != 0) {
1060 cleanupNode(std::exchange(element.nodeIndex, NodeIndex{0}));
1064 void eraseAtIndex(ElementIndex elementIndex) {
1067 GREM_ASSERT(elements[elementIndex].value.has_value());
1069 elements[elementIndex].value.reset();
1070 cleanupElement(elementIndex);
1073 ArrayList<Node> tree{};
1074 ArrayList<Element> elements{};
1079 NodeIndex firstFreeNodeIndex = 0;
1080 ElementIndex firstFreeElementIndex = INVALID_ELEMENT;
1095template <
typename Scalar,
typename T>
1110template <
typename Scalar,
typename T>
#define GREM_ASSERT(expression)
Definition assertions.hpp:77
constexpr size_type size() const noexcept
Definition ArrayList.hpp:297
Opaque handle to an element in a LooseOrthtree.
Definition LooseOrthtree.hpp:32
constexpr LooseOrthtreeID() noexcept=default
friend class LooseOrthtree
Definition LooseOrthtree.hpp:48
Orthtree-based space subdivision structure, optimized for intersection queries between axis-aligned b...
Definition LooseOrthtree.hpp:65
Box< N, Scalar > getRootBox() const noexcept
Get the current root box of the tree.
Definition LooseOrthtree.hpp:291
iterator begin() noexcept
Get the begin iterator of the elements in the tree.
Definition LooseOrthtree.hpp:303
iterator insert(const Box< N, Scalar > &elementBoundingBox, T &&value)
Move an element into the tree.
Definition LooseOrthtree.hpp:543
iterator erase(const_iterator pos)
Remove an element from the tree.
Definition LooseOrthtree.hpp:556
const T & const_reference
Const reference type of the container.
Definition LooseOrthtree.hpp:71
iterator end() noexcept
Get the end iterator of the elements in the tree.
Definition LooseOrthtree.hpp:344
void reset(const Box< N, Scalar > &newWorldBoundingBox, Scalar newMinOrthantSize) noexcept
Reset the tree to an empty state with new world parameters.
Definition LooseOrthtree.hpp:250
const_iterator begin() const noexcept
Get the begin iterator of the elements in the tree.
Definition LooseOrthtree.hpp:318
size_t size_type
Size type of the container.
Definition LooseOrthtree.hpp:74
Scalar getMinOrthantSize() const noexcept
Get the current minimum orthant size of the tree.
Definition LooseOrthtree.hpp:282
iterator emplace(const Box< N, Scalar > &elementBoundingBox, Args &&... args)
Construct a new element in the tree.
Definition LooseOrthtree.hpp:404
LooseOrthtree() noexcept
Construct an invalid tree that must be reset with valid world parameters before use.
Definition LooseOrthtree.hpp:221
auto traverseElements(Callback &&callback, Predicate &&predicate) const
Execute a callback function for each element in the tree.
Definition LooseOrthtree.hpp:737
T & reference
Reference type of the container.
Definition LooseOrthtree.hpp:70
const_iterator cend() const noexcept
Get the end iterator of the elements in the tree.
Definition LooseOrthtree.hpp:366
bool test(const Box< N, Scalar > &box) const noexcept
Check if it is possible that some element in the tree is intersecting with a given axis-aligned box.
Definition LooseOrthtree.hpp:897
LocalIterator< true > const_local_iterator
Const local iterator type for the nodes of the container.
Definition LooseOrthtree.hpp:215
void clear() noexcept
Erase all inserted elements from the tree.
Definition LooseOrthtree.hpp:269
auto traverseNodes(Callback &&callback, Predicate &&predicate) const
Execute a callback function for each active node of the tree, including empty internal nodes without ...
Definition LooseOrthtree.hpp:644
T value_type
Value type of the container.
Definition LooseOrthtree.hpp:69
auto test(const Box< N, Scalar > &box, Callback &&callback) const
Execute a callback function for each element in the tree that might be intersecting with a given axis...
Definition LooseOrthtree.hpp:877
Iterator< false > iterator
Iterator type of the container.
Definition LooseOrthtree.hpp:212
LooseOrthtree(const Box< N, Scalar > &worldBoundingBox, Scalar minOrthantSize) noexcept
Construct an empty tree.
Definition LooseOrthtree.hpp:234
void erase(LooseOrthtreeID id)
Remove an element from the tree.
Definition LooseOrthtree.hpp:571
auto traverseNodes(Callback &&callback) const
Execute a callback function for each active node of the tree, including empty internal nodes without ...
Definition LooseOrthtree.hpp:695
iterator insert(const Box< N, Scalar > &elementBoundingBox, const T &value)
Copy an element into the tree.
Definition LooseOrthtree.hpp:524
const T * const_pointer
Const pointer type of the container.
Definition LooseOrthtree.hpp:73
const_iterator cbegin() const noexcept
Get the begin iterator of the elements in the tree.
Definition LooseOrthtree.hpp:333
bool test(Point< N, Scalar > point) const noexcept
Check if it is possible that some element in the tree contains a given point.
Definition LooseOrthtree.hpp:842
const_iterator end() const noexcept
Get the end iterator of the elements in the tree.
Definition LooseOrthtree.hpp:355
reference operator[](LooseOrthtreeID id)
Get the element with a specific handle.
Definition LooseOrthtree.hpp:583
LocalIterator< false > local_iterator
Local iterator type for the nodes of the container.
Definition LooseOrthtree.hpp:214
Iterator< true > const_iterator
Const iterator type of the container.
Definition LooseOrthtree.hpp:213
bool empty() const noexcept
Check whether the tree is empty or not.
Definition LooseOrthtree.hpp:384
friend size_type erase_if(LooseOrthtree &c, Predicate predicate)
Definition LooseOrthtree.hpp:907
size_type size() const noexcept
Get the number of elements in the tree.
Definition LooseOrthtree.hpp:375
friend size_type erase(LooseOrthtree &c, const U &value)
Definition LooseOrthtree.hpp:902
auto test(Point< N, Scalar > point, Callback &&callback) const
Execute a callback function for each element in the tree that might contain a given point.
Definition LooseOrthtree.hpp:823
auto traverseElements(Callback &&callback) const
Execute a callback function for each element in the tree.
Definition LooseOrthtree.hpp:788
const_reference operator[](LooseOrthtreeID id) const
Get the element with a specific handle.
Definition LooseOrthtree.hpp:595
ptrdiff_t difference_type
Difference type of the container.
Definition LooseOrthtree.hpp:75
Optional value type that holds either a value or no value.
Definition Optional.hpp:58
Definition concepts.hpp:106
@ N
'n'
Definition keyboard.hpp:84
size_t NodeIndex
Index into Asset::nodes.
Definition gltf.hpp:145
float Scalar
Underlying scalar type of physics quantity components.
Definition quantities.hpp:1480
LooseOrthtreeID LooseQuadtreeID
Opaque handle to an element in a LooseQuadtree.
Definition LooseOrthtree.hpp:1086
vec< N, T > Length
Generic length in N-dimensional space.
Definition geometry.hpp:38
constexpr bool intersects(const spherical_shape auto &a, const spherical_shape auto &b) noexcept
Check if two spherical shapes intersect.
Definition geometry.hpp:1662
GREM_ALWAYS_INLINE T copysign(T magnitude, T sign)
Get a value with the sign of a different value.
Definition math.hpp:3601
LooseOrthtree< 2, Scalar, T > LooseQuadtree
Quadtree-based space subdivision container, optimized for intersection queries between 2D axis-aligne...
Definition LooseOrthtree.hpp:1096
vec< N, T > Point
Generic point in N-dimensional space.
Definition geometry.hpp:29
LooseOrthtreeID LooseOctreeID
Opaque handle to an element in a LooseOctree.
Definition LooseOrthtree.hpp:1101
GREM_ALWAYS_INLINE constexpr decltype(auto) max(A &&a, B &&b)
Get the greater of two values, or the first value if they are equivalent.
Definition fundamentals.hpp:598
GREM_ALWAYS_INLINE vec< N, bool > GREM_VECTORCALL signbit(vec< N, T > values)
Get the sign bits of the components of a vector.
Definition math.hpp:3584
constexpr bool allOf(input_range auto &&range, auto predicate)
Definition algorithms.hpp:226
LooseOrthtree< 3, Scalar, T > LooseOctree
Octree-based space subdivision container, optimized for intersection queries between 3D axis-aligned ...
Definition LooseOrthtree.hpp:1111
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL maxComponent(vec< 1, T > a)
Definition math.hpp:1920
Generic axis-aligned box shape with minimum and maximum extents in N-dimensional space.
Definition geometry.hpp:149
constexpr bool contains(const Point< N, T > &point) const noexcept
Check if a given point is contained within the extents of this box.
Definition geometry.hpp:182
Point< N, T > max
Position with the maximum coordinates of the box extents on each coordinate axis.
Definition geometry.hpp:154
Point< N, T > min
Position with the minimum coordinates of the box extents on each coordinate axis.
Definition geometry.hpp:153
static constexpr T MAX
Definition fundamentals.hpp:29