From b3dcacecd8794344b56671128d1e204add152d19 Mon Sep 17 00:00:00 2001 From: "Elijah C. Voigt" Date: Mon, 13 May 2024 22:02:44 -0700 Subject: [PATCH] Fast ish compiles, improved intro flow --- .cargo/config.toml | 36 +++++++++- Cargo.lock | 10 +++ Cargo.toml | 5 +- src/display3d.rs | 160 ++++++++++++++------------------------------- 4 files changed, 95 insertions(+), 116 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 6417e48..9cfcbf3 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,5 +1,35 @@ +# Add the contents of this file to `config.toml` to enable "fast build" configuration. Please read the notes below. + +# NOTE: For maximum performance, build using a nightly compiler +# If you are using rust stable, remove the "-Zshare-generics=y" below. + [target.x86_64-unknown-linux-gnu] -rustflags = ["-Zshare-generics=y", "-Z", "threads=8"] +linker = "clang" +rustflags = [ + "-Clink-arg=-fuse-ld=lld", # Use LLD Linker + "-Zshare-generics=y", # (Nightly) Make the current crate share its generic instantiations + "-Zthreads=0", # (Nightly) Use improved multithreading with the recommended amount of threads. +] + +# NOTE: you must install [Mach-O LLD Port](https://lld.llvm.org/MachO/index.html) on mac. you can easily do this by installing llvm which includes lld with the "brew" package manager: +# `brew install llvm` +[target.x86_64-apple-darwin] +rustflags = [ + "-Clink-arg=-fuse-ld=/usr/local/opt/llvm/bin/ld64.lld", # Use LLD Linker + "-Zshare-generics=y", # (Nightly) Make the current crate share its generic instantiations + "-Zthreads=0", # (Nightly) Use improved multithreading with the recommended amount of threads. +] + +[target.aarch64-apple-darwin] +rustflags = [ + "-Clink-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld", # Use LLD Linker + "-Zshare-generics=y", # (Nightly) Make the current crate share its generic instantiations + "-Zthreads=0", # (Nightly) Use improved multithreading with the recommended amount of threads. +] -[target.x86_64-pc-windows-gnu] -rustflags = ["-Zshare-generics=y", "-Z", "threads=8"] +[target.x86_64-pc-windows-msvc] +linker = "rust-lld.exe" # Use LLD Linker +rustflags = [ + "-Zshare-generics=n", + "-Zthreads=0", # (Nightly) Use improved multithreading with the recommended amount of threads. +] \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 8a1d43d..1042f0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -362,6 +362,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65b9eadaacf8fe971331bc3f250f35c18bc9dace3f96b483062f38ac07e3a1b4" dependencies = [ + "bevy_dylib", "bevy_internal", ] @@ -567,6 +568,15 @@ dependencies = [ "sysinfo", ] +[[package]] +name = "bevy_dylib" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "922826e3b8f37c19836b49e18ceca662260cce87ab8faa4db6df8433903660cc" +dependencies = [ + "bevy_internal", +] + [[package]] name = "bevy_ecs" version = "0.11.3" diff --git a/Cargo.toml b/Cargo.toml index 6a621bb..478833f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ build = "build.rs" [dependencies] bevy_fmod = { version = "0.4", features = ["live-update"] } -bevy = { version = "0.13", features = ["jpeg", "hdr", "serialize", "file_watcher"] } +bevy = { version = "0.13", features = ["jpeg", "hdr", "serialize", "file_watcher", "dynamic_linking"] } serde = "1" toml = { version = "0.8", features = ["parse"] } anyhow = "*" @@ -19,6 +19,9 @@ gltf = "*" trace = ["bevy/trace_tracy", "bevy/trace_tracy_memory"] [profile.dev] +debug = 1 + +[profile.dev.package."*"] opt-level = 3 [profile.release] diff --git a/src/display3d.rs b/src/display3d.rs index 7bed2c3..129ec9e 100644 --- a/src/display3d.rs +++ b/src/display3d.rs @@ -12,7 +12,6 @@ impl Plugin for Display3dPlugin { TemporalAntiAliasPlugin, MaterialPlugin::::default(), )) - .init_state::() .init_resource::() .init_resource::() .insert_resource(Msaa::Off) @@ -122,18 +121,9 @@ impl Plugin for Display3dPlugin { .run_if(in_state(GameState::Play)) .run_if(in_state(DisplayState::Display3d)), ) - .add_systems( - Update, - ( - animate_title_light_in.run_if(in_state(DissolvingAnimation::In)), - animate_title_light_out.run_if(in_state(DissolvingAnimation::Out)), - ), - ) .add_systems( OnEnter(GameState::Intro), ( - // Toggle hidden/visible 3d entities - manage_state_entities::(), color_grading_tweak.run_if(resource_exists::), fog_tweak.run_if(resource_exists::), bloom_tweak.run_if(resource_exists::), @@ -191,20 +181,11 @@ pub(crate) enum Dissolving { Out(f32), } -#[derive(Debug, States, Hash, Default, PartialEq, Eq, Clone, Component)] -enum DissolvingAnimation { - #[default] - None, - In, - Out, -} - #[derive(Debug, Resource)] pub(crate) struct AnimationSpeed { pub movement: f32, pub text: f32, pub dissolve: f32, - pub light: f32, } impl Default for AnimationSpeed { @@ -213,7 +194,6 @@ impl Default for AnimationSpeed { movement: 1.0, text: 1.0, dissolve: 1.0, - light: 1.0, } } } @@ -252,7 +232,6 @@ fn initialize(mut commands: Commands, board: Res, assets: Res, assets: Res, assets: Res, assets: Res, With)>) { +fn opening_animation( + mut players: Query<&mut AnimationPlayer, (With, With)>, + mut query: Query<(Entity, &Dissolvable), Or<(With, With)>>, + mut commands: Commands, +) { players.iter_mut().for_each(|mut player| { debug!("Playing intro camera animation"); player.resume() }); + query.iter_mut().for_each(|(e, d)| { + commands.entity(e).insert(Dissolving::In(d.duration)); + }); } - fn set_animation_speed( mut animation_speed: ResMut, tweaks: Res>, @@ -1032,8 +1030,7 @@ fn set_animation_speed( let movement = tweak.get::("animation_fast_movement_speed").unwrap(); let text = tweak.get::("animation_fast_text_speed").unwrap(); let dissolve = tweak.get::("animation_fast_dissolve_speed").unwrap(); - let light = tweak.get::("animation_fast_light_speed").unwrap(); - AnimationSpeed { movement, text, dissolve, light } + AnimationSpeed { movement, text, dissolve } } else { AnimationSpeed::default() }; @@ -1253,26 +1250,22 @@ fn monitor_animations( fn intro_title_dissolve( mut query: Query<(Entity, &Dissolvable), With>, mut commands: Commands, - mut next: ResMut>, ) { query.iter_mut().for_each(|(entity, dissolving)| { commands .entity(entity) .insert(Dissolving::In(dissolving.duration)); - next.set(DissolvingAnimation::In); }); } fn outro_title_dissolve( mut query: Query<(Entity, &Dissolvable), With>, mut commands: Commands, - mut next: ResMut>, ) { query.iter_mut().for_each(|(entity, dissolving)| { commands .entity(entity) .insert(Dissolving::Out(dissolving.duration)); - next.set(DissolvingAnimation::Out); }); } @@ -1285,19 +1278,18 @@ fn continue_title(mut next_state: ResMut>) { /// Calculating how far along the animation it should be update the material's percentage /// Materials are on the children of the tagged entity fn dissolve_animation( - mut query: Query<(Entity, &Dissolvable, &mut Dissolving)>, + mut query: Query<(Entity, &Dissolvable, &mut Dissolving, &mut Visibility)>, children: Query<&Children>, // Used to create Handle mut dissolve_materials: ResMut>, object_materials: Query<(Entity, &Handle)>, mut commands: Commands, time: Res