pub use self::collider::*;
pub use self::shape_views::ColliderView;
pub use rapier::geometry::SolverFlags;
pub use rapier::parry::query::{ShapeCastOptions, ShapeCastStatus};
pub use rapier::parry::shape::TriMeshFlags;
pub use rapier::parry::transformation::{vhacd::VHACDParameters, voxelization::FillMode};
use crate::math::{Real, Vect};
use rapier::prelude::FeatureId;
mod collider;
mod collider_impl;
pub mod shape_views;
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct PointProjection {
pub is_inside: bool,
pub point: Vect,
}
impl PointProjection {
pub(crate) fn from_rapier(raw: rapier::parry::query::PointProjection) -> Self {
Self {
is_inside: raw.is_inside,
point: raw.point.into(),
}
}
}
impl From<rapier::parry::query::PointProjection> for PointProjection {
fn from(projection: rapier::parry::query::PointProjection) -> PointProjection {
PointProjection {
is_inside: projection.is_inside,
point: projection.point.into(),
}
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct RayIntersection {
pub time_of_impact: Real,
pub point: Vect,
pub normal: Vect,
pub feature: FeatureId,
}
impl RayIntersection {
pub(crate) fn from_rapier(
inter: rapier::parry::query::RayIntersection,
unscaled_origin: Vect,
unscaled_dir: Vect,
) -> Self {
Self {
time_of_impact: inter.time_of_impact,
point: unscaled_origin + unscaled_dir * inter.time_of_impact,
normal: inter.normal.into(),
feature: inter.feature,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct ShapeCastHit {
pub time_of_impact: Real,
pub details: Option<ShapeCastHitDetails>,
pub status: ShapeCastStatus,
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct ShapeCastHitDetails {
pub witness1: Vect,
pub witness2: Vect,
pub normal1: Vect,
pub normal2: Vect,
}
impl ShapeCastHit {
pub fn from_rapier(
hit: rapier::parry::query::ShapeCastHit,
details_always_computed: bool,
) -> Self {
let details = if !details_always_computed
&& hit.status != ShapeCastStatus::PenetratingOrWithinTargetDist
{
Some(ShapeCastHitDetails {
witness1: hit.witness1.into(),
witness2: hit.witness2.into(),
normal1: hit.normal1.into(),
normal2: hit.normal2.into(),
})
} else {
None
};
Self {
time_of_impact: hit.time_of_impact,
status: hit.status,
details,
}
}
}