Skip to content

Commit

Permalink
cargo fmt (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
djeedai authored Jun 10, 2023
1 parent e0ebf1b commit f43742c
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion examples/visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ fn update(
// (time.elapsed() - Duration::from_millis(*last_time)).as_millis()
// );
if time.elapsed() - Duration::from_millis(*last_time) >= Duration::from_millis(1500) {
//warn!("TOGGLE: ");
// warn!("TOGGLE: ");
*last_time = time.elapsed().as_millis() as u64;
for mut visibility in query.iter_mut() {
*visibility = if *visibility == Visibility::Visible {
Expand Down
8 changes: 4 additions & 4 deletions src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,20 +328,20 @@ mod tests {
InitVelocitySphereModifier::default().apply(&mut init_context);
InitAgeModifier::default().apply(&mut init_context);
InitLifetimeModifier::default().apply(&mut init_context);
//assert_eq!(effect., init_context.init_code);
// assert_eq!(effect., init_context.init_code);

let mut update_context = UpdateContext::default();
AccelModifier::constant(Vec3::ONE).apply(&mut update_context);
LinearDragModifier::default().apply(&mut update_context);
ForceFieldModifier::default().apply(&mut update_context);
//assert_eq!(effect.update_layout, update_layout);
// assert_eq!(effect.update_layout, update_layout);

let mut render_context = RenderContext::default();
ParticleTextureModifier::default().apply(&mut render_context);
ColorOverLifetimeModifier::default().apply(&mut render_context);
SizeOverLifetimeModifier::default().apply(&mut render_context);
BillboardModifier::default().apply(&mut render_context);
//assert_eq!(effect.render_layout, render_layout);
// assert_eq!(effect.render_layout, render_layout);
}

#[test]
Expand All @@ -355,6 +355,6 @@ mod tests {

let s = ron::to_string(&effect).unwrap();
let _effect_serde: EffectAsset = ron::from_str(&s).unwrap();
//assert_eq!(effect, effect_serde);
// assert_eq!(effect, effect_serde);
}
}
8 changes: 4 additions & 4 deletions src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,11 +766,11 @@ impl ParticleLayout {
/// of attributes.
pub fn merged_with(
&self,
//attributes: impl IntoIterator<Item = Attribute>,
// attributes: impl IntoIterator<Item = Attribute>,
attributes: &[Attribute],
) -> ParticleLayout {
let mut builder = ParticleLayoutBuilder::from(self);
//for attr in attributes.into_iter() {
// for attr in attributes.into_iter() {
for attr in attributes {
builder = builder.append(*attr);
}
Expand Down Expand Up @@ -850,7 +850,7 @@ impl ParticleLayout {

/// Generate the WGSL attribute code corresponding to the layout.
pub fn generate_code(&self) -> String {
//assert!(self.layout.is_sorted_by_key(|entry| entry.offset));
// assert!(self.layout.is_sorted_by_key(|entry| entry.offset));
self.layout
.iter()
.map(|entry| {
Expand Down Expand Up @@ -910,7 +910,7 @@ mod tests {
}
assert!(res.is_ok());
let m = res.unwrap();
//println!("Module: {:?}", m);
// println!("Module: {:?}", m);

// Retrieve the "x" constant and the size/align of its type
let (_cst_handle, cst) = m
Expand Down
2 changes: 1 addition & 1 deletion src/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ mod tests {
let g = make_test_gradient();

let s = ron::to_string(&g).unwrap();
//println!("gradient: {:?}", s);
// println!("gradient: {:?}", s);
let g_serde: Gradient<Vec4> = ron::from_str(&s).unwrap();
assert_eq!(g, g_serde);
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ pub enum SimulationSpace {
/// influenced anymore by the emitter's [`Transform`] after spawning.
#[default]
Global,
//Local, // TODO
// Local, // TODO
}

/// Value a user wants to assign to a property with
Expand Down Expand Up @@ -1280,7 +1280,7 @@ else { return c1; }

let mut app = App::new();
app.insert_resource(asset_server);
//app.add_plugins(DefaultPlugins);
// app.add_plugins(DefaultPlugins);
app.add_asset::<Mesh>();
app.add_asset::<Shader>();
app.add_plugin(VisibilityPlugin);
Expand Down
2 changes: 1 addition & 1 deletion src/modifier/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ fn main() {{
{init_code}
}}"##
);
//println!("code: {:?}", code);
// println!("code: {:?}", code);

let mut parser = Parser::new();
let res = parser.parse(&code);
Expand Down
6 changes: 3 additions & 3 deletions src/modifier/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct UpdateContext {
/// Extra functions emitted at top level, which `update_code` can call.
pub update_extra: String,

//TEMP
// TEMP
/// Array of force field components with a maximum number of components
/// determined by [`ForceFieldSource::MAX_SOURCES`].
pub force_field: [ForceFieldSource; ForceFieldSource::MAX_SOURCES],
Expand Down Expand Up @@ -598,7 +598,7 @@ impl UpdateModifier for ForceFieldModifier {

context.update_code += &format!("{}(&particle);\n", func_name);

//TEMP
// TEMP
context.force_field = self.sources;
}
}
Expand Down Expand Up @@ -709,7 +709,7 @@ mod tests {
modifier.apply(&mut context);

// force_field_code.wgsl is too big
//assert!(context.update_code.contains(&include_str!("../render/
// assert!(context.update_code.contains(&include_str!("../render/
// force_field_code.wgsl")));
}

Expand Down
2 changes: 1 addition & 1 deletion src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ impl PropertyLayout {

/// Generate the WGSL attribute code corresponding to the layout.
pub fn generate_code(&self) -> String {
//assert!(self.layout.is_sorted_by_key(|entry| entry.offset));
// assert!(self.layout.is_sorted_by_key(|entry| entry.offset));
let content = self
.layout
.iter()
Expand Down
4 changes: 2 additions & 2 deletions src/render/aligned_buffer_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ mod gpu_tests {
queue.on_submitted_work_done(move || {
tx.send(()).unwrap();
});
let _ = futures::executor::block_on(async { rx.await });
let _ = futures::executor::block_on(rx);
println!("Buffer written");

// Read back (GPU -> CPU)
Expand All @@ -395,7 +395,7 @@ mod gpu_tests {
tx.send(result).unwrap();
});
device.poll(wgpu::Maintain::Wait);
let _result = futures::executor::block_on(async { rx.await });
let _result = futures::executor::block_on(rx);
let view = buffer.get_mapped_range();

// Validate content
Expand Down
4 changes: 2 additions & 2 deletions src/render/buffer_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ mod gpu_tests {
tx.send(result).unwrap();
});
device.poll(wgpu::Maintain::Wait);
let result = futures::executor::block_on(async { rx.await });
let result = futures::executor::block_on(rx);
assert!(result.is_ok());
slice.get_mapped_range()
}
Expand All @@ -670,7 +670,7 @@ mod gpu_tests {
queue.on_submitted_work_done(move || {
tx.send(()).unwrap();
});
let _ = futures::executor::block_on(async { rx.await });
let _ = futures::executor::block_on(rx);
}

/// Convert a byte slice to a string of hexadecimal values separated by a
Expand Down
16 changes: 8 additions & 8 deletions src/render/effect_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub struct EffectBuffer {
/// the buffer.
free_slices: Vec<Range<u32>>,
/// Compute pipeline for the effect update pass.
//pub compute_pipeline: ComputePipeline, // FIXME - ComputePipelineId, to avoid duplicating per
// pub compute_pipeline: ComputePipeline, // FIXME - ComputePipelineId, to avoid duplicating per
// instance!
/// Handle of all effects common in this buffer. TODO - replace with
/// compatible layout.
Expand All @@ -122,7 +122,7 @@ impl EffectBuffer {
// N, and inability for a particle index to tell which Spawner it should
// use. Setting this to 1 effectively ensures that all new buffers just fit
// the effect, so batching never occurs.
pub const MIN_CAPACITY: u32 = 1; //65536; // at least 64k particles
pub const MIN_CAPACITY: u32 = 1; // 65536; // at least 64k particles

/// Create a new group and a GPU buffer to back it up.
///
Expand All @@ -135,7 +135,7 @@ impl EffectBuffer {
capacity: u32,
particle_layout: ParticleLayout,
property_layout: PropertyLayout,
//compute_pipeline: ComputePipeline,
// compute_pipeline: ComputePipeline,
render_device: &RenderDevice,
label: Option<&str>,
) -> Self {
Expand Down Expand Up @@ -305,7 +305,7 @@ impl EffectBuffer {
capacity,
used_size: 0,
free_slices: vec![],
//compute_pipeline,
// compute_pipeline,
asset,
}
}
Expand Down Expand Up @@ -576,7 +576,7 @@ impl EffectCache {
capacity: u32,
particle_layout: &ParticleLayout,
property_layout: &PropertyLayout,
//pipeline: ComputePipeline,
// pipeline: ComputePipeline,
_queue: &RenderQueue,
) -> EffectCacheId {
let (buffer_index, slice) = self
Expand Down Expand Up @@ -774,7 +774,7 @@ mod gpu_tests {
fn effect_buffer() {
let renderer = MockRenderer::new();
let render_device = renderer.device();
//let render_queue = renderer.queue();
// let render_queue = renderer.queue();

let l64 = ParticleLayout::new()
.append(F4A)
Expand Down Expand Up @@ -848,7 +848,7 @@ mod gpu_tests {
fn pop_free_slice() {
let renderer = MockRenderer::new();
let render_device = renderer.device();
//let render_queue = renderer.queue();
// let render_queue = renderer.queue();

let l64 = ParticleLayout::new()
.append(F4A)
Expand All @@ -859,7 +859,7 @@ mod gpu_tests {
assert_eq!(64, l64.size());

let asset = Handle::weak(HandleId::random::<EffectAsset>());
let capacity = 2048; //EffectBuffer::MIN_CAPACITY;
let capacity = 2048; // EffectBuffer::MIN_CAPACITY;
assert!(capacity >= 2048); // otherwise the logic below breaks
let mut buffer = EffectBuffer::new(
asset,
Expand Down
36 changes: 18 additions & 18 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ pub(crate) struct ExtractedEffect {
// until we have a proper graph solution to replace it.
force_field: [ForceFieldSource; ForceFieldSource::MAX_SOURCES],
// Texture to use for the sprites of the particles of this effect.
//pub image: Handle<Image>,
// pub image: Handle<Image>,
pub has_image: bool, // TODO -> use flags
/// Texture to modulate the particle color.
pub image_handle_id: HandleId,
Expand Down Expand Up @@ -1498,7 +1498,7 @@ impl EffectsMeta {
added_effect.capacity,
&added_effect.particle_layout,
&added_effect.property_layout,
//update_pipeline.pipeline.clone(),
// update_pipeline.pipeline.clone(),
render_queue,
);

Expand Down Expand Up @@ -1630,7 +1630,7 @@ pub(crate) fn prepare_effects(
update_pipeline: Res<ParticlesUpdatePipeline>,
mut specialized_init_pipelines: ResMut<SpecializedComputePipelines<ParticlesInitPipeline>>,
mut specialized_update_pipelines: ResMut<SpecializedComputePipelines<ParticlesUpdatePipeline>>,
//update_pipeline: Res<ParticlesUpdatePipeline>, // TODO move update_pipeline.pipeline to
// update_pipeline: Res<ParticlesUpdatePipeline>, // TODO move update_pipeline.pipeline to
// EffectsMeta
mut effects_meta: ResMut<EffectsMeta>,
mut extracted_effects: ResMut<ExtractedEffects>,
Expand All @@ -1641,7 +1641,7 @@ pub(crate) fn prepare_effects(
effects_meta.update_gpu_limits(&render_device);

// Allocate spawner buffer if needed
//if effects_meta.spawner_buffer.is_empty() {
// if effects_meta.spawner_buffer.is_empty() {
// effects_meta.spawner_buffer.push(GpuSpawnerParams::default());
//}

Expand Down Expand Up @@ -1789,7 +1789,7 @@ pub(crate) fn prepare_effects(
spawn_count,
slice: start..end,
particle_layout: std::mem::take(&mut particle_layout),
//property_layout: std::mem::take(&mut property_layout),
// property_layout: std::mem::take(&mut property_layout),
handle: asset.clone_weak(),
layout_flags,
image_handle_id,
Expand Down Expand Up @@ -2002,7 +2002,7 @@ pub(crate) fn prepare_effects(
.write_buffer(&render_device, &render_queue);

// Allocate simulation uniform if needed
//if effects_meta.sim_params_uniforms.is_empty() {
// if effects_meta.sim_params_uniforms.is_empty() {
effects_meta
.sim_params_uniforms
.set(SimParamsUniform::default());
Expand Down Expand Up @@ -2734,7 +2734,7 @@ fn draw<'w>(
effect_batch.buffer_index,
effect_batch.slice
);
return; //continue;
return; // continue;
}
}

Expand Down Expand Up @@ -2830,7 +2830,7 @@ pub(crate) struct VfxSimulateNode {
impl VfxSimulateNode {
/// Output particle buffer for that view. TODO - how to handle multiple
/// buffers?! Should use Entity instead??
//pub const OUT_PARTICLE_BUFFER: &'static str = "particle_buffer";
// pub const OUT_PARTICLE_BUFFER: &'static str = "particle_buffer";

/// Create a new node for simulating the effects of the given world.
pub fn new(world: &mut World) -> Self {
Expand Down Expand Up @@ -2860,12 +2860,12 @@ impl Node for VfxSimulateNode {

// Get the Entity containing the ViewEffectsEntity component used as container
// for the input data for this node.
//let view_entity = graph.get_input_entity(Self::IN_VIEW)?;
// let view_entity = graph.get_input_entity(Self::IN_VIEW)?;
let pipeline_cache = world.resource::<PipelineCache>();

let effects_meta = world.resource::<EffectsMeta>();
let effect_bind_groups = world.resource::<EffectBindGroups>();
//let render_queue = world.resource::<RenderQueue>();
// let render_queue = world.resource::<RenderQueue>();

// Make sure to schedule any buffer copy from changed effects before accessing
// them
Expand Down Expand Up @@ -2902,14 +2902,14 @@ impl Node for VfxSimulateNode {
const WORKGROUP_SIZE: u32 = 64;
let workgroup_count = (spawn_count + WORKGROUP_SIZE - 1) / WORKGROUP_SIZE;

//for (effect_entity, effect_slice) in effects_meta.entity_map.iter() {
// for (effect_entity, effect_slice) in effects_meta.entity_map.iter() {
// Retrieve the ExtractedEffect from the entity
//trace!("effect_entity={:?} effect_slice={:?}", effect_entity,
// trace!("effect_entity={:?} effect_slice={:?}", effect_entity,
// effect_slice); let effect =
// self.effect_query.get_manual(world, *effect_entity).unwrap();

// Get the slice to init
//let effect_slice = effects_meta.get(&effect_entity);
// 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; };
Expand Down Expand Up @@ -2943,7 +2943,7 @@ impl Node for VfxSimulateNode {
);

// Setup compute pass
//compute_pass.set_pipeline(&effect_group.init_pipeline);
// compute_pass.set_pipeline(&effect_group.init_pipeline);
compute_pass.set_pipeline(init_pipeline);
compute_pass.set_bind_group(
0,
Expand Down Expand Up @@ -3030,14 +3030,14 @@ impl Node for VfxSimulateNode {
if let Some(update_pipeline) =
pipeline_cache.get_compute_pipeline(batch.update_pipeline_id)
{
//for (effect_entity, effect_slice) in effects_meta.entity_map.iter() {
// for (effect_entity, effect_slice) in effects_meta.entity_map.iter() {
// Retrieve the ExtractedEffect from the entity
//trace!("effect_entity={:?} effect_slice={:?}", effect_entity,
// trace!("effect_entity={:?} effect_slice={:?}", effect_entity,
// effect_slice); let effect =
// self.effect_query.get_manual(world, *effect_entity).unwrap();

// Get the slice to update
//let effect_slice = effects_meta.get(&effect_entity);
// 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; };
Expand Down Expand Up @@ -3069,7 +3069,7 @@ impl Node for VfxSimulateNode {
);

// Setup compute pass
//compute_pass.set_pipeline(&effect_group.update_pipeline);
// compute_pass.set_pipeline(&effect_group.update_pipeline);
compute_pass.set_pipeline(update_pipeline);
compute_pass.set_bind_group(
0,
Expand Down
Loading

0 comments on commit f43742c

Please sign in to comment.