bevy_tnua_physics_integration_layer::spatial_ext

Trait TnuaSpatialExt

Source
pub trait TnuaSpatialExt {
    type ColliderData<'a>
       where Self: 'a;

    // Required methods
    fn fetch_collider_data(
        &self,
        entity: Entity,
    ) -> Option<Self::ColliderData<'_>>;
    fn project_point(
        &self,
        point: Vector3,
        solid: bool,
        collider_data: &Self::ColliderData<'_>,
    ) -> TnuaPointProjectionResult;
    fn cast_ray(
        &self,
        origin: Vector3,
        direction: Vector3,
        max_time_of_impact: Float,
        collider_data: &Self::ColliderData<'_>,
    ) -> Option<(Float, Vector3)>;
    fn can_interact(&self, entity1: Entity, entity2: Entity) -> bool;
}
Expand description

Structured spatial queries.

Physics integration crates should define a SystemParam type and implement this trait on it. The main Tnua crate (or third party crates) can define wrappers (like TnuaRadarLens) that can utilize these queries to present helper methods for user code.

Required Associated Types§

Source

type ColliderData<'a> where Self: 'a

The data required to answer queries on a collider.

Required Methods§

Source

fn fetch_collider_data(&self, entity: Entity) -> Option<Self::ColliderData<'_>>

Get the ColliderData from the sytem.

Since the struct implementing TnuaSpatialExt is typically a SystemParam, it can use its fields to get that data from the ECS.

Source

fn project_point( &self, point: Vector3, solid: bool, collider_data: &Self::ColliderData<'_>, ) -> TnuaPointProjectionResult

Return the point on the collider that’s closest to some external point.

Source

fn cast_ray( &self, origin: Vector3, direction: Vector3, max_time_of_impact: Float, collider_data: &Self::ColliderData<'_>, ) -> Option<(Float, Vector3)>

Cast a ray on the collider, returning the time-of-impact and the normal.

Source

fn can_interact(&self, entity1: Entity, entity2: Entity) -> bool

Check if the physics engine is solving interaction between the two entities.

If the physics engine is detecting the collision but does not apply forces according to it, this method should return false.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§