Skip to content

Commit

Permalink
Bevy 0.13 (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManevilleF authored Feb 21, 2024
1 parent b98fad5 commit 2d0a5c0
Show file tree
Hide file tree
Showing 17 changed files with 173 additions and 139 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
matrix:
version:
- stable
- 1.72.1 # MSRV
# - 1.74.1 # MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

* Bumped `bevy`, `bevy_egui` and `bevy_inspector_egui` dev dependencies
* Bumped `glam` to 0.25
* Dropped MSRV

## 0.14.0

* Defined MSRV to be 1.72.1 (#145)
Expand Down
11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ categories = ["game-development", "mathematics"]
repository = "https://github.com/ManevilleF/hexx"
exclude = [".github"]
resolver = "2"
rust-version = "1.72.1"

[features]
default = ["algorithms", "mesh"]
Expand All @@ -28,7 +27,7 @@ ser_de = ["serde"]
bevy_reflect = ["dep:bevy_reflect"]

[dependencies]
glam = "0.24"
glam = "0.25"

[dependencies.serde]
version = "1"
Expand All @@ -37,14 +36,14 @@ features = ["derive"]
optional = true

[dependencies.bevy_reflect]
version = "0.12"
version = "0.13"
default-features = false
features = ["glam"]
optional = true

# For lib.rs doctests and examples
[dev-dependencies.bevy]
version = "0.12"
version = "0.13"
features = [
"bevy_asset",
"bevy_winit",
Expand All @@ -69,8 +68,8 @@ features = ["html_reports"]

[dev-dependencies]
rand = "0.8"
bevy-inspector-egui = "0.22"
bevy_egui = "0.24"
bevy-inspector-egui = "0.23"
bevy_egui = "0.25"

[[example]]
name = "hex_grid"
Expand Down
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
## Installation

> Minimum supported rust version (MSRV) is `1.72.1`
Run `cargo add hexx` in your project or add the following line to your
`Cargo.toml`:

Expand Down Expand Up @@ -207,16 +205,22 @@
```rust
use bevy::{
prelude::Mesh,
render::{mesh::Indices, render_resource::PrimitiveTopology},
render::{
mesh::Indices, render_asset::RenderAssetUsages, render_resource::PrimitiveTopology,
},
};
use hexx::MeshInfo;

pub fn hexagonal_plane(mesh_info: MeshInfo) -> Mesh {
Mesh::new(PrimitiveTopology::TriangleList)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, mesh_info.vertices)
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, mesh_info.normals)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, mesh_info.uvs)
.with_indices(Some(Indices::U16(mesh_info.indices)))
Mesh::new(
PrimitiveTopology::TriangleList,
// Means you won't edit the mesh afterwards, check bevy docs for more information
RenderAssetUsages::RENDER_WORLD,
)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, mesh_info.vertices)
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, mesh_info.normals)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, mesh_info.uvs)
.with_inserted_indices(Indices::U16(mesh_info.indices))
}
```

Expand Down
23 changes: 13 additions & 10 deletions examples/3d_columns.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::{
prelude::*,
render::{mesh::Indices, render_resource::PrimitiveTopology},
render::{mesh::Indices, render_asset::RenderAssetUsages, render_resource::PrimitiveTopology},
time::common_conditions::on_timer,
};
use hexx::{shapes, *};
Expand All @@ -18,7 +18,7 @@ const TIME_STEP: Duration = Duration::from_millis(100);
pub fn main() {
App::new()
.insert_resource(AmbientLight {
brightness: 0.1,
brightness: 200.0,
..default()
})
.add_plugins(DefaultPlugins)
Expand Down Expand Up @@ -47,6 +47,7 @@ fn setup_camera(mut commands: Commands) {
transform,
..default()
});
let transform = Transform::from_xyz(60.0, 60.0, 00.0).looking_at(Vec3::ZERO, Vec3::Y);
commands.spawn(DirectionalLightBundle {
transform,
..default()
Expand All @@ -64,8 +65,8 @@ fn setup_grid(
..default()
};
// materials
let default_material = materials.add(Color::WHITE.into());
let highlighted_material = materials.add(Color::YELLOW.into());
let default_material = materials.add(Color::WHITE);
let highlighted_material = materials.add(Color::YELLOW);
// mesh
let mesh = hexagonal_column(&layout);
let mesh_handle = meshes.add(mesh);
Expand Down Expand Up @@ -123,12 +124,14 @@ fn animate_rings(
fn hexagonal_column(hex_layout: &HexLayout) -> Mesh {
let mesh_info = ColumnMeshBuilder::new(hex_layout, COLUMN_HEIGHT)
.without_bottom_face()
.with_scale(Vec3::splat(0.9))
.center_aligned()
.build();
Mesh::new(PrimitiveTopology::TriangleList)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, mesh_info.vertices)
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, mesh_info.normals)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, mesh_info.uvs)
.with_indices(Some(Indices::U16(mesh_info.indices)))
Mesh::new(
PrimitiveTopology::TriangleList,
RenderAssetUsages::RENDER_WORLD,
)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, mesh_info.vertices)
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, mesh_info.normals)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, mesh_info.uvs)
.with_inserted_indices(Indices::U16(mesh_info.indices))
}
23 changes: 13 additions & 10 deletions examples/a_star.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bevy::{
log,
prelude::*,
render::{mesh::Indices, render_resource::PrimitiveTopology},
render::{mesh::Indices, render_asset::RenderAssetUsages, render_resource::PrimitiveTopology},
utils::{HashMap, HashSet},
window::PrimaryWindow,
};
Expand Down Expand Up @@ -51,9 +51,9 @@ fn setup_grid(
..default()
};
let mesh = meshes.add(hexagonal_plane(&layout));
let default_mat = materials.add(Color::WHITE.into());
let blocked_mat = materials.add(Color::BLACK.into());
let path_mat = materials.add(Color::CYAN.into());
let default_mat = materials.add(Color::WHITE);
let blocked_mat = materials.add(Color::BLACK);
let path_mat = materials.add(Color::CYAN);
let mut blocked_coords = HashSet::new();
let entities = Hex::ZERO
.spiral_range(0..=MAP_RADIUS)
Expand Down Expand Up @@ -92,7 +92,7 @@ fn setup_grid(
/// Input interaction
fn handle_input(
mut commands: Commands,
buttons: Res<Input<MouseButton>>,
buttons: Res<ButtonInput<MouseButton>>,
windows: Query<&Window, With<PrimaryWindow>>,
cameras: Query<(&Camera, &GlobalTransform)>,
mut current: Local<Hex>,
Expand Down Expand Up @@ -156,9 +156,12 @@ fn hexagonal_plane(hex_layout: &HexLayout) -> Mesh {
.with_scale(Vec3::splat(0.9))
.center_aligned()
.build();
Mesh::new(PrimitiveTopology::TriangleList)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, mesh_info.vertices)
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, mesh_info.normals)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, mesh_info.uvs)
.with_indices(Some(Indices::U16(mesh_info.indices)))
Mesh::new(
PrimitiveTopology::TriangleList,
RenderAssetUsages::RENDER_WORLD,
)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, mesh_info.vertices)
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, mesh_info.normals)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, mesh_info.uvs)
.with_inserted_indices(Indices::U16(mesh_info.indices))
}
17 changes: 10 additions & 7 deletions examples/chunks.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::{
prelude::*,
render::{mesh::Indices, render_resource::PrimitiveTopology},
render::{mesh::Indices, render_asset::RenderAssetUsages, render_resource::PrimitiveTopology},
};
use hexx::{shapes, *};

