Skip to content

Commit e5ab5cf

Browse files
committed
Max octree depth is increased to 21
1 parent 9b19128 commit e5ab5cf

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ What is Morton-Z space-filling curve? https://en.wikipedia.org/wiki/Z-order_curv
2828

2929
## Limitations
3030
* Maximum number of dimensions is 63.
31-
* Maximum depth of octree solutions is 10.
31+
* Maximum depth of octree solutions is 21.
3232

3333
## Requirements
3434
* Language standard: C++20 or above

octree.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ Node size is not stored within the nodes. It will be calculated ad-hoc every tim
3333
#define ORTHOTREE__DISABLED_NODESIZE
3434
3535
// PMR is used with MSVC only by default. To use PMR anyway
36-
ORTHOTREE__USE_PMR
36+
#define ORTHOTREE__USE_PMR
3737
3838
// To disable PMR on all platforms use:
39-
ORTHOTREE__DISABLE_PMR
39+
#define ORTHOTREE__DISABLE_PMR
40+
41+
// If the depth is less than 10, 32bit location code is enough (otherwise 64bit will be used)
42+
#define ORTHOTREE__LOCATIONCODE_32
4043
4144
// Contiguous container of geometry data does not have specified index type. Octree lib uses index_t for it, it can specified to int or std::size_t.
4245
ORTHOTREE_INDEX_T__INT / ORTHOTREE_INDEX_T__SIZE_T / ORTHOTREE_INDEX_T__UINT_FAST32_T
@@ -1966,7 +1969,11 @@ namespace OrthoTree
19661969
template<dim_t DIMENSION_NO>
19671970
struct MortonSpaceIndexing
19681971
{
1969-
static auto constexpr IS_32BIT_LOCATION = DIMENSION_NO < 4;
1972+
#ifdef ORTHOTREE__LOCATIONCODE_32
1973+
static auto constexpr IS_32BIT_LOCATION = DIMENSION_NO <= 3;
1974+
#else
1975+
static auto constexpr IS_32BIT_LOCATION = DIMENSION_NO <= 2;
1976+
#endif
19701977
static auto constexpr IS_64BIT_LOCATION = !IS_32BIT_LOCATION && DIMENSION_NO < 15;
19711978

19721979
// Indexing can be solved with integral types (above this, internal container will be changed to std::map)
@@ -4593,7 +4600,8 @@ namespace OrthoTree
45934600
}
45944601
}
45954602

4596-
if (stuckedAndNonSplittableEndLocationNo){
4603+
if (stuckedAndNonSplittableEndLocationNo)
4604+
{
45974605
if constexpr (std::is_trivially_copyable_v<TEntityID>)
45984606
std::memcpy(entityIDs.data() + splitEntityNoFromParent, &(*locationIt.GetSecond()), stuckedAndNonSplittableEndLocationNo * sizeof(TEntityID));
45994607
else
@@ -5094,7 +5102,7 @@ namespace OrthoTree
50945102
};
50955103

50965104
public:
5097-
// Client-defined Collision detector based on indices. AABB intersection is executed independently from this checker.
5105+
// Client-defined Collision detector based on indexes. AABB intersection is executed independently from this checker.
50985106
using FCollisionDetector = std::function<bool(TEntityID, TEntityID)>;
50995107

51005108
// Collision detection: Returns all overlapping boxes from the source trees.

unittests/general.tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2612,7 +2612,7 @@ namespace Tree3DTest
26122612
std::vector<BoundingBox3D> boxes0;
26132613
OctreeBox tree(
26142614
boxes0,
2615-
8,
2615+
21,
26162616
BoundingBox3D{
26172617
{-10, -10, -10},
26182618
{+10, +10, +10}

0 commit comments

Comments
 (0)