upgrade to bevy 0.8 [broken]

only a black screen shows up
main
annieversary 2022-08-01 23:50:41 +01:00
parent 4447ff2aa6
commit b315e589e6
6 changed files with 448 additions and 494 deletions

841
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,25 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
bevy = "0.7.0" bevy = "0.8.0"
bevy_mod_raycast = "0.5.0" bevy_mod_raycast = "0.6.0"
bevy_prototype_debug_lines = { version = "0.7", features = ["3d"] }
# Enable a small amount of optimization in debug mode
[profile.dev]
opt-level = 1
# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
[profile.dev.package."*"]
opt-level = 3
[profile.wasm-release]
inherits = "release"
# Optimize with size in mind, also try "s", sometimes it is better.
# This doesn't increase compilation times compared to -O3, great improvements
opt-level = "z"
# Do a second optimization pass removing duplicate or unused code from dependencies.
# Slows compile times, marginal improvements
lto = "fat"
# When building crates, optimize larger chunks at a time
# Slows compile times, marginal improvements
codegen-units = 1

View File

@ -9,7 +9,7 @@ pub struct MyRaycastSet;
pub struct Camera; pub struct Camera;
pub fn spawn_camera(commands: &mut Commands) { pub fn spawn_camera(commands: &mut Commands) {
commands commands
.spawn_bundle(PerspectiveCameraBundle::default()) .spawn_bundle(Camera3dBundle::default())
.insert(Camera) .insert(Camera)
.insert(RayCastSource::<MyRaycastSet>::new()); .insert(RayCastSource::<MyRaycastSet>::new());
} }

View File

@ -1,9 +1,9 @@
use std::f32::consts::TAU; // use std::f32::consts::TAU;
use bevy::{ecs::schedule::ShouldRun, prelude::*}; use bevy::{ecs::schedule::ShouldRun, prelude::*};
use bevy_prototype_debug_lines::*; // use bevy_prototype_debug_lines::*;
use crate::illumination::Illumination; // use crate::illumination::Illumination;
#[derive(Default)] #[derive(Default)]
pub struct Debug { pub struct Debug {
@ -18,29 +18,29 @@ pub fn debug_run_criteria(debug: Res<Debug>) -> ShouldRun {
} }
} }
pub fn debug_draw_illumination( // pub fn debug_draw_illumination(
query: Query<(&GlobalTransform, &Illumination)>, // query: Query<(&GlobalTransform, &Illumination)>,
mut lines: ResMut<DebugLines>, // mut lines: ResMut<DebugLines>,
) { // ) {
for (trans, illumination) in query.iter() { // for (trans, illumination) in query.iter() {
draw_sphere(&mut lines, trans.translation, illumination.radius); // draw_sphere(&mut lines, trans.translation, illumination.radius);
} // }
} // }
fn draw_sphere(lines: &mut DebugLines, c: Vec3, r: f32) { // fn draw_sphere(lines: &mut DebugLines, c: Vec3, r: f32) {
const THICKNESS: f32 = 0.1; // const THICKNESS: f32 = 0.1;
const MAX_LINES: usize = 10; // const MAX_LINES: usize = 10;
for i in 0..MAX_LINES { // for i in 0..MAX_LINES {
let angle1 = (i as f32 / MAX_LINES as f32) * TAU; // let angle1 = (i as f32 / MAX_LINES as f32) * TAU;
let angle2 = ((i + 1) as f32 / MAX_LINES as f32) * TAU; // let angle2 = ((i + 1) as f32 / MAX_LINES as f32) * TAU;
let start = Vec3::new(r * f32::cos(angle1), 1.0, r * f32::sin(angle1)) + c; // let start = Vec3::new(r * f32::cos(angle1), 1.0, r * f32::sin(angle1)) + c;
let end = Vec3::new(r * f32::cos(angle2), 1.0, r * f32::sin(angle2)) + c; // let end = Vec3::new(r * f32::cos(angle2), 1.0, r * f32::sin(angle2)) + c;
lines.line(start, end, THICKNESS); // lines.line(start, end, THICKNESS);
} // }
} // }
pub fn toggle_debug(mut debug: ResMut<Debug>, input: Res<Input<KeyCode>>) { pub fn toggle_debug(mut debug: ResMut<Debug>, input: Res<Input<KeyCode>>) {
if input.pressed(KeyCode::J) && input.pressed(KeyCode::K) && input.just_pressed(KeyCode::L) { if input.pressed(KeyCode::J) && input.pressed(KeyCode::K) && input.just_pressed(KeyCode::L) {

View File

@ -1,6 +1,9 @@
use bevy::{ use bevy::{
prelude::*, prelude::*,
render::render_resource::{AddressMode, FilterMode}, render::{
render_resource::{AddressMode, FilterMode, SamplerDescriptor},
texture::ImageSampler,
},
}; };
use crate::AppState; use crate::AppState;
@ -23,10 +26,15 @@ pub fn loading(
mut state: ResMut<State<AppState>>, mut state: ResMut<State<AppState>>,
) { ) {
if let Some(t) = textures.get_mut(&assets.floor) { if let Some(t) = textures.get_mut(&assets.floor) {
t.sampler_descriptor.address_mode_u = AddressMode::MirrorRepeat; let s = SamplerDescriptor {
t.sampler_descriptor.address_mode_v = AddressMode::Repeat; address_mode_u: AddressMode::MirrorRepeat,
t.sampler_descriptor.address_mode_w = AddressMode::Repeat; address_mode_v: AddressMode::Repeat,
t.sampler_descriptor.mipmap_filter = FilterMode::Linear; address_mode_w: AddressMode::Repeat,
mipmap_filter: FilterMode::Linear,
..default()
};
t.sampler_descriptor = ImageSampler::Descriptor(s);
state.set(AppState::Game).unwrap(); state.set(AppState::Game).unwrap();
} }

View File

@ -1,6 +1,6 @@
use bevy::{input::system::exit_on_esc_system, pbr::AmbientLight, prelude::*}; use bevy::{pbr::AmbientLight, prelude::*, window::close_on_esc};
use bevy_mod_raycast::{DefaultRaycastingPlugin, RayCastMesh, RaycastSystem}; use bevy_mod_raycast::{DefaultRaycastingPlugin, RayCastMesh, RaycastSystem};
use bevy_prototype_debug_lines::*; // use bevy_prototype_debug_lines::*;
mod camera; mod camera;
mod columns; mod columns;
@ -28,7 +28,7 @@ fn main() {
.insert_resource(Msaa { samples: 4 }) .insert_resource(Msaa { samples: 4 })
.insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0))) .insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0)))
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_plugin(DebugLinesPlugin::with_depth_test(true)) // .add_plugin(DebugLinesPlugin::with_depth_test(true))
.init_resource::<Debug>() .init_resource::<Debug>()
.init_resource::<LightBallMaterials>() .init_resource::<LightBallMaterials>()
.init_resource::<PillarMaterials>() .init_resource::<PillarMaterials>()
@ -52,7 +52,7 @@ fn main() {
SystemSet::on_update(AppState::Game) SystemSet::on_update(AppState::Game)
.with_system(update_raw_mouse_coords) .with_system(update_raw_mouse_coords)
.with_system(update_processed_mouse_coords) .with_system(update_processed_mouse_coords)
.with_system(exit_on_esc_system) .with_system(close_on_esc)
.with_system(light_movement) .with_system(light_movement)
.with_system(move_light_friends) .with_system(move_light_friends)
.with_system(update_floating_orbs_interpolation) .with_system(update_floating_orbs_interpolation)
@ -66,9 +66,7 @@ fn main() {
.with_system(toggle_debug), .with_system(toggle_debug),
) )
.add_system_set( .add_system_set(
SystemSet::on_update(AppState::Game) SystemSet::on_update(AppState::Game).with_run_criteria(debug_run_criteria), // .with_system(debug_draw_illumination),
.with_run_criteria(debug_run_criteria)
.with_system(debug_draw_illumination),
) )
.run(); .run();
} }