Struct Rail3

Source
pub struct Rail3<'a> { /* private fields */ }
Expand description

Bounded immutable timeline over caller-owned prepared segments.

Implementations§

Source§

impl<'a> Rail3<'a>

Source

pub fn new( segments: &'a [RailSegment3<'a>], mode: RailMode, ) -> Result<Rail3<'a>, RailError>

Validate capacity, exact adjacent-key continuity and representable timing. Loops require positive total duration; a Once rail may contain only cuts. No allocation or root registration is needed beyond camera::rail. See module recipe.

Source

pub fn duration(&self) -> f64

Total authored seconds, before wrapping. See module recipe.

Source

pub fn sample_at( &self, seconds: f64, reduced_motion: bool, ) -> Result<RailSample3, RailError>

Stateless absolute-time query. Seeking/backward sampling retains no state. Reduced motion selects the final key immediately, ignoring loop topology. Finite nonnegative time is required even in reduced-motion mode. See module recipe and RailPlayer3 for crossed-boundary detection.

Source

pub fn sample_into( &self, times: &[f64], reduced_motion: bool, output: &mut [RailSample3], ) -> Result<usize, RailError>

Sample up to 1024 supplied times into a caller slice. Entire destination (including unused tail) is unchanged on any error, including a late numeric failure. Success writes exactly times.len() entries. Empty input succeeds. Validates in one pass, then writes in a second: bounded O(times * segments). No allocation; immutable paths guarantee repeatability within the call.

use ferravex_math::{Vec3, projection::NdcDepth};
use ferravex_play::camera::{Pose3, transition::*, rail::*};
let key = RailKey3 { pose: Pose3::default(), projection: Perspective3 {
    aspect: 1., near: 0.1, far: 100., handedness: ViewHandedness::Right,
    depth: NdcDepth::ZeroToOne } };
let segments = [RailSegment3::new(RailPath3::Cut, key, key, 0.)?];
let rail = Rail3::new(&segments, RailMode::Once)?;
let sentinel = rail.sample_at(0., false)?;
let mut out = [sentinel; 3];
assert!(rail.sample_into(&[0., f64::NAN], false, &mut out).is_err());
assert_eq!(out, [sentinel; 3]);
assert_eq!(rail.sample_into(&[0., 2.], false, &mut out)?, 2);
assert_eq!(out[2], sentinel);

Trait Implementations§

Source§

impl<'a> Clone for Rail3<'a>

Source§

fn clone(&self) -> Rail3<'a>

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<'a> Copy for Rail3<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Rail3<'a>

§

impl<'a> RefUnwindSafe for Rail3<'a>

§

impl<'a> Send for Rail3<'a>

§

impl<'a> Sync for Rail3<'a>

§

impl<'a> Unpin for Rail3<'a>

§

impl<'a> UnwindSafe for Rail3<'a>

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.