Skip to content

Commit

Permalink
cargo fmt (djeedai#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
djeedai authored Sep 8, 2023
1 parent d9305be commit 5cd2183
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 15 deletions.
4 changes: 3 additions & 1 deletion examples/force_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ fn update(
// Note: On first frame where the effect spawns, EffectSpawner is spawned during
// CoreSet::PostUpdate, so will not be available yet. Ignore for a frame if
// so.
let Ok((mut spawner, mut effect_transform)) = q_effect.get_single_mut() else { return; };
let Ok((mut spawner, mut effect_transform)) = q_effect.get_single_mut() else {
return;
};

let (camera, camera_transform) = camera_query.single();

Expand Down
4 changes: 3 additions & 1 deletion examples/multicam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ fn update_camera_viewports(
// A resize_event is sent when the window is first created, allowing us to reuse
// this system for initial setup.
for resize_event in resize_events.iter() {
let Ok(window) = window.get(resize_event.window) else {continue;};
let Ok(window) = window.get(resize_event.window) else {
continue;
};
let dw = window.physical_width() / 2;
let dh = window.physical_height() / 2;
let physical_size = UVec2::new(dw, dh);
Expand Down
4 changes: 3 additions & 1 deletion examples/spawn_on_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ fn update(
// Note: On first frame where the effect spawns, EffectSpawner is spawned during
// CoreSet::PostUpdate, so will not be available yet. Ignore for a frame if
// so.
let Ok((mut effect, mut spawner, mut effect_transform)) = effect.get_single_mut() else { return; };
let Ok((mut effect, mut spawner, mut effect_transform)) = effect.get_single_mut() else {
return;
};

for (mut ball, mut transform) in balls.iter_mut() {
let mut pos = transform.translation.xy() + ball.velocity * time.delta_seconds();
Expand Down
8 changes: 6 additions & 2 deletions src/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,15 +625,19 @@ mod tests {
.type_name()
.starts_with("bevy_hanabi::gradient::Gradient<")); // the Vec4 type name depends on platform
let keys = g.field("keys").unwrap();
let ReflectRef::List(keys) = keys.reflect_ref() else { panic!("Invalid type"); };
let ReflectRef::List(keys) = keys.reflect_ref() else {
panic!("Invalid type");
};
assert_eq!(keys.len(), 3);
for (i, (r, v)) in [(0.5, RED), (0.8, BLUE), (0.8, GREEN)].iter().enumerate() {
let k = keys.get(i).unwrap();
let gk = k.downcast_ref::<GradientKey<Vec4>>().unwrap();
assert_approx_eq!(gk.ratio(), r);
assert_approx_eq!(gk.value, v);

let ReflectRef::Struct(k) = k.reflect_ref() else { panic!("Invalid type"); };
let ReflectRef::Struct(k) = k.reflect_ref() else {
panic!("Invalid type");
};
assert!(k.type_name().contains("GradientKey"));
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,9 @@ fn compile_effects(
// Check if asset is available, otherwise silently ignore as we can't check for
// changes, and conceptually it makes no sense to render a particle effect whose
// asset was unloaded.
let Some(asset) = effects.get(&effect.handle) else { return None; };
let Some(asset) = effects.get(&effect.handle) else {
return None;
};

Some((asset, entity, effect, compiled_effect))
})
Expand Down
4 changes: 3 additions & 1 deletion src/render/buffer_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,9 @@ impl<T: Pod + ShaderSize> BufferTable<T> {
);

// If there's no more GPU buffer, there's nothing to do
let Some(ab) = self.buffer.as_ref() else { return; };
let Some(ab) = self.buffer.as_ref() else {
return;
};

// Copy any old buffer into the new one, and clear the old buffer. Note that we
// only clear the ref-counted reference to the buffer, not the actual buffer,
Expand Down
27 changes: 20 additions & 7 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,10 @@ pub(crate) fn extract_effects(

// Check if asset is available, otherwise silently ignore
let Some(asset) = effects.get(&effect.asset) else {
trace!("EffectAsset not ready; skipping ParticleEffect instance on entity {:?}.", entity);
trace!(
"EffectAsset not ready; skipping ParticleEffect instance on entity {:?}.",
entity
);
continue;
};

Expand Down Expand Up @@ -2236,7 +2239,9 @@ pub(crate) fn queue_effects(

// Get the binding for the ViewUniform, the uniform data structure containing
// the Camera data for the current view.
let Some(view_binding) = view_uniforms.uniforms.binding() else { return; };
let Some(view_binding) = view_uniforms.uniforms.binding() else {
return;
};

// Create the bind group for the camera/view parameters
effects_meta.view_bind_group = Some(render_device.create_bind_group(&BindGroupDescriptor {
Expand Down Expand Up @@ -2620,9 +2625,9 @@ fn draw<'w>(

let gpu_limits = &effects_meta.gpu_limits;

let Some(pipeline) = pipeline_cache
.into_inner()
.get_render_pipeline(pipeline_id) else { return; };
let Some(pipeline) = pipeline_cache.into_inner().get_render_pipeline(pipeline_id) else {
return;
};

trace!("render pass");

Expand Down Expand Up @@ -2879,7 +2884,11 @@ impl Node for VfxSimulateNode {
// let effect_slice = effects_meta.get(&effect_entity);
// let effect_group =
// &effects_meta.effect_cache.buffers()[batch.buffer_index as usize];
let Some(particles_bind_group) = effect_bind_groups.particle_simulate(batch.buffer_index) else { continue; };
let Some(particles_bind_group) =
effect_bind_groups.particle_simulate(batch.buffer_index)
else {
continue;
};

let item_size = batch.particle_layout.min_binding_size();
let item_count = batch.slice.end - batch.slice.start;
Expand Down Expand Up @@ -3007,7 +3016,11 @@ impl Node for VfxSimulateNode {
// let effect_slice = effects_meta.get(&effect_entity);
// let effect_group =
// &effects_meta.effect_cache.buffers()[batch.buffer_index as usize];
let Some(particles_bind_group) = effect_bind_groups.particle_simulate(batch.buffer_index) else { continue; };
let Some(particles_bind_group) =
effect_bind_groups.particle_simulate(batch.buffer_index)
else {
continue;
};

let item_size = batch.particle_layout.size();
let item_count = batch.slice.end - batch.slice.start;
Expand Down
4 changes: 3 additions & 1 deletion src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,9 @@ pub fn tick_spawners(
for (entity, effect, maybe_computed_visibility, maybe_spawner) in query.iter_mut() {
// TODO - maybe cache simulation_condition so we don't need to unconditionally
// query the asset?
let Some(asset) = effects.get(&effect.handle) else { continue; };
let Some(asset) = effects.get(&effect.handle) else {
continue;
};

if asset.simulation_condition == SimulationCondition::WhenVisible {
if let Some(computed_visibility) = maybe_computed_visibility {
Expand Down

0 comments on commit 5cd2183

Please sign in to comment.