pub struct SceneCommands { /* private fields */ }Expand description
Independent bounded structural queue. Application owns ordering and frame boundaries.
Implementations§
Source§impl SceneCommands
impl SceneCommands
Sourcepub fn new(capacity: usize) -> Result<Self, RenderError>
pub fn new(capacity: usize) -> Result<Self, RenderError>
Reserve 1..256 operations; no workers, timers or automatic application.
Examples found in repository?
examples/scene.rs (line 44)
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}Sourcepub fn push(&mut self, command: SceneCommand) -> Result<(), RenderError>
pub fn push(&mut self, command: SceneCommand) -> Result<(), RenderError>
Queue before world mutation; overflow leaves existing queued operations intact.
Examples found in repository?
examples/scene.rs (line 46)
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}Sourcepub fn apply(
self,
world: &mut SceneWorld,
) -> Result<Vec<Result<(), RenderError>>, RenderError>
pub fn apply( self, world: &mut SceneWorld, ) -> Result<Vec<Result<(), RenderError>>, RenderError>
Apply in order, returning one outcome per command. This batch is explicitly nontransactional: an invalid command does not undo earlier effects or discard subsequent commands. Outcome allocation is admitted before any mutation; no user callbacks run inside the batch.
Examples found in repository?
examples/scene.rs (line 48)
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 SceneCommands
impl RefUnwindSafe for SceneCommands
impl Send for SceneCommands
impl Sync for SceneCommands
impl Unpin for SceneCommands
impl UnsafeUnpin for SceneCommands
impl UnwindSafe for SceneCommands
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