diff --git a/assets/voxygen/background/map.png b/assets/voxygen/background/map.png deleted file mode 100644 index a9733ceb45..0000000000 --- a/assets/voxygen/background/map.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:398b577a57ad9670b3400a3772a0798ccc409d8dfcb073ae050fae8cb314fbd2 -size 906590 diff --git a/client/src/lib.rs b/client/src/lib.rs index a49101b605..d8021759a9 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -107,7 +107,6 @@ impl Client { *state.ecs_mut().write_resource() = time_of_day; assert_eq!(world_map.len(), (map_size.x * map_size.y) as usize); - // let map_size = Vec2::new(1024, 1024); let mut world_map_raw = vec![0u8; 4 * world_map.len()/*map_size.x * map_size.y*/]; LittleEndian::write_u32_into(&world_map, &mut world_map_raw); log::debug!("Preparing image..."); @@ -118,6 +117,8 @@ impl Client { image::ImageBuffer::from_raw(map_size.x, map_size.y, world_map_raw); world_map.ok_or(Error::Other("Server sent a bad world map image".into()))? }) + // Flip the image, since Voxygen uses an orientation where rotation from + // positive x axis to positive y axis is counterclockwise around the z axis. .flipv(), ); log::debug!("Done preparing image..."); diff --git a/common/src/terrain/chonk.rs b/common/src/terrain/chonk.rs index e6fe2a50df..8026b310f3 100644 --- a/common/src/terrain/chonk.rs +++ b/common/src/terrain/chonk.rs @@ -26,7 +26,8 @@ impl VolSize for SubChunkSize { const SIZE: Vec3 = Vec3 { x: ChonkSize::RECT_SIZE.x, y: ChonkSize::RECT_SIZE.x, - z: ChonkSize::RECT_SIZE.x / /*2*//*16*//*32*/2, + // NOTE: Currently, use 32 instead of 2 for RECT_SIZE.x = 128. + z: ChonkSize::RECT_SIZE.x / 2, }; } diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index b4ad9ed9f4..8bb7319866 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -254,7 +254,6 @@ image_ids! { help:"voxygen.element.help", charwindow_gradient:"voxygen.element.misc_bg.charwindow", - map_placeholder: "voxygen.background.map", death_bg: "voxygen.background.death", hurt_bg: "voxygen.background.hurt", diff --git a/voxygen/src/hud/map.rs b/voxygen/src/hud/map.rs index 536a0e3ae4..3955ae012a 100644 --- a/voxygen/src/hud/map.rs +++ b/voxygen/src/hud/map.rs @@ -162,7 +162,7 @@ impl<'a> Widget for Map<'a> { let (world_map, worldsize) = self.world_map; let worldsize = worldsize.map2(TerrainChunkSize::RECT_SIZE, |e, f| e as f64 * f as f64); - Image::new(world_map /*self.imgs.map_placeholder*/) + Image::new(world_map) .middle_of(state.ids.map_bg) .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade - 0.1))) .w_h(700.0, 700.0) @@ -177,7 +177,7 @@ impl<'a> Widget for Map<'a> { .get(self.client.entity()) .map_or(Vec3::zero(), |pos| pos.0); - let x = player_pos.x as f64 / worldsize.x * 700.0/*= x-Size of the map image*/; + let x = player_pos.x as f64 / worldsize.x * 700.0; let y = player_pos.y as f64 / worldsize.y * 700.0; let indic_ani = (self.pulse * 6.0/*animation speed*/).cos()/*starts at 1.0*/ * 0.5 + 0.50; // changes the animation frame let indic_scale = 1.2; diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs index 76904741c7..a42ca8ad4c 100644 --- a/voxygen/src/hud/minimap.rs +++ b/voxygen/src/hud/minimap.rs @@ -137,7 +137,7 @@ impl<'a> Widget for MiniMap<'a> { // Map Image let (world_map, worldsize) = self.world_map; let worldsize = worldsize.map2(TerrainChunkSize::RECT_SIZE, |e, f| e as f64 * f as f64); - Image::new(world_map /*self.imgs.map_placeholder*/) + Image::new(world_map) .middle_of(state.ids.mmap_frame_bg) .w_h(92.0 * 4.0 * zoom, 82.0 * 4.0 * zoom) .parent(state.ids.mmap_frame_bg) diff --git a/world/examples/water.rs b/world/examples/water.rs index aaa13919f4..da70cc36c8 100644 --- a/world/examples/water.rs +++ b/world/examples/water.rs @@ -1,5 +1,4 @@ use common::{terrain::TerrainChunkSize, vol::RectVolSize}; -// use self::Mode::*; use std::{f64, io::Write, path::PathBuf, time::SystemTime}; use vek::*; use veloren_world::{ @@ -10,24 +9,12 @@ use veloren_world::{ const W: usize = 1024; const H: usize = 1024; -/* enum Mode { - /// Directional keys affect position of the camera. - /// - /// (W A S D move left and right, F B zoom in and out). - Alt, - /// Directional keys affect angle of the lens - /// - /// (W - Lens, - /// Directional keys affect light direction. - /// - /// (W A S D move left and right, F B move towards and awaay). - Light, -}; */ - fn main() { pretty_env_logger::init(); + // To load a map file of your choice, replace map_file with the name of your map (stored + // locally in the map directory of your Veloren root), and swap the sim::FileOpts::Save line + // below for the sim::FileOpts::Load one. let map_file = // "map_1575990726223.bin"; // "map_1575987666972.bin"; @@ -120,7 +107,7 @@ fn main() { let j = pos.y; (&mut buf[(j * x + i) * 4..]).write(&[r, g, b, a]).unwrap(); }); - // TODO: Justify fits in u32. + // TODO: Justify fits in u32. let world_map = image::RgbaImage::from_raw(x as u32, y as u32, buf) .expect("Image dimensions must be valid"); let mut path = PathBuf::from("./screenshots"); @@ -248,7 +235,6 @@ fn main() { if (scale * 2.0).is_normal() { scale *= 2.0; } - // scale += 1; } } if win.is_key_down(minifb::Key::F) { @@ -258,7 +244,6 @@ fn main() { if (scale / 2.0).is_normal() { scale /= 2.0; } - // scale = (scale - 1).max(0); } } diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 3bae06e6ee..1f95db0f5e 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -190,7 +190,7 @@ impl<'a> BlockGen<'a> { .warp_nz .get(wposf.div(24.0)) .mul((chaos - 0.1).max(0.0).min(1.0).powf(2.0)) - .mul(/*48.0*/ 16.0); + .mul(16.0); let warp = Lerp::lerp(0.0, warp, warp_factor); let surface_height = alt + warp; @@ -203,7 +203,6 @@ impl<'a> BlockGen<'a> { world.gen_ctx.fast_turb_x_nz.get(wposf.div(25.0)) as f32, world.gen_ctx.fast_turb_y_nz.get(wposf.div(25.0)) as f32, ) * 8.0; - // let turb = Lerp::lerp(0.0, turb, warp_factor); let wpos_turb = Vec2::from(wpos).map(|e: i32| e as f32) + turb; let cliff_height = Self::get_cliff_height( @@ -236,8 +235,7 @@ impl<'a> BlockGen<'a> { // Sample blocks - // let stone_col = Rgb::new(240, 230, 220); - //let stone_col = Rgb::new(195, 187, 201); + // let stone_col = Rgb::new(195, 187, 201); // let dirt_col = Rgb::new(79, 67, 60); @@ -253,7 +251,6 @@ impl<'a> BlockGen<'a> { let grass_depth = (1.5 + 2.0 * chaos).min(height - basement_height); let block = if (wposf.z as f32) < height - grass_depth { let col = Lerp::lerp( - // saturate_srgb(sub_surface_color, 0.45).map(|e| (e * 255.0) as u8), sub_surface_color, stone_col.map(|e| e as f32 / 255.0), (height - grass_depth - wposf.z as f32) * 0.15, @@ -277,7 +274,6 @@ impl<'a> BlockGen<'a> { // Surface Some(Block::new( BlockKind::Normal, - // saturate_srgb(col, 0.45).map(|e| (e * 255.0) as u8), col.map(|e| (e * 255.0) as u8), )) } else if (wposf.z as f32) < height + 0.9 diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index 5d400490c2..a1a8298dbf 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -232,6 +232,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { let rockiness = sim.get_interpolated(wpos, |chunk| chunk.rockiness)?; let tree_density = sim.get_interpolated(wpos, |chunk| chunk.tree_density)?; let spawn_rate = sim.get_interpolated(wpos, |chunk| chunk.spawn_rate)?; + let alt = sim.get_interpolated_monotone(wpos, |chunk| chunk.alt)?; let sim_chunk = sim.get(chunk_pos)?; let neighbor_coef = TerrainChunkSize::RECT_SIZE.map(|e| e as f64); let my_chunk_idx = vec2_as_uniform_idx(chunk_pos); @@ -406,44 +407,6 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { ) }); - let downhill = sim_chunk.downhill; - let downhill_pos = downhill.and_then(|downhill_pos| sim.get(downhill_pos)); - debug_assert!(sim_chunk.water_alt >= CONFIG.sea_level); - - let downhill_water_alt = downhill_pos - .map(|downhill_chunk| { - downhill_chunk - .water_alt - .min(sim_chunk.water_alt) - .max(sim_chunk.alt.min(sim_chunk.water_alt)) - }) - .unwrap_or(CONFIG.sea_level); - - let is_cliffs = sim_chunk.is_cliffs; - let near_cliffs = sim_chunk.near_cliffs; - - let is_rocky = sim_chunk.humidity < CONFIG.desert_hum - && (/*sim_chunk.temp < CONFIG.snow_temp || */sim_chunk.alt.sub(CONFIG.sea_level) >= CONFIG.mountain_scale * 0.25); - /* let downhill_alt_rocky = downhill_pos - .map(|downhill_chunk| { - downhill_chunk.humidity < CONFIG.forest_hum && - (downhill_chunk.temperature < CONFIG.|| downhill_chunk.alt.sub(CONFIG.sea_level) >= CONFIG.mountain_scale * 0.25) - }) - .unwrap_or(CONFIG.sea_level); */ - - let alt = if - /*humidity < CONFIG.desert_hum && - (temp < CONFIG.snow_temp || - downhill_alt.sub(CONFIG.sea_level) >= CONFIG.mountain_scale * 0.25)*/ - is_rocky { - sim.get_interpolated_monotone(wpos, |chunk| chunk.alt)? - // sim.get_interpolated_bilinear(wpos, |chunk| chunk.alt)? - // sim.get_interpolated(wpos, |chunk| chunk.alt)? - } else { - sim.get_interpolated_monotone(wpos, |chunk| chunk.alt)? - // sim.get_interpolated(wpos, |chunk| chunk.alt)? - }; - // Find the average distance to each neighboring body of water. let mut river_count = 0.0f64; let mut overlap_count = 0.0f64; @@ -579,12 +542,6 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { } }; - let cliff_hill = (sim - .gen_ctx - .small_nz - .get((wposf_turb.div(128.0)).into_array()) as f32) - .mul(4.0); - let alt_for_river = alt + if overlap_count == 0.0 { 0.0 @@ -592,6 +549,44 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { river_overlap_distance_product / overlap_count } as f32; + let cliff_hill = (sim + .gen_ctx + .small_nz + .get((wposf_turb.div(128.0)).into_array()) as f32) + .mul(4.0); + + let riverless_alt_delta = (sim.gen_ctx.small_nz.get( + (wposf_turb.div(200.0 * (32.0 / TerrainChunkSize::RECT_SIZE.x as f64))).into_array(), + ) as f32) + .min(1.0) + .max(-1.0) + .abs() + .mul(3.0) + + (sim.gen_ctx.small_nz.get( + (wposf_turb.div(400.0 * (32.0 / TerrainChunkSize::RECT_SIZE.x as f64))) + .into_array(), + ) as f32) + .min(1.0) + .max(-1.0) + .abs() + .mul(3.0); + + let downhill = sim_chunk.downhill; + let downhill_pos = downhill.and_then(|downhill_pos| sim.get(downhill_pos)); + debug_assert!(sim_chunk.water_alt >= CONFIG.sea_level); + + let downhill_water_alt = downhill_pos + .map(|downhill_chunk| { + downhill_chunk + .water_alt + .min(sim_chunk.water_alt) + .max(sim_chunk.alt.min(sim_chunk.water_alt)) + }) + .unwrap_or(CONFIG.sea_level); + + let is_cliffs = sim_chunk.is_cliffs; + let near_cliffs = sim_chunk.near_cliffs; + let river_gouge = 0.5; let (in_water, alt_, water_level, warp_factor) = if let Some(( max_border_river_pos, @@ -755,7 +750,6 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { lake_dist <= TerrainChunkSize::RECT_SIZE.x as f64 * 0.5; if gouge_factor == 1.0 { return Some(( - /*alt_for_river < lake_water_alt || in_bounds,*/ true, alt.min(lake_water_alt - 1.0 - river_gouge), downhill_water_alt.max(lake_water_alt) @@ -764,7 +758,6 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { )); } else { return Some(( - /*alt_for_river < lake_water_alt || in_bounds,*/ true, alt_for_river, if in_bounds_ { @@ -806,35 +799,13 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { } else { (false, alt_for_river, downhill_water_alt, 1.0) }; + // NOTE: To disable warp, uncomment this line. // let warp_factor = 0.0; - let riverless_alt_delta = (sim - .gen_ctx - .small_nz - .get((wposf_turb.div(/*200.0*//*50.0*/200.0 * (32.0 / TerrainChunkSize::RECT_SIZE.x as f64)/*24.0*//*56.0 / (chaos as f64).max(0.05)*//*50.0*/)).into_array()) as f32) - .min(1.0).max(-1.0) - // .mul(0.5).add(0.5) - .abs() - .mul(3.0) - // .mul(chaos.min(1.0).max(0.05)) - /* .mul(27.0) */ - + (sim - .gen_ctx - .small_nz - .get((wposf_turb.div(400.0 * (32.0 / TerrainChunkSize::RECT_SIZE.x as f64))).into_array()) as f32) - .min(1.0).max(-1.0) - // .mul(0.5).add(0.5) - .abs() - .mul(3.0) - /* .mul((1.0 - chaos).min(1.0).max(0.3)) - .mul(1.0 - humidity) */ - /* .mul(32.0) */; - let riverless_alt_delta = Lerp::lerp(0.0, riverless_alt_delta, warp_factor); let alt = alt_ + riverless_alt_delta; - let basement = alt - + sim./*get_interpolated*/get_interpolated_monotone(wpos, |chunk| chunk.basement.sub(chunk.alt))?; - // let basement = basement.min(alt); + let basement = + alt + sim.get_interpolated_monotone(wpos, |chunk| chunk.basement.sub(chunk.alt))?; let rock = (sim.gen_ctx.small_nz.get( Vec3::new(wposf.x, wposf.y, alt as f64) @@ -858,37 +829,19 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { .mul(0.5) .add(marble_small.sub(0.5).mul(0.25)); - //let temp = temp.add((marble - 0.5) * 0.1); - //let humidity = humidity.add((marble - 0.5) * 0.10); - // Colours let cold_grass = Rgb::new(0.0, 0.5, 0.25); - // let cold_grass = Rgb::new(0.1, 0.5, 0.1); let warm_grass = Rgb::new(0.4, 0.8, 0.0); - // let warm_grass = Rgb::new(0.1, 0.9, 0.2); let dark_grass = Rgb::new(0.15, 0.4, 0.1); - // let dark_grass = Rgb::new(0.1, 0.3, 0.2); let wet_grass = Rgb::new(0.1, 0.8, 0.2); - // let wet_grass = Rgb::new(0.1, 0.5, 0.5); let cold_stone = Rgb::new(0.57, 0.67, 0.8); - // let cold_stone = Rgb::new(0.5, 0.5, 0.5); let hot_stone = Rgb::new(0.07, 0.07, 0.06); let warm_stone = Rgb::new(0.77, 0.77, 0.64); - // //let warm_stone = Rgb::new(0.6, 0.6, 0.5); - // let warm_stone = Rgb::new(0.6, 0.5, 0.1); let beach_sand = Rgb::new(0.9, 0.82, 0.6); let desert_sand = Rgb::new(0.95, 0.75, 0.5); - // let desert_sand = Rgb::new(0.7, 0.7, 0.4); let snow = Rgb::new(0.8, 0.85, 1.0); - // let snow = Rgb::new(0.0, 0.0, 0.1); - // let stone_col = Rgb::new(152, 98, 16); let stone_col = Rgb::new(195, 187, 201); - /*let dirt = Lerp::lerp( - Rgb::new(0.4, 0.4, 0.4), - Rgb::new(0.4, 0.4, 0.4), - marble, - );*/ let dirt = Lerp::lerp( Rgb::new(0.075, 0.07, 0.3), Rgb::new(0.75, 0.55, 0.1), @@ -896,7 +849,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { ); let tundra = Lerp::lerp(snow, Rgb::new(0.01, 0.3, 0.0), 0.4 + marble * 0.6); let dead_tundra = Lerp::lerp(warm_stone, Rgb::new(0.3, 0.12, 0.2), marble); - let cliff = Rgb::lerp(cold_stone, /*warm_stone*/ hot_stone, marble); + let cliff = Rgb::lerp(cold_stone, hot_stone, marble); let grass = Rgb::lerp( cold_grass, @@ -924,28 +877,13 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { // For below desert humidity, we are always sand or rock, depending on altitude and // temperature. - /* let ground = Rgb::lerp( - cliff, - Rgb::lerp( - dead_tundra, - sand, - temp.sub(CONFIG.snow_temp) - .div(CONFIG.desert_temp.sub(CONFIG.snow_temp)) - .mul(/*4.5*/ 0.5), - ), - alt.sub(basement) - .mul(0.25) - /* alt.sub(CONFIG.sea_level) - .sub(CONFIG.mountain_scale * 0.25) - .div(CONFIG.mountain_scale * 0.125), */ - ); */ let ground = Lerp::lerp( Lerp::lerp( dead_tundra, sand, temp.sub(CONFIG.snow_temp) .div(CONFIG.desert_temp.sub(CONFIG.snow_temp)) - .mul(/*4.5*/ 0.5), + .mul(0.5), ), dirt, humidity @@ -956,17 +894,6 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { let sub_surface_color = Lerp::lerp(cliff, ground, alt.sub(basement).mul(0.25)); - /* let ground = Rgb::lerp( - dead_tundra, - sand, - temp.sub(CONFIG.snow_temp) - .div(CONFIG.desert_temp.sub(CONFIG.snow_temp)) - .mul(/*4.5*/ 0.5), - /* alt.sub(CONFIG.sea_level) - .sub(CONFIG.mountain_scale * 0.25) - .div(CONFIG.mountain_scale * 0.125), */ - ); */ - // From desert to forest humidity, we go from tundra to dirt to grass to moss to sand, // depending on temperature. let ground = Rgb::lerp( @@ -983,7 +910,6 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { /*.sub((marble - 0.5) * 0.05) .mul(256.0)*/ .mul(1.0), - // .mul(2.0), ), // temperate_temp to tropical_temp grass, @@ -996,20 +922,17 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { temp.sub(CONFIG.tropical_temp) .div(CONFIG.desert_temp.sub(CONFIG.tropical_temp)) .mul(1.0), - // .mul(2.0), ), // above desert_temp sand, temp.sub(CONFIG.desert_temp) .div(1.0 - CONFIG.desert_temp) .mul(4.0), - // .mul(2.0), ), humidity .sub(CONFIG.desert_hum) .div(CONFIG.forest_hum.sub(CONFIG.desert_hum)) .mul(1.0), - // .mul(2.0), ); // From forest to jungle humidity, we go from snow to dark grass to grass to tropics to sand // depending on temperature. @@ -1030,20 +953,17 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { temp.sub(CONFIG.tropical_temp) .div(CONFIG.desert_temp.sub(CONFIG.tropical_temp)) .mul(1.0), - // .mul(2.0), ), // above desert_temp sand, temp.sub(CONFIG.desert_temp) .div(1.0 - CONFIG.desert_temp) .mul(4.0), - // .mul(2.0), ), humidity .sub(CONFIG.forest_hum) .div(CONFIG.jungle_hum.sub(CONFIG.forest_hum)) .mul(1.0), - // .mul(2.0), ); // From jungle humidity upwards, we go from snow to grass to rainforest to tropics to sand. let ground = Rgb::lerp( @@ -1063,33 +983,23 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { temp.sub(CONFIG.tropical_temp) .div(CONFIG.desert_temp.sub(CONFIG.tropical_temp)) .mul(4.0), - // .mul(2.0), ), // above desert_temp sand, temp.sub(CONFIG.desert_temp) .div(1.0 - CONFIG.desert_temp) .mul(4.0), - // .mul(2.0), ), humidity.sub(CONFIG.jungle_hum).mul(1.0), ); - /* // Bedrock - let ground = Rgb::lerp( - cliff, - ground, - alt.sub(basement) - .mul(0.25) - ); */ - // Snow covering let snow_cover = temp .sub(CONFIG.snow_temp) .max(-humidity.sub(CONFIG.desert_hum)) .mul(16.0) .add((marble_small - 0.5) * 0.5); - let (alt, ground, sub_surface_color) = if snow_cover /*< 0.1*/<= 0.5 && alt > water_level { + let (alt, ground, sub_surface_color) = if snow_cover <= 0.5 && alt > water_level { // Allow snow cover. ( alt + 1.0 - snow_cover.max(0.0), @@ -1099,14 +1009,6 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { } else { (alt, ground, sub_surface_color) }; - /* let ground = Rgb::lerp( - snow, - ground, - temp.sub(CONFIG.snow_temp) - .max(-humidity.sub(CONFIG.desert_hum)) - .mul(16.0) - .add((marble_small - 0.5) * 0.5), - ); */ // Caves let cave_at = |wposf: Vec2| { @@ -1165,7 +1067,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { // Beach ((ocean_level - 1.0) / 2.0).max(0.0), ), - sub_surface_color, // /*warm_grass*/Lerp::lerp(cliff, dirt, alt.sub(basement).mul(0.25)), + sub_surface_color, // No growing directly on bedrock. tree_density: Lerp::lerp(0.0, tree_density, alt.sub(2.0).sub(basement).mul(0.5)), forest_kind: sim_chunk.forest_kind, @@ -1225,7 +1127,6 @@ pub struct ColumnSample<'a> { pub humidity: f32, pub spawn_rate: f32, pub location: Option<&'a LocationInfo>, - //making cliffs pub stone_col: Rgb, pub chunk: &'a SimChunk, diff --git a/world/src/util/small_cache.rs b/world/src/util/small_cache.rs index 25222305b1..1d04e5d4e1 100644 --- a/world/src/util/small_cache.rs +++ b/world/src/util/small_cache.rs @@ -9,7 +9,8 @@ fn calc_idx(v: Vec2) -> usize { (x ^ y) as usize } -const CACHE_LEN: usize = /*512*//*128*/32; +// NOTE: Use 128 if TerrainChunkSize::RECT_SIZE.x = 128. +const CACHE_LEN: usize = 32; pub struct SmallCache { index: [Option>; CACHE_LEN + 9], @@ -20,15 +21,11 @@ impl Default for SmallCache { fn default() -> Self { Self { index: [None; CACHE_LEN + 9], - data: arr![V::default(); /*521*//*137*/41], // TODO: Use CACHE_LEN + 9 + data: arr![V::default(); 41], // TODO: Use CACHE_LEN random: 1, } } } - -/* pub struct SmalllCacheKeys<'id, V> { -} */ - impl SmallCache { pub fn get) -> V>(&mut self, key: Vec2, f: F) -> &V { let idx = calc_idx(key) % CACHE_LEN;