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§
Sourcetype ColliderData<'a>
where
Self: 'a
type ColliderData<'a> where Self: 'a
The data required to answer queries on a collider.
Required Methods§
Sourcefn fetch_collider_data(&self, entity: Entity) -> Option<Self::ColliderData<'_>>
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.
Sourcefn project_point(
&self,
point: Vector3,
solid: bool,
collider_data: &Self::ColliderData<'_>,
) -> TnuaPointProjectionResult
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.
Sourcefn cast_ray(
&self,
origin: Vector3,
direction: Vector3,
max_time_of_impact: Float,
collider_data: &Self::ColliderData<'_>,
) -> Option<(Float, Vector3)>
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.
Sourcefn can_interact(&self, entity1: Entity, entity2: Entity) -> bool
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.