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

Bevy 0.13 #15

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 14 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,25 @@ debug = ["bevy/bevy_gizmos", "bevy/bevy_render"]
[dependencies]

[dependencies.bevy]
version = "0.12"
version = "0.13"
default-features = false

[dev-dependencies]

[dev-dependencies.bevy]
version = "0.12"
features = ["bevy_render", "bevy_winit", "x11", "bevy_core_pipeline", "bevy_sprite", "bevy_pbr"]
version = "0.13"
features = [
"bevy_render",
"bevy_winit",
"bevy_core_pipeline",
"bevy_sprite",
"bevy_pbr",
"x11",
"multi-threaded",
"tonemapping_luts",
# Faster compilation
"dynamic_linking",
]
default-features = false

[[example]]
Expand Down
2 changes: 1 addition & 1 deletion examples/2d_cloth_cutter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn cut_sticks(
mut commands: Commands,
points: Query<&Transform, With<VerletPoint>>,
sticks: Query<(Entity, &VerletStick)>,
mouse_input: Res<Input<MouseButton>>,
mouse_input: Res<ButtonInput<MouseButton>>,
windows: Query<&Window, With<PrimaryWindow>>,
) {
if !mouse_input.pressed(MouseButton::Left) {
Expand Down
6 changes: 3 additions & 3 deletions examples/3d_cloth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ fn setup(
transform: Transform::from_xyz(-50., 0., -50.).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
});
let material = materials.add(Color::WHITE.into());
let fixed_material = materials.add(Color::RED.into());
let mesh = meshes.add(Mesh::from(shape::Cube::new(1.)));
let material = materials.add(Color::WHITE);
let fixed_material = materials.add(Color::RED);
let mesh = meshes.add(Cuboid::new(1., 1., 1.));
let stick_length: f32 = 2.;
let (origin_x, origin_y) = (-5., 10.);
let (points_x_count, points_y_count) = (20, 15);
Expand Down
12 changes: 6 additions & 6 deletions examples/3d_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ fn setup_free_line(
mut materials: ResMut<Assets<StandardMaterial>>,
mut meshes: ResMut<Assets<Mesh>>,
) {
let material = materials.add(Color::WHITE.into());
let fixed_material = materials.add(Color::RED.into());
let mesh = meshes.add(Mesh::from(shape::Cube::new(1.)));
let material = materials.add(Color::WHITE);
let fixed_material = materials.add(Color::RED);
let mesh = meshes.add(Cuboid::new(1., 1., 1.));
let stick_length: f32 = 2.;
let points_count = 10;
let mut previous_entity = None;
Expand Down Expand Up @@ -71,9 +71,9 @@ fn setup_fixed_line(
mut materials: ResMut<Assets<StandardMaterial>>,
mut meshes: ResMut<Assets<Mesh>>,
) {
let material = materials.add(Color::WHITE.into());
let fixed_material = materials.add(Color::RED.into());
let mesh = meshes.add(Mesh::from(shape::Cube::new(1.)));
let material = materials.add(Color::WHITE);
let fixed_material = materials.add(Color::RED);
let mesh = meshes.add(Cuboid::new(1., 1., 1.));
let stick_length: f32 = 2.;
let points_count = 20;
let start_pos = -10.;
Expand Down
22 changes: 12 additions & 10 deletions src/systems/sticks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
components::{VerletLocked, VerletPoint, VerletStick},
VerletConfig, VerletStickMaxTension,
};
use bevy::{log, prelude::*};
use bevy::{log, prelude::*, utils::HashMap};

#[allow(
clippy::type_complexity,
Expand All @@ -13,18 +13,20 @@ use bevy::{log, prelude::*};
pub fn update_sticks(
config: Res<VerletConfig>,
sticks_query: Query<&VerletStick>,
mut points_query: Query<(&mut Transform, Option<&VerletLocked>), With<VerletPoint>>,
mut points_query: Query<(Entity, &mut Transform, Option<&VerletLocked>), With<VerletPoint>>,
) {
let mut points_map: HashMap<_, _> = points_query
.iter_mut()
.map(|(e, t, l)| (e, (t, l)))
.collect();
for _ in 0..=config.sticks_computation_depth {
for stick in sticks_query.iter() {
let [(mut transform_a, a_locked), (mut transform_b, b_locked)] =
match points_query.get_many_mut([stick.point_a_entity, stick.point_b_entity]) {
Ok(v) => v,
Err(e) => {
log::error!("Could not find point entities for stick: {}", e);
continue;
}
};
let Some([(ref mut transform_a, a_locked), (ref mut transform_b, b_locked)]) =
points_map.get_many_mut([&stick.point_a_entity, &stick.point_b_entity])
else {
log::error!("Could not find point entities for stick {stick:?}");
continue;
};
let (a_locked, b_locked) = (a_locked.is_some(), b_locked.is_some());
if a_locked && b_locked {
continue;
Expand Down
Loading