mirror of
https://github.com/eliasstepanik/voxel-simulation.git
synced 2026-01-11 22:08:29 +00:00
Update for Bevy 0.16
This commit is contained in:
parent
d56d28c966
commit
13a0b54364
@ -10,7 +10,7 @@ impl Plugin for AppPlugin {
|
||||
app.add_plugins(crate::plugins::environment::environment_plugin::EnvironmentPlugin);
|
||||
//app.add_plugins(crate::plugins::network::network_plugin::NetworkPlugin);
|
||||
app.add_plugins(crate::plugins::input::input_plugin::InputPlugin);
|
||||
app.add_plugins(WireframePlugin);
|
||||
app.add_plugins(WireframePlugin::default());
|
||||
|
||||
app.add_systems(Update, (debug_gizmos));
|
||||
app.register_type::<Option<Handle<Image>>>();
|
||||
|
||||
@ -13,7 +13,7 @@ use bevy::render::RenderPlugin;
|
||||
use bevy::DefaultPlugins;
|
||||
use bevy::input::gamepad::AxisSettingsError::DeadZoneUpperBoundGreaterThanLiveZoneUpperBound;
|
||||
use bevy::window::PresentMode;
|
||||
use big_space::plugin::BigSpacePlugin;
|
||||
use big_space::plugin::BigSpaceDefaultPlugins;
|
||||
use toml;
|
||||
use crate::config::Config;
|
||||
use crate::plugins::big_space::big_space_plugin::BigSpaceIntegrationPlugin;
|
||||
|
||||
@ -16,7 +16,7 @@ pub struct RootGrid(pub Entity);
|
||||
|
||||
impl Plugin for BigSpaceIntegrationPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_plugins(BigSpacePlugin::<i64>::default());
|
||||
app.add_plugins(BigSpaceDefaultPlugins);
|
||||
|
||||
app.add_systems(PreStartup, (spawn_root, cache_root.after(spawn_root)));
|
||||
app.add_systems(PostStartup, (fix_invalid_children));
|
||||
@ -27,7 +27,7 @@ impl Plugin for BigSpaceIntegrationPlugin {
|
||||
|
||||
// 1) build the Big-Space root
|
||||
fn spawn_root(mut commands: Commands) {
|
||||
commands.spawn_big_space_default::<i64>(|_| {});
|
||||
commands.spawn_big_space_default(|_| {});
|
||||
}
|
||||
|
||||
// 2) cache the root entity for later use
|
||||
@ -44,10 +44,10 @@ fn cache_root(
|
||||
|
||||
fn fix_invalid_children(
|
||||
mut commands: Commands,
|
||||
bad: Query<Entity, (With<FloatingOrigin>, Without<GridCell<i64>>, With<ChildOf>)>,
|
||||
bad: Query<Entity, (With<FloatingOrigin>, Without<GridCell>, With<ChildOf>)>,
|
||||
) {
|
||||
for e in &bad {
|
||||
commands.entity(e).insert(GridCell::<i64>::ZERO);
|
||||
commands.entity(e).insert(GridCell::ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,11 +63,11 @@ pub fn move_by(
|
||||
|
||||
|
||||
|
||||
pub fn teleport_to<P: GridPrecision>(
|
||||
pub fn teleport_to(
|
||||
e: Entity,
|
||||
target: DVec3,
|
||||
grids: Grids<'_, '_, P>,
|
||||
mut q: Query<(&ChildOf, &mut GridCell<P>, &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();
|
||||
|
||||
@ -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::<i64>::ZERO,
|
||||
GridCell::ZERO,
|
||||
Transform::from_scale(scale_v3).with_translation(pos),
|
||||
GlobalTransform::default(),
|
||||
// rendering
|
||||
|
||||
@ -36,7 +36,7 @@ pub fn setup(
|
||||
Name::new("Planet"),
|
||||
Mesh3d(sphere_mesh.clone()),
|
||||
MeshMaterial3d(material_handle),
|
||||
GridCell::<i64>::ZERO,
|
||||
GridCell::ZERO,
|
||||
Transform::default(),
|
||||
PlanetMaker,
|
||||
Wireframe,
|
||||
|
||||
@ -109,7 +109,7 @@ pub fn rebuild_dirty_chunks(
|
||||
Mesh3d::from(mesh_h.clone()),
|
||||
MeshMaterial3d(mat_h.clone()),
|
||||
Transform::default(),
|
||||
GridCell::<i64>::ZERO,
|
||||
GridCell::ZERO,
|
||||
Chunk { key, voxels: Vec::new(), dirty: false },
|
||||
ChunkLod(lod),
|
||||
/*Wireframe,*/
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -43,9 +43,9 @@ pub fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
/// - 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<i64>, &Transform, &CameraController)>,
|
||||
camera_q: Query<(Entity, &GridCell, &Transform, &CameraController)>,
|
||||
mut ui_q: Query<&mut Text, With<SpeedDisplay>>,
|
||||
) {
|
||||
let Ok((cam_ent, cell, tf, ctrl)) = camera_q.get_single() else { return };
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user