Skip to content

Commit

Permalink
Upgrade to Bevy 0.8
Browse files Browse the repository at this point in the history
This unfortunately introduces a bug: the app keeps running even after
all windows are closed bevyengine/bevy#5524
  • Loading branch information
Indy2222 committed Aug 10, 2022
1 parent 432efba commit d064ca0
Show file tree
Hide file tree
Showing 31 changed files with 463 additions and 467 deletions.
740 changes: 376 additions & 364 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ de_behaviour = { path = "crates/behaviour", version = "0.1.0-dev" }
de_attacking = { path = "crates/attacking", version = "0.1.0-dev" }

# Other
bevy = "0.7.0"
iyes_loopless = "0.5.1"
bevy = "0.8"
iyes_loopless = "0.7"

[workspace]
members = ["crates/*"]
6 changes: 3 additions & 3 deletions crates/attacking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ de_spawner = { path = "../spawner", version = "0.1.0-dev" }
de_behaviour = { path = "../behaviour", version = "0.1.0-dev" }

# Other
bevy = "0.7.0"
iyes_loopless = "0.5.1"
glam = "0.20.2"
bevy = "0.8"
iyes_loopless = "0.7"
glam = "0.21"
parry3d = "0.9.0"
4 changes: 2 additions & 2 deletions crates/attacking/src/attack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ fn aim_and_fire(
.compute_aabb()
.center()
.into();
transform.translation + centroid
transform.translation() + centroid
}
Err(_) => continue,
};

let muzzle = attacker_transform.translation + cannon.muzzle();
let muzzle = attacker_transform.translation() + cannon.muzzle();
let to_target = (target_position - muzzle)
.try_normalize()
.expect("Attacker and target to close together");
Expand Down
6 changes: 3 additions & 3 deletions crates/behaviour/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ de_objects = { path = "../objects", version = "0.1.0-dev" }
de_pathing = { path = "../pathing", version = "0.1.0-dev" }

# Other
bevy = "0.7.0"
iyes_loopless = "0.5.1"
glam = "0.20.2"
bevy = "0.8"
iyes_loopless = "0.7"
glam = "0.21"
parry3d = "0.9.0"
4 changes: 2 additions & 2 deletions crates/behaviour/src/chase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn chase(
) {
for (entity, transform, chase_target, path_target) in chasing.iter() {
let target_position = match targets.get(chase_target.entity()) {
Ok(transform) => transform.translation.to_flat(),
Ok(transform) => transform.translation().to_flat(),
Err(_) => {
commands.entity(entity).remove::<ChaseTarget>();
continue;
Expand All @@ -84,7 +84,7 @@ fn chase(

let (path_target, distance) = path_target
.map(|path_target| (path_target.location(), path_target.properties().distance()))
.unwrap_or((transform.translation.to_flat(), 0.));
.unwrap_or((transform.translation().to_flat(), 0.));

if (target_position - path_target).length() + distance <= chase_target.max_distance() {
continue;
Expand Down
4 changes: 2 additions & 2 deletions crates/camera/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ de_map = { path = "../map", version = "0.1.0-dev" }
de_terrain = { path = "../terrain", version = "0.1.0-dev" }

# Other
bevy = "0.7.0"
iyes_loopless = "0.5.1"
bevy = "0.8"
iyes_loopless = "0.7"
parry3d = "0.9.0"
5 changes: 2 additions & 3 deletions crates/camera/src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::f32::consts::FRAC_PI_2;
use bevy::{
input::mouse::{MouseMotion, MouseScrollUnit, MouseWheel},
prelude::*,
render::camera::Camera3d,
};
use de_core::{events::ResendEventPlugin, projection::ToMsl, state::GameState};
use de_map::size::MapBounds;
Expand Down Expand Up @@ -232,7 +231,7 @@ fn setup(mut commands: Commands) {
point: Vec3::ZERO,
distance: MAX_CAMERA_DISTANCE,
});
commands.spawn_bundle(PerspectiveCameraBundle {
commands.spawn_bundle(Camera3dBundle {
transform: Transform::from_xyz(0.0, MAX_CAMERA_DISTANCE.into(), 0.0)
.looking_at(Vec3::ZERO, -Vec3::Z),
..Default::default()
Expand All @@ -251,7 +250,7 @@ fn update_focus(

let camera_transform = camera_query.single();
let ray = Ray::new(
camera_transform.translation.into(),
camera_transform.translation().into(),
camera_transform.forward().into(),
);

Expand Down
6 changes: 3 additions & 3 deletions crates/controller/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ de_behaviour = { path = "../behaviour", version = "0.1.0-dev" }
de_attacking = { path = "../attacking", version = "0.1.0-dev" }

# Other
bevy = "0.7.0"
iyes_loopless = "0.5.1"
glam = "^0.20.2"
bevy = "0.8"
iyes_loopless = "0.7"
glam = "0.21"
parry3d = "0.9.0"
enum-map = "2.3.0"
6 changes: 3 additions & 3 deletions crates/controller/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::{
input::{keyboard::KeyboardInput, mouse::MouseButtonInput, ElementState},
input::{keyboard::KeyboardInput, mouse::MouseButtonInput, ButtonState},
prelude::*,
};
use de_attacking::{AttackEvent, AttackingLabels};
Expand Down Expand Up @@ -57,7 +57,7 @@ fn on_pressed(button: MouseButton) -> impl Fn(EventReader<MouseButtonInput>) ->
// used instead of .any()
events
.iter()
.filter(|e| e.button == button && e.state == ElementState::Pressed)
.filter(|e| e.button == button && e.state == ButtonState::Pressed)
.count()
> 0
}
Expand Down Expand Up @@ -139,7 +139,7 @@ fn key_press_handler(
) {
let key = match key_events
.iter()
.filter(|e| e.state == ElementState::Pressed)
.filter(|e| e.state == ButtonState::Pressed)
.last()
{
Some(event) => match event.key_code {
Expand Down
6 changes: 3 additions & 3 deletions crates/controller/src/pointer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::{ecs::system::SystemParam, prelude::*, render::camera::Camera3d, window::Windows};
use bevy::{ecs::system::SystemParam, prelude::*, window::Windows};
use de_core::state::GameState;
use de_index::SpatialQuery;
use de_terrain::TerrainCollider;
Expand Down Expand Up @@ -70,9 +70,9 @@ impl<'w, 's> MouseInWorld<'w, 's> {
};

let (camera_transform, camera) = self.cameras.single();
let ndc_to_world = camera_transform.compute_matrix() * camera.projection_matrix.inverse();
let ndc_to_world = camera_transform.compute_matrix() * camera.projection_matrix().inverse();
let ray_origin = ndc_to_world.project_point3(cursor_position.extend(1.));
let ray_direction = ray_origin - camera_transform.translation;
let ray_direction = ray_origin - camera_transform.translation();
Some(Ray::new(ray_origin.into(), ray_direction.into()))
}
}
Expand Down
10 changes: 5 additions & 5 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ repository = "https://github.com/DigitalExtinction/Game"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
bevy = "0.7.0"
iyes_loopless = "0.5.1"
iyes_progress = { version = "0.3.0", features = [ "iyes_loopless" ] }
glam = "0.20.2"
nalgebra = { version = "0.31.0", features = ["convert-glam020"] }
bevy = "0.8"
iyes_loopless = "0.7"
iyes_progress = { version = "0.4", features = [ "iyes_loopless" ] }
glam = "0.21"
nalgebra = { version = "0.31.0", features = ["convert-glam021"] }
parry2d = { git = "https://github.com/Indy2222/parry", branch = "feature/dilation" }
parry3d = "0.9.0"
enum-map = "2.3.0"
8 changes: 4 additions & 4 deletions crates/index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ de_core = { path = "../core", version = "0.1.0-dev" }
de_objects = { path = "../objects", version = "0.1.0-dev" }

# Other
bevy = "0.7.0"
glam = "0.20.2"
iyes_loopless = "0.5.1"
bevy = "0.8"
glam = "0.21"
iyes_loopless = "0.7"
parry3d = "0.9.0"
parry2d = { git = "https://github.com/Indy2222/parry", branch = "feature/dilation" }
ahash = "0.7.6"
nalgebra = { version = "0.31.0", features = ["convert-glam020"] }
nalgebra = { version = "0.31.0", features = ["convert-glam021"] }

[dev-dependencies]
criterion = "0.3"
Expand Down
11 changes: 6 additions & 5 deletions crates/index/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::cmp::Ordering;
use ahash::AHashMap;
use bevy::{
ecs::{
query::{Fetch, FilterFetch, WorldQuery},
query::{Fetch, WorldQuery, WorldQueryGats},
system::SystemParam,
},
prelude::{Entity, Query, Res},
Expand Down Expand Up @@ -112,7 +112,6 @@ pub struct SpatialQuery<'w, 's, Q, F = ()>
where
Q: WorldQuery + Sync + Send + 'static,
F: WorldQuery + Sync + Send + 'static,
<F as WorldQuery>::Fetch: FilterFetch,
{
index: Res<'w, EntityIndex>,
entities: Query<'w, 's, Q, F>,
Expand All @@ -122,7 +121,6 @@ impl<'w, 's, Q, F> SpatialQuery<'w, 's, Q, F>
where
Q: WorldQuery + Sync + Send + 'static,
F: WorldQuery + Sync + Send + 'static,
<F as WorldQuery>::Fetch: FilterFetch,
{
/// Returns closest entity whose shape, as indexed by systems registered by
/// [`super::systems::IndexPlugin`], intersects a given ray.
Expand All @@ -142,8 +140,11 @@ where
ray: &Ray,
max_toi: f32,
ignore: Option<Entity>,
) -> Option<RayEntityIntersection<<<Q as WorldQuery>::ReadOnlyFetch as Fetch<'_, '_>>::Item>>
{
) -> Option<
RayEntityIntersection<
<<<Q as WorldQuery>::ReadOnly as WorldQueryGats<'_>>::Fetch as Fetch<'_>>::Item,
>,
> {
let candidate_sets = match self.index.cast_ray(ray, max_toi) {
Some(candidates) => candidates,
None => return None,
Expand Down
10 changes: 2 additions & 8 deletions crates/index/src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ fn insert(
query: SolidEntityQuery,
) {
for (entity, object_type, transform) in query.iter() {
let position = Isometry::new(
transform.translation.into(),
transform.rotation.to_scaled_axis().into(),
);
let position = Isometry::try_from(transform.compute_matrix()).unwrap();
let collider = LocalCollider::new(cache.get_collider(*object_type).clone(), position);
index.insert(entity, collider);
commands.entity(entity).insert(Indexed);
Expand All @@ -104,10 +101,7 @@ fn remove(mut index: ResMut<EntityIndex>, removed: RemovedComponents<Indexed>) {

fn update(mut index: ResMut<EntityIndex>, moved: MovedQuery) {
for (entity, transform) in moved.iter() {
let position = Isometry::new(
transform.translation.into(),
transform.rotation.to_scaled_axis().into(),
);
let position = Isometry::try_from(transform.compute_matrix()).unwrap();
index.update(entity, position);
}
}
6 changes: 3 additions & 3 deletions crates/loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ de_spawner = { path = "../spawner", version = "0.1.0-dev" }
de_camera = { path = "../camera", version = "0.1.0-dev" }

# Other
bevy = "0.7.0"
iyes_loopless = "0.5.1"
iyes_progress = { version = "0.3.0", features = [ "iyes_loopless" ] }
bevy = "0.8"
iyes_loopless = "0.7"
iyes_progress = { version = "0.4", features = [ "iyes_loopless" ] }
futures-lite = "1.11"
8 changes: 2 additions & 6 deletions crates/loader/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,15 @@ impl Plugin for MapLoaderPlugin {

struct MapLoadingTask(Task<Result<Map, MapLoadingError>>);

fn load_map_system(
mut commands: Commands,
thread_pool: Res<IoTaskPool>,
game_config: Res<GameConfig>,
) {
fn load_map_system(mut commands: Commands, game_config: Res<GameConfig>) {
let map_path = if game_config.map_path().is_relative() {
asset_path(game_config.map_path())
} else {
game_config.map_path().to_owned()
};

info!("Loading map from {}", map_path.display());
let task = thread_pool.spawn(async { load_map(map_path).await });
let task = IoTaskPool::get().spawn(async { load_map(map_path).await });
commands.insert_resource(MapLoadingTask(task));
}

Expand Down
4 changes: 2 additions & 2 deletions crates/map/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ repository = "https://github.com/DigitalExtinction/Game"
de_core = { path = "../core", version = "0.1.0-dev" }

# other
bevy = "0.7"
glam = "0.20.2"
bevy = "0.8"
glam = "0.21"
parry2d = { git = "https://github.com/Indy2222/parry", branch = "feature/dilation" }
serde = "1.0"
serde_json = "1.0"
Expand Down
4 changes: 2 additions & 2 deletions crates/movement/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ de_core = { path = "../core", version = "0.1.0-dev" }
de_pathing = { path = "../pathing", version = "0.1.0-dev" }

# Other
bevy = "0.7.0"
iyes_loopless = "0.5.1"
bevy = "0.8"
iyes_loopless = "0.7"
8 changes: 4 additions & 4 deletions crates/objects/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ repository = "https://github.com/DigitalExtinction/Game"
de_core = { path = "../core", version = "0.1.0-dev" }

# Other
bevy = "0.7.0"
iyes_loopless = "0.5.1"
iyes_progress = { version = "0.3.0", features = [ "iyes_loopless" ] }
glam = "0.20.2"
bevy = "0.8"
iyes_loopless = "0.7"
iyes_progress = { version = "0.4", features = [ "iyes_loopless" ] }
glam = "0.21"
parry2d = { git = "https://github.com/Indy2222/parry", branch = "feature/dilation" }
parry3d = "0.9.0"
enum-map = "2.3.0"
Expand Down
8 changes: 4 additions & 4 deletions crates/pathing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ de_map = { path = "../map", version = "0.1.0-dev" }
de_objects = { path = "../objects", version = "0.1.0-dev" }

# Other
bevy = "0.7"
glam = "^0.20.2"
bevy = "0.8"
glam = "0.21"
parry2d = { git = "https://github.com/Indy2222/parry", branch = "feature/dilation" }
nalgebra = { version = "0.31.0", features = ["convert-glam020"] }
nalgebra = { version = "0.31.0", features = ["convert-glam021"] }
ahash = "0.7.6"
approx = "0.5.1"
# Use released version once this
# https://github.com/georust/rstar/commit/923e73fc4dbee43ed43f2248eae6c4143e5282cc
# is released.
rstar = { git = "https://github.com/georust/rstar", branch = "master" }
tinyvec = { version = "1.6.0", features = ["rustc_1_40", "alloc"] }
iyes_loopless = "0.5.1"
iyes_loopless = "0.7"
spade = "2.0.0"
futures-lite = "1.11.3"

Expand Down
2 changes: 1 addition & 1 deletion crates/pathing/src/dijkstra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::{cmp::Ordering, collections::BinaryHeap};

use ahash::AHashSet;
use bevy::core::FloatOrd;
use bevy::utils::FloatOrd;
use parry2d::{math::Point, na, query::PointQuery, shape::Segment};

use crate::{
Expand Down
6 changes: 3 additions & 3 deletions crates/pathing/src/exclusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ impl ExclusionArea {
/// Creates a new exclusion area from a static object ichnography and its
/// world-to-object transform.
fn from_ichnography(transform: &GlobalTransform, ichnography: &Ichnography) -> Self {
let angle = transform.rotation.to_euler(EulerRot::YXZ).0;
let translation = transform.translation.to_flat();
let isometry = Isometry::new(translation.into(), angle);
let (_scale, rotation, translation) = transform.to_scale_rotation_translation();
let angle = rotation.to_euler(EulerRot::YXZ).0;
let isometry = Isometry::new(translation.to_flat().into(), angle);
let vertices: Vec<Point<f32>> = ichnography
.offset_convex_hull()
.points()
Expand Down

0 comments on commit d064ca0

Please sign in to comment.