Package spatial
SLOctree #sleela 2.5 (lib/spatial/SLOctree.sleela)
SLOctree class
A sparse point-region octree over an integer cube [0, size)^3, where size is rounded up to a power of two. Each node covers an axis-aligned cube and either is a leaf (holding at most one point payload) or has up to eight children, one per octant. insert descends, subdividing only along the path to the inserted point, so empty space costs nothing. Every scan (count, collectRegion) prunes whole subtrees whose cube does not overlap the query, turning an O(size^3) volume walk into a walk of only the occupied subtrees. Suited to sparse volumes, point clouds, frustum/region queries, and ray traversal. A node is both the tree handle and a subtree root.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
ox | int ox = 0 | No description in source. |
oy | int oy = 0 | No description in source. |
oz | int oz = 0 | No description in source. |
span | int span = 0 | No description in source. |
kids | SLOctree[] kids = new SLOctree[0] | No description in source. |
leaf | String leaf = null | No description in source. |
px | int px = 0 | No description in source. |
py | int py = 0 | No description in source. |
pz | int pz = 0 | No description in source. |
count | int count = 0 | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
roundPow2 | int roundPow2(int requested) | No description in source. |
allocate | void allocate(int size) | No description in source. |
getSpan | int getSpan() | Edge length of the root cube (a power of two). |
length | int length() | Number of occupied unit cells in this subtree. |
empty | boolean empty() | True when no points are stored. |
branched | boolean branched() | True when this node has been subdivided into octants. |
covers | boolean covers(int x, int y, int z) | True when (x,y,z) lies inside this node cube. |
octantOf | int octantOf(int x, int y, int z) | No description in source. |
subdivide | void subdivide() | No description in source. |
initNode | void initNode(int nox, int noy, int noz, int nspan) | No description in source. |
insert | boolean insert(int x, int y, int z, String value) | No description in source. |
query | String query(int x, int y, int z) | No description in source. |
contains | boolean contains(int x, int y, int z) | True when the cell at (x,y,z) is occupied. |
overlapsBox | boolean overlapsBox(int qx, int qy, int qz, int qw, int qh, int qd) | No description in source. |
collectRegion | int collectRegion(int qx, int qy, int qz, int qw, int qh, int qd, SLList out) | No description in source. |
collectAll | int collectAll(SLList out) | No description in source. |
SLSpatialHash #sleela 2.5 (lib/spatial/SLSpatialHash.sleela)
SLSpatialHash class
A sparse 3D spatial hash grid. Continuous points are quantized to integer cells of a fixed cellSize, and each occupied cell maps to a String payload (an id or label). Buckets are a fixed number of parallel native arrays keyed by a mixed hash of the cell coordinates, so insert and point lookup are near O(1) and a "what is near P" scan only visits the 27 cells of the 3x3x3 neighbourhood around P rather than the whole volume. Suited to sparse worlds, point clouds, and broad-phase collision. Negative coordinates are handled with floor division and a non-negative bucket index.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
cellSize | int cellSize = 1 | No description in source. |
buckets | int buckets = 0 | No description in source. |
bucketHead | int[] bucketHead = new int[0] | No description in source. |
keyX | int[] keyX = new int[0] | No description in source. |
keyY | int[] keyY = new int[0] | No description in source. |
keyZ | int[] keyZ = new int[0] | No description in source. |
bucketNext | int[] bucketNext = new int[0] | No description in source. |
payload | String[] payload = new String[0] | No description in source. |
size | int size = 0 | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
configure | void configure(int cell, int bucketCount) | No description in source. |
getCellSize | int getCellSize() | No description in source. |
getBucketCount | int getBucketCount() | No description in source. |
length | int length() | No description in source. |
empty | boolean empty() | No description in source. |
cellOf | int cellOf(int v) | No description in source. |
bucketOf | int bucketOf(int cx, int cy, int cz) | No description in source. |
findCell | int findCell(int cx, int cy, int cz) | No description in source. |
insert | boolean insert(int x, int y, int z, String value) | No description in source. |
queryPoint | String queryPoint(int x, int y, int z) | No description in source. |
contains | boolean contains(int x, int y, int z) | True when the cell containing point (x,y,z) is occupied. |
queryNeighbourhood | int queryNeighbourhood(int x, int y, int z, int radius, SLList out) | No description in source. |
cellX | int cellX(int x) | Integer cell X of a point coordinate (exposed for callers that bucket themselves). |
cellY | int cellY(int y) | Integer cell Y of a point coordinate. |
cellZ | int cellZ(int z) | Integer cell Z of a point coordinate. |
SLVoxelGrid #sleela 2.5 (lib/spatial/SLVoxelGrid.sleela)
SLVoxelGrid class
A dense 3D grid of int cells stored in a single flat, contiguous native array indexed by i = x + y*width + z*width*height (row-major, x fastest). This is the "integrated" alternative to a nested int array of arrays of arrays: one allocation, cache-linear scans, and no per-axis pointer chasing. Cells carry a caller-chosen empty sentinel (default 0) so a scan can skip unset space. Suited to dense volumes where most cells are addressed.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
width | int width = 0 | No description in source. |
height | int height = 0 | No description in source. |
depth | int depth = 0 | No description in source. |
empty | int empty = 0 | No description in source. |
cells | int[] cells = new int[0] | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
allocate | void allocate(int w, int h, int d, int emptyValue) | No description in source. |
getWidth | int getWidth() | No description in source. |
getHeight | int getHeight() | No description in source. |
getDepth | int getDepth() | No description in source. |
getEmptyValue | int getEmptyValue() | No description in source. |
size | int size() | Total number of cells (width*height*depth). |
inBounds | boolean inBounds(int x, int y, int z) | True when a coordinate is inside the grid. |
indexOf | int indexOf(int x, int y, int z) | No description in source. |
get | int get(int x, int y, int z) | No description in source. |
set | boolean set(int x, int y, int z, int value) | Write a cell; returns false when the coordinate is out of range. |
getFlat | int getFlat(int index) | Read by flat index directly (0..size()-1); empty sentinel when out of range. |
setFlat | boolean setFlat(int index, int value) | Write by flat index directly; returns false when out of range. |
isEmpty | boolean isEmpty(int x, int y, int z) | True when the cell at (x,y,z) holds the empty sentinel. |
clear | void clear() | Set every cell back to the empty sentinel. |
fill | void fill(int value) | Set every cell to value. |
occupancy | int occupancy() | No description in source. |
nextOccupied | int nextOccupied(int startFlat) | No description in source. |
xOf | int xOf(int index) | X coordinate of a flat index. |
yOf | int yOf(int index) | Y coordinate of a flat index. |
zOf | int zOf(int index) | Z coordinate of a flat index. |