Class SpatialIndexAttribute
- Namespace
- Typhon.Schema.Definition
- Assembly
- Typhon.Schema.Definition.dll
Marks a spatial (AABB or bounding-sphere) component field for R-Tree indexing, enabling range and nearest-neighbor queries over its bounds.
[AttributeUsage(AttributeTargets.Field)]
public sealed class SpatialIndexAttribute : Attribute
- Inheritance
-
SpatialIndexAttribute
- Inherited Members
Constructors
SpatialIndexAttribute(float, float)
Marks a spatial field with the given fat-AABB margin and optional broadphase cellSize.
public SpatialIndexAttribute(float margin, float cellSize = 0)
Parameters
marginfloatFat-AABB expansion margin in world units (see Margin).
cellSizefloatBroadphase grid cell size in world units, or
0to disable the coarse filter (see CellSize).
Properties
Category
Archetype-level category bitmask used by the per-cell cluster spatial broadphase to skip entire clusters whose category does not intersect the
query's category mask (issue #230 Phase 3). Defaults to MaxValue — "accept every query" — so archetypes that don't set this
remain queryable with any mask, including the default uint.MaxValue query mask.
public uint Category { get; set; }
Property Value
Remarks
Archetype-level, not per-entity. Every entity in an archetype contributes the same Category value, so the per-cluster category mask
is the OR of N identical values — effectively a constant for the archetype. This simplification makes the design-doc "incremental OR on spawn,
recompute on destroy" invariants trivially satisfied: both are no-ops because the mask never changes.
Query semantics. A cluster is admitted when (clusterMask & queryMask) != 0 — "any bit overlap".
A query mask of 0 is a special sentinel that bypasses category filtering entirely (accepts all clusters regardless of their mask).
Typical usage: assign distinct bit positions to archetype roles (Ants = 1 << 0,
Food = 1 << 1, Enemies = 1 << 2) and query with the OR of the roles you want.
CellSize
Cell size, in world units, for the coarse-grid broadphase occupancy filter. 0 (default) disables the filter — queries go straight to the tree.
public float CellSize { get; }
Property Value
Margin
Fat-AABB expansion margin, in world units, added to each dynamic entry so small movements don't force a re-insert. Only meaningful for Dynamic.
public float Margin { get; }
Property Value
Mode
public SpatialMode Mode { get; set; }