35 void DebugRender(ImDrawList* drawList, ImVec2 offset,
float scale);
101 uint numNodes = worldSize / maxSize;
103 for (
uint x = 0; x < numNodes; x++)
106 for (
uint y = 0; y < numNodes; y++)
133 else if (node->
size > size && node->
size != this->minSize)
139 const uint halfNodeSize = node->
size / 2;
213 if (node->
size == size)
215 if (node->
x == coord.
x && node->
y == coord.
y)
223 else if (node->
size > size)
281 if (node->
size == size)
283 if (node->
x == coord.
x && node->
y == coord.
y)
288 else if (node->
size > size)
342 static ImU32 colors[] =
344 IM_COL32(128, 0, 0, 128),
345 IM_COL32(0, 128, 0, 128),
346 IM_COL32(0, 0, 128, 128),
347 IM_COL32(128, 0, 128, 128),
348 IM_COL32(128, 128, 0, 128),
349 IM_COL32(0, 128, 128, 128),
356 ImVec2 min{ (float)offset.
x + node->
x * scale, (
float)offset.
y + node->
y * scale };
357 ImVec2 max{ (float)offset.
x + (node->
x + node->
size) * scale, (float)offset.
y + (node->
y + node->
size) * scale };
358 drawList->AddRectFilled(min, max, colors[
colorIndex]);
Allocates memory in chunks.
Definition arenaallocator.h:36
Definition occupancyquadtree.h:18
Math::uint2 Allocate(uint size)
allocate a region, return region
Definition occupancyquadtree.h:191
bool RecursiveDeallocate(Node *node, Math::uint2 coord, uint size)
recursively traverse tree and deallocate
Definition occupancyquadtree.h:210
Memory::ArenaAllocator< sizeof(Node) *64 > allocator
Definition occupancyquadtree.h:71
void RecursiveDebugRender(Node *node, ImDrawList *drawList, ImVec2 offset, float scale)
recursively debug render
Definition occupancyquadtree.h:340
uint minSize
Definition occupancyquadtree.h:73
Util::FixedArray< Util::FixedArray< Node > > topLevelNodes
Definition occupancyquadtree.h:72
bool IsOccupied(const Math::uint2 coord, uint size)
check if region is alloced
Definition occupancyquadtree.h:319
void DebugRender(ImDrawList *drawList, ImVec2 offset, float scale)
debug render
Definition occupancyquadtree.h:373
bool RecursiveSearch(Node *node, Math::uint2 coord, uint size)
recursively traverse tree and find if allocated
Definition occupancyquadtree.h:278
void Setup(uint worldSize, uint maxSize, uint minSize)
setup with a world size and a biggest allocation size
Definition occupancyquadtree.h:98
bool RecursiveAllocate(Node *node, uint size, Math::uint2 &outCoord)
recursively traverse tree to allocate node from tree
Definition occupancyquadtree.h:120
~OccupancyQuadTree()
destructor
Definition occupancyquadtree.h:89
OccupancyQuadTree()
constructor
Definition occupancyquadtree.h:80
bool Deallocate(const Math::uint2 coord, uint size)
deallocate region
Definition occupancyquadtree.h:259
Implements a fixed size one-dimensional array.
Definition fixedarray.h:20
#define n_assert(exp)
Definition debug.h:50
The occupancy quad tree implements a tree which allows for a quick search.
Definition occupancyquadtree.h:15
static uint colorIndex
Definition occupancyquadtree.h:334
Nebula's scalar datatype.
scalar x
Definition scalar.h:61
scalar y
Definition scalar.h:61
unsigned int x
Definition scalar.h:115
unsigned int y
Definition scalar.h:115
Definition occupancyquadtree.h:39
Node()
Definition occupancyquadtree.h:40
Node * bottomRight
Definition occupancyquadtree.h:54
uint size
Definition occupancyquadtree.h:57
Node * bottomLeft
Definition occupancyquadtree.h:53
Node * topLeft
Definition occupancyquadtree.h:51
uint x
Definition occupancyquadtree.h:58
bool occupied
Definition occupancyquadtree.h:55
uint y
Definition occupancyquadtree.h:58
Node * topRight
Definition occupancyquadtree.h:52
uint occupancyCounter
Definition occupancyquadtree.h:56
unsigned int uint
Definition types.h:31