Expand description
A spatial index over a level’s hittable objects, shared by viewport culling and hit-testing.
Every shape (block, port, text, image, area) and route on the current
level is stored in one rstar R*-tree keyed by its coarse
Bounded::bounds box. Both broad phases —
“which objects are on screen?” (culling) and “which objects are under the
cursor?” (hit-testing) — resolve to an in_rect / at_point query returning
candidate HitIds; the caller then runs its exact fine-phase test on the
few candidates instead of scanning the whole level.
The index owns copies of each object’s bounds + id (it holds no reference into
the document), so it can be cached across frames and rebuilt whenever the
document value (DocStamp) or the current level changes. Because the bounds
already include a query margin, a point query is just a degenerate-rect
in_rect.
Structs§
- Built
From 🔒 - What an index was built from: the level it covers and the document value it saw. The index contents are a pure function of this pair, so an index whose key still matches cannot be stale.
- Cached
Index - The
SpatialIndexcached across frames.Self::getrebuilds it whenever a fold produced a new document value (a freshDocStamp) or the current level changed, so no mutation site has to remember to invalidate anything. - Entry 🔒
- Spatial
Index - R*-tree over the current level’s hittables. Built with
Self::from_drawingand queried withSelf::in_rect.
Enums§
- HitId
- A hittable object on the current level: either a shape (blocks, ports, texts,
images, areas — all carried by
ShapeId) or a route.
Functions§
- aabb 🔒