Skip to main content

StandardCameras

Struct StandardCameras 

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

Bundle of inputs specifying the “standard” configuration of Cameras and other things to render an All is Cubes scene and user interface.

All of its data is provided through listen::DynSources, and consists of:

When StandardCameras::update() is called, all of these data sources are read and used to update the Camera data. Those cameras, and copies of the input data, are then available for use while rendering.

Because every input is a listen::DynSource, it is never necessary to call a setter. Every StandardCameras which was created with the same sources will have the same results (after update()).

Design note: The sense in which this is “standard” is that if an application wished to, for example, have multiple views into the same Space, it would need to create additional Cameras (or multiple StandardCameras) and update them itself.

Implementations§

Source§

impl StandardCameras

Source

pub fn update(&mut self, read_tickets: Layers<ReadTicket<'_>>) -> bool

Updates camera state from data sources.

This should be called at the beginning of each frame or as needed when the cameras are to be used.

Returns whether any values actually changed. (This does not include tracking changes to space content — only which part of which spaces are being looked at.)

Source

pub fn graphics_options(&self) -> &GraphicsOptions

Returns current graphics options as of the last update().

These options are to be used for the world and not the UI.

Source

pub fn graphics_options_source(&self) -> DynSource<Arc<GraphicsOptions>>

Returns a clone of the source of graphics options that this StandardCameras was created with.

These options are to be used for the world and not the UI.

Source

pub fn cameras(&self) -> &Layers<Camera>

Returns Cameras appropriate for drawing each graphical layer.

Source

pub fn character(&self) -> Option<&StrongHandle<Character>>

Returns the character’s viewpoint to draw in the world layer. May be None if there is no current character.

Source

pub fn world_space(&self) -> DynSource<Option<Handle<Space>>>

Returns the space that should be drawn as the game world, using self.cameras().world.

This is a listen::DynSource to make it simple to cache the Space rendering data and follow space transitions. It updates when Self::update() is called.

Source

pub fn ui_space(&self) -> Option<&Handle<Space>>

Returns the UI space, that should be drawn on top of the world using self.cameras().ui.

This implements GraphicsOptions::show_ui by returning None when the option is false.

TODO: Make this also a listen::DynSource

Source

pub fn viewport(&self) -> Viewport

Returns the current viewport.

This is always equal to the viewports of all managed Cameras, and only updates when StandardCameras::update() is called.

Source

pub fn viewport_source(&self) -> DynSource<Viewport>

Returns a clone of the viewport source this is following.

Source

pub fn project_cursor( &self, read_tickets: Layers<ReadTicket<'_>>, ndc_pos: NdcPoint2, ) -> Result<Option<Cursor>, HandleError>

Perform a raycast through these cameras to find what the cursor hits.

Make sure to call StandardCameras::update first so that the cameras are up to date with game state.

Source

pub fn clone_unupdated(&self) -> Self

Returns a StandardCameras which tracks the same data sources (graphics options, scene sources, viewport) as self, but whose local state (such as the last updated camera state) is independent.

The local state is also not updated; you must call StandardCameras::update() on the clone before reading anything from it.

Trait Implementations§

Source§

impl Debug for StandardCameras

Source§

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

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

impl Pointer for StandardCameras

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> ConditionalSend for T
where T: Send,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.