CHANGE, client time lerp would cause flashing lights for large discrepancies, it now no longer lerps if the flashing lights setting is not on

This commit is contained in:
pepsalt 2022-08-26 13:45:00 +01:00 committed by LunarEclipse
parent 3e580138df
commit 775025ac63
2 changed files with 30 additions and 2 deletions

View File

@ -252,8 +252,10 @@ pub struct Client {
tick: u64,
state: State,
server_view_distance_limit: Option<u32>,
flashing_lights_enabled: bool,
/// Terrrain view distance
server_view_distance_limit: Option<u32>,
view_distance: Option<u32>,
lod_distance: f32,
// TODO: move into voxygen
@ -731,6 +733,9 @@ impl Client {
tick: 0,
state,
flashing_lights_enabled: true,
server_view_distance_limit: None,
view_distance: None,
lod_distance: 4.0,
@ -1003,6 +1008,10 @@ impl Client {
self.lod_distance = lod_distance;
}
pub fn set_flashing_lights_enabled(&mut self, flashing_lights_enabled: bool){
self.flashing_lights_enabled = flashing_lights_enabled;
}
pub fn use_slot(&mut self, slot: Slot) {
self.control_action(ControlAction::InventoryAction(InventoryAction::Use(slot)))
}
@ -1766,12 +1775,25 @@ impl Client {
// Lerp towards the target time of day - this ensures a smooth transition for
// large jumps in TimeOfDay such as when using /time
const DAY: f64 = 86400.0;
if let Some(target_tod) = self.target_time_of_day {
let mut tod = self.state.ecs_mut().write_resource::<TimeOfDay>();
tod.0 = Lerp::lerp(tod.0, target_tod.0, dt.as_secs_f64());
// When the target time of day and time of day have a large discrepancy
// (i.e two days), the linear interpolation causes brght flashing effects
// in the sky. This will instantly set the time of day to the target
// time of day for the client to avoid the flashing effect if flashing
// lights is disabled.
if !self.flashing_lights_enabled && target_tod.0 - tod.0 >= DAY*2 {
tod.0 = target_tod.0;
} else {
tod.0 = Lerp::lerp(tod.0, target_tod.0, dt.as_secs_f64());
}
if tod.0 >= target_tod.0 {
self.target_time_of_day = None;
}
}
// 4) Tick the client's LocalState

View File

@ -470,7 +470,13 @@ impl SettingsChange {
.renderer_mut()
.set_render_mode((*new_render_mode).clone())
.unwrap();
session_state
.client
.borrow_mut()
.set_flashing_lights_enabled((*new_render_mode).flashing_lights_enabled);
settings.graphics.render_mode = *new_render_mode;
},
Graphics::ChangeFullscreenMode(new_fullscreen_settings) => {
global_state