diff --git a/client/src/lib.rs b/client/src/lib.rs index 1fc6a8a740..cd2b3f617c 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -147,7 +147,7 @@ impl Client { frontend_events.append(&mut self.handle_new_messages()?); self.state.terrain().iter().for_each(|(k, _)| { - println!("Chunk at {:?}", k); + //println!("Chunk at {:?}", k); }); self.state.write_component( @@ -194,9 +194,9 @@ impl Client { { let chunk_pos = self.state.terrain().pos_key(pos.0.map(|e| e as i32)); - for i in chunk_pos.x - 1..chunk_pos.x + 1 { - for j in chunk_pos.y - 1..chunk_pos.y + 1 { - for k in -1..3 { + for i in chunk_pos.x - 2..chunk_pos.x + 2 { + for j in chunk_pos.y - 2..chunk_pos.y + 2 { + for k in 0..1 { let key = chunk_pos + Vec3::new(i, j, k); if self.state.terrain().get_key(key).is_none() && !self.pending_chunks.contains(&key) diff --git a/common/src/volumes/vol_map.rs b/common/src/volumes/vol_map.rs index fcf45d32cd..136ae987d2 100644 --- a/common/src/volumes/vol_map.rs +++ b/common/src/volumes/vol_map.rs @@ -73,6 +73,7 @@ impl SampleVol for VolMap { /// Note that the resultant volume does not carry forward metadata from the original chunks. fn sample(&self, range: Aabb) -> Result { // Return early if we don't have all the needed chunks that we need! + /* let min_chunk = Self::chunk_key(range.min); let max_chunk = Self::chunk_key(range.max - Vec3::one()); for x in min_chunk.x..=max_chunk.x { @@ -84,6 +85,7 @@ impl SampleVol for VolMap { } } } + */ let mut sample = Dyna::filled( range.size().map(|e| e as u32).into(), @@ -92,7 +94,7 @@ impl SampleVol for VolMap { ); for pos in sample.iter_positions() { - sample.set(pos, self.get(range.min + pos)?.clone()) + sample.set(pos, self.get(range.min + pos).map(|v| v.clone()).unwrap_or(V::empty())) .map_err(|err| VolMapErr::DynaErr(err))?; } diff --git a/server/src/lib.rs b/server/src/lib.rs index 1235b0faec..9904df0832 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -182,6 +182,7 @@ impl Server { // Fetch any generated `TerrainChunk`s and insert them into the terrain // Also, send the chunk data to anybody that is close by for (key, chunk) in self.chunk_rx.try_iter() { + println!("Generation finished {:?}", key); // Send the chunk to all nearby players for (entity, player, pos) in ( &self.state.ecs().entities(), @@ -193,12 +194,11 @@ impl Server { // TODO: Distance check // if self.state.terrain().key_pos(key) - /* + println!("Send to player {:?}", key); self.clients.notify(entity, ServerMsg::TerrainChunkUpdate { key, chunk: Box::new(chunk.clone()), }); - */ } self.state.insert_chunk(key, chunk); @@ -322,10 +322,10 @@ impl Server { } ClientState::Spectator | ClientState::Character => { match state.terrain().get_key(key) { - Some(chunk) => {} /*client.postbox.send_message(ServerMsg::TerrainChunkUpdate { - key, - chunk: Box::new(chunk.clone()), - }),*/ + Some(chunk) => client.postbox.send_message(ServerMsg::TerrainChunkUpdate { + key, + chunk: Box::new(chunk.clone()), + }), None => requested_chunks.push(key), } } diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index 2c33d61d00..45c9431eb2 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -99,14 +99,22 @@ impl Terrain { // What happens if the block on the edge of a chunk gets modified? We need to spawn // a mesh worker to remesh its neighbour(s) too since their ambient occlusion and face // elision information changes too! - match self.mesh_todo.iter_mut().find(|todo| todo.pos == *pos) { - Some(todo) => todo.started_tick = current_tick, - // The chunk it's queued yet, add it to the queue - None => self.mesh_todo.push_back(ChunkMeshState { - pos: *pos, - started_tick: current_tick, - active_worker: false, - }), + for i in -1..2 { + for j in -1..2 { + for k in -1..2 { + let pos = pos + Vec3::new(i, j, k); + + match self.mesh_todo.iter_mut().find(|todo| todo.pos == pos) { + Some(todo) => todo.started_tick = current_tick, + // The chunk it's queued yet, add it to the queue + None => self.mesh_todo.push_back(ChunkMeshState { + pos, + started_tick: current_tick, + active_worker: false, + }), + } + } + } } }