pub struct SceneSnapshot { /* private fields */ }Implementations§
Source§impl SceneSnapshot
impl SceneSnapshot
Sourcepub fn instances(&self) -> &[SceneInstance]
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§
impl Freeze for SceneSnapshot
impl RefUnwindSafe for SceneSnapshot
impl Send for SceneSnapshot
impl Sync for SceneSnapshot
impl Unpin for SceneSnapshot
impl UnsafeUnpin for SceneSnapshot
impl UnwindSafe for SceneSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more