Home › Packages › spatial

Package spatial

This package contains 3 source unit(s) defining 3 class(es) / struct(s). Each unit below lists its fields (the values it stores) and methods (the actions it performs), with a plain explanation of each.

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.

Carries the standard Metadata Class record — eleven catalogued provenance attributes (version, id, author, date, copyright, trademark, corporation, origin, birth date, science rating, national schedule) with matching get/set accessors. These are omitted from the tables below for brevity.

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
oxint ox = 0No description in source.
oyint oy = 0No description in source.
ozint oz = 0No description in source.
spanint span = 0No description in source.
kidsSLOctree[] kids = new SLOctree[0]No description in source.
leafString leaf = nullNo description in source.
pxint px = 0No description in source.
pyint py = 0No description in source.
pzint pz = 0No description in source.
countint count = 0No description in source.

Methods — the actions this unit can perform.

MethodSignatureWhat it does
roundPow2int roundPow2(int requested)No description in source.
allocatevoid allocate(int size)No description in source.
getSpanint getSpan()Edge length of the root cube (a power of two).
lengthint length()Number of occupied unit cells in this subtree.
emptyboolean empty()True when no points are stored.
branchedboolean branched()True when this node has been subdivided into octants.
coversboolean covers(int x, int y, int z)True when (x,y,z) lies inside this node cube.
octantOfint octantOf(int x, int y, int z)No description in source.
subdividevoid subdivide()No description in source.
initNodevoid initNode(int nox, int noy, int noz, int nspan)No description in source.
insertboolean insert(int x, int y, int z, String value)No description in source.
queryString query(int x, int y, int z)No description in source.
containsboolean contains(int x, int y, int z)True when the cell at (x,y,z) is occupied.
overlapsBoxboolean overlapsBox(int qx, int qy, int qz, int qw, int qh, int qd)No description in source.
collectRegionint collectRegion(int qx, int qy, int qz, int qw, int qh, int qd, SLList out)No description in source.
collectAllint 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.

Carries the standard Metadata Class record — eleven catalogued provenance attributes (version, id, author, date, copyright, trademark, corporation, origin, birth date, science rating, national schedule) with matching get/set accessors. These are omitted from the tables below for brevity.

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
cellSizeint cellSize = 1No description in source.
bucketsint buckets = 0No description in source.
bucketHeadint[] bucketHead = new int[0]No description in source.
keyXint[] keyX = new int[0]No description in source.
keyYint[] keyY = new int[0]No description in source.
keyZint[] keyZ = new int[0]No description in source.
bucketNextint[] bucketNext = new int[0]No description in source.
payloadString[] payload = new String[0]No description in source.
sizeint size = 0No description in source.

Methods — the actions this unit can perform.

MethodSignatureWhat it does
configurevoid configure(int cell, int bucketCount)No description in source.
getCellSizeint getCellSize()No description in source.
getBucketCountint getBucketCount()No description in source.
lengthint length()No description in source.
emptyboolean empty()No description in source.
cellOfint cellOf(int v)No description in source.
bucketOfint bucketOf(int cx, int cy, int cz)No description in source.
findCellint findCell(int cx, int cy, int cz)No description in source.
insertboolean insert(int x, int y, int z, String value)No description in source.
queryPointString queryPoint(int x, int y, int z)No description in source.
containsboolean contains(int x, int y, int z)True when the cell containing point (x,y,z) is occupied.
queryNeighbourhoodint queryNeighbourhood(int x, int y, int z, int radius, SLList out)No description in source.
cellXint cellX(int x)Integer cell X of a point coordinate (exposed for callers that bucket themselves).
cellYint cellY(int y)Integer cell Y of a point coordinate.
cellZint 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.

Carries the standard Metadata Class record — eleven catalogued provenance attributes (version, id, author, date, copyright, trademark, corporation, origin, birth date, science rating, national schedule) with matching get/set accessors. These are omitted from the tables below for brevity.

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
widthint width = 0No description in source.
heightint height = 0No description in source.
depthint depth = 0No description in source.
emptyint empty = 0No description in source.
cellsint[] cells = new int[0]No description in source.

Methods — the actions this unit can perform.

MethodSignatureWhat it does
allocatevoid allocate(int w, int h, int d, int emptyValue)No description in source.
getWidthint getWidth()No description in source.
getHeightint getHeight()No description in source.
getDepthint getDepth()No description in source.
getEmptyValueint getEmptyValue()No description in source.
sizeint size()Total number of cells (width*height*depth).
inBoundsboolean inBounds(int x, int y, int z)True when a coordinate is inside the grid.
indexOfint indexOf(int x, int y, int z)No description in source.
getint get(int x, int y, int z)No description in source.
setboolean set(int x, int y, int z, int value)Write a cell; returns false when the coordinate is out of range.
getFlatint getFlat(int index)Read by flat index directly (0..size()-1); empty sentinel when out of range.
setFlatboolean setFlat(int index, int value)Write by flat index directly; returns false when out of range.
isEmptyboolean isEmpty(int x, int y, int z)True when the cell at (x,y,z) holds the empty sentinel.
clearvoid clear()Set every cell back to the empty sentinel.
fillvoid fill(int value)Set every cell to value.
occupancyint occupancy()No description in source.
nextOccupiedint nextOccupied(int startFlat)No description in source.
xOfint xOf(int index)X coordinate of a flat index.
yOfint yOf(int index)Y coordinate of a flat index.
zOfint zOf(int index)Z coordinate of a flat index.