Added partial chunk loading, package section to workspace Cargo.toml

Former-commit-id: 4164daf4ccbe6695f664a44d0fce0ee10df39b8d
This commit is contained in:
Joshua Barretto 2019-04-12 10:09:14 +01:00
parent 507c47e771
commit 3112486005
3 changed files with 28 additions and 0 deletions

View File

@ -1,3 +1,9 @@
[package]
name = "veloren"
description = "Veloren is an open-world, open-source multiplayer voxel RPG."
documentation = "https://docs.veloren.net"
repository = "https://www.gitlab.com/veloren/veloren"
[workspace] [workspace]
members = [ members = [
"common", "common",

View File

@ -144,6 +144,10 @@ impl Client {
// Handle new messages from the server // Handle new messages from the server
frontend_events.append(&mut self.handle_new_messages()?); frontend_events.append(&mut self.handle_new_messages()?);
self.state.terrain().iter().for_each(|(k, _)| {
println!("Chunk at {:?}", k);
});
// Step 1 // Step 1
if let Some(ecs_entity) = self.player { if let Some(ecs_entity) = self.player {
// TODO: remove this // TODO: remove this

View File

@ -141,4 +141,22 @@ impl<V: Vox, S: VolSize, M> VolMap<V, S, M> {
pub fn pos_key(&self, pos: Vec3<i32>) -> Vec3<i32> { pub fn pos_key(&self, pos: Vec3<i32>) -> Vec3<i32> {
Self::chunk_key(pos) Self::chunk_key(pos)
} }
pub fn iter<'a>(&'a self) -> ChunkIter<'a, V, S, M> {
ChunkIter {
iter: self.chunks.iter(),
}
}
}
pub struct ChunkIter<'a, V: Vox, S: VolSize, M> {
iter: std::collections::hash_map::Iter<'a, Vec3<i32>, Chunk<V, S, M>>,
}
impl<'a, V: Vox, S: VolSize, M> Iterator for ChunkIter<'a, V, S, M> {
type Item = (Vec3<i32>, &'a Chunk<V, S, M>);
fn next(&mut self) -> Option<Self::Item> {
self.iter.next().map(|(k, c)| (*k, c))
}
} }