Skip to content

Commit

Permalink
Update to Bevy 0.14
Browse files Browse the repository at this point in the history
Better menu
Revert tonemapper changes
  • Loading branch information
VirxEC committed Jul 6, 2024
1 parent 57f196b commit 7e2110a
Show file tree
Hide file tree
Showing 11 changed files with 1,163 additions and 1,019 deletions.
1,415 changes: 764 additions & 651 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
[package]
version = "0.7.10"
version = "0.7.11"
name = "rlviser"
edition = "2021"
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy_atmosphere = "0.9.1"
bevy_egui = "0.27.0"
bevy_eventlistener = "0.7.0"
bevy_framepace = { version = "0.15.0", default-features = false }
bevy_mod_picking = { version = "0.18.0", default-features = false, features = ["backend_raycast"] }
bevy_vector_shapes = "0.7.0"
bevy_atmosphere = "0.10"
bevy_egui = "0.28"
bevy_eventlistener = "0.8"
bevy_vector_shapes = "0.8"
bevy_framepace = { version = "0.17", default-features = false }
# bevy_mod_picking = { version = "0.20", default-features = false, features = ["backend_raycast"] }
bevy_mod_picking = { git = "https://github.com/aevyrie/bevy_mod_picking", branch = "v0.20-release", default-features = false, features = ["backend_raycast"] }
byteorder = "1.4.3"
include-flate = "0.3.0"
once_cell = "1.17.1"
Expand All @@ -27,11 +28,12 @@ crossbeam-channel = "0.5.12"
itertools = "0.13.0"

[dependencies.bevy]
version = "0.13.0"
version = "0.14"
default-features = false
features = ["bevy_core_pipeline", "bevy_pbr", "bevy_ui", "wayland", "x11", "tga", "tonemapping_luts", "default_font", "bevy_gizmos"]
features = ["bevy_core_pipeline", "bevy_pbr", "bevy_ui", "wayland", "x11", "tga", "default_font", "bevy_gizmos", "bevy_state"]

[features]
default = []
full_load = []
ssao = []
team_goal_barriers = []
Expand Down
28 changes: 15 additions & 13 deletions src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use crate::{
};
use bevy::{
asset::{io::Reader, AssetLoader, AsyncReadExt},
color::palettes::css,
prelude::*,
utils::ConditionalSendFuture,
};
use byteorder::{LittleEndian, ReadBytesExt};
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -389,7 +391,7 @@ fn retreive_material(
if let Some(texture_name) = diffuse {
debug!("Found texture for {name}");
if texture_name == "ForcefieldHex" {
material.base_color = Color::rgba(0.3, 0.3, 0.3, 0.3);
material.base_color = Color::srgba(0.3, 0.3, 0.3, 0.3);
}
material.base_color_texture = Some(load_texture(texture_name, asset_server));
}
Expand All @@ -416,7 +418,7 @@ fn get_default_material(name: &str, side: Option<Team>) -> Option<StandardMateri
.contains(&name)
{
// primary
Color::rgb_u8(45, 49, 66)
Color::srgb_u8(45, 49, 66)
} else if [
"FutureTech.Materials.Reflective_Floor_V2_Mat",
"Proto_BBall.SM.BackBoard_Teams_MIC",
Expand All @@ -427,12 +429,12 @@ fn get_default_material(name: &str, side: Option<Team>) -> Option<StandardMateri
{
// secondary
match side {
Some(Team::Blue) => Color::rgb_u8(86, 136, 199),
Some(Team::Orange) => Color::rgb_u8(222, 145, 81),
None => Color::rgb_u8(131, 144, 115),
Some(Team::Blue) => Color::srgb_u8(86, 136, 199),
Some(Team::Orange) => Color::srgb_u8(222, 145, 81),
None => Color::srgb_u8(131, 144, 115),
}
} else if name == "OOBFloor_MAT_CUSTOM" {
Color::rgb_u8(41, 2, 0)
Color::srgb_u8(41, 2, 0)
} else if [
"FutureTech.Materials.Frame_01_MIC",
"FutureTech.Materials.Frame_01_V2_Mat",
Expand All @@ -448,25 +450,25 @@ fn get_default_material(name: &str, side: Option<Team>) -> Option<StandardMateri
|| name.contains("PaintedLine_MIC")
{
// tertiary
Color::rgb_u8(55, 30, 48)
Color::srgb_u8(55, 30, 48)
} else if [
"FutureTech.Materials.Frame_01_White_MIC",
"Graybox_Assets.Materials.ForceFieldCage_Solid_Mat",
]
.contains(&name)
{
Color::SILVER
Color::from(css::SILVER)
} else if name == "FutureTech.Materials.CrossHatched_Grate_MIC" {
Color::TOMATO
Color::from(css::TOMATO)
} else if [
"Pickup_Boost.Materials.BoostPad_Small_MIC",
"Pickup_Boost.Materials.BoostPad_Large_MIC",
]
.contains(&name)
{
Color::rgb_u8(152, 29, 23)
Color::srgb_u8(152, 29, 23)
} else if name.contains("Advert") || name.contains("DarkMetal") {
Color::rgb_u8(191, 192, 192)
Color::srgb_u8(191, 192, 192)
} else {
println!("Unknown material {name}");
return None;
Expand Down Expand Up @@ -510,7 +512,7 @@ pub fn get_material(
return material.clone();
}

let base_color = base_color.unwrap_or(Color::rgb(0.3, 0.3, 0.3));
let base_color = base_color.unwrap_or(Color::srgb(0.3, 0.3, 0.3));

material_names
.entry(key)
Expand Down Expand Up @@ -679,7 +681,7 @@ impl AssetLoader for PskxLoader {
reader: &'a mut Reader,
_settings: &'a Self::Settings,
load_context: &'a mut bevy::asset::LoadContext,
) -> bevy::utils::BoxedFuture<'a, Result<Self::Asset, Self::Error>> {
) -> impl ConditionalSendFuture<Output = Result<Self::Asset, Self::Error>> {
Box::pin(async move {
let mut bytes = Vec::new();
reader.read_to_end(&mut bytes).await?;
Expand Down
4 changes: 2 additions & 2 deletions src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl<const N: usize> ByteWriter<N> {

impl ToBytesExact<{ bool::NUM_BYTES * 4 }> for [bool; 4] {
fn to_bytes(&self) -> [u8; bool::NUM_BYTES * 4] {
let mut writer = ByteWriter::<{ bool::NUM_BYTES * 4 }>::new();
let mut writer = const { ByteWriter::<{ bool::NUM_BYTES * 4 }>::new() };
for item in self {
writer.write(item);
}
Expand Down Expand Up @@ -293,7 +293,7 @@ macro_rules! impl_to_bytes_exact {
($t:ty, $($p:ident),+) => {
impl ToBytesExact<{ Self::NUM_BYTES }> for $t {
fn to_bytes(&self) -> [u8; Self::NUM_BYTES] {
let mut writer = ByteWriter::<{ Self::NUM_BYTES }>::new();
let mut writer = const { ByteWriter::<{ Self::NUM_BYTES }>::new() };
$(writer.write(&self.$p);)+
writer.inner()
}
Expand Down
39 changes: 27 additions & 12 deletions src/camera.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
use crate::spectator::{Spectator, SpectatorPlugin, SpectatorSettings};
use bevy::{
pbr::{CascadeShadowConfigBuilder, DirectionalLightShadowMap},
color::palettes::css,
core_pipeline::tonemapping::Tonemapping,
pbr::{CascadeShadowConfigBuilder, DirectionalLightShadowMap, ShadowFilteringMethod},
prelude::*,
};
use serde::{Deserialize, Serialize};
use std::f32::consts::PI;

use bevy_atmosphere::prelude::*;
use bevy_framepace::{FramepacePlugin, FramepaceSettings};
use bevy_mod_picking::{
backends::raycast::{RaycastBackendSettings, RaycastPickable},
prelude::*,
};
use bevy_vector_shapes::prelude::*;
use serde::{Deserialize, Serialize};
use std::{f32::consts::PI, time::Duration};
use std::time::Duration;

#[cfg(feature = "ssao")]
use bevy::{
Expand Down Expand Up @@ -81,8 +85,10 @@ fn setup(mut commands: Commands) {
.into(),
transform: Transform::from_translation(Vec3::new(-3000., 1000., 0.)).looking_to(Vec3::X, Vec3::Y),
camera: Camera { hdr: true, ..default() },
tonemapping: Tonemapping::ReinhardLuminance,
..default()
},
ShadowFilteringMethod::Gaussian,
AtmosphereCamera::default(),
RaycastPickable,
Spectator,
Expand Down Expand Up @@ -111,7 +117,7 @@ fn setup(mut commands: Commands) {
"",
TextStyle {
font_size: BOOST_INDICATOR_FONT_SIZE,
color: Color::SILVER,
color: Color::from(css::SILVER),
..default()
},
)
Expand Down Expand Up @@ -141,7 +147,7 @@ fn setup(mut commands: Commands) {
"00m:00s",
TextStyle {
font_size: 40.0,
color: Color::DARK_GRAY,
color: Color::from(css::DARK_GRAY),
..default()
},
)
Expand Down Expand Up @@ -193,6 +199,7 @@ pub struct EntityName {
}

#[cfg(debug_assertions)]

impl EntityName {
#[inline]
pub const fn new(name: Box<str>) -> Self {
Expand All @@ -201,6 +208,7 @@ impl EntityName {
}

#[cfg(debug_assertions)]

impl From<&str> for EntityName {
#[inline]
fn from(name: &str) -> Self {
Expand All @@ -209,6 +217,7 @@ impl From<&str> for EntityName {
}

#[cfg(debug_assertions)]

impl From<String> for EntityName {
#[inline]
fn from(name: String) -> Self {
Expand All @@ -217,37 +226,43 @@ impl From<String> for EntityName {
}

#[derive(Component, Clone, Copy)]

pub struct HighlightedEntity;

pub struct CameraPlugin;

impl Plugin for CameraPlugin {
fn build(&self, app: &mut App) {
app.insert_resource(SpectatorSettings::default())
.insert_resource(FramepaceSettings {
{
app.insert_resource(FramepaceSettings {
limiter: bevy_framepace::Limiter::from_framerate(60.),
})
.insert_resource(AtmosphereModel::default())
.insert_resource(CycleTimer(Timer::new(
Duration::from_secs_f32(1. / 60.),
TimerMode::Repeating,
)))
.insert_resource(DaylightOffset::default())
.insert_resource(AtmosphereModel::default())
.insert_resource(RaycastBackendSettings {
require_markers: true,
..default()
})
.insert_resource(DirectionalLightShadowMap::default())
.add_plugins((
FramepacePlugin,
SpectatorPlugin,
DefaultPickingPlugins,
AtmospherePlugin,
Shape2dPlugin::default(),
))
.add_systems(Update, daylight_cycle);
}

app.insert_resource(SpectatorSettings::default())
.insert_resource(DaylightOffset::default())
.insert_resource(DirectionalLightShadowMap::default())
.add_plugins((
SpectatorPlugin,
#[cfg(feature = "ssao")]
TemporalAntiAliasPlugin,
))
.add_systems(Update, daylight_cycle)
.add_systems(Startup, setup);
}
}
34 changes: 17 additions & 17 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,28 @@ fn main() {
assets::uncook().unwrap();

App::new()
.init_state::<GameLoadState>()
.insert_resource(ServerPort {
primary_port,
secondary_port,
})
.add_plugins((DefaultPlugins
.set(ImagePlugin {
default_sampler: ImageSamplerDescriptor {
address_mode_u: ImageAddressMode::Repeat,
address_mode_v: ImageAddressMode::Repeat,
address_mode_w: ImageAddressMode::Repeat,
..default()
},
})
.set(WindowPlugin {
primary_window: Some(Window {
title: "RLViser-rs".into(),
present_mode: PresentMode::AutoNoVsync,
.add_plugins((
DefaultPlugins
.set(ImagePlugin {
default_sampler: ImageSamplerDescriptor {
address_mode_u: ImageAddressMode::Repeat,
address_mode_v: ImageAddressMode::Repeat,
address_mode_w: ImageAddressMode::Repeat,
..default()
},
})
.set(WindowPlugin {
primary_window: Some(Window {
title: "RLViser-rs".into(),
present_mode: PresentMode::AutoNoVsync,
..default()
}),
..default()
}),
..default()
}),))
.add_plugins((
LogDiagnosticsPlugin {
debug: cfg!(feature = "debug"),
..default()
Expand All @@ -80,5 +79,6 @@ fn main() {
udp::RocketSimPlugin,
assets::AssetsLoaderPlugin,
))
.init_state::<GameLoadState>()
.run();
}
Loading

0 comments on commit 7e2110a

Please sign in to comment.