Skip to content

Commit

Permalink
Bevy 0.15 (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManevilleF authored Jan 4, 2025
1 parent 53dbcdc commit ebdcf4d
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 92 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: build
run: cargo build --verbose

build_features:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: all features
run: cargo build --verbose --all-features
Expand All @@ -33,7 +33,7 @@ jobs:
build_examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: build 2d cloth
run: cargo clippy --all-features --example 2d_cloth
Expand All @@ -49,7 +49,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: tests
run: cargo test --tests
Expand All @@ -59,7 +59,7 @@ jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: "rustfmt"
Expand All @@ -69,15 +69,15 @@ jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Cargo clippy check
run: cargo clippy --all-features --all --tests -- -D warnings

rustdoc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: rustdoc
run: cargo rustdoc --all-features -- -D warnings
25 changes: 12 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,24 @@ debug = ["bevy/bevy_gizmos", "bevy/bevy_render"]
[dependencies]

[dependencies.bevy]
version = "0.14"
version = "0.15"
default-features = false

[dev-dependencies]

[dev-dependencies.bevy]
version = "0.14"
version = "0.15"
features = [
"bevy_render",
"bevy_winit",
"bevy_color",
"bevy_core_pipeline",
"bevy_sprite",
"bevy_pbr",
"x11",
"multi_threaded",
"tonemapping_luts",
# Faster compilation
"dynamic_linking",
"bevy_render",
"bevy_winit",
"bevy_window",
"bevy_color",
"bevy_core_pipeline",
"bevy_sprite",
"bevy_pbr",
"x11",
"multi_threaded",
"tonemapping_luts",
]
default-features = false

Expand Down
21 changes: 9 additions & 12 deletions examples/2d_cloth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,24 @@ fn main() {
}

fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d::default());
let stick_length: f32 = 35.;
let (origin_x, origin_y) = (-450., 350.);
let (points_x_count, points_y_count) = (30, 15);
let mut entities = Vec::new();
for j in 0..points_y_count {
for i in 0..points_x_count {
let mut cmd = commands.spawn((
SpriteBundle {
sprite: Sprite {
color: if j == 0 { RED.into() } else { WHITE.into() },
custom_size: Some(Vec2::splat(10.)),
..Default::default()
},
transform: Transform::from_xyz(
origin_x + (30. * i as f32),
origin_y + (-30. * (j + i / 3) as f32),
0.,
),
Sprite {
color: if j == 0 { RED.into() } else { WHITE.into() },
custom_size: Some(Vec2::splat(10.)),
..Default::default()
},
Transform::from_xyz(
origin_x + (30. * i as f32),
origin_y + (-30. * (j + i / 3) as f32),
0.,
),
VerletPoint::new(0.2),
Name::new(format!("Point {}", i)),
));
Expand Down
6 changes: 3 additions & 3 deletions examples/2d_cloth_cutter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ fn main() {
}

fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d::default());
let stick_length: f32 = 11.;
let (origin_x, origin_y) = (-690., 420.);
let (points_x_count, points_y_count) = (139, 80);
let mut entities = Vec::new();
for j in 0..points_y_count {
for i in 0..points_x_count {
let mut cmd = commands.spawn((
TransformBundle::from_transform(Transform::from_xyz(
Transform::from_xyz(
origin_x + (10. * i as f32),
origin_y + (-10. * j as f32),
0.,
)),
),
VerletPoint::new(0.1),
Name::new(format!("Point {}", i)),
));
Expand Down
28 changes: 13 additions & 15 deletions examples/2d_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn main() {
}

fn setup_camera(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d::default());
}

fn setup_free_line(mut commands: Commands) {
Expand All @@ -26,7 +26,12 @@ fn setup_free_line(mut commands: Commands) {
let mut previous_entity = None;
for i in 0..=points_count {
let mut cmd = commands.spawn((
sprite_bundle(Color::WHITE, Vec2::new(50. * i as f32, 300.)),
Sprite {
color: Color::WHITE,
custom_size: Some(Vec2::splat(10.)),
..default()
},
Transform::from_xyz(50.0 * i as f32, 300.0, 0.),
VerletPoint::new(0.1),
Name::new(format!("Point {}", i)),
));
Expand Down Expand Up @@ -55,7 +60,12 @@ fn setup_fixed_line(mut commands: Commands) {
let mut previous_entity = None;
for i in 0..=points_count {
let mut cmd = commands.spawn((
sprite_bundle(Color::WHITE, Vec2::new(start_pos + 30. * i as f32, 0.)),
Sprite {
color: Color::WHITE,
custom_size: Some(Vec2::splat(10.)),
..default()
},
Transform::from_xyz(start_pos + 30.0 * i as f32, 0.0, 0.),
VerletPoint::default(),
Name::new(format!("Point {}", i)),
));
Expand All @@ -76,15 +86,3 @@ fn setup_fixed_line(mut commands: Commands) {
previous_entity = Some(entity);
}
}

fn sprite_bundle(color: Color, pos: Vec2) -> SpriteBundle {
SpriteBundle {
sprite: Sprite {
color,
custom_size: Some(Vec2::splat(10.)),
..Default::default()
},
transform: Transform::from_xyz(pos.x, pos.y, 0.),
..Default::default()
}
}
27 changes: 12 additions & 15 deletions examples/3d_cloth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ fn setup(
mut materials: ResMut<Assets<StandardMaterial>>,
mut meshes: ResMut<Assets<Mesh>>,
) {
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-50., 0., -50.).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
});
commands.spawn((
Camera3d::default(),
Transform::from_xyz(-50., 0., -50.).looking_at(Vec3::ZERO, Vec3::Y),
));
let material = materials.add(Color::from(WHITE));
let fixed_material = materials.add(Color::from(RED));
let mesh = meshes.add(Cuboid::new(1., 1., 1.));
Expand All @@ -42,21 +42,18 @@ fn setup(
for j in 0..points_y_count {
for i in 0..points_x_count {
let mut cmd = commands.spawn((
PbrBundle {
mesh: mesh.clone(),
material: material.clone(),
transform: Transform::from_xyz(
origin_x + (2.0 * i as f32),
origin_y + (2.0 * (j + i / 2) as f32),
0.,
),
..Default::default()
},
Mesh3d(mesh.clone()),
MeshMaterial3d(material.clone()),
Transform::from_xyz(
origin_x + (2.0 * i as f32),
origin_y + (2.0 * (j + i / 2) as f32),
0.,
),
VerletPoint::default(),
Name::new(format!("Point {}", i)),
));
if j == 0 {
cmd.insert((VerletLocked, fixed_material.clone()));
cmd.insert((VerletLocked, MeshMaterial3d(fixed_material.clone())));
}
entities.push(cmd.id());
}
Expand Down
37 changes: 12 additions & 25 deletions examples/3d_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ fn main() {
}

fn setup_camera(mut commands: Commands) {
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-30., 4., -80.).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
});
commands.spawn((
Camera3d::default(),
Transform::from_xyz(-30., 4., -80.).looking_at(Vec3::ZERO, Vec3::Y),
));
}

fn setup_free_line(
Expand All @@ -43,16 +43,14 @@ fn setup_free_line(
let mut previous_entity = None;
for i in 0..=points_count {
let mut cmd = commands.spawn((
pbr_bundle(
material.clone(),
mesh.clone(),
Vec3::new((i * 2) as f32, 20., 0.),
),
MeshMaterial3d(material.clone()),
Mesh3d(mesh.clone()),
Transform::from_xyz((i * 2) as f32, 20., 0.),
VerletPoint::default(),
Name::new(format!("Point {}", i)),
));
if previous_entity.is_none() {
cmd.insert((VerletLocked, fixed_material.clone()));
cmd.insert((VerletLocked, MeshMaterial3d(fixed_material.clone())));
}
let entity = cmd.id();
if let Some(e) = previous_entity {
Expand Down Expand Up @@ -83,16 +81,14 @@ fn setup_fixed_line(
let mut previous_entity = None;
for i in 0..=points_count {
let mut cmd = commands.spawn((
pbr_bundle(
material.clone(),
mesh.clone(),
Vec3::new(start_pos + (i * 2) as f32, 0., 0.),
),
MeshMaterial3d(material.clone()),
Mesh3d(mesh.clone()),
Transform::from_xyz(start_pos + (i * 2) as f32, 0., 0.),
VerletPoint::default(),
Name::new(format!("Point {}", i)),
));
if previous_entity.is_none() || i == points_count {
cmd.insert((VerletLocked, fixed_material.clone()));
cmd.insert((VerletLocked, MeshMaterial3d(fixed_material.clone())));
}
let entity = cmd.id();
if let Some(e) = previous_entity {
Expand All @@ -108,12 +104,3 @@ fn setup_fixed_line(
previous_entity = Some(entity);
}
}

fn pbr_bundle(material: Handle<StandardMaterial>, mesh: Handle<Mesh>, pos: Vec3) -> PbrBundle {
PbrBundle {
mesh,
material,
transform: Transform::from_translation(pos),
..Default::default()
}
}
4 changes: 2 additions & 2 deletions src/systems/points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn update_points(
&mut point,
gravity,
friction,
time.delta_seconds(),
time.delta_secs(),
);
});
} else {
Expand All @@ -45,7 +45,7 @@ pub fn update_points(
&mut point,
gravity,
friction,
time.delta_seconds(),
time.delta_secs(),
);
}
}
Expand Down

0 comments on commit ebdcf4d

Please sign in to comment.