Skip to main content

SceneSnapshot

Struct SceneSnapshot 

Source
pub struct SceneSnapshot { /* private fields */ }

Implementations§

Source§

impl SceneSnapshot

Source

pub fn instances(&self) -> &[SceneInstance]

Contiguous immutable instances, in archetype order rather than spawn order.

Examples found in repository?
examples/scene.rs (line 42)
15fn main() -> Result<(), Box<dyn std::error::Error>> {
16    // Opaque asset identities only; this example qualifies CPU scene ownership, not drawing.
17    let mut assets = ResourceArena::new(RenderLimits::default())?;
18    let binding = RenderBinding {
19        mesh: assets.insert((), 1)?,
20        material: assets.insert((), 1)?,
21        tint: [1.0; 4],
22        animation: 0,
23        morph: 0,
24    };
25    let mut world = SceneWorld::new(SceneLimits {
26        max_entities: 64,
27        max_snapshot_instances: 64,
28        ..Default::default()
29    })?;
30    let mut first = None;
31    for i in 0..64 {
32        let id = world.spawn(
33            Transform::default().with_position([i as f32, 0.0, 0.0])?,
34            binding,
35            Some(Velocity::new([1.0, 0.0, 0.0])?),
36        )?;
37        first = first.or(Some(id));
38    }
39    let before = world.snapshot()?;
40    world.step_velocity(0.016)?;
41    let after = world.snapshot()?;
42    assert_eq!(before.instances()[0].transform.position()[0], 0.0);
43    assert_eq!(after.instances()[0].transform.position()[0], 0.016);
44    let mut commands = SceneCommands::new(8)?;
45    if let Some(first) = first {
46        commands.push(SceneCommand::SetVelocity(first, None))?;
47    }
48    for outcome in commands.apply(&mut world)? {
49        outcome?;
50    }
51    println!(
52        "entities={} owned_snapshots=2 moving_rows={}",
53        world.len(),
54        world.moving_columns().entities.len()
55    );
56    Ok(())
57}

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