Struct Rig3

Source
pub struct Rig3 {
    pub shake: CameraShake,
    /* private fields */
}
Expand description

Copyable complete presentation state; update errors preserve it unchanged.

Fields§

§shake: CameraShake

Implementations§

Source§

impl Rig3

Source

pub fn new(settings: Settings3) -> Result<Rig3, CameraError>

Source

pub fn settings(&self) -> Settings3

Source

pub fn set_settings(&mut self, settings: Settings3) -> Result<(), CameraError>

Source

pub fn pose(&self) -> Option<Pose3>

Last successful pose, or None before initialization or after Self::reset.

Source

pub fn reset(&mut self)

Forget the pose, damping, orbit and obstruction history, retaining settings.

Clears active shake without replacing its configured seed or sequence. The next valid update initializes directly, even with zero elapsed time. Shake queued after resetting belongs to the new scene and is retained.

use ferravex_play::camera::Rig3;
let mut camera = Rig3::default();
let tuning = camera.settings();
camera.reset(); // The restarted scene has not supplied its spawn yet.
assert_eq!(camera.pose(), None);
assert_eq!(camera.settings(), tuning);
Source

pub fn cut(&mut self)

Cut on the next valid update and discard current presentation shake. The last pose remains available; shake queued after this call is retained.

Source

pub fn snap( &mut self, input: Input3, collision: &(impl CollisionQuery + ?Sized), ) -> Result<Frame3, CameraError>

Immediately initialize or relocate the camera, clearing current shake.

Position, look target, FOV and orbit state snap to input; obstruction still constrains the boom, without sweeping from the old scene’s pose. Subsequent updates smooth from the new state with the same settings. Input or collision errors preserve the complete previous camera state, including shake and pending cuts. Queue new-scene shake after this call.

use ferravex_math::Vec3;
use ferravex_play::camera::{Input3, Mode3, NoObstructions, Rig3, Target3};
let mut camera = Rig3::default();
let frame = camera.snap(Input3 {
    target: Target3::at(Vec3::X * 100.),
    mode: Mode3::Follow {
        eye_offset: Vec3::Z * 10., look_offset: Vec3::ZERO,
    },
    fov_y: 1.,
}, &NoObstructions)?;
assert!(frame.cut);
assert_eq!(frame.pose.position, Vec3::new(100., 0., 10.));
Source

pub fn update( &mut self, dt: f32, input: Input3, collision: &(impl CollisionQuery + ?Sized), ) -> Result<Frame3, CameraError>

Advance presentation with elapsed seconds in 0..=0.25.

Invalid or larger timesteps return CameraError::InvalidInput and leave all state unchanged. Use Self::snap after a long host suspension if an immediate view of the current target is desired. Zero time freezes damping and shake time; initialization, cuts, first-person aim and collision still apply. Automatic teleports and mode changes cut and clear old shake.

Trait Implementations§

Source§

impl Clone for Rig3

Source§

fn clone(&self) -> Rig3

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 Rig3

Source§

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

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

impl Default for Rig3

Source§

fn default() -> Rig3

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

impl PartialEq for Rig3

Source§

fn eq(&self, other: &Rig3) -> 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 Rig3

Source§

impl StructuralPartialEq for Rig3

Auto Trait Implementations§

§

impl Freeze for Rig3

§

impl RefUnwindSafe for Rig3

§

impl Send for Rig3

§

impl Sync for Rig3

§

impl Unpin for Rig3

§

impl UnwindSafe for Rig3

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.