Struct PathCursor

Source
pub struct PathCursor { /* private fields */ }
Expand description

Exact distance cursor for authored rail/path movement. Collision-driven actors should use WaypointFollower, so a blocked body cannot advance along a route.

Implementations§

Source§

impl PathCursor

Source

pub fn reset(&mut self)

Source

pub fn distance(&self) -> f64

Source

pub fn seek( &mut self, route: &Route3, distance: f64, ) -> Result<(), NavigationError>

Seeks to a finite nonnegative distance, clamping open routes and wrapping closed routes. See Route3::set_closed for a cursor example.

Source

pub fn recover( &mut self, route: &Route3, position: Vec3, ) -> Result<Option<RouteProjection>, NavigationError>

Repositions the cursor to the global nearest projection after a teleport or route replacement. This can move backward or jump across the seam; it neither advances time nor awards laps/checkpoints. Invalid positions and empty routes leave the cursor unchanged. See Route3::project for tie rules. No route identity or previous projection is cached.

use ferravex_math::Vec3;
use ferravex_play::navigation::{PathCursor, Route3};
let mut route = Route3::new(2)?;
route.set(&[Vec3::ZERO, Vec3::X * 10.])?;
let mut cursor = PathCursor::default();
cursor.seek(&route, 9.)?;
cursor.recover(&route, Vec3::new(2., 3., 0.))?;
assert_eq!(cursor.distance(), 2.);
assert_eq!(cursor.advance(&route, 1., 1.)?.unwrap().position, Vec3::X * 3.);
Source

pub fn advance( &mut self, route: &Route3, speed: f32, dt: f32, ) -> Result<Option<RouteSample>, NavigationError>

Advances by a caller-supplied speed and simulation delta. Open routes stop at the endpoint; closed routes wrap without tracking completed laps.

Trait Implementations§

Source§

impl Clone for PathCursor

Source§

fn clone(&self) -> PathCursor

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 PathCursor

Source§

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

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

impl Default for PathCursor

Source§

fn default() -> PathCursor

Returns the “default value” for a type. Read more
Source§

impl Copy for PathCursor

Auto Trait Implementations§

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.