mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
renames and comments
This commit is contained in:
parent
2eae780e71
commit
7d37646dac
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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),
|
||||
|
@ -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,
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user