Skip to content

Commit

Permalink
Update to bevy 0.13 and bevy_xpbd 0.4 (#9)
Browse files Browse the repository at this point in the history
I updated everything to bevy 0.13 and bevy_xpbd 0.4

This should now be fine to merge.

Fixes: #8

---------

Co-authored-by: Hendrik Decke <hendrik@decke.online>
  • Loading branch information
Affinator and Hendrik Decke authored Mar 5, 2024
1 parent 36d8710 commit 7bcce45
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 60 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_firework"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
readme = "README.md"
license = "MIT OR Apache-2.0"
Expand All @@ -10,11 +10,11 @@ keywords = ["bevy", "gamedev", "particles", "graphics"]
resolver = "2"

[dependencies]
bevy = "0.12.0"
bevy = "0.13"
bytemuck = "1.14.3"
rand = "0.8.5"
bevy_utilitarian = { version = "0.3.0" }
bevy_xpbd_3d = { version = "0.3.0", features = ["serialize"], optional = true }
bevy_utilitarian = "0.4"
bevy_xpbd_3d = { version = "0.4", features = ["serialize"], optional = true }
serde = { version = "1.0.197", features = ["derive"] }

[features]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ physics data for particle collision, simplified particle system animation).
| --------------- | ------ | ------------------ |
| 0.1 | 0.12 | 0.2 |
| 0.2 | 0.12 | 0.3 |
| 0.3 | 0.13 | 0.4 |
14 changes: 7 additions & 7 deletions examples/collision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ fn setup(
// circular base
commands
.spawn(PbrBundle {
mesh: meshes.add(shape::Box::new(8., 1., 8.).into()),
material: materials.add(Color::WHITE.into()),
mesh: meshes.add(Cuboid::from_size(Vec3::new(8., 1., 8.))),
material: materials.add(Color::WHITE),
transform: Transform::from_translation(Vec3::new(0., -0.5, 0.)),
..default()
})
Expand Down Expand Up @@ -73,7 +73,7 @@ fn setup(
scale_curve: ParamCurve::constant(1.),
linear_drag: 0.15,
color: Gradient::linear(vec![
(0., Color::rgba(300., 100., 1., 1.).into()),
(0., Color::rgba(10., 7., 1., 1.).into()),
(0.7, Color::rgba(3., 1., 1., 1.).into()),
(0.8, Color::rgba(1., 0.3, 0.3, 1.).into()),
(0.9, Color::rgba(0.3, 0.3, 0.3, 1.).into()),
Expand All @@ -98,8 +98,8 @@ fn setup(
// angled cube
commands
.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
mesh: meshes.add(Cuboid::from_size(Vec3::ONE)),
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
transform: Transform {
translation: Vec3::new(0., 0.5, 0.),
rotation: Quat::from_rotation_x(PI / 4.) * Quat::from_rotation_y(PI / 4.),
Expand All @@ -112,7 +112,7 @@ fn setup(
// light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
intensity: 1500000.0,
shadows_enabled: true,
..default()
},
Expand All @@ -137,7 +137,7 @@ fn setup(
fn adjust_time_scale(
mut slowmo: Local<bool>,
mut time: ResMut<Time<Virtual>>,
input: Res<Input<KeyCode>>,
input: Res<ButtonInput<KeyCode>>,
) {
if input.just_pressed(KeyCode::Space) {
*slowmo = !*slowmo;
Expand Down
12 changes: 6 additions & 6 deletions examples/pbr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ fn setup(

// circular base
commands.spawn(PbrBundle {
mesh: meshes.add(shape::Circle::new(4.0).into()),
material: materials.add(Color::WHITE.into()),
mesh: meshes.add(Circle::new(4.0)),
material: materials.add(Color::WHITE),
transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
..default()
});
Expand Down Expand Up @@ -82,16 +82,16 @@ fn setup(
.insert(Transform::from_xyz(0., 0.1, 0.));
// cube
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
mesh: meshes.add(Cuboid::from_size(Vec3::ONE)),
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(1.0, 1.5, 0.0),
..default()
});

// light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
intensity: 1500000.0,
shadows_enabled: true,
..default()
},
Expand All @@ -117,7 +117,7 @@ fn setup(
fn adjust_time_scale(
mut slowmo: Local<bool>,
mut time: ResMut<Time<Virtual>>,
input: Res<Input<KeyCode>>,
input: Res<ButtonInput<KeyCode>>,
) {
if input.just_pressed(KeyCode::Space) {
*slowmo = !*slowmo;
Expand Down
10 changes: 5 additions & 5 deletions examples/sparks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ fn setup(

// circular base
commands.spawn(PbrBundle {
mesh: meshes.add(shape::Circle::new(4.0).into()),
material: materials.add(Color::WHITE.into()),
mesh: meshes.add(Circle::new(4.0)),
material: materials.add(Color::WHITE),
transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
..default()
});
Expand All @@ -72,7 +72,7 @@ fn setup(
},
scale_curve: ParamCurve::constant(1.),
color: Gradient::linear(vec![
(0., Color::rgba(300., 100., 1., 1.).into()),
(0., Color::rgba(10., 7., 1., 1.).into()),
(0.7, Color::rgba(3., 1., 1., 1.).into()),
(0.8, Color::rgba(1., 0.3, 0.3, 1.).into()),
(0.9, Color::rgba(0.3, 0.3, 0.3, 1.).into()),
Expand All @@ -89,7 +89,7 @@ fn setup(
// light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
intensity: 1500000.0,
shadows_enabled: true,
..default()
},
Expand All @@ -114,7 +114,7 @@ fn setup(
fn adjust_time_scale(
mut slowmo: Local<bool>,
mut time: ResMut<Time<Virtual>>,
input: Res<Input<KeyCode>>,
input: Res<ButtonInput<KeyCode>>,
) {
if input.just_pressed(KeyCode::Space) {
*slowmo = !*slowmo;
Expand Down
12 changes: 6 additions & 6 deletions examples/stress_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ fn setup(

// circular base
commands.spawn(PbrBundle {
mesh: meshes.add(shape::Circle::new(4.0).into()),
material: materials.add(Color::WHITE.into()),
mesh: meshes.add(Circle::new(4.0)),
material: materials.add(Color::WHITE),
transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
..default()
});
Expand All @@ -125,7 +125,7 @@ fn setup(
},
scale_curve: ParamCurve::constant(1.),
color: Gradient::linear(vec![
(0., Color::rgba(300., 100., 1., 1.).into()),
(0., Color::rgba(10., 7., 1., 1.).into()),
(0.7, Color::rgba(3., 1., 1., 1.).into()),
(0.8, Color::rgba(1., 0.3, 0.3, 1.).into()),
(0.9, Color::rgba(0.3, 0.3, 0.3, 1.).into()),
Expand All @@ -142,7 +142,7 @@ fn setup(
// light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
intensity: 1500000.0,
shadows_enabled: true,
..default()
},
Expand All @@ -167,7 +167,7 @@ fn setup(
fn adjust_time_scale(
mut slowmo: Local<bool>,
mut time: ResMut<Time<Virtual>>,
input: Res<Input<KeyCode>>,
input: Res<ButtonInput<KeyCode>>,
) {
if input.just_pressed(KeyCode::Space) {
*slowmo = !*slowmo;
Expand All @@ -190,7 +190,7 @@ fn update_debug_info_text(
}

fn update_fps(mut debug_info: ResMut<DebugInfo>, diagnostics: Res<DiagnosticsStore>) {
if let Some(fps) = diagnostics.get(FrameTimeDiagnosticsPlugin::FPS) {
if let Some(fps) = diagnostics.get(&FrameTimeDiagnosticsPlugin::FPS) {
if let Some(value) = fps.smoothed() {
debug_info.fps = value as f32;
}
Expand Down
21 changes: 10 additions & 11 deletions examples/stress_test_collision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ use bevy_firework::{
plugin::ParticleSystemPlugin,
};
use bevy_utilitarian::prelude::*;
use bevy_xpbd_3d::{
components::Collider,
plugins::{spatial_query::SpatialQueryFilter, PhysicsPlugins},
use bevy_xpbd_3d::plugins::{
collision::Collider, spatial_query::SpatialQueryFilter, PhysicsPlugins,
};
use std::f32::consts::PI;

Expand Down Expand Up @@ -105,8 +104,8 @@ fn setup(
// circular base
commands
.spawn(PbrBundle {
mesh: meshes.add(shape::Box::new(8., 1., 8.).into()),
material: materials.add(Color::WHITE.into()),
mesh: meshes.add(Cuboid::from_size(Vec3::new(8., 1., 8.))),
material: materials.add(Color::WHITE),
transform: Transform::from_translation(Vec3::new(0., -0.5, 0.)),
..default()
})
Expand Down Expand Up @@ -134,7 +133,7 @@ fn setup(
scale_curve: ParamCurve::constant(1.),
linear_drag: 0.15,
color: Gradient::linear(vec![
(0., Color::rgba(300., 100., 1., 1.).into()),
(0., Color::rgba(10., 7., 1., 1.).into()),
(0.7, Color::rgba(3., 1., 1., 1.).into()),
(0.8, Color::rgba(1., 0.3, 0.3, 1.).into()),
(0.9, Color::rgba(0.3, 0.3, 0.3, 1.).into()),
Expand All @@ -159,8 +158,8 @@ fn setup(
// angled cube
commands
.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
mesh: meshes.add(Cuboid::from_size(Vec3::ONE)),
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
transform: Transform {
translation: Vec3::new(0., 0.5, 0.),
rotation: Quat::from_rotation_x(PI / 4.) * Quat::from_rotation_y(PI / 4.),
Expand All @@ -173,7 +172,7 @@ fn setup(
// light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
intensity: 1500000.0,
shadows_enabled: true,
..default()
},
Expand All @@ -198,7 +197,7 @@ fn setup(
fn adjust_time_scale(
mut slowmo: Local<bool>,
mut time: ResMut<Time<Virtual>>,
input: Res<Input<KeyCode>>,
input: Res<ButtonInput<KeyCode>>,
) {
if input.just_pressed(KeyCode::Space) {
*slowmo = !*slowmo;
Expand All @@ -221,7 +220,7 @@ fn update_debug_info_text(
}

fn update_fps(mut debug_info: ResMut<DebugInfo>, diagnostics: Res<DiagnosticsStore>) {
if let Some(fps) = diagnostics.get(FrameTimeDiagnosticsPlugin::FPS) {
if let Some(fps) = diagnostics.get(&FrameTimeDiagnosticsPlugin::FPS) {
if let Some(value) = fps.smoothed() {
debug_info.fps = value as f32;
}
Expand Down
7 changes: 5 additions & 2 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ pub fn propagate_particle_spawner_modifier(
pub fn setup_default_mesh(mut meshes: ResMut<Assets<Mesh>>) {
meshes.insert(
DEFAULT_MESH.clone(),
Mesh::from(shape::Quad::new(Vec2::new(1., 1.))),
Rectangle::from_size(Vec2::new(1., 1.)).mesh(),
);
}

Expand Down Expand Up @@ -421,7 +421,10 @@ fn particle_collision(
while delta > 0. && n_steps < 4 {
if let Some(hit) = spatial_query.cast_ray(
pos,
vel.try_normalize().unwrap_or(Vec3::Y),
match Direction3d::try_from(vel) {
Ok(dir) => dir,
Err(_) => Direction3d::Y,
},
vel.length() * delta,
true,
collision_settings.filter.clone(),
Expand Down
Loading

0 comments on commit 7bcce45

Please sign in to comment.