Skip to content

Conversation

CuddlyBunion341
Copy link
Owner

@CuddlyBunion341 CuddlyBunion341 commented Jan 25, 2025

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

  • Increased world size
  • Optimized chunk batch response handling using parallel iteration (useful now that the world is bigger)

Todo

  • Add surface stone
  • Update density scale to allow for canyons
  • Look into Cave Gen?
  • Experiment with block pallete
  • ORES

@CuddlyBunion341 CuddlyBunion341 self-assigned this Jan 25, 2025
@CuddlyBunion341 CuddlyBunion341 mentioned this pull request Jan 25, 2025
3 tasks
src/lib.rs Outdated
.filter(|chunk| {
let chunk_position = chunk.position;
let chunk = self.get_chunk_mut(chunk_position);
chunk.is_none()
Copy link
Owner Author

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

Copy link
Owner Author

@CuddlyBunion341 CuddlyBunion341 Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/lib.rs Outdated
Self::new(Vec3::ZERO)
}
}

Copy link
Owner Author

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;
Copy link
Owner Author

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()
Copy link
Owner Author

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> {
Copy link
Owner Author

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> {
Copy link
Owner Author

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;
Copy link
Owner Author

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 🥰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant