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]
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.
]

10
Cargo.lock generated

@ -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"

@ -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]

@ -12,7 +12,6 @@ impl Plugin for Display3dPlugin {
TemporalAntiAliasPlugin,
MaterialPlugin::<DissolveMaterial>::default(),
))
.init_state::<DissolvingAnimation>()
.init_resource::<PiecePointer>()
.init_resource::<AnimationSpeed>()
.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::<DisplayState>(),
color_grading_tweak.run_if(resource_exists::<tweak::GameTweaks>),
fog_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),
}
#[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<game::Board>, assets: Res<Asset
commands
.spawn((
SpatialBundle {
visibility: Visibility::Hidden,
..default()
},
Display3d,
@ -260,12 +239,37 @@ fn initialize(mut commands: Commands, board: Res<game::Board>, assets: Res<Asset
))
.with_children(|parent| {
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
.spawn((
Display3d,
DisplayState::Display3d,
game::BoardComponent,
SceneBundle { ..default() },
SceneBundle {
visibility: Visibility::Hidden,
..default()
},
Dissolvable {
start: 0.0,
duration: 6.0,
}, // Marks pieces as dissolving
))
.with_children(|parent| {
// Hitboxes
@ -323,6 +327,7 @@ fn initialize(mut commands: Commands, board: Res<game::Board>, assets: Res<Asset
*piece,
*index,
SceneBundle {
visibility: Visibility::Hidden,
transform,
..default()
},
@ -333,19 +338,6 @@ fn initialize(mut commands: Commands, board: Res<game::Board>, assets: Res<Asset
}, // 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| {
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<AnimationSpeed>,
tweaks: Res<Assets<Tweaks>>,
@ -1032,8 +1030,7 @@ fn set_animation_speed(
let movement = tweak.get::<f32>("animation_fast_movement_speed").unwrap();
let text = tweak.get::<f32>("animation_fast_text_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, 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<TitleText>>,
mut commands: Commands,
mut next: ResMut<NextState<DissolvingAnimation>>,
) {
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<TitleText>>,
mut commands: Commands,
mut next: ResMut<NextState<DissolvingAnimation>>,
) {
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<NextState<GameState>>) {
/// 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<DissolveMaterial>
mut dissolve_materials: ResMut<Assets<DissolveMaterial>>,
object_materials: Query<(Entity, &Handle<DissolveMaterial>)>,
mut commands: Commands,
time: Res<Time>,
mut next: ResMut<NextState<DissolvingAnimation>>,
animation_speed: Res<AnimationSpeed>,
) {
query
.iter_mut()
.for_each(|(entity, dissolvable, mut dissolving)| {
.for_each(|(entity, dissolvable, mut dissolving, mut visibility)| {
debug!("Entity {:?} has Dissolving {:?}", entity, dissolving);
let percentage = match *dissolving {
@ -1307,6 +1299,10 @@ fn dissolve_animation(
*dissolving = Dissolving::In(sec);
if *visibility != Visibility::Inherited {
*visibility = Visibility::Inherited
}
// Calculate the target percentage value
1.0 - (sec / dissolvable.duration)
}
@ -1316,6 +1312,10 @@ fn dissolve_animation(
*dissolving = Dissolving::Out(sec);
if sec <= 0.0 {
*visibility = Visibility::Hidden;
}
// Calculate the target percentage value
sec / dissolvable.duration
}
@ -1338,8 +1338,9 @@ fn dissolve_animation(
"Removing dissolving from {:?} with percentage {:?}",
entity, percentage
);
// info!("Removing dissolving marker from {:?}", entity);
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();
})
}
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