Struct Sweep

Source
pub struct Sweep {
    pub start: Vec3,
    pub end: Vec3,
    pub radius: f32,
}
Expand description

A sphere-center segment. Equal endpoints perform a stationary overlap check. Use Sweep::new to check inputs, or Sweep::probe to also check adapter results and obtain distances and a padded placement.

Fields§

§start: Vec3§end: Vec3§radius: f32

Implementations§

Source§

impl Sweep

Source

pub fn new(start: Vec3, end: Vec3, radius: f32) -> Result<Sweep, CameraError>

Construct a checked probe with finite endpoints in [-1e6, 1e6] on each axis and a finite radius in 0.001..=1000.

Invalid inputs return CameraError::InvalidQuery. Zero-length segments are valid and must still be sent to the collision query.

use ferravex_math::Vec3;
use ferravex_play::camera::{CameraError, Sweep};
let point = Sweep::new(Vec3::ZERO, Vec3::ZERO, 0.25)?;
assert!(point.valid());
assert_eq!(Sweep::new(Vec3::ZERO, Vec3::Z, 0.),
           Err(CameraError::InvalidQuery));
Source

pub fn valid(self) -> bool

Source

pub fn probe( self, query: &(impl CollisionQuery + ?Sized), padding: f32, ) -> Result<SweepOutcome, CameraError>

Run exactly one query and report travel available before the first hit.

padding is a finite distance in 0..=10, matching camera obstruction settings. It retreats along the segment only when a hit is reported; it does not enlarge the probe or change a clear endpoint. Zero padding permits contact. A blocked start has no permitted placement: this method does not depenetrate or search for an escape route.

Invalid sweep/padding or an invalid adapter fraction returns CameraError::InvalidQuery; adapter errors propagate unchanged. A stationary query still runs, and may return only None or Some(0). Storage and query count are constant; slice adapters retain their MAX_BLOCKERS budget. Custom adapters determine geometric accuracy.

use ferravex_math::Vec3;
use ferravex_play::camera::{Blocker, CameraError, NoObstructions, Sweep};
let sweep = Sweep::new(Vec3::ZERO, Vec3::Z * 10., 0.25)?;
let wall = [Blocker::Plane { normal: -Vec3::Z, offset: -5. }];
let hit = sweep.probe(&wall[..], 0.25)?;
assert_eq!(hit.requested_distance, 10.);
assert_eq!(hit.hit_fraction, Some(0.475));
assert_eq!(hit.allowed_distance, 4.5);
assert_eq!(hit.allowed_position, Some(Vec3::Z * 4.5));
assert!(!hit.starts_blocked());
let clear = sweep.probe(&NoObstructions, 0.25)?;
assert_eq!(clear.hit_fraction, None);
assert_eq!(clear.allowed_position, Some(sweep.end));

Trait Implementations§

Source§

impl Clone for Sweep

Source§

fn clone(&self) -> Sweep

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Sweep

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Sweep

Source§

fn eq(&self, other: &Sweep) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Sweep

Source§

impl StructuralPartialEq for Sweep

Auto Trait Implementations§

§

impl Freeze for Sweep

§

impl RefUnwindSafe for Sweep

§

impl Send for Sweep

§

impl Sync for Sweep

§

impl Unpin for Sweep

§

impl UnwindSafe for Sweep

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.