-
Notifications
You must be signed in to change notification settings - Fork 0
Fancy terrain #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fancy terrain #33
Conversation
85a5e89
to
97bd2e0
Compare
176ed2b
to
2e19adc
Compare
src/lib.rs
Outdated
.filter(|chunk| { | ||
let chunk_position = chunk.position; | ||
let chunk = self.get_chunk_mut(chunk_position); | ||
chunk.is_none() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsure about this.
We want to exclude all chunks that already exist, so keep positions where chunks don't already exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wording 😂
The missile knows where it is..
src/lib.rs
Outdated
Self::new(Vec3::ZERO) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a shitton of messy duplicate code and tests. This made me super sad, so here is the cleaner version.
A shared lib ChunkManger 🎉
src/lib.rs
Outdated
let render_distance = 2; | ||
let chunks = ChunkManager::instantiate_chunks(position, render_distance); | ||
|
||
let render_diameter = render_distance * 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awkward name render_diameter
maybe there is a less shitty alternative..
|
||
let chunks: Vec<Chunk> = positions | ||
.into_iter() | ||
.into_par_iter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
speeeeeed
src/lib.rs
Outdated
} | ||
} | ||
|
||
pub fn instantiate_chunks_vec(position: Vec3, render_distance: Vec3) -> Vec<Chunk> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use case:
- smaller y render distance than x and z → less chunks to render as the map is more horizontal than vertical
src/lib.rs
Outdated
self.chunks.get(&[x as i32, y as i32, z as i32]) | ||
} | ||
|
||
pub fn get_chunk_mut(&mut self, position: Vec3) -> Option<&mut Chunk> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe there is a way to make this method not that "damp". idk how. this seemed sensible
pub use renet::*; | ||
|
||
// other crates | ||
pub use rayon::iter::IntoParallelIterator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This crate is so much fun 🥰
TODO: Revisit once codebase is less shitty
WIP: At the moment this PR only refactors how the chunks are managed. more work tbd.
New stuff
Todo