From 7d37646dac1a063e386505317eb6c86bc9ec917b Mon Sep 17 00:00:00 2001 From: Isse Date: Thu, 28 Sep 2023 17:21:52 +0200 Subject: [PATCH] renames and comments --- assets/voxygen/shaders/include/globals.glsl | 10 +++++----- assets/voxygen/shaders/particle-vert.glsl | 4 +++- voxygen/src/render/pipelines/mod.rs | 10 +++++----- voxygen/src/render/pipelines/particle.rs | 4 ++-- voxygen/src/session/mod.rs | 2 ++ 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/assets/voxygen/shaders/include/globals.glsl b/assets/voxygen/shaders/include/globals.glsl index 41580c5d0d..5a6c58a871 100644 --- a/assets/voxygen/shaders/include/globals.glsl +++ b/assets/voxygen/shaders/include/globals.glsl @@ -39,11 +39,11 @@ mat4 threshold_matrix = mat4( float distance_divider = 2; float shadow_dithering = 0.5; -float tick_loop_time = 300000.0; +float tick_overflow = 300000.0; // Get a scaled time with an offset that loops at a period. float tick_loop(float period, float scale, float offset) { - float loop = tick_loop_time * scale; + float loop = tick_overflow * scale; float rem = mod(loop, period); float rest = rem * tick.y; @@ -56,16 +56,16 @@ float tick_loop(float period) { vec4 tick_loop4(float period, vec4 scale, vec4 offset) { - vec4 loop = tick_loop_time * scale; + vec4 loop = tick_overflow * scale; vec4 rem = mod(loop, period); vec4 rest = rem * tick.y; return mod(rest + tick.x * scale + offset, period); } -// Only works if t happened within tick_loop_time +// Only works if t happened within tick_overflow float time_since(float t) { - return tick.x < t ? (tick_loop_time - t + tick.x) : (tick.x - t); + return tick.x < t ? (tick_overflow - t + tick.x) : (tick.x - t); } #endif diff --git a/assets/voxygen/shaders/particle-vert.glsl b/assets/voxygen/shaders/particle-vert.glsl index 494d15e2ea..844caea3ec 100644 --- a/assets/voxygen/shaders/particle-vert.glsl +++ b/assets/voxygen/shaders/particle-vert.glsl @@ -96,9 +96,11 @@ struct Attr { float lifetime = time_since(inst_time); +// Retrieves inst_time, repeating over a period. This will be consistent +// over a time overflow. float loop_inst_time(float period) { if (tick.x < inst_time) { - return mod(mod(tick_loop_time, period) + inst_time, period); + return mod(mod(tick_overflow, period) + inst_time, period); } else { return mod(inst_time, period); } diff --git a/voxygen/src/render/pipelines/mod.rs b/voxygen/src/render/pipelines/mod.rs index ac907be720..4545ade835 100644 --- a/voxygen/src/render/pipelines/mod.rs +++ b/voxygen/src/render/pipelines/mod.rs @@ -91,7 +91,7 @@ pub struct Shadow { pos_radius: [f32; 4], } -pub const TIME_PRECISION: f64 = 300000.0; +pub const TIME_OVERFLOW: f64 = 300000.0; impl Globals { /// Create global consts from the provided parameters. @@ -131,15 +131,15 @@ impl Globals { view_distance: [view_distance, tgt_detail, map_bounds.x, map_bounds.y], time_of_day: [ (time_of_day % (3600.0 * 24.0)) as f32, - (time_of_day / (3600.0 * 24.0) % TIME_PRECISION) as f32, + (time_of_day / (3600.0 * 24.0) % TIME_OVERFLOW) as f32, 0.0, 0.0, ], sun_dir: Vec4::from_direction(Self::get_sun_dir(time_of_day)).into_array(), moon_dir: Vec4::from_direction(Self::get_moon_dir(time_of_day)).into_array(), tick: [ - (tick % TIME_PRECISION) as f32, - (tick / TIME_PRECISION).floor() as f32, + (tick % TIME_OVERFLOW) as f32, + (tick / TIME_OVERFLOW).floor() as f32, tick as f32, 0.0, ], @@ -177,7 +177,7 @@ impl Globals { gamma_exposure: [gamma, exposure, 0.0, 0.0], last_lightning: last_lightning .0 - .with_w((last_lightning.1 % TIME_PRECISION) as f32) + .with_w((last_lightning.1 % TIME_OVERFLOW) as f32) .into_array(), wind_vel: wind_vel.into_array(), ambiance: ambiance.clamped(0.0, 1.0), diff --git a/voxygen/src/render/pipelines/particle.rs b/voxygen/src/render/pipelines/particle.rs index 05ff056caf..f81a807cea 100644 --- a/voxygen/src/render/pipelines/particle.rs +++ b/voxygen/src/render/pipelines/particle.rs @@ -147,7 +147,7 @@ impl Instance { ) -> Self { use rand::Rng; Self { - inst_time: (inst_time % super::TIME_PRECISION) as f32, + inst_time: (inst_time % super::TIME_OVERFLOW) as f32, inst_lifespan: lifespan, inst_entropy: rand::thread_rng().gen(), inst_mode: inst_mode as i32, @@ -165,7 +165,7 @@ impl Instance { ) -> Self { use rand::Rng; Self { - inst_time: (inst_time % super::TIME_PRECISION) as f32, + inst_time: (inst_time % super::TIME_OVERFLOW) as f32, inst_lifespan: lifespan, inst_entropy: rand::thread_rng().gen(), inst_mode: inst_mode as i32, diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index a62c4c57ef..bc3a24d512 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -1196,6 +1196,8 @@ impl PlayState for SessionState { self.viewpoint_entity = None; self.scene.camera_mut().set_mode(CameraMode::Freefly); let mut ori = self.scene.camera().get_orientation(); + // Remove any roll that could have possibly been set to the + // camera as a result of spectating. ori.z = 0.0; self.scene.camera_mut().set_orientation(ori); } else if let Some(interactable) = &self.interactable {