experimenting with water surface mesh

This commit is contained in:
2024-10-19 01:33:03 -04:00
parent b61dacf5e2
commit cc3e43da16
17 changed files with 263 additions and 124 deletions

View File

@@ -6,6 +6,7 @@ pub struct MeshChunkData {
pub heights: [f32; Chunk::AREA],
pub textures: [[u32; 2]; Chunk::AREA],
pub min_height: f32,
pub sealevel: f32,
}
impl MeshChunkData {
@@ -22,4 +23,18 @@ impl MeshChunkData {
return data;
}
pub fn get_neighbors_map_bounded(&self, coord: &HexCoord, width: usize, height: usize) -> [f32; 6] {
let mut data = [self.min_height; 6];
let n_tiles = coord.get_neighbors();
for i in 0..6 {
let n = n_tiles[i];
if !n.is_in_bounds(Chunk::SIZE * width, Chunk::SIZE * height) {
continue;
}
data[i] = self.heights[n.to_index(Chunk::SIZE)];
}
return data;
}
}