forked from feather-rs/feather
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.rs
More file actions
18 lines (15 loc) · 697 Bytes
/
Copy pathutil.rs
File metadata and controls
18 lines (15 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Utilities for world generation.
use base::ChunkPosition;
/// Deterministically a seed for the given chunk. This allows
/// different seeds to be used for different chunk.
pub fn shuffle_seed_for_chunk(seed: u64, chunk: ChunkPosition) -> u64 {
seed.wrapping_mul((chunk.x as u64).wrapping_add(1))
.wrapping_add((chunk.z as u64).wrapping_add(1))
}
/// Deterministically shuffles a seed for the given chunk and chunk column.
pub fn shuffle_seed_for_column(seed: u64, chunk: ChunkPosition, col_x: usize, col_z: usize) -> u64 {
shuffle_seed_for_chunk(seed, chunk)
.wrapping_add(2)
.wrapping_mul(((col_x as u64) << 4) + 4)
.wrapping_mul(col_z as u64 + 4)
}