mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
client local time
This commit is contained in:
parent
472b996c8e
commit
72db9b61b3
@ -16,7 +16,7 @@ layout(std140, set = 0, binding = 0) uniform u_globals {
|
|||||||
vec4 moon_dir;
|
vec4 moon_dir;
|
||||||
// .x = The `Time` resource, repeated every `tick_overflow`
|
// .x = The `Time` resource, repeated every `tick_overflow`
|
||||||
// .y = a floored (`Time` / `tick_overflow`)
|
// .y = a floored (`Time` / `tick_overflow`)
|
||||||
// .z = `Time`, not recommended to be used as it might have low precision
|
// .z = Client time, not synced between clients.
|
||||||
vec4 tick;
|
vec4 tick;
|
||||||
vec4 screen_res;
|
vec4 screen_res;
|
||||||
uvec4 light_shadow_count;
|
uvec4 light_shadow_count;
|
||||||
|
@ -106,6 +106,7 @@ impl Globals {
|
|||||||
map_bounds: Vec2<f32>,
|
map_bounds: Vec2<f32>,
|
||||||
time_of_day: f64,
|
time_of_day: f64,
|
||||||
tick: f64,
|
tick: f64,
|
||||||
|
client_tick: f64,
|
||||||
screen_res: Vec2<u16>,
|
screen_res: Vec2<u16>,
|
||||||
shadow_planes: Vec2<f32>,
|
shadow_planes: Vec2<f32>,
|
||||||
light_count: usize,
|
light_count: usize,
|
||||||
@ -147,7 +148,7 @@ impl Globals {
|
|||||||
tick: [
|
tick: [
|
||||||
(tick % TIME_OVERFLOW) as f32,
|
(tick % TIME_OVERFLOW) as f32,
|
||||||
(tick / TIME_OVERFLOW).floor() as f32,
|
(tick / TIME_OVERFLOW).floor() as f32,
|
||||||
tick as f32,
|
client_tick as f32,
|
||||||
0.0,
|
0.0,
|
||||||
],
|
],
|
||||||
// Provide the shadow map far plane as well.
|
// Provide the shadow map far plane as well.
|
||||||
@ -224,6 +225,7 @@ impl Default for Globals {
|
|||||||
Vec2::new(140.0, 2048.0),
|
Vec2::new(140.0, 2048.0),
|
||||||
0.0,
|
0.0,
|
||||||
0.0,
|
0.0,
|
||||||
|
0.0,
|
||||||
Vec2::new(800, 500),
|
Vec2::new(800, 500),
|
||||||
Vec2::new(1.0, 25.0),
|
Vec2::new(1.0, 25.0),
|
||||||
0,
|
0,
|
||||||
|
@ -33,7 +33,7 @@ use common::{
|
|||||||
calendar::Calendar,
|
calendar::Calendar,
|
||||||
comp::{self, ship::figuredata::VOXEL_COLLIDER_MANIFEST},
|
comp::{self, ship::figuredata::VOXEL_COLLIDER_MANIFEST},
|
||||||
outcome::Outcome,
|
outcome::Outcome,
|
||||||
resources::DeltaTime,
|
resources::{DeltaTime, TimeScale},
|
||||||
terrain::{BlockKind, TerrainChunk, TerrainGrid},
|
terrain::{BlockKind, TerrainChunk, TerrainGrid},
|
||||||
vol::ReadVol,
|
vol::ReadVol,
|
||||||
};
|
};
|
||||||
@ -113,6 +113,7 @@ pub struct Scene {
|
|||||||
wind_vel: Vec2<f32>,
|
wind_vel: Vec2<f32>,
|
||||||
pub interpolated_time_of_day: Option<f64>,
|
pub interpolated_time_of_day: Option<f64>,
|
||||||
last_lightning: Option<(Vec3<f32>, f64)>,
|
last_lightning: Option<(Vec3<f32>, f64)>,
|
||||||
|
client_time: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SceneData<'a> {
|
pub struct SceneData<'a> {
|
||||||
@ -348,6 +349,7 @@ impl Scene {
|
|||||||
wind_vel: Vec2::zero(),
|
wind_vel: Vec2::zero(),
|
||||||
interpolated_time_of_day: None,
|
interpolated_time_of_day: None,
|
||||||
last_lightning: None,
|
last_lightning: None,
|
||||||
|
client_time: 0.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,6 +525,8 @@ impl Scene {
|
|||||||
|
|
||||||
let dt = ecs.fetch::<DeltaTime>().0;
|
let dt = ecs.fetch::<DeltaTime>().0;
|
||||||
|
|
||||||
|
self.client_time += dt as f64 * ecs.fetch::<TimeScale>().0;
|
||||||
|
|
||||||
let positions = ecs.read_storage::<comp::Pos>();
|
let positions = ecs.read_storage::<comp::Pos>();
|
||||||
|
|
||||||
let viewpoint_pos = if let Some(viewpoint_pos) =
|
let viewpoint_pos = if let Some(viewpoint_pos) =
|
||||||
@ -846,6 +850,7 @@ impl Scene {
|
|||||||
self.map_bounds,
|
self.map_bounds,
|
||||||
time_of_day,
|
time_of_day,
|
||||||
scene_data.state.get_time(),
|
scene_data.state.get_time(),
|
||||||
|
self.client_time,
|
||||||
renderer.resolution().as_(),
|
renderer.resolution().as_(),
|
||||||
Vec2::new(SHADOW_NEAR, SHADOW_FAR),
|
Vec2::new(SHADOW_NEAR, SHADOW_FAR),
|
||||||
lights.len(),
|
lights.len(),
|
||||||
|
@ -272,6 +272,7 @@ impl Scene {
|
|||||||
self.map_bounds,
|
self.map_bounds,
|
||||||
TIME,
|
TIME,
|
||||||
scene_data.time,
|
scene_data.time,
|
||||||
|
0.0,
|
||||||
renderer.resolution().as_(),
|
renderer.resolution().as_(),
|
||||||
Vec2::new(SHADOW_NEAR, SHADOW_FAR),
|
Vec2::new(SHADOW_NEAR, SHADOW_FAR),
|
||||||
0,
|
0,
|
||||||
|
Loading…
Reference in New Issue
Block a user