Use new update syntax

This commit is contained in:
hodasemi 2025-04-08 09:44:10 +02:00
parent 21c02e2e98
commit 0a8ea8972a
3 changed files with 18 additions and 17 deletions

View file

@ -379,11 +379,11 @@ impl ParticleSystem {
&self, &self,
recorder: &mut CommandBufferRecorder<'_>, recorder: &mut CommandBufferRecorder<'_>,
pipeline: &Arc<Pipeline>, pipeline: &Arc<Pipeline>,
world: &World, now: Duration,
) -> Result<()> { ) -> Result<()> {
recorder.bind_pipeline(pipeline)?; recorder.bind_pipeline(pipeline)?;
recorder.bind_descriptor_sets_minimal(&[&self.descriptor_set]); recorder.bind_descriptor_sets_minimal(&[&self.descriptor_set]);
recorder.push_constants(VK_SHADER_STAGE_COMPUTE_BIT, &world.now().as_secs_f32()); recorder.push_constants(VK_SHADER_STAGE_COMPUTE_BIT, &now.as_secs_f32());
recorder.dispatch(self.particle_buffer.size() as u32, 1, 1); recorder.dispatch(self.particle_buffer.size() as u32, 1, 1);
recorder.buffer_barrier( recorder.buffer_barrier(

View file

@ -142,8 +142,8 @@ impl Scene {
world.add_update( world.add_update(
"animate", "animate",
5_500_000, 5_500_000,
|world: &mut World, _entity, draw: &mut Draw, animation: &mut Animation| { |commands: &mut Commands, _entity, draw: &mut Draw, animation: &mut Animation| {
animation.animate(world.now(), draw)?; animation.animate(commands.now(), draw)?;
Ok(()) Ok(())
}, },
@ -153,11 +153,14 @@ impl Scene {
world.add_update( world.add_update(
"particle_system", "particle_system",
5_000_000, 5_000_000,
|world: &mut World, entity, particle_system: &mut ParticleSystem| { |commands: &mut Commands,
let now = world.now(); entity,
particle_system: &mut ParticleSystem,
scene: &mut Scene| {
let now = commands.now();
if !particle_system.update(now) { if !particle_system.update(now) {
world.remove_entity(entity); commands.remove_entity(entity);
return Ok(()); return Ok(());
} }
@ -167,13 +170,11 @@ impl Scene {
VkCommandBufferBeginInfo::new(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT); VkCommandBufferBeginInfo::new(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
begin_info.set_inheritance_info(&inheritance_info); begin_info.set_inheritance_info(&inheritance_info);
let scene = world.resources.get_mut_unchecked::<Scene>();
let particle_handles = scene.particle_system_vulkan_objects_mut(); let particle_handles = scene.particle_system_vulkan_objects_mut();
let pipeline = particle_handles.pipeline.clone(); let pipeline = particle_handles.pipeline.clone();
let mut recorder = particle_handles.begin(begin_info)?; let mut recorder = particle_handles.begin(begin_info)?;
particle_system.animate(&mut recorder, &pipeline, world)?; particle_system.animate(&mut recorder, &pipeline, now)?;
} }
Ok(()) Ok(())

View file

@ -321,21 +321,21 @@ impl Game {
// updates // updates
impl Game { impl Game {
fn player_orientation( fn player_orientation(
world: &mut World, commands: &mut Commands,
_entity: Entity, _entity: Entity,
draw: &mut Draw, draw: &mut Draw,
control: &mut FreeSpaceControl, control: &mut FreeSpaceControl,
) -> Result<()> { ) -> Result<()> {
control.update(world.now()); control.update(commands.now());
draw.set_transform(control.transform()) draw.set_transform(control.transform())
} }
fn camera_update( fn camera_update(
world: &mut World, _commands: &mut Commands,
_entity: Entity, _entity: Entity,
control: &mut FreeSpaceControl, control: &mut FreeSpaceControl,
scene: &mut Scene,
) -> Result<()> { ) -> Result<()> {
let scene: &mut Scene = world.resources.get_mut()?;
let view = scene.view_mut(); let view = scene.view_mut();
view.camera_mut() view.camera_mut()
@ -349,7 +349,7 @@ impl Game {
} }
fn celestial_buffer_update( fn celestial_buffer_update(
_: &mut World, _commands: &mut Commands,
_: Entity, _: Entity,
draw: &mut Draw, draw: &mut Draw,
control: &mut CelestialObjectSettings, control: &mut CelestialObjectSettings,
@ -360,7 +360,7 @@ impl Game {
} }
fn celestial_velocity_update( fn celestial_velocity_update(
world: &mut World, commands: &mut Commands,
(_, draw, lhs_control, reference): ( (_, draw, lhs_control, reference): (
Entity, Entity,
&mut Draw, &mut Draw,
@ -370,7 +370,7 @@ impl Game {
(rhs_entity, rhs_control): (Entity, &mut CelestialObjectSettings), (rhs_entity, rhs_control): (Entity, &mut CelestialObjectSettings),
) -> Result<()> { ) -> Result<()> {
if reference.entity == rhs_entity { if reference.entity == rhs_entity {
lhs_control.update(world.now(), draw, rhs_control)?; lhs_control.update(commands.now(), draw, rhs_control)?;
} }
Ok(()) Ok(())