Skip to main content

SpatialQuery

Trait SpatialQuery 

Source
pub trait SpatialQuery: Debug + Send {
    // Required methods
    fn actor_capacity(&self) -> usize;
    fn candidates_on_layer_into(
        &self,
        layer: SpatialLayerId,
        output: &mut [EnemyIdx],
    ) -> usize;
    fn candidates_in_envelope_into(
        &self,
        layer: SpatialLayerId,
        envelope: SpatialEnvelope,
        output: &mut [EnemyIdx],
    ) -> usize;
    fn actors_in_radius_into(
        &self,
        query: RadiusQuery,
        allowed: Option<&[EnemyIdx]>,
        output: &mut [EnemyIdx],
    ) -> usize;
    fn actors_in_cone_into(
        &self,
        query: ConeQuery,
        allowed: Option<&[EnemyIdx]>,
        output: &mut [EnemyIdx],
    ) -> usize;
    fn actors_by_distance_into(
        &self,
        layer: SpatialLayerId,
        origin: Position2,
        allowed: Option<&[EnemyIdx]>,
        output: &mut [EnemyIdx],
    ) -> usize;
    fn segment_visible(
        &self,
        layer: SpatialLayerId,
        start: Position2,
        end: Position2,
    ) -> bool;
    fn validate_transform(
        &self,
        transform: SpatialTransform,
    ) -> Result<(), SpatialQueryError>;
    fn insert_actor(
        &mut self,
        actor: SpatialActor,
    ) -> Result<(), SpatialQueryError>;
    fn remove_actor(
        &mut self,
        actor: SpatialActor,
    ) -> Result<(), SpatialQueryError>;
    fn relocate_actor(
        &mut self,
        actor: EnemyIdx,
        from: SpatialTransform,
        to: SpatialTransform,
    ) -> Result<(), SpatialQueryError>;
}
Expand description

Deterministic spatial queries over active enemy points and immutable blockers.

Caller-owned output covers the finalized actor count and receives sorted, unique IDs.

Required Methods§

Source

fn actor_capacity(&self) -> usize

Finalized actor-slot capacity required by every caller-owned output slice.

Source

fn candidates_on_layer_into( &self, layer: SpatialLayerId, output: &mut [EnemyIdx], ) -> usize

Sorted, deduplicated broad-phase actor IDs on one spatial layer.

Source

fn candidates_in_envelope_into( &self, layer: SpatialLayerId, envelope: SpatialEnvelope, output: &mut [EnemyIdx], ) -> usize

Source

fn actors_in_radius_into( &self, query: RadiusQuery, allowed: Option<&[EnemyIdx]>, output: &mut [EnemyIdx], ) -> usize

Source

fn actors_in_cone_into( &self, query: ConeQuery, allowed: Option<&[EnemyIdx]>, output: &mut [EnemyIdx], ) -> usize

Source

fn actors_by_distance_into( &self, layer: SpatialLayerId, origin: Position2, allowed: Option<&[EnemyIdx]>, output: &mut [EnemyIdx], ) -> usize

Active actors ordered by increasing distance, then ascending actor ID.

Source

fn segment_visible( &self, layer: SpatialLayerId, start: Position2, end: Position2, ) -> bool

Whether a same-layer closed segment is unobstructed by static geometry.

Source

fn validate_transform( &self, transform: SpatialTransform, ) -> Result<(), SpatialQueryError>

Validates that a transform can be represented by this index.

§Errors

Returns an error for non-finite, blocked, or otherwise invalid transforms.

Source

fn insert_actor(&mut self, actor: SpatialActor) -> Result<(), SpatialQueryError>

Adds an actor to the index.

§Errors

Returns an error when the actor already exists or its transform is invalid.

Source

fn remove_actor(&mut self, actor: SpatialActor) -> Result<(), SpatialQueryError>

Removes an actor from the index.

§Errors

Returns an error when the actor is absent or its transform does not match.

Source

fn relocate_actor( &mut self, actor: EnemyIdx, from: SpatialTransform, to: SpatialTransform, ) -> Result<(), SpatialQueryError>

Moves an indexed actor between validated transforms.

§Errors

Returns an error when the actor is absent, the source differs, or the destination is invalid.

Implementors§