mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'zesterer/network-tweaks' into 'master'
Reduced rubber-banding and interpolation jerk without significantly impacting upon network usage See merge request veloren/veloren!1935
This commit is contained in:
commit
6c939b35b8
@ -45,7 +45,7 @@ impl<T: 'static + Send + Sync> Component for InterpBuffer<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0 is pure physics, 1 is pure extrapolation
|
// 0 is pure physics, 1 is pure extrapolation
|
||||||
const PHYSICS_VS_EXTRAPOLATION_FACTOR: f32 = 0.2;
|
const PHYSICS_VS_EXTRAPOLATION_FACTOR: f32 = 0.1;
|
||||||
const POSITION_INTERP_SANITY: Option<f32> = None;
|
const POSITION_INTERP_SANITY: Option<f32> = None;
|
||||||
const VELOCITY_INTERP_SANITY: Option<f32> = None;
|
const VELOCITY_INTERP_SANITY: Option<f32> = None;
|
||||||
const ENABLE_POSITION_HERMITE: bool = false;
|
const ENABLE_POSITION_HERMITE: bool = false;
|
||||||
|
@ -199,14 +199,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
.map(|msg| client.send_prepared(&msg));
|
.map(|msg| client.send_prepared(&msg));
|
||||||
});
|
});
|
||||||
|
|
||||||
enum PhysInsert {
|
|
||||||
Pos(Pos),
|
|
||||||
Vel(Vel),
|
|
||||||
Ori(Ori),
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut last_inserts = Vec::new();
|
|
||||||
|
|
||||||
for (client, _, client_entity, client_pos) in &mut subscribers {
|
for (client, _, client_entity, client_pos) in &mut subscribers {
|
||||||
let mut comp_sync_package = CompSyncPackage::new();
|
let mut comp_sync_package = CompSyncPackage::new();
|
||||||
|
|
||||||
@ -237,24 +229,25 @@ impl<'a> System<'a> for Sys {
|
|||||||
let id_staggered_tick = tick + entity.id() as u64;
|
let id_staggered_tick = tick + entity.id() as u64;
|
||||||
|
|
||||||
// More entities farther away so checks start there
|
// More entities farther away so checks start there
|
||||||
if distance_sq > 350.0f32.powi(2) {
|
if distance_sq > 500.0f32.powi(2) {
|
||||||
id_staggered_tick % 64 == 0
|
|
||||||
} else if distance_sq > 180.0f32.powi(2) {
|
|
||||||
id_staggered_tick % 32 == 0
|
id_staggered_tick % 32 == 0
|
||||||
} else if distance_sq > 100.0f32.powi(2) {
|
} else if distance_sq > 300.0f32.powi(2) {
|
||||||
id_staggered_tick % 16 == 0
|
id_staggered_tick % 16 == 0
|
||||||
} else if distance_sq > 48.0f32.powi(2) {
|
} else if distance_sq > 200.0f32.powi(2) {
|
||||||
id_staggered_tick % 8 == 0
|
id_staggered_tick % 8 == 0
|
||||||
} else if distance_sq > 24.0f32.powi(2) {
|
} else if distance_sq > 120.0f32.powi(2) {
|
||||||
id_staggered_tick % 4 == 0
|
id_staggered_tick % 6 == 0
|
||||||
} else {
|
} else if distance_sq > 64.0f32.powi(2) {
|
||||||
id_staggered_tick % 3 == 0
|
id_staggered_tick % 3 == 0
|
||||||
|
} else if distance_sq > 24.0f32.powi(2) {
|
||||||
|
id_staggered_tick % 2 == 0
|
||||||
|
} else {
|
||||||
|
true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if last_pos.get(entity).is_none() {
|
if last_pos.get(entity).is_none() {
|
||||||
comp_sync_package.comp_inserted(uid, pos);
|
comp_sync_package.comp_inserted(uid, pos);
|
||||||
last_inserts.push((entity, PhysInsert::Pos(pos)));
|
|
||||||
} else if send_now {
|
} else if send_now {
|
||||||
comp_sync_package.comp_modified(uid, pos);
|
comp_sync_package.comp_modified(uid, pos);
|
||||||
}
|
}
|
||||||
@ -262,7 +255,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
vel.map(|v| {
|
vel.map(|v| {
|
||||||
if last_vel.get(entity).is_none() {
|
if last_vel.get(entity).is_none() {
|
||||||
comp_sync_package.comp_inserted(uid, *v);
|
comp_sync_package.comp_inserted(uid, *v);
|
||||||
last_inserts.push((entity, PhysInsert::Vel(*v)));
|
|
||||||
} else if send_now {
|
} else if send_now {
|
||||||
comp_sync_package.comp_modified(uid, *v);
|
comp_sync_package.comp_modified(uid, *v);
|
||||||
}
|
}
|
||||||
@ -271,7 +263,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
ori.map(|o| {
|
ori.map(|o| {
|
||||||
if last_ori.get(entity).is_none() {
|
if last_ori.get(entity).is_none() {
|
||||||
comp_sync_package.comp_inserted(uid, *o);
|
comp_sync_package.comp_inserted(uid, *o);
|
||||||
last_inserts.push((entity, PhysInsert::Ori(*o)));
|
|
||||||
} else if send_now {
|
} else if send_now {
|
||||||
comp_sync_package.comp_modified(uid, *o);
|
comp_sync_package.comp_modified(uid, *o);
|
||||||
}
|
}
|
||||||
@ -281,18 +272,19 @@ impl<'a> System<'a> for Sys {
|
|||||||
client.send_fallible(ServerGeneral::CompSync(comp_sync_package));
|
client.send_fallible(ServerGeneral::CompSync(comp_sync_package));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (entity, insert) in last_inserts {
|
// Update the last physics components for each entity
|
||||||
match insert {
|
for (_, entity, &pos, vel, ori) in (
|
||||||
PhysInsert::Pos(pos) => {
|
region.entities(),
|
||||||
|
&entities,
|
||||||
|
&positions,
|
||||||
|
velocities.maybe(),
|
||||||
|
orientations.maybe(),
|
||||||
|
)
|
||||||
|
.join()
|
||||||
|
{
|
||||||
let _ = last_pos.insert(entity, Last(pos));
|
let _ = last_pos.insert(entity, Last(pos));
|
||||||
},
|
vel.map(|v| last_vel.insert(entity, Last(*v)));
|
||||||
PhysInsert::Vel(vel) => {
|
ori.map(|o| last_ori.insert(entity, Last(*o)));
|
||||||
let _ = last_vel.insert(entity, Last(vel));
|
|
||||||
},
|
|
||||||
PhysInsert::Ori(ori) => {
|
|
||||||
let _ = last_ori.insert(entity, Last(ori));
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user