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
impl PathCursor
pub fn reset(&mut self)
pub fn distance(&self) -> f64
Sourcepub fn seek(
&mut self,
route: &Route3,
distance: f64,
) -> Result<(), NavigationError>
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.
Sourcepub fn recover(
&mut self,
route: &Route3,
position: Vec3,
) -> Result<Option<RouteProjection>, NavigationError>
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.);Sourcepub fn advance(
&mut self,
route: &Route3,
speed: f32,
dt: f32,
) -> Result<Option<RouteSample>, NavigationError>
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
impl Clone for PathCursor
Source§fn clone(&self) -> PathCursor
fn clone(&self) -> PathCursor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more