Skip to main content

Flyer

Struct Flyer 

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

A camera the keyboard flies.

Holds a position and two angles rather than a Camera, because a camera is an eye and a target: integrating a target directly makes turning depend on how far away it happens to be.

Implementations§

Source§

impl Flyer

Source

pub fn at(camera: &Camera) -> Self

A flyer standing where camera stands and looking where it looks, at SPEED.

Starting at the golden pose is what makes a sample’s free camera and its fixed camera the same first frame: a reviewer comparing a windowed run against a golden is comparing the same picture until they press a key.

Source

pub const fn with_speed(self, speed: f32) -> Self

The same flyer walking at speed metres a second instead of SPEED.

The default is sized for a room, and a scene that is not room-sized needs its own number: a camera that takes a minute and a half to cross the subject is as unusable as one that overshoots it. The turn rates are not configurable beside it, because an angle is an angle at every scale.

Source

pub const fn speed(&self) -> f32

How fast a held movement key walks it, in metres a second.

Source

pub const fn has_moved(&self) -> bool

Whether a key has ever moved this camera.

Source

pub const fn eye(&self) -> Vec3

Where the camera is.

Source

pub const fn key(&mut self, key: KeyCode, pressed: bool) -> bool

Takes a key edge, and says whether it was one of this camera’s.

Returning the answer rather than swallowing everything: the loop hands a game every key its own three did not claim, and a camera that reported “mine” for all of them would leave the sample unable to bind anything else later.

Source

pub fn release_all(&mut self)

Lets go of every key.

Called when the window loses focus: a platform sends no release for a key that was down when focus went away, so without this the camera keeps walking into a wall for as long as the window is in the background.

Source

pub fn look(&mut self, motion: Vec2)

Turns by one frame’s worth of mouse movement.

motion is PointerUpdate::motion: framebuffer pixels, Y down. That is why the pitch subtracts where the yaw adds — pushing the mouse away from the hand is a negative Y and has to raise the view — and it is the one sign in this file that no compiler can check.

§Not on the fixed timestep, unlike advance

A held key is a rate and has to be integrated against the clock or the camera flies at a speed proportional to how fast the machine is. A mouse delta is already a distance the hand moved: scaling it by dt would make the same sweep turn a different amount on a slow frame, and running it once per tick would apply one frame’s movement two or three times over on a frame that owed the clock several. So this lands where it arrives, in the frame, exactly once.

Source

pub fn advance(&mut self, dt: f32)

Advances by dt seconds of held input.

Source

pub fn camera(&self, projection: Projection) -> Camera

The camera this flyer is, with projection taken from the fixed one.

The projection is the caller’s rather than a field here because it is the lens, and the whole point of the pair is that the free camera and the golden camera see through the same one.

Trait Implementations§

Source§

impl Clone for Flyer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Flyer

Source§

impl Debug for Flyer

Source§

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

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

impl PartialEq for Flyer

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Flyer

Auto Trait Implementations§

§

impl Forget for Flyer

§

impl Freeze for Flyer

§

impl Move for Flyer

§

impl RefUnwindSafe for Flyer

§

impl Send for Flyer

§

impl Sync for Flyer

§

impl Unpin for Flyer

§

impl UnsafeUnpin for Flyer

§

impl UnwindSafe for Flyer

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> HalThreadSafe for T
where T: Send + Sync,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.