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,
recorder: &mut CommandBufferRecorder<'_>,
pipeline: &Arc<Pipeline>,
world: &World,
now: Duration,
) -> Result<()> {
recorder.bind_pipeline(pipeline)?;
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.buffer_barrier(

View file

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

View file

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