hex coords unit tests wip
Some checks failed
Rust / build (push) Failing after 4s

This commit is contained in:
2026-03-14 20:56:06 -04:00
parent 13a74f7620
commit 227b654e50
9 changed files with 18 additions and 14 deletions

View File

@@ -18,7 +18,7 @@ pub fn generate_chunk_collider(chunk: &MeshChunkData) -> (Vec<Vec3>, Vec<[u32; 3
for x in 0..Chunk::SIZE
{
let height = chunk.heights[x + z * Chunk::SIZE];
let coord = HexCoord::from_grid_pos(x, z);
let coord = HexCoord::from_offset_pos(x, z);
let neighbors = chunk.get_neighbors(&coord);
let off_pos = Vec3::new(x as f32, height, z as f32);
let tile_pos = offset3d_to_world(off_pos);

View File

@@ -25,7 +25,7 @@ pub fn generate_chunk_mesh(chunk: &MeshChunkData) -> Mesh
let height = chunk.heights[idx];
let off_pos = Vec3::new(x as f32, height, z as f32);
let tile_pos = offset3d_to_world(off_pos);
let coord = HexCoord::from_grid_pos(x, z);
let coord = HexCoord::from_offset_pos(x, z);
let n = chunk.get_neighbors(&coord);
create_tile(
@@ -121,7 +121,7 @@ pub fn generate_chunk_water_mesh(chunk: &MeshChunkData, sealevel: f32, map_width
}
let off_pos = Vec3::new(x as f32, sealevel, z as f32);
let tile_pos = offset3d_to_world(off_pos);
let coord = HexCoord::from_grid_pos(x, z);
let coord = HexCoord::from_offset_pos(x, z);
let (n, neighbor_has_land) = chunk.get_neighbors_with_water_info(&coord);
create_tile_water_surface(

View File

@@ -19,7 +19,7 @@ pub fn generate_packed_chunk_mesh(chunk: &MeshChunkData) -> Mesh
{
let idx = x + z * Chunk::SIZE;
let height = chunk.heights[idx];
let coord = HexCoord::from_grid_pos(x, z);
let coord = HexCoord::from_offset_pos(x, z);
let n = chunk.get_neighbors(&coord);
create_packed_tile(

View File

@@ -58,7 +58,7 @@ impl Map
{
for x in 0..Chunk::SIZE
{
let coord = HexCoord::from_grid_pos(x + cx, z + cz);
let coord = HexCoord::from_offset_pos(x + cx, z + cz);
let index = coord.to_chunk_local_index();
if !self.is_in_bounds(&coord)

View File

@@ -64,7 +64,7 @@ pub fn render_map(map: &Map, smooth: f32) -> ImageBuffer<image::Rgba<u8>, Vec<u8
pub fn update_map(map: &Map, smooth: f32, image: &mut ImageBuffer<image::Rgba<u8>, Vec<u8>>)
{
image.par_enumerate_pixels_mut().for_each(|(x, y, pixel)| {
let coord = HexCoord::from_grid_pos(x as usize, y as usize);
let coord = HexCoord::from_offset_pos(x as usize, y as usize);
let right = coord.get_neighbor(1);
let height = map.sample_height(&coord);
@@ -155,7 +155,7 @@ pub fn update_biome_map(map: &Map, biome_map: &BiomeMap, image: &mut ImageBuffer
{
let map_biome_count = map.biome_count as f32;
image.par_enumerate_pixels_mut().for_each(|(x, y, pixel)| {
let coord = HexCoord::from_grid_pos(x as usize, y as usize);
let coord = HexCoord::from_offset_pos(x as usize, y as usize);
let biome_blend = biome_map.get_biome(x as i32, y as i32).unwrap();
let right = coord.get_neighbor(1);
let mut color = Oklaba::BLACK;

View File

@@ -74,7 +74,7 @@ impl MeshChunkData
{
for x in 0..Chunk::SIZE
{
let coord = HexCoord::from_grid_pos(x + offset_x, z + offset_z);
let coord = HexCoord::from_offset_pos(x + offset_x, z + offset_z);
let idx = coord.to_chunk_local_index();
let h = self.heights[idx];
self.distance_to_land[idx] = if h > self.sealevel { 0.0 } else { 4.0 };