From aa12121f001897bf05434fdc6f771d1da26bbf20 Mon Sep 17 00:00:00 2001 From: VirxEC Date: Sat, 18 May 2024 20:34:11 -0400 Subject: [PATCH] Ignore ball rot in packets On-by-default option that's toggleable --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/gui.rs | 22 ++++++++++++++++++++++ src/udp.rs | 48 ++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 64 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79f36d4..fad3b8c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3037,7 +3037,7 @@ checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" [[package]] name = "rlviser" -version = "0.7.2" +version = "0.7.3" dependencies = [ "ahash", "bevy", diff --git a/Cargo.toml b/Cargo.toml index 2f41d7a..cdf4c7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -version = "0.7.2" +version = "0.7.3" name = "rlviser" edition = "2021" publish = false diff --git a/src/gui.rs b/src/gui.rs index 2b3dc91..402c351 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -97,6 +97,7 @@ impl Plugin for DebugOverlayPlugin { .insert_resource(PacketSendTime::default()) .insert_resource(RenderInfo::default()) .insert_resource(UpdateRenderInfoTime::default()) + .insert_resource(CalcBallRot::default()) .add_event::() .add_event::() .add_event::() @@ -120,6 +121,7 @@ impl Plugin for DebugOverlayPlugin { update_allow_rendering, update_render_info, update_interpolation, + update_calc_ball_rot, update_ball_info.run_if(resource_equals(EnableBallInfo(true))), update_car_info.run_if(|enable_menu: Res| !enable_menu.0.is_empty()), update_boost_pad_info.run_if(|enable_menu: Res| !enable_menu.0.is_empty()), @@ -146,6 +148,16 @@ impl Plugin for DebugOverlayPlugin { } } +#[derive(Resource)] +pub struct CalcBallRot(pub bool); + +impl Default for CalcBallRot { + #[inline] + fn default() -> Self { + Self(true) + } +} + #[derive(Resource, Default, PartialEq, Eq)] pub struct EnableBallInfo(bool); @@ -776,6 +788,7 @@ struct Options { mouse_sensitivity: f32, allow_rendering: bool, interpolation: bool, + calc_ball_rot: bool, } impl Default for Options { @@ -800,6 +813,7 @@ impl Default for Options { mouse_sensitivity: 1., allow_rendering: true, interpolation: false, + calc_ball_rot: true, } } } @@ -846,6 +860,7 @@ impl Options { "mouse_sensitivity" => options.mouse_sensitivity = value.parse().unwrap(), "allow_rendering" => options.allow_rendering = value.parse().unwrap(), "interpolation" => options.interpolation = value.parse().unwrap(), + "calc_ball_rot" => options.calc_ball_rot = value.parse().unwrap(), _ => println!("Unknown key {key} with value {value}"), } } @@ -883,6 +898,7 @@ impl Options { file.write_fmt(format_args!("mouse_sensitivity={}\n", self.mouse_sensitivity))?; file.write_fmt(format_args!("allow_rendering={}\n", self.allow_rendering))?; file.write_fmt(format_args!("interpolation={}\n", self.interpolation))?; + file.write_fmt(format_args!("calc_ball_rot={}\n", self.calc_ball_rot))?; Ok(()) } @@ -907,6 +923,7 @@ impl Options { || self.mouse_sensitivity != other.mouse_sensitivity || self.allow_rendering != other.allow_rendering || self.interpolation != other.interpolation + || self.calc_ball_rot != other.calc_ball_rot } } @@ -1022,6 +1039,7 @@ fn ui_system( }); ui.checkbox(&mut options.interpolation, "Packet Interpolation"); + ui.checkbox(&mut options.calc_ball_rot, "Ignore packet ball rotation"); ui.menu_button("Open rendering manager", |ui| { ui.checkbox(&mut options.allow_rendering, "Allow rendering"); @@ -1152,6 +1170,10 @@ fn toggle_vsync(options: Res, mut framepace: ResMut) }; } +fn update_calc_ball_rot(options: Res, mut calc_ball_rot: ResMut) { + calc_ball_rot.0 = options.calc_ball_rot; +} + #[cfg(not(feature = "ssao"))] fn update_msaa(options: Res, mut msaa: ResMut) { const MSAA_SAMPLES: [u32; 4] = [1, 2, 4, 8]; diff --git a/src/udp.rs b/src/udp.rs index 0969b7f..aa852a1 100644 --- a/src/udp.rs +++ b/src/udp.rs @@ -2,7 +2,7 @@ use crate::{ assets::{get_material, get_mesh_info, BoostPickupGlows, CarWheelMesh}, bytes::{FromBytes, ToBytes, ToBytesExact}, camera::{BoostAmount, HighlightedEntity, PrimaryCamera, TimeDisplay, BOOST_INDICATOR_FONT_SIZE, BOOST_INDICATOR_POS}, - gui::{BallCam, GameSpeed, ShowTime, UiScale, UserCarStates}, + gui::{BallCam, CalcBallRot, GameSpeed, ShowTime, UiScale, UserCarStates}, mesh::{BoostPadClicked, CarClicked, ChangeCarPos, LargeBoostPadLocRots}, morton::Morton, renderer::{RenderGroups, RenderMessage, UdpRendererPlugin}, @@ -382,6 +382,7 @@ pub struct PausedUpdate(pub bool); fn handle_udp( socket: Res, game_speed: Res, + calc_ball_rot: Res, mut game_state: ResMut, mut exit: EventWriter, mut packet_updated: ResMut, @@ -516,7 +517,14 @@ fn handle_udp( } packet_updated.0 = true; - *game_state = GameState::from_bytes(&buf); + + let mut new_game_state = GameState::from_bytes(&buf); + + if calc_ball_rot.0 { + new_game_state.ball.rot_mat = game_state.ball.rot_mat; + }; + + *game_state = new_game_state; } fn update_ball( @@ -1103,15 +1111,24 @@ fn update_field(state: Res, mut game_mode: ResMut, mut load } } -fn interpolate_packet(mut state: ResMut, game_speed: Res, time: Res