Skip to content

Commit 83ad66c

Browse files
authored
Merge pull request #59 from GabrielCarpr/main
Upgrade to Bevy 0.16
2 parents 7227f81 + ef6bb09 commit 83ad66c

16 files changed

Lines changed: 632 additions & 501 deletions

Cargo.lock

Lines changed: 573 additions & 462 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ categories = ["game-development", "graphics"]
1717
opt-level = 3
1818

1919
[dependencies]
20-
bevy = { version = "0.15", features = [
20+
bevy = { version = "0.16", features = [
2121
"bevy_render",
2222
"bevy_asset",
2323
"bevy_pbr",
@@ -29,7 +29,8 @@ rand = "0.9.0"
2929
ahash = "0.8.11"
3030
weak-table = { version = "0.3.2", features = ["ahash"] }
3131
noise = { version = "0.9.0", optional = true }
32-
smooth-bevy-cameras = { version = "0.13.0", optional = true }
32+
smooth-bevy-cameras = { version = "0.14.0", optional = true }
33+
hashbrown = "0.15.2"
3334

3435
[dev-dependencies]
3536

examples/bombs.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bevy::{pbr::CascadeShadowConfigBuilder, prelude::*, utils::HashMap};
1+
use bevy::{pbr::CascadeShadowConfigBuilder, platform::collections::HashMap, prelude::*};
22
use bevy_voxel_world::prelude::*;
33
use noise::{HybridMulti, NoiseFn, Perlin};
44
use std::{sync::Arc, time::Duration};
@@ -77,6 +77,7 @@ fn setup(mut commands: Commands) {
7777
commands.insert_resource(AmbientLight {
7878
color: Color::srgb(0.98, 0.95, 0.82),
7979
brightness: 100.0,
80+
affects_lightmapped_meshes: true,
8081
});
8182
}
8283

@@ -131,8 +132,9 @@ fn move_camera(
131132
time: Res<Time>,
132133
mut cam_transform: Query<&mut Transform, With<VoxelWorldCamera<MainWorld>>>,
133134
) {
134-
cam_transform.single_mut().translation.x += time.delta_secs() * 7.0;
135-
cam_transform.single_mut().translation.z += time.delta_secs() * 12.0;
135+
let mut transform = cam_transform.get_single_mut().unwrap();
136+
transform.translation.x += time.delta_secs() * 7.0;
137+
transform.translation.z += time.delta_secs() * 12.0;
136138
}
137139

138140
fn explosion(

examples/custom_meshing.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use bevy::{
66
wireframe::{WireframeConfig, WireframePlugin},
77
CascadeShadowConfigBuilder,
88
},
9+
platform::collections::HashMap,
910
prelude::*,
1011
render::{
1112
mesh::{Indices, VertexAttributeValues},
@@ -14,7 +15,6 @@ use bevy::{
1415
settings::{RenderCreation, WgpuSettings},
1516
RenderPlugin,
1617
},
17-
utils::HashMap,
1818
};
1919

2020
use bevy_voxel_world::{
@@ -172,7 +172,7 @@ fn main() {
172172
}),
173173
..default()
174174
}),
175-
WireframePlugin,
175+
WireframePlugin::default(),
176176
))
177177
.add_plugins(VoxelWorldPlugin::with_config(MainWorld))
178178
.insert_resource(WireframeConfig {
@@ -210,6 +210,7 @@ fn setup(mut commands: Commands) {
210210
commands.insert_resource(AmbientLight {
211211
color: Color::srgb(0.98, 0.95, 0.82),
212212
brightness: 100.0,
213+
affects_lightmapped_meshes: true,
213214
});
214215
}
215216

@@ -258,6 +259,7 @@ fn move_camera(
258259
time: Res<Time>,
259260
mut cam_transform: Query<&mut Transform, With<VoxelWorldCamera<MainWorld>>>,
260261
) {
261-
cam_transform.single_mut().translation.x += time.delta_secs() * 5.0;
262-
cam_transform.single_mut().translation.z += time.delta_secs() * 10.0;
262+
let mut transform = cam_transform.single_mut().unwrap();
263+
transform.translation.x += time.delta_secs() * 5.0;
264+
transform.translation.z += time.delta_secs() * 10.0;
263265
}

examples/fast_traversal_ray.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ fn update_cursor_cube(
144144
) {
145145
for ev in cursor_evr.read() {
146146
// Get a ray from the cursor position into the world
147-
let (camera, cam_gtf) = camera_info.single();
147+
let (camera, cam_gtf) = camera_info.single().unwrap();
148148
let Ok(ray) = camera.viewport_to_world(cam_gtf, ev.position) else {
149149
return;
150150
};
151151

152152
if let Some(result) = voxel_world_raycast.raycast(ray, &|(_pos, _vox)| true) {
153-
let (mut transform, mut cursor_cube) = cursor_cube.single_mut();
153+
let (mut transform, mut cursor_cube) = cursor_cube.single_mut().unwrap();
154154

155155
// Camera could end up inside geometry - in that case just ignore the trace
156156
if let Some(normal) = result.normal {
@@ -216,7 +216,9 @@ fn inputs(
216216
if keys.just_released(KeyCode::ControlLeft) {
217217
trace.start = None;
218218
} else if keys.pressed(KeyCode::ControlLeft) && keys.just_pressed(KeyCode::KeyE) {
219-
let cursor = cursor_cube.single();
219+
let Ok(cursor) = cursor_cube.single() else {
220+
return;
221+
};
220222
let trace_end = cursor.voxel_pos.as_vec3() + Vec3::splat(VOXEL_SIZE / 2.);
221223

222224
voxel_line_traversal(
@@ -233,7 +235,9 @@ fn inputs(
233235
}
234236

235237
if buttons.just_pressed(MouseButton::Left) {
236-
let cursor = cursor_cube.single();
238+
let Ok(cursor) = cursor_cube.single() else {
239+
return;
240+
};
237241

238242
if keys.pressed(KeyCode::ControlLeft) {
239243
trace.start = Some(cursor.voxel_pos.as_vec3() + Vec3::splat(VOXEL_SIZE / 2.))

examples/multiple_worlds.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::sync::Arc;
22

33
use bevy::{
44
pbr::{CascadeShadowConfigBuilder, MaterialPipeline, MaterialPipelineKey},
5+
platform::collections::HashMap,
56
prelude::*,
67
render::{
78
mesh::MeshVertexBufferLayoutRef,
@@ -10,7 +11,6 @@ use bevy::{
1011
SpecializedMeshPipelineError,
1112
},
1213
},
13-
utils::HashMap,
1414
};
1515
use bevy_voxel_world::{
1616
prelude::*,
@@ -111,6 +111,7 @@ fn setup(mut commands: Commands, mut second_world: VoxelWorld<SecondWorld>) {
111111
commands.insert_resource(AmbientLight {
112112
color: Color::srgb(0.98, 0.95, 0.82),
113113
brightness: 100.0,
114+
affects_lightmapped_meshes: true,
114115
});
115116

116117
// Set some voxels in the second world

examples/noise_terrain.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::sync::Arc;
22

3-
use bevy::{pbr::CascadeShadowConfigBuilder, prelude::*, utils::HashMap};
3+
use bevy::{pbr::CascadeShadowConfigBuilder, platform::collections::HashMap, prelude::*};
44
use bevy_voxel_world::prelude::*;
55
use noise::{HybridMulti, NoiseFn, Perlin};
66

@@ -67,6 +67,7 @@ fn setup(mut commands: Commands) {
6767
commands.insert_resource(AmbientLight {
6868
color: Color::srgb(0.98, 0.95, 0.82),
6969
brightness: 100.0,
70+
affects_lightmapped_meshes: true,
7071
});
7172
}
7273

@@ -115,6 +116,9 @@ fn move_camera(
115116
time: Res<Time>,
116117
mut cam_transform: Query<&mut Transform, With<VoxelWorldCamera<MainWorld>>>,
117118
) {
118-
cam_transform.single_mut().translation.x += time.delta_secs() * 30.0;
119-
cam_transform.single_mut().translation.z += time.delta_secs() * 60.0;
119+
let Ok(mut transform) = cam_transform.get_single_mut() else {
120+
return;
121+
};
122+
transform.translation.x += time.delta_secs() * 30.0;
123+
transform.translation.z += time.delta_secs() * 60.0;
120124
}

examples/ray_cast.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ fn update_cursor_cube(
113113
) {
114114
for ev in cursor_evr.read() {
115115
// Get a ray from the cursor position into the world
116-
let (camera, cam_gtf) = camera_info.single();
116+
let (camera, cam_gtf) = camera_info.single().unwrap();
117117
let Ok(ray) = camera.viewport_to_world(cam_gtf, ev.position) else {
118118
return;
119119
};
120120

121121
if let Some(result) = voxel_world_raycast.raycast(ray, &|(_pos, _vox)| true) {
122-
let (mut transform, mut cursor_cube) = cursor_cube.single_mut();
122+
let (mut transform, mut cursor_cube) = cursor_cube.single_mut().unwrap();
123123
// Move the cursor cube to the position of the voxel we hit
124124
// Camera is by construction not in a solid voxel, so result.normal must be Some(...)
125125
let voxel_pos = result.position + result.normal.unwrap();
@@ -135,7 +135,7 @@ fn mouse_button_input(
135135
cursor_cube: Query<&CursorCube>,
136136
) {
137137
if buttons.just_pressed(MouseButton::Left) {
138-
let vox_pos = cursor_cube.single().voxel_pos;
139-
voxel_world.set_voxel(vox_pos, WorldVoxel::Solid(FULL_BRICK));
138+
let vox = cursor_cube.single().unwrap();
139+
voxel_world.set_voxel(vox.voxel_pos, WorldVoxel::Solid(FULL_BRICK));
140140
}
141141
}

examples/set_voxel.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fn setup(mut commands: Commands) {
2424
commands.insert_resource(AmbientLight {
2525
color: Color::srgb(0.98, 0.95, 0.82),
2626
brightness: 1000.0,
27+
affects_lightmapped_meshes: true,
2728
});
2829
}
2930

@@ -48,7 +49,7 @@ fn move_camera(
4849
time: Res<Time>,
4950
mut query: Query<&mut Transform, With<VoxelWorldCamera<DefaultWorld>>>,
5051
) {
51-
let mut transform = query.single_mut();
52+
let mut transform = query.single_mut().unwrap();
5253
let time_seconds = time.elapsed_secs();
5354
transform.translation.x = 25.0 * (time_seconds * 0.1).sin();
5455
transform.translation.z = 25.0 * (time_seconds * 0.1).cos();

src/chunk.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use bevy::{prelude::*, render::primitives::Aabb, tasks::Task, utils::HashSet};
1+
use bevy::{
2+
platform::collections::HashSet, prelude::*, render::primitives::Aabb, tasks::Task,
3+
};
24
use ndshape::{ConstShape, ConstShape3u32};
35
use std::{
46
hash::{Hash, Hasher},

0 commit comments

Comments
 (0)