Contents
Class VolumeSpatialIndex
java.lang.Object
com.hypixel.hytale.builtin.triggervolumes.system.VolumeSpatialIndex
Broad-phase spatial index over enabled trigger volumes, built for volumes that move and resize
frequently. Each volume is stamped into every grid cell its world-space AABB overlaps
(overlap insertion), so the per-tick point query "which volumes might contain this position?"
is a single-cell lookup with no neighbourhood search. Volumes whose footprint would cover more
than
maxCellsPerVolume cells are kept in a short overflow list scanned on every query
instead, capping stamping cost for region-scale volumes.
The grid holds only enabled volumes. Mutations are buffered as pending changes and
drained incrementally by applyPendingChanges() at the start of a tick; there is no
global rebuild on the hot path. The grid never persists per-entry bounds: a mutated volume's old
footprint is recomputed from the SpatialSnapshot captured before the edit, and its new
footprint from the entry's current state.
The cells/largeVolumes structures are touched only by applyPendingChanges()
and queries, which run on the world thread; the pending/removed buffers are concurrent so
off-thread mutation paths can register changes safely.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDrains buffered changes into the grid.voidclear()Drops all stamped and pending state (used by global wipes).voidcollectCandidates(org.joml.Vector3d point, List<VolumeEntry> results) Broad phase: returns every enabled volume whose footprint cell holdspoint, plus any large volume whose world AABB contains it.intintbooleanisEmpty()voidmarkChanged(VolumeEntry entry, SpatialSnapshot oldState) Buffers a spatial change.voidmarkRemoved(VolumeEntry entry, SpatialSnapshot oldState) Buffers a removal; the entry is unstamped on the next drain and never re-added.voidrebuild(Collection<VolumeEntry> volumes) Rebuilds the whole index from scratch over the given volumes; for bulk load (decode) only.voidsetCellSize(int cellSize) Sets the grid cell size.voidsetMaxCellsPerVolume(int maxCellsPerVolume)
-
Constructor Details
-
VolumeSpatialIndex
public VolumeSpatialIndex()
-
-
Method Details
-
getCellSize
public int getCellSize() -
setCellSize
public void setCellSize(int cellSize) Sets the grid cell size. Must be a positive multiple of two (a power-of-two value lets the world-to-cell conversion stay cheap). The grid must be empty; tune before any volume is stamped and re-stamp viarebuild(Collection)if needed. -
getMaxCellsPerVolume
public int getMaxCellsPerVolume() -
setMaxCellsPerVolume
public void setMaxCellsPerVolume(int maxCellsPerVolume) -
markChanged
Buffers a spatial change. First write wins, so the snapshot of the volume's last-stamped footprint is preserved across multiple edits in one tick. -
markRemoved
Buffers a removal; the entry is unstamped on the next drain and never re-added. -
clear
public void clear()Drops all stamped and pending state (used by global wipes). -
rebuild
Rebuilds the whole index from scratch over the given volumes; for bulk load (decode) only. -
isEmpty
public boolean isEmpty() -
applyPendingChanges
public void applyPendingChanges()Drains buffered changes into the grid. For each pending volume the old footprint (recomputed from its snapshot) is unstamped, then the new footprint is stamped if the volume is still enabled and not removed. Removals with no buffered snapshot are unstamped from their current footprint, which is unchanged since they were last stamped. -
collectCandidates
Broad phase: returns every enabled volume whose footprint cell holdspoint, plus any large volume whose world AABB contains it. Over-inclusion is harmless because callers run the exactcontains/entity test; only a missed cell would be a bug. A multi-cell volume is returned at most once because a point query touches a single cell.
-