pub struct SpatialIndex { /* private fields */ }Expand description
Accelerated spatial index maintaining entity bounding boxes and event listeners.
Implementations§
Source§impl SpatialIndex
impl SpatialIndex
Sourcepub fn sync_bounds(&mut self, layout_root: &LayoutNode)
pub fn sync_bounds(&mut self, layout_root: &LayoutNode)
Synchronizes cached entry bounding boxes from layout_root in O(entries) without
walking blueprints or reallocating the index (used on high-frequency scroll ticks).
Sourcepub fn sync_bounds_for_prefix(
&mut self,
layout_root: &LayoutNode,
prefix: &[usize],
)
pub fn sync_bounds_for_prefix( &mut self, layout_root: &LayoutNode, prefix: &[usize], )
Synchronizes cached entry bounding boxes only for descendants of prefix, avoiding
unrelated root-to-node layout walks on high-frequency smooth scroll ticks.
Sourcepub fn rebuild(&mut self, blueprint: &NodeBlueprint, layout: &LayoutNode)
pub fn rebuild(&mut self, blueprint: &NodeBlueprint, layout: &LayoutNode)
Clears and rebuilds the spatial index from the active blueprint and computed layout hierarchy.
Sourcepub fn query_entity_at_point(&self, px: f32, py: f32) -> Option<EntityId>
pub fn query_entity_at_point(&self, px: f32, py: f32) -> Option<EntityId>
Queries the front-most / deepest EntityId at point (px, py), honoring stacking z_index
and paint order without piercing through opaque higher-z overlays.
Sourcepub fn query_event_at_point(
&self,
px: f32,
py: f32,
event_type: EventType,
) -> Option<(EntityId, Rc<dyn Fn(Event)>, Rect)>
pub fn query_event_at_point( &self, px: f32, py: f32, event_type: EventType, ) -> Option<(EntityId, Rc<dyn Fn(Event)>, Rect)>
Queries the front-most event listener registered for event_type at point (px, py),
matching W3C DOM non-piercing hit-testing: resolves the single front-most visual target
first, then searches strictly along its DOM ancestor layout_path.
Sourcepub fn get_bounds(&self, entity_id: EntityId) -> Option<Rect>
pub fn get_bounds(&self, entity_id: EntityId) -> Option<Rect>
Returns the bounding box of an entity if present in the index.