Expand Down Expand Up @@ -38,7 +38,7 @@ fn setup_grid(
..default()
};
// materials
let materials = COLORS.map(|c| materials.add(c.into()));
let materials = COLORS.map(|c| materials.add(c));
// mesh
let mesh = hexagonal_plane(&layout);
let mesh_handle = meshes.add(mesh);
Expand All @@ -63,9 +63,12 @@ fn hexagonal_plane(hex_layout: &HexLayout) -> Mesh {
.facing(Vec3::Z)
.center_aligned()
.build();
Mesh::new(PrimitiveTopology::TriangleList)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, mesh_info.vertices)
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, mesh_info.normals)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, mesh_info.uvs)
.with_indices(Some(Indices::U16(mesh_info.indices)))
Mesh::new(
PrimitiveTopology::TriangleList,
RenderAssetUsages::RENDER_WORLD,
)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, mesh_info.vertices)
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, mesh_info.normals)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, mesh_info.uvs)
.with_inserted_indices(Indices::U16(mesh_info.indices))
}
23 changes: 13 additions & 10 deletions examples/field_of_movement.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::{
prelude::*,
render::{mesh::Indices, render_resource::PrimitiveTopology},
render::{mesh::Indices, render_asset::RenderAssetUsages, render_resource::PrimitiveTopology},
utils::{HashMap, HashSet},
window::PrimaryWindow,
};
Expand Down Expand Up @@ -90,10 +90,10 @@ fn setup_grid(
..default()
};
let mesh = meshes.add(hexagonal_plane(&layout));
let plains_mat = materials.add(Color::WHITE.into());
let forest_mat = materials.add(Color::GREEN.into());
let desert_mat = materials.add(Color::YELLOW.into());
let wall_mat = materials.add(Color::DARK_GRAY.into());
let plains_mat = materials.add(Color::WHITE);
let forest_mat = materials.add(Color::GREEN);
let desert_mat = materials.add(Color::YELLOW);
let wall_mat = materials.add(Color::DARK_GRAY);

let mut rng = rand::thread_rng();

Expand Down Expand Up @@ -139,9 +139,12 @@ fn hexagonal_plane(hex_layout: &HexLayout) -> Mesh {
.facing(Vec3::Z)
.center_aligned()
.build();
Mesh::new(PrimitiveTopology::TriangleList)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, mesh_info.vertices)
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, mesh_info.normals)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, mesh_info.uvs)
.with_indices(Some(Indices::U16(mesh_info.indices)))
Mesh::new(
PrimitiveTopology::TriangleList,
RenderAssetUsages::RENDER_WORLD,
)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, mesh_info.vertices)
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, mesh_info.normals)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, mesh_info.uvs)
.with_inserted_indices(Indices::U16(mesh_info.indices))
}
23 changes: 13 additions & 10 deletions examples/field_of_view.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::{
prelude::*,
render::{mesh::Indices, render_resource::PrimitiveTopology},
render::{mesh::Indices, render_asset::RenderAssetUsages, render_resource::PrimitiveTopology},
utils::{HashMap, HashSet},
window::PrimaryWindow,
};
Expand Down Expand Up @@ -51,9 +51,9 @@ fn setup_grid(
..default()
};
let mesh = meshes.add(hexagonal_plane(&layout));
let default_mat = materials.add(Color::WHITE.into());
let blocked_mat = materials.add(Color::BLACK.into());
let visible_mat = materials.add(Color::CYAN.into());
let default_mat = materials.add(Color::WHITE);
let blocked_mat = materials.add(Color::BLACK);
let visible_mat = materials.add(Color::CYAN);
let mut blocked_coords = HashSet::new();
let entities = Hex::ZERO
.spiral_range(0..=MAP_RADIUS)
Expand Down Expand Up @@ -91,7 +91,7 @@ fn setup_grid(
/// Input interaction
fn handle_input(
mut commands: Commands,
buttons: Res<Input<MouseButton>>,
buttons: Res<ButtonInput<MouseButton>>,
windows: Query<&Window, With<PrimaryWindow>>,
cameras: Query<(&Camera, &GlobalTransform)>,
mut current: Local<Hex>,
Expand Down Expand Up @@ -146,9 +146,12 @@ fn hexagonal_plane(hex_layout: &HexLayout) -> Mesh {
.with_scale(Vec3::splat(0.9))
.center_aligned()
.build();
Mesh::new(PrimitiveTopology::TriangleList)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, mesh_info.vertices)
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, mesh_info.normals)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, mesh_info.uvs)
.with_indices(Some(Indices::U16(mesh_info.indices)))
Mesh::new(
PrimitiveTopology::TriangleList,
RenderAssetUsages::RENDER_WORLD,
)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, mesh_info.vertices)
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, mesh_info.normals)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, mesh_info.uvs)
.with_inserted_indices(Indices::U16(mesh_info.indices))
}
29 changes: 16 additions & 13 deletions examples/hex_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;

use bevy::{
prelude::*,
render::{mesh::Indices, render_resource::PrimitiveTopology},
render::{mesh::Indices, render_asset::RenderAssetUsages, render_resource::PrimitiveTopology},
window::PrimaryWindow,
};
use hexx::{shapes, *};
Expand Down Expand Up @@ -65,13 +65,13 @@ fn setup_grid(
..default()
};
// materials
let selected_material = materials.add(Color::RED.into());
let ring_material = materials.add(Color::YELLOW.into());
let wedge_material = materials.add(Color::CYAN.into());
let dir_wedge_material = materials.add(Color::VIOLET.into());
let line_material = materials.add(Color::ORANGE.into());
let half_ring_material = materials.add(Color::LIME_GREEN.into());
let default_material = materials.add(Color::WHITE.into());
let selected_material = materials.add(Color::RED);
let ring_material = materials.add(Color::YELLOW);
let wedge_material = materials.add(Color::CYAN);
let dir_wedge_material = materials.add(Color::VIOLET);
let line_material = materials.add(Color::ORANGE);
let half_ring_material = materials.add(Color::LIME_GREEN);
let default_material = materials.add(Color::WHITE);
// mesh
let mesh = hexagonal_plane(&layout);
let mesh_handle = meshes.add(mesh);
Expand Down Expand Up @@ -204,9 +204,12 @@ fn hexagonal_plane(hex_layout: &HexLayout) -> Mesh {
.with_scale(Vec3::splat(0.95))
.center_aligned()
.build();
Mesh::new(PrimitiveTopology::TriangleList)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, mesh_info.vertices)
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, mesh_info.normals)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, mesh_info.uvs)
.with_indices(Some(Indices::U16(mesh_info.indices)))
Mesh::new(
PrimitiveTopology::TriangleList,
RenderAssetUsages::RENDER_WORLD,
)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, mesh_info.vertices)
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, mesh_info.normals)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, mesh_info.uvs)
.with_inserted_indices(Indices::U16(mesh_info.indices))
}
Loading

0 comments on commit 2d0a5c0

Please sign in to comment.