Skip to content

Sein Spatial Index

C++ type · FSeinSpatialIndex

#include "Collision/SeinSpatialIndex.h"

The simulation’s one spatial index: a deterministic 2D cell grid with three tiers.

  • Static colliders: persistent, rebuilt when a static collider appears, disappears, moves or changes footprint. Static colliders are expected not to move; one that does warns once. Each is stamped into every cell its footprint (position ± bounding radius) covers, so a query near any part of a long wall finds it.

  • Dynamic colliders: Movable and Stationary colliders, rebuilt from current poses each tick with the same footprint stamping. One array sorted by (cell, handle), gathered in parallel and canonicalized by the sort, so the result does not depend on thread count.

  • Entities: every live placed entity in its centre cell, refreshed when a query finds the entity set or a pose changed since the last refresh.

Collision resolution asks the collider tiers for neighbours (QueryColliders). Entity queries (range, box, nearest, target finding) ask the entity tier (QueryEntities). Both return candidates for an exact test, sorted by handle and without duplicates.

Derived state: rebuilt from the world, never captured. Pure C++; no UObject.

C++ members (12)
  • void Initialize(FFixedPoint InCellSize, FFixedVector InOrigin); Set the cell size and the world-space origin of cell (0, 0). Clears every tier.
  • void Clear(); Drop every tier and mark the static tier dirty.
  • void RebuildFromWorld(const USeinWorldSubsystem& World); Rebuild the dynamic collider tier from current poses, and the static tier when its colliders differ from the last build.
  • void RefreshEntities(const USeinWorldSubsystem& World); Rebuild the entity tier when the world’s entity set or a pose changed since its last build.
  • void InsertStatic(FSeinEntityHandle Handle, const FFixedVector& Pos, FFixedPoint BoundingRadius); Stamp a static collider into every cell its footprint covers (the centre cell alone when BoundingRadius <= 0). RebuildFromWorld fills the static tier this way.
  • bool IsStaticDirty() const; True after Clear until the next RebuildFromWorld rebuilds the static tier.
  • void BuildDynamic(const TArray<FColliderInput>& Colliders); Rebuild the dynamic collider tier from explicit inputs. A movement module keeping its own per-tick neighbour grid uses this with QueryColliders.
  • void QueryColliders(const FFixedVector& QueryPos, FFixedPoint Radius, TArray<FSeinEntityHandle>& Out, FSeinEntityHandle Exclude = FSeinEntityHandle()) const; Append the colliders (static and dynamic tiers) whose cells lie within Radius of QueryPos, sorted by handle, without duplicates or Exclude. The caller tests the actual shapes.
  • bool QueryEntities(const FFixedVector& Min, const FFixedVector& Max, FSeinEntityHandle Exclude, TArray<FSeinEntityHandle>& Out) const; Append the entities of the entity tier whose centre cells overlap the ground-plane box Min..Max, sorted by handle, without Exclude. False, with nothing appended, when the box is wider than the tier holds entries; a full sweep is cheaper then. Refresh first.
  • FFixedPoint GetCellSize() const;
  • int32 NumStaticBuckets() const;
  • int32 NumDynamicEntries() const; (cell, handle) entries in the dynamic collider tier.