From 1152799b4e5ddde244ae17572cd23348ecaa1679 Mon Sep 17 00:00:00 2001 From: Elias Stepanik <40958815+eliasstepanik@users.noreply.github.com> Date: Fri, 13 Jun 2025 00:52:40 +0200 Subject: [PATCH 1/4] Update to Bevy 0.16.1 --- client/Cargo.toml | 2 +- client/src/plugins/big_space/big_space_plugin.rs | 12 +++++++----- client/src/plugins/environment/environment_plugin.rs | 10 ++++++---- .../plugins/environment/systems/voxels/culling.rs | 5 +++-- .../src/plugins/environment/systems/voxels/debug.rs | 2 +- client/src/plugins/environment/systems/voxels/lod.rs | 5 +++-- .../environment/systems/voxels/queue_systems.rs | 7 ++++--- client/src/plugins/input/systems/flight.rs | 6 +++--- client/src/plugins/input/systems/ui.rs | 4 ++-- client/src/plugins/input/systems/voxels.rs | 4 ++-- 10 files changed, 32 insertions(+), 25 deletions(-) diff --git a/client/Cargo.toml b/client/Cargo.toml index a29dc88..47f6bf9 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -9,7 +9,7 @@ build = "build.rs" [dependencies] -bevy = { version = "0.15.1", features = ["jpeg", "trace_tracy", "trace_tracy_memory", "serialize"] } +bevy = { version = "0.16.1", features = ["jpeg", "trace_tracy", "trace_tracy_memory", "serialize"] } rand = "0.8.5" serde = { version = "1.0", features = ["derive"] } toml = "0.8" diff --git a/client/src/plugins/big_space/big_space_plugin.rs b/client/src/plugins/big_space/big_space_plugin.rs index 8850753..35cf465 100644 --- a/client/src/plugins/big_space/big_space_plugin.rs +++ b/client/src/plugins/big_space/big_space_plugin.rs @@ -1,5 +1,7 @@ use bevy::math::DVec3; use bevy::prelude::*; +use bevy::ecs::prelude::ChildOf; + use big_space::prelude::*; /// Plugin enabling high precision coordinates using `big_space`. @@ -31,7 +33,7 @@ fn spawn_root(mut commands: Commands) { // 2) cache the root entity for later use fn cache_root( mut commands: Commands, - roots: Query, Without)>, // top-level grid + roots: Query, Without)>, // top-level grid ) { if let Ok(entity) = roots.get_single() { @@ -42,7 +44,7 @@ fn cache_root( fn fix_invalid_children( mut commands: Commands, - bad: Query, Without>, With)>, + bad: Query, Without>, With)>, ) { for e in &bad { commands.entity(e).insert(GridCell::::ZERO); @@ -65,10 +67,10 @@ pub fn teleport_to( e: Entity, target: DVec3, grids: Grids<'_, '_, P>, - mut q: Query<(&Parent, &mut GridCell

, &mut Transform)>, + mut q: Query<(&ChildOf, &mut GridCell

, &mut Transform)>, ) { - let (parent, mut cell, mut tf) = q.get_mut(e).unwrap(); - let grid = grids.parent_grid(parent.get()).unwrap(); + let (child_of, mut cell, mut tf) = q.get_mut(e).unwrap(); + let grid = grids.parent_grid(child_of.parent()).unwrap(); let (new_cell, local) = grid.translation_to_grid(target); diff --git a/client/src/plugins/environment/environment_plugin.rs b/client/src/plugins/environment/environment_plugin.rs index f6ae4e7..c28841c 100644 --- a/client/src/plugins/environment/environment_plugin.rs +++ b/client/src/plugins/environment/environment_plugin.rs @@ -64,10 +64,12 @@ fn log_mesh_count(meshes: Res>, time: Res

, &mut Transform)>, + grids: Grids<'_, '_>, + mut q: Query<(&ChildOf, &mut GridCell, &mut Transform)>, ) { let (child_of, mut cell, mut tf) = q.get_mut(e).unwrap(); let grid = grids.parent_grid(child_of.parent()).unwrap(); diff --git a/client/src/plugins/environment/systems/environment_system.rs b/client/src/plugins/environment/systems/environment_system.rs index b5b12c1..6606a6b 100644 --- a/client/src/plugins/environment/systems/environment_system.rs +++ b/client/src/plugins/environment/systems/environment_system.rs @@ -21,21 +21,21 @@ pub(crate) fn setup( ..default() }); - // light (unchanged) + // light commands.entity(root.0).with_children(|p| { - p.spawn(DirectionalLightBundle { - transform: Transform::from_rotation(Quat::from_euler( + p.spawn(( + Transform::from_rotation(Quat::from_euler( EulerRot::XYZ, -std::f32::consts::FRAC_PI_4, 0.0, 0.0, )), - directional_light: DirectionalLight { + GlobalTransform::default(), + DirectionalLight { shadows_enabled: true, ..default() }, - ..default() - }); + )); }); /*// ---------- spawn spheres from football-size up to Earth-size ---------- @@ -59,7 +59,7 @@ pub(crate) fn setup( parent.spawn(( // spatial requirements for big_space - GridCell::::ZERO, + GridCell::ZERO, Transform::from_scale(scale_v3).with_translation(pos), GlobalTransform::default(), // rendering diff --git a/client/src/plugins/environment/systems/planet_system.rs b/client/src/plugins/environment/systems/planet_system.rs index cbd490c..fc8753c 100644 --- a/client/src/plugins/environment/systems/planet_system.rs +++ b/client/src/plugins/environment/systems/planet_system.rs @@ -36,7 +36,7 @@ pub fn setup( Name::new("Planet"), Mesh3d(sphere_mesh.clone()), MeshMaterial3d(material_handle), - GridCell::::ZERO, + GridCell::ZERO, Transform::default(), PlanetMaker, Wireframe, diff --git a/client/src/plugins/environment/systems/voxels/render_chunks.rs b/client/src/plugins/environment/systems/voxels/render_chunks.rs index 36d1eac..eb74e1d 100644 --- a/client/src/plugins/environment/systems/voxels/render_chunks.rs +++ b/client/src/plugins/environment/systems/voxels/render_chunks.rs @@ -109,7 +109,7 @@ pub fn rebuild_dirty_chunks( Mesh3d::from(mesh_h.clone()), MeshMaterial3d(mat_h.clone()), Transform::default(), - GridCell::::ZERO, + GridCell::ZERO, Chunk { key, voxels: Vec::new(), dirty: false }, ChunkLod(lod), /*Wireframe,*/ diff --git a/client/src/plugins/input/input_plugin.rs b/client/src/plugins/input/input_plugin.rs index b64cc76..b5bda72 100644 --- a/client/src/plugins/input/input_plugin.rs +++ b/client/src/plugins/input/input_plugin.rs @@ -1,6 +1,7 @@ use bevy::app::{App, Plugin, PreUpdate, Startup}; -use bevy::prelude::{IntoSystemConfigs, Update}; +use bevy::ecs::schedule::IntoScheduleConfigs; +use bevy::prelude::Update; pub struct InputPlugin; impl Plugin for InputPlugin { diff --git a/client/src/plugins/ui/systems/ui_system.rs b/client/src/plugins/ui/systems/ui_system.rs index 95e8944..4c949a9 100644 --- a/client/src/plugins/ui/systems/ui_system.rs +++ b/client/src/plugins/ui/systems/ui_system.rs @@ -43,9 +43,9 @@ pub fn setup(mut commands: Commands, asset_server: Res) { /// - current chunk coordinate pub fn update( - grids: Grids<'_, '_, i64>, // helper from big_space + grids: Grids<'_, '_>, // helper from big_space // we need the entity id, the cell & the local transform - camera_q: Query<(Entity, &GridCell, &Transform, &CameraController)>, + camera_q: Query<(Entity, &GridCell, &Transform, &CameraController)>, mut ui_q: Query<&mut Text, With>, ) { let Ok((cam_ent, cell, tf, ctrl)) = camera_q.get_single() else { return }; From d93063a8ba1151c6bc50ceae8658c0f80bff2470 Mon Sep 17 00:00:00 2001 From: Elias Stepanik Date: Fri, 13 Jun 2025 02:22:23 +0200 Subject: [PATCH 4/4] Last small fixes --- client/src/plugins/environment/systems/planet_system.rs | 2 +- client/src/plugins/environment/systems/voxel_system.rs | 4 ++-- client/src/plugins/environment/systems/voxels/debug.rs | 4 ++-- client/src/plugins/ui/ui_plugin.rs | 1 - 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/client/src/plugins/environment/systems/planet_system.rs b/client/src/plugins/environment/systems/planet_system.rs index fc8753c..0b71618 100644 --- a/client/src/plugins/environment/systems/planet_system.rs +++ b/client/src/plugins/environment/systems/planet_system.rs @@ -29,7 +29,7 @@ pub fn setup( SphereMeshBuilder::new(radius, SphereKind::Ico { subdivisions: 100 }) .build(), ); - let material_handle = materials.add(StandardMaterial::from(Color::rgb(0.3, 0.6, 1.0))); + let material_handle = materials.add(StandardMaterial::from(Color::srgb(0.3, 0.6, 1.0))); commands.entity(root.0).with_children(|parent| { parent.spawn(( diff --git a/client/src/plugins/environment/systems/voxel_system.rs b/client/src/plugins/environment/systems/voxel_system.rs index 72ed8da..ab9a445 100644 --- a/client/src/plugins/environment/systems/voxel_system.rs +++ b/client/src/plugins/environment/systems/voxel_system.rs @@ -30,10 +30,10 @@ pub fn setup( } } else { let mut tree = SparseVoxelOctree::new(octree_depth, octree_base_size, false, false, false); - let color = Color::rgb(0.2, 0.8, 0.2); + let color = Color::srgb(0.2, 0.8, 0.2); // How many random spheres? /*const NUM_SPHERES: usize = 5; - let mut rng = thread_rng(); + let mut rng = threald_rng(); for _ in 0..NUM_SPHERES { let center = Vec3::new( diff --git a/client/src/plugins/environment/systems/voxels/debug.rs b/client/src/plugins/environment/systems/voxels/debug.rs index 4246a95..85a2de6 100644 --- a/client/src/plugins/environment/systems/voxels/debug.rs +++ b/client/src/plugins/environment/systems/voxels/debug.rs @@ -15,7 +15,7 @@ pub fn visualize_octree_system( gizmos.cuboid( Transform::from_translation(octree_tf.translation) .with_scale(Vec3::splat(octree.size)), - Color::rgba(1.0, 1.0, 0.0, 0.15), + Color::srgba(1.0, 1.0, 0.0, 0.15), ); // Recursively draw children: @@ -62,7 +62,7 @@ fn visualize_recursive_center( // Draw the child bounding box gizmos.cuboid( Transform::from_translation(child_center).with_scale(Vec3::splat(child_size)), - Color::rgba(0.5, 1.0, 0.5, 0.15), // greenish + Color::srgba(0.5, 1.0, 0.5, 0.15), // greenish ); // Recurse diff --git a/client/src/plugins/ui/ui_plugin.rs b/client/src/plugins/ui/ui_plugin.rs index e26b033..c98c5aa 100644 --- a/client/src/plugins/ui/ui_plugin.rs +++ b/client/src/plugins/ui/ui_plugin.rs @@ -1,6 +1,5 @@ use crate::plugins::ui::systems::ui_system::*; use bevy::app::{App, FixedUpdate, Plugin, PreUpdate, Startup}; -use bevy::prelude::IntoSystemConfigs; pub struct UiPlugin; impl Plugin for UiPlugin {