Interface ISpatialBox
- Namespace
- Typhon.Schema.Definition
- Assembly
- Typhon.Schema.Definition.dll
Marker interface narrowing generic cluster-spatial-query box parameters to the supported AABB variants.
Implemented by AABB2F, AABB3F, AABB2D, and AABB3D.
Consumed by Typhon.Engine.ClusterSpatialQuery<TArch>.AABB<TBox> (issue #230 Phase 2.5) to accept any of the 4 dimensionality × precision
combinations as a query region while preserving native-precision reads at the API boundary.
public interface ISpatialBox
Remarks
Marker-only by design. This interface intentionally has no members. Each query method that takes an ISpatialBox dispatches
on typeof(TBox) == typeof(Concrete) at JIT specialization time and reads box fields
via As<TFrom, TTo>(ref TFrom).
Why no accessor methods: a methoded interface would need to commit to a single return type (float or double) for any MinX/MaxX
accessor, which would either narrow (losing precision for f64 variants) or widen (wasting work for f32 variants) at the interface boundary. That is exactly
the precision-smearing problem issue #230 exists to prevent. Keeping the interface as a pure marker avoids the trade-off entirely and lets each dispatch
branch read its concrete struct fields at native precision.
Location rationale. This interface lives in Typhon.Schema.Definition alongside the AABB value types it marks, rather than in
Typhon.Engine, because Typhon.Engine references Typhon.Schema.Definition (not the other way around). Placing the marker here keeps the
schema project self-contained and lets engine code consume it through the existing project reference.
Adding a new box variant. (1) Add : ISpatialBox to the variant's partial struct declaration in SpatialTypes.cs. (2) Add a
typeof(TBox) == typeof(NewVariant) branch to Typhon.Engine.SpatialTierExtensions.TBoxToTier<TBox>. (3) Add a dispatch branch to every
query method that operates on ISpatialBox (currently just Typhon.Engine.ClusterSpatialQuery<TArch>.AABB<TBox>).
The compiler will NOT catch a missed dispatch branch — follow the same discipline used by Typhon.Engine.SpatialMaintainer.ReadAndValidateBoundsFromPtr,
which has maintained an 8-case SpatialFieldType switch without a bug for the life of the legacy per-entity R-Tree.