Significantly upped view distances

Former-commit-id: 4cd306ebfa1acd765cb68d4a6d5a026b43fafa2f
This commit is contained in:
Joshua Barretto 2019-05-01 12:01:50 +01:00
parent 3cd48ba468
commit 342ea6aa65
3 changed files with 9 additions and 5 deletions

View File

@ -195,7 +195,7 @@ impl Client {
// Remove chunks that are too far from the player
let mut chunks_to_remove = Vec::new();
self.state.terrain().iter().for_each(|(key, _)| {
if (Vec2::from(chunk_pos) - Vec2::from(key)).map(|e: i32| e.abs()).reduce_max() > 3 {
if (Vec2::from(chunk_pos) - Vec2::from(key)).map(|e: i32| e.abs()).reduce_max() > 6 {
chunks_to_remove.push(key);
}
});
@ -204,8 +204,8 @@ impl Client {
}
// Request chunks from the server
for i in chunk_pos.x - 2..chunk_pos.x + 3 {
for j in chunk_pos.y - 2..chunk_pos.y + 3 {
for i in chunk_pos.x - 4..chunk_pos.x + 5 {
for j in chunk_pos.y - 4..chunk_pos.y + 5 {
for k in 0..2 {
let key = Vec3::new(i, j, k);
if self.state.terrain().get_key(key).is_none()

View File

@ -196,6 +196,10 @@ impl<S: PostMsg, R: PostMsg> PostBox<S, R> {
let msg_bytes = bincode::serialize(&send_msg).unwrap();
let mut msg_bytes = lz4_compress::compress(&msg_bytes);
if msg_bytes.len() > 512 {
println!("MSG SIZE: {}", msg_bytes.len());
}
// Assemble into packet
let mut packet_bytes = msg_bytes
.len()

View File

@ -193,7 +193,7 @@ impl Server {
let chunk_pos = self.state.terrain().pos_key(pos.0.map(|e| e as i32));
let dist = (Vec2::from(chunk_pos) - Vec2::from(key)).map(|e: i32| e.abs()).reduce_max();
if dist < 4 {
if dist < 5 {
self.clients.notify(
entity,
ServerMsg::TerrainChunkUpdate {
@ -225,7 +225,7 @@ impl Server {
min_dist = min_dist.min(dist);
}
if min_dist > 3 {
if min_dist > 6 {
chunks_to_remove.push(key);
}
});