pub struct Rail3<'a> { /* private fields */ }Expand description
Bounded immutable timeline over caller-owned prepared segments.
Implementations§
Source§impl<'a> Rail3<'a>
impl<'a> Rail3<'a>
Sourcepub fn new(
segments: &'a [RailSegment3<'a>],
mode: RailMode,
) -> Result<Rail3<'a>, RailError>
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.
Sourcepub fn sample_at(
&self,
seconds: f64,
reduced_motion: bool,
) -> Result<RailSample3, RailError>
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.
Sourcepub fn sample_into(
&self,
times: &[f64],
reduced_motion: bool,
output: &mut [RailSample3],
) -> Result<usize, RailError>
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);