Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement particle groups, enabling simple particle trails. #296

Merged
merged 7 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "bevy/png", "3d" ]
name = "2d"
required-features = [ "bevy/bevy_winit", "bevy/bevy_sprite", "2d" ]

[[example]]
name = "worms"
required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "3d" ]
pcwalton marked this conversation as resolved.
Show resolved Hide resolved

[workspace]
resolver = "2"
members = ["."]
Binary file added assets/circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fn setup(
// By default the asset spawns the particles at Z=0.
let spawner = Spawner::rate(30.0.into());
let effect = effects.add(
EffectAsset::new(4096, spawner, writer.finish())
EffectAsset::new(vec![4096], spawner, writer.finish())
.with_name("2d")
.init(init_pos)
.init(init_vel)
Expand Down
7 changes: 2 additions & 5 deletions examples/activate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ use bevy::{
log::LogPlugin,
prelude::*,
render::{
camera::{Projection, ScalingMode},
render_resource::WgpuFeatures,
settings::WgpuSettings,
RenderPlugin,
camera::ScalingMode, render_resource::WgpuFeatures, settings::WgpuSettings, RenderPlugin,
},
};
#[cfg(feature = "examples_world_inspector")]
Expand Down Expand Up @@ -136,7 +133,7 @@ fn setup(
};

let effect = effects.add(
EffectAsset::new(32768, spawner, writer.finish())
EffectAsset::new(vec![32768], spawner, writer.finish())
.with_name("activate")
.init(init_pos)
.init(init_vel)
Expand Down
2 changes: 1 addition & 1 deletion examples/billboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ fn setup(
let rotation_attr = writer.attr(Attribute::F32_0).expr();

let effect = effects.add(
EffectAsset::new(32768, Spawner::rate(64.0.into()), writer.finish())
EffectAsset::new(vec![32768], Spawner::rate(64.0.into()), writer.finish())
.with_name("billboard")
.with_alpha_mode(bevy_hanabi::AlphaMode::Mask(alpha_cutoff))
.init(init_pos)
Expand Down
2 changes: 1 addition & 1 deletion examples/circle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn setup(

let effect = effects.add(
EffectAsset::new(
32768,
vec![32768],
Spawner::burst(32.0.into(), 8.0.into()),
writer.finish(),
)
Expand Down
2 changes: 1 addition & 1 deletion examples/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn setup(mut commands: Commands, mut effects: ResMut<Assets<EffectAsset>>) {
};

let effect = effects.add(
EffectAsset::new(32768, Spawner::rate(500.0.into()), writer.finish())
EffectAsset::new(vec![32768], Spawner::rate(500.0.into()), writer.finish())
.with_name("whirlwind")
.init(init_pos)
.init(init_age)
Expand Down
2 changes: 1 addition & 1 deletion examples/firework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fn setup(mut commands: Commands, mut effects: ResMut<Assets<EffectAsset>>) {
};

let effect = EffectAsset::new(
32768,
vec![32768],
Spawner::burst(2500.0.into(), 2.0.into()),
writer.finish(),
)
Expand Down
13 changes: 3 additions & 10 deletions examples/force_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ use bevy::{
core_pipeline::tonemapping::Tonemapping,
log::LogPlugin,
prelude::*,
render::{
camera::Projection, render_resource::WgpuFeatures, settings::WgpuSettings, RenderPlugin,
},
render::{render_resource::WgpuFeatures, settings::WgpuSettings, RenderPlugin},
};
#[cfg(feature = "examples_world_inspector")]
use bevy_inspector_egui::quick::WorldInspectorPlugin;
Expand Down Expand Up @@ -80,12 +78,7 @@ struct RepulsorMarker(pub bool);

#[cfg(feature = "examples_world_inspector")]
mod inspector {
use bevy::{
ecs::system::{Local, Resource},
prelude::*,
reflect::Reflect,
window::PrimaryWindow,
};
use bevy::{ecs::system::Resource, prelude::*, reflect::Reflect, window::PrimaryWindow};
use bevy_egui::EguiContext;
use bevy_hanabi::EffectProperties;
use bevy_inspector_egui::{inspector_options::std_options::NumberDisplay, prelude::*};
Expand Down Expand Up @@ -338,7 +331,7 @@ fn setup(

// Force field effects
let effect = effects.add(
EffectAsset::new(32768, spawner, writer.finish())
EffectAsset::new(vec![32768], spawner, writer.finish())
.with_name("force_field")
.with_property("repulsor_position", Value::Vector(REPULSOR_POS.into()))
.with_property("attraction_accel", Value::Scalar(20.0.into()))
Expand Down
2 changes: 1 addition & 1 deletion examples/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn setup(
};

let effect = effects.add(
EffectAsset::new(32768, Spawner::rate(1000.0.into()), writer.finish())
EffectAsset::new(vec![32768], Spawner::rate(1000.0.into()), writer.finish())
.with_name("gradient")
.init(init_pos)
.init(init_vel)
Expand Down
22 changes: 13 additions & 9 deletions examples/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,19 @@ where

let init = make_modifier(&writer);

EffectAsset::new(32768, Spawner::once(COUNT.into(), true), writer.finish())
.with_name(name)
.with_simulation_space(SimulationSpace::Local)
.init(init)
.render(OrientModifier::new(OrientMode::FaceCameraPosition))
.render(SetColorModifier {
color: COLOR.into(),
})
.render(SetSizeModifier { size: SIZE.into() })
EffectAsset::new(
vec![32768],
Spawner::once(COUNT.into(), true),
writer.finish(),
)
.with_name(name)
.with_simulation_space(SimulationSpace::Local)
.init(init)
.render(OrientModifier::new(OrientMode::FaceCameraPosition))
.render(SetColorModifier {
color: COLOR.into(),
})
.render(SetSizeModifier { size: SIZE.into() })
}

fn spawn_effect(
Expand Down
2 changes: 1 addition & 1 deletion examples/instancing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ fn setup(
};

let effect = effects.add(
EffectAsset::new(512, Spawner::rate(50.0.into()), writer.finish())
EffectAsset::new(vec![512], Spawner::rate(50.0.into()), writer.finish())
.with_name("instancing")
.init(init_pos)
.init(init_vel)
Expand Down
6 changes: 3 additions & 3 deletions examples/lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn setup(
};
let effect1 = effects.add(
EffectAsset::new(
512,
vec![512],
Spawner::burst(50.0.into(), period.into()),
writer1.finish(),
)
Expand Down Expand Up @@ -172,7 +172,7 @@ fn setup(
};
let effect2 = effects.add(
EffectAsset::new(
512,
vec![512],
Spawner::burst(50.0.into(), period.into()),
writer2.finish(),
)
Expand Down Expand Up @@ -227,7 +227,7 @@ fn setup(
};
let effect3 = effects.add(
EffectAsset::new(
512,
vec![512],
Spawner::burst(50.0.into(), period.into()),
writer3.finish(),
)
Expand Down
2 changes: 1 addition & 1 deletion examples/multicam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn make_effect(color: Color) -> EffectAsset {
speed: writer.lit(6.).expr(),
};

EffectAsset::new(32768, Spawner::rate(5.0.into()), writer.finish())
EffectAsset::new(vec![32768], Spawner::rate(5.0.into()), writer.finish())
.with_name("effect")
.init(init_pos)
.init(init_vel)
Expand Down
2 changes: 1 addition & 1 deletion examples/portal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn setup(mut commands: Commands, mut effects: ResMut<Assets<EffectAsset>>) {
let tangent_accel = TangentAccelModifier::constant(&mut module, Vec3::ZERO, Vec3::Z, 30.);

let effect1 = effects.add(
EffectAsset::new(32768, Spawner::rate(5000.0.into()), module)
EffectAsset::new(vec![16384, 16384], Spawner::rate(5000.0.into()), module)
.with_name("portal")
.init(init_pos)
.init(init_age)
Expand Down
2 changes: 1 addition & 1 deletion examples/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn setup(

let effect = effects.add(
EffectAsset::new(
32768,
vec![32768],
Spawner::burst(CpuValue::Uniform((1., 100.)), CpuValue::Uniform((1., 4.))),
writer.finish(),
)
Expand Down
26 changes: 15 additions & 11 deletions examples/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn setup(
};

let effect1 = effects.add(
EffectAsset::new(32768, Spawner::rate(500.0.into()), writer1.finish())
EffectAsset::new(vec![32768], Spawner::rate(500.0.into()), writer1.finish())
.with_name("emit:rate")
.with_property("my_accel", Vec3::new(0., -3., 0.).into())
.init(init_pos1)
Expand Down Expand Up @@ -198,15 +198,19 @@ fn setup(
speed: writer2.lit(2.).expr(),
};
let effect2 = effects.add(
EffectAsset::new(32768, Spawner::once(1000.0.into(), true), writer2.finish())
.with_name("emit:once")
.init(init_pos2)
.init(init_vel2)
.init(init_age2)
.init(init_lifetime2)
.render(ColorOverLifetimeModifier {
gradient: gradient2,
}),
EffectAsset::new(
vec![32768],
Spawner::once(1000.0.into(), true),
writer2.finish(),
)
.with_name("emit:once")
.init(init_pos2)
.init(init_vel2)
.init(init_age2)
.init(init_lifetime2)
.render(ColorOverLifetimeModifier {
gradient: gradient2,
}),
);

commands
Expand Down Expand Up @@ -266,7 +270,7 @@ fn setup(

let effect3 = effects.add(
EffectAsset::new(
32768,
vec![32768],
Spawner::burst(400.0.into(), 3.0.into()),
writer3.finish(),
)
Expand Down
2 changes: 1 addition & 1 deletion examples/spawn_on_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn setup(
let init_vel = SetAttributeModifier::new(Attribute::VELOCITY, velocity.expr());

let effect = effects.add(
EffectAsset::new(32768, spawner, writer.finish())
EffectAsset::new(vec![32768], spawner, writer.finish())
.with_name("spawn_on_command")
.with_property("spawn_color", 0xFFFFFFFFu32.into())
.with_property("normal", Vec3::ZERO.into())
Expand Down
2 changes: 1 addition & 1 deletion examples/visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn setup(
};

let mut asset = EffectAsset::new(
4096,
vec![4096],
Spawner::burst(50.0.into(), 15.0.into()),
writer.finish(),
)
Expand Down
Loading
Loading