Skip to main content

Scene

Struct Scene 

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

Top-level scene container. Holds a flat collection of grids keyed by GridId.

S2.0 only exposes registration / removal / lookup. Address math helpers (S2.x), edit API (S2.x), and rendering composition (S3) land in later sub-substages.

Implementations§

Source§

impl Scene

Source

pub fn to_snapshot(&self) -> SceneSnapshot

Capture the scene’s full state as a serde-friendly value. Each chunk is encoded via roxlap_formats::vxl::serialize; the rest is plain field data.

Grid iteration order in the produced snapshot is sorted by GridId so two snapshots of the same scene produce byte-identical output (the live HashMap iteration order would be non-deterministic).

Source

pub fn from_snapshot(snap: &SceneSnapshot) -> Result<Self, FromSnapshotError>

Restore a Scene from a snapshot. Each chunk’s bytes are re-parsed via roxlap_formats::vxl::parse and re-armed for edits via roxlap_formats::vxl::Vxl::reserve_edit_capacity.

§Errors

Returns FromSnapshotError::ChunkParse tagged with the owning grid + chunk index if any chunk’s bytes fail to parse. The partial scene is dropped — restoration is all-or-nothing.

Source§

impl Scene

Source

pub fn new() -> Self

New empty scene — no grids.

Source

pub fn grid_count(&self) -> usize

Number of grids currently registered.

Source

pub fn add_grid(&mut self, transform: GridTransform) -> GridId

Register a new grid. Returns its fresh, unique GridId.

Source

pub fn remove_grid(&mut self, id: GridId) -> Option<Grid>

Remove a grid by id. Returns the removed Grid (so the caller can reclaim its chunks) or None if the id wasn’t registered. Removed ids are not reissued.

Source

pub fn grid(&self, id: GridId) -> Option<&Grid>

Borrow a registered grid.

Source

pub fn grid_mut(&mut self, id: GridId) -> Option<&mut Grid>

Mutably borrow a registered grid.

Source

pub fn grids(&self) -> impl Iterator<Item = (GridId, &Grid)>

Iterator over all (id, grid) pairs in registration order is not guaranteed — the underlying map is a HashMap. Callers that need a stable order must sort by GridId.

Source

pub fn grids_mut(&mut self) -> impl Iterator<Item = (GridId, &mut Grid)>

Mutable iterator over all (id, grid) pairs. Yield order is not guaranteed (HashMap-backed).

Trait Implementations§

Source§

impl Debug for Scene

Source§

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

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

impl Default for Scene

Source§

fn default() -> Scene

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

Auto Trait Implementations§

§

impl Freeze for Scene

§

impl RefUnwindSafe for Scene

§

impl Send for Scene

§

impl Sync for Scene

§

impl Unpin for Scene

§

impl UnsafeUnpin for Scene

§

impl UnwindSafe for Scene

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> 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> 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, 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.