From 57ce3a64edc77dbde85750aac21d01d68e625cf9 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Sat, 22 Oct 2022 20:43:39 +0200 Subject: [PATCH] Try shifting chunks with `uniform` --- src/main.rs | 3 ++- src/support/mod.rs | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0ac99e6..d853578 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,7 +43,7 @@ fn main() { let display = glium::Display::new(wb, cb, &event_loop).unwrap(); // building the vertex and index buffers - let vertex_buffer = support::load_ground(&display); + let (vertex_buffer, chunks) = support::load_ground(&display); let textures: [SrgbTexture2d; BIOMES_NUMBER] = BIOMES.map(|biome| { println!("{}", biome); @@ -172,6 +172,7 @@ fn main() { tex16: &textures[16], tex17: &textures[17], tex18: &textures[18], + chunks: &chunks, }; // draw parameters diff --git a/src/support/mod.rs b/src/support/mod.rs index 05d5bb0..f179c2d 100644 --- a/src/support/mod.rs +++ b/src/support/mod.rs @@ -74,7 +74,7 @@ fn get_altitude(height_columns: &Vec<&str>, columns_index: usize) -> f32 { } /// Returns a vertex buffer that should be rendered as `TrianglesList`. -pub fn load_ground(display: &Display) -> VertexBufferAny { +pub fn load_ground(display: &Display) -> (VertexBufferAny, Vec<[u32; 2]>) { #[derive(Copy, Clone)] struct Vertex { altitude: f32, @@ -86,6 +86,7 @@ pub fn load_ground(display: &Display) -> VertexBufferAny { implement_vertex!(Vertex, altitude, normal, index, biome); let mut vertex_data: Vec = Vec::new(); + let mut chunks: Vec<[u32; 2]> = Vec::new(); let ground_folder = "Extensions/LemnosLife/Map/Altis/Ground/"; let paths = fs::read_dir(ground_folder).unwrap(); @@ -101,6 +102,10 @@ pub fn load_ground(display: &Display) -> VertexBufferAny { .replace("Extensions/LemnosLife/Map/Altis/Ground/", "") .replace(".height", ""); println!("{}", file_name); + let file_name_parts: Vec<&str> = file_name.split(' ').collect(); + + chunks.push([file_name_parts[0].parse().unwrap(), file_name_parts[1].parse().unwrap()]); + // have deleted a few height files to make it work // TODO: use triangle strip let height_contents = fs::read_to_string(&format!( @@ -202,7 +207,7 @@ pub fn load_ground(display: &Display) -> VertexBufferAny { } println!("charlie"); - glium::vertex::VertexBuffer::new(display, &vertex_data) + (glium::vertex::VertexBuffer::new(display, &vertex_data) .unwrap() - .into() + .into(), chunks) }