Fast ish compiles, improved intro flow

main
Elijah C. Voigt 1 year ago
parent e7364b4344
commit b3dcacecd8

@ -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] [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] [target.x86_64-pc-windows-msvc]
rustflags = ["-Zshare-generics=y", "-Z", "threads=8"] linker = "rust-lld.exe" # Use LLD Linker
rustflags = [
"-Zshare-generics=n",
"-Zthreads=0", # (Nightly) Use improved multithreading with the recommended amount of threads.
]

10
Cargo.lock generated

@ -362,6 +362,7 @@ version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65b9eadaacf8fe971331bc3f250f35c18bc9dace3f96b483062f38ac07e3a1b4" checksum = "65b9eadaacf8fe971331bc3f250f35c18bc9dace3f96b483062f38ac07e3a1b4"
dependencies = [ dependencies = [
"bevy_dylib",
"bevy_internal", "bevy_internal",
] ]
@ -567,6 +568,15 @@ dependencies = [
"sysinfo", "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]] [[package]]
name = "bevy_ecs" name = "bevy_ecs"
version = "0.11.3" version = "0.11.3"

@ -6,7 +6,7 @@ build = "build.rs"
[dependencies] [dependencies]
bevy_fmod = { version = "0.4", features = ["live-update"] } 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" serde = "1"
toml = { version = "0.8", features = ["parse"] } toml = { version = "0.8", features = ["parse"] }
anyhow = "*" anyhow = "*"
@ -19,6 +19,9 @@ gltf = "*"
trace = ["bevy/trace_tracy", "bevy/trace_tracy_memory"] trace = ["bevy/trace_tracy", "bevy/trace_tracy_memory"]
[profile.dev] [profile.dev]
debug = 1
[profile.dev.package."*"]
opt-level = 3 opt-level = 3
[profile.release] [profile.release]

@ -12,7 +12,6 @@ impl Plugin for Display3dPlugin {
TemporalAntiAliasPlugin, TemporalAntiAliasPlugin,
MaterialPlugin::<DissolveMaterial>::default(), MaterialPlugin::<DissolveMaterial>::default(),
)) ))
.init_state::<DissolvingAnimation>()
.init_resource::<PiecePointer>() .init_resource::<PiecePointer>()
.init_resource::<AnimationSpeed>() .init_resource::<AnimationSpeed>()
.insert_resource(Msaa::Off) .insert_resource(Msaa::Off)
@ -122,18 +121,9 @@ impl Plugin for Display3dPlugin {
.run_if(in_state(GameState::Play)) .run_if(in_state(GameState::Play))
.run_if(in_state(DisplayState::Display3d)), .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( .add_systems(
OnEnter(GameState::Intro), OnEnter(GameState::Intro),
( (
// Toggle hidden/visible 3d entities
manage_state_entities::<DisplayState>(),
color_grading_tweak.run_if(resource_exists::<tweak::GameTweaks>), color_grading_tweak.run_if(resource_exists::<tweak::GameTweaks>),
fog_tweak.run_if(resource_exists::<tweak::GameTweaks>), fog_tweak.run_if(resource_exists::<tweak::GameTweaks>),
bloom_tweak.run_if(resource_exists::<tweak::GameTweaks>), bloom_tweak.run_if(resource_exists::<tweak::GameTweaks>),
@ -191,20 +181,11 @@ pub(crate) enum Dissolving {
Out(f32), Out(f32),
} }
#[derive(Debug, States, Hash, Default, PartialEq, Eq, Clone, Component)]
enum DissolvingAnimation {
#[default]
None,
In,
Out,
}
#[derive(Debug, Resource)] #[derive(Debug, Resource)]
pub(crate) struct AnimationSpeed { pub(crate) struct AnimationSpeed {
pub movement: f32, pub movement: f32,
pub text: f32, pub text: f32,
pub dissolve: f32, pub dissolve: f32,
pub light: f32,
} }
impl Default for AnimationSpeed { impl Default for AnimationSpeed {
@ -213,7 +194,6 @@ impl Default for AnimationSpeed {
movement: 1.0, movement: 1.0,
text: 1.0, text: 1.0,
dissolve: 1.0, dissolve: 1.0,
light: 1.0,
} }
} }
} }
@ -252,7 +232,6 @@ fn initialize(mut commands: Commands, board: Res<game::Board>, assets: Res<Asset
commands commands
.spawn(( .spawn((
SpatialBundle { SpatialBundle {
visibility: Visibility::Hidden,
..default() ..default()
}, },
Display3d, Display3d,
@ -260,12 +239,37 @@ fn initialize(mut commands: Commands, board: Res<game::Board>, assets: Res<Asset
)) ))
.with_children(|parent| { .with_children(|parent| {
debug!("Intializing 3D Board!"); debug!("Intializing 3D Board!");
// Title
parent.spawn((
DisplayState::Display3d,
Display3d,
// GameState::Title,
SceneBundle {
visibility: Visibility::Hidden,
..default()
},
TitleText,
Dissolvable {
start: 0.0,
duration: 6.0,
}, // Marks title text as dissolving
));
// Board
parent parent
.spawn(( .spawn((
Display3d, Display3d,
DisplayState::Display3d, DisplayState::Display3d,
game::BoardComponent, game::BoardComponent,
SceneBundle { ..default() }, SceneBundle {
visibility: Visibility::Hidden,
..default()
},
Dissolvable {
start: 0.0,
duration: 6.0,
}, // Marks pieces as dissolving
)) ))
.with_children(|parent| { .with_children(|parent| {
// Hitboxes // Hitboxes
@ -323,6 +327,7 @@ fn initialize(mut commands: Commands, board: Res<game::Board>, assets: Res<Asset
*piece, *piece,
*index, *index,
SceneBundle { SceneBundle {
visibility: Visibility::Hidden,
transform, transform,
..default() ..default()
}, },
@ -333,19 +338,6 @@ fn initialize(mut commands: Commands, board: Res<game::Board>, assets: Res<Asset
}, // Marks pieces as dissolving }, // Marks pieces as dissolving
)); ));
}); });
// Title
parent.spawn((
DisplayState::Display3d,
Display3d,
// GameState::Title,
SceneBundle { ..default() },
TitleText,
Dissolvable {
start: 0.0,
duration: 6.0,
}, // Marks title text as dissolving
));
}); });
}); });
} }
@ -1010,14 +1002,20 @@ fn set_tile_hitbox(
}); });
} }
fn opening_animation(mut players: Query<&mut AnimationPlayer, (With<Camera>, With<Display3d>)>) { fn opening_animation(
mut players: Query<&mut AnimationPlayer, (With<Camera>, With<Display3d>)>,
mut query: Query<(Entity, &Dissolvable), Or<(With<BoardComponent>, With<Piece>)>>,
mut commands: Commands,
) {
players.iter_mut().for_each(|mut player| { players.iter_mut().for_each(|mut player| {
debug!("Playing intro camera animation"); debug!("Playing intro camera animation");
player.resume() player.resume()
}); });
query.iter_mut().for_each(|(e, d)| {
commands.entity(e).insert(Dissolving::In(d.duration));
});
} }
fn set_animation_speed( fn set_animation_speed(
mut animation_speed: ResMut<AnimationSpeed>, mut animation_speed: ResMut<AnimationSpeed>,
tweaks: Res<Assets<Tweaks>>, tweaks: Res<Assets<Tweaks>>,
@ -1032,8 +1030,7 @@ fn set_animation_speed(
let movement = tweak.get::<f32>("animation_fast_movement_speed").unwrap(); let movement = tweak.get::<f32>("animation_fast_movement_speed").unwrap();
let text = tweak.get::<f32>("animation_fast_text_speed").unwrap(); let text = tweak.get::<f32>("animation_fast_text_speed").unwrap();
let dissolve = tweak.get::<f32>("animation_fast_dissolve_speed").unwrap(); let dissolve = tweak.get::<f32>("animation_fast_dissolve_speed").unwrap();
let light = tweak.get::<f32>("animation_fast_light_speed").unwrap(); AnimationSpeed { movement, text, dissolve }
AnimationSpeed { movement, text, dissolve, light }
} else { } else {
AnimationSpeed::default() AnimationSpeed::default()
}; };
@ -1253,26 +1250,22 @@ fn monitor_animations(
fn intro_title_dissolve( fn intro_title_dissolve(
mut query: Query<(Entity, &Dissolvable), With<TitleText>>, mut query: Query<(Entity, &Dissolvable), With<TitleText>>,
mut commands: Commands, mut commands: Commands,
mut next: ResMut<NextState<DissolvingAnimation>>,
) { ) {
query.iter_mut().for_each(|(entity, dissolving)| { query.iter_mut().for_each(|(entity, dissolving)| {
commands commands
.entity(entity) .entity(entity)
.insert(Dissolving::In(dissolving.duration)); .insert(Dissolving::In(dissolving.duration));
next.set(DissolvingAnimation::In);
}); });
} }
fn outro_title_dissolve( fn outro_title_dissolve(
mut query: Query<(Entity, &Dissolvable), With<TitleText>>, mut query: Query<(Entity, &Dissolvable), With<TitleText>>,
mut commands: Commands, mut commands: Commands,
mut next: ResMut<NextState<DissolvingAnimation>>,
) { ) {
query.iter_mut().for_each(|(entity, dissolving)| { query.iter_mut().for_each(|(entity, dissolving)| {
commands commands
.entity(entity) .entity(entity)
.insert(Dissolving::Out(dissolving.duration)); .insert(Dissolving::Out(dissolving.duration));
next.set(DissolvingAnimation::Out);
}); });
} }
@ -1285,19 +1278,18 @@ fn continue_title(mut next_state: ResMut<NextState<GameState>>) {
/// Calculating how far along the animation it should be update the material's percentage /// Calculating how far along the animation it should be update the material's percentage
/// Materials are on the children of the tagged entity /// Materials are on the children of the tagged entity
fn dissolve_animation( fn dissolve_animation(
mut query: Query<(Entity, &Dissolvable, &mut Dissolving)>, mut query: Query<(Entity, &Dissolvable, &mut Dissolving, &mut Visibility)>,
children: Query<&Children>, children: Query<&Children>,
// Used to create Handle<DissolveMaterial> // Used to create Handle<DissolveMaterial>
mut dissolve_materials: ResMut<Assets<DissolveMaterial>>, mut dissolve_materials: ResMut<Assets<DissolveMaterial>>,
object_materials: Query<(Entity, &Handle<DissolveMaterial>)>, object_materials: Query<(Entity, &Handle<DissolveMaterial>)>,
mut commands: Commands, mut commands: Commands,
time: Res<Time>, time: Res<Time>,
mut next: ResMut<NextState<DissolvingAnimation>>,
animation_speed: Res<AnimationSpeed>, animation_speed: Res<AnimationSpeed>,
) { ) {
query query
.iter_mut() .iter_mut()
.for_each(|(entity, dissolvable, mut dissolving)| { .for_each(|(entity, dissolvable, mut dissolving, mut visibility)| {
debug!("Entity {:?} has Dissolving {:?}", entity, dissolving); debug!("Entity {:?} has Dissolving {:?}", entity, dissolving);
let percentage = match *dissolving { let percentage = match *dissolving {
@ -1307,6 +1299,10 @@ fn dissolve_animation(
*dissolving = Dissolving::In(sec); *dissolving = Dissolving::In(sec);
if *visibility != Visibility::Inherited {
*visibility = Visibility::Inherited
}
// Calculate the target percentage value // Calculate the target percentage value
1.0 - (sec / dissolvable.duration) 1.0 - (sec / dissolvable.duration)
} }
@ -1316,6 +1312,10 @@ fn dissolve_animation(
*dissolving = Dissolving::Out(sec); *dissolving = Dissolving::Out(sec);
if sec <= 0.0 {
*visibility = Visibility::Hidden;
}
// Calculate the target percentage value // Calculate the target percentage value
sec / dissolvable.duration sec / dissolvable.duration
} }
@ -1338,8 +1338,9 @@ fn dissolve_animation(
"Removing dissolving from {:?} with percentage {:?}", "Removing dissolving from {:?} with percentage {:?}",
entity, percentage entity, percentage
); );
// info!("Removing dissolving marker from {:?}", entity);
commands.entity(entity).remove::<Dissolving>(); commands.entity(entity).remove::<Dissolving>();
next.set(DissolvingAnimation::None);
} }
}); });
} }
@ -1415,68 +1416,3 @@ fn bloom_tweak(
bloom.intensity = tweak.get::<f32>("color_bloom_intensity").unwrap(); bloom.intensity = tweak.get::<f32>("color_bloom_intensity").unwrap();
}) })
} }
fn animate_title_light_in(
mut query: Query<(Entity, &mut Visibility), With<TitleText>>,
children: Query<&Children>,
mut lights: Query<&mut SpotLight>,
mut t: Local<Timer>,
mut started: Local<bool>,
time: Res<Time>,
animation_speed: Res<AnimationSpeed>,
) {
// Over 6 seconds, fade in to 600 intensity
if !(*started) {
*t = Timer::from_seconds(6.0, TimerMode::Once);
*started = true
} else {
t.tick(Duration::from_secs_f32(time.delta_seconds() * animation_speed.light));
}
let intensity = t.fraction() * 409800.0;
query.iter_mut().for_each(|(e, mut v)| {
if *v == Visibility::Hidden {
*v = Visibility::Inherited;
}
children.iter_descendants(e).for_each(|c| {
if let Ok(mut spot_light) = lights.get_mut(c) {
spot_light.intensity = intensity;
}
})
});
}
fn animate_title_light_out(
mut query: Query<(Entity, &mut Visibility), With<TitleText>>,
children: Query<&Children>,
mut lights: Query<&mut SpotLight>,
mut t: Local<Timer>,
mut started: Local<bool>,
time: Res<Time>,
animation_speed: Res<AnimationSpeed>,
) {
// Over 6 seconds, fade in to 600 intensity
if !(*started) {
*t = Timer::from_seconds(3.0, TimerMode::Once);
*started = true
} else {
t.tick(Duration::from_secs_f32(time.delta_seconds() * animation_speed.light));
}
let intensity = (1.0 - t.fraction()) * 409800.0;
query.iter_mut().for_each(|(e, mut v)| {
if *v == Visibility::Hidden {
*v = Visibility::Inherited;
}
children.iter_descendants(e).for_each(|c| {
if let Ok(mut spot_light) = lights.get_mut(c) {
spot_light.intensity = intensity;
}
})
});
}

Loading…
Cancel
Save