From a166ae0360395387e09fb35a1f84210c2ce5ec24 Mon Sep 17 00:00:00 2001 From: Joshua Yanovski Date: Mon, 17 Aug 2020 05:28:05 +0200 Subject: [PATCH] Addressing imbris's initial feedback. Fixes two minor bugs: explosion particles were no longer spawning randomly, and LOD grids were not perfectly even. --- voxygen/src/mesh/mod.rs | 3 +++ voxygen/src/render/mod.rs | 15 ++++++++------- voxygen/src/scene/figure/mod.rs | 6 +++--- voxygen/src/scene/lod.rs | 4 ++-- voxygen/src/scene/mod.rs | 2 +- voxygen/src/scene/particle.rs | 7 +++---- voxygen/src/session.rs | 14 +++++++------- world/src/civ/mod.rs | 4 +++- 8 files changed, 30 insertions(+), 25 deletions(-) diff --git a/voxygen/src/mesh/mod.rs b/voxygen/src/mesh/mod.rs index e66b176515..657d635e32 100644 --- a/voxygen/src/mesh/mod.rs +++ b/voxygen/src/mesh/mod.rs @@ -11,6 +11,9 @@ pub type MeshGen = ( >::Result, ); +/// FIXME: Remove this whole trait at some point. This "abstraction" is never +/// abstracted over, and is organized completely differently from how we +/// actually mesh things nowadays. pub trait Meshable { type Pipeline: render::Pipeline; type TranslucentPipeline: render::Pipeline; diff --git a/voxygen/src/render/mod.rs b/voxygen/src/render/mod.rs index 74bac19f19..9aadf43031 100644 --- a/voxygen/src/render/mod.rs +++ b/voxygen/src/render/mod.rs @@ -69,7 +69,8 @@ pub enum AaMode { None, /// Fast approximate antialiasing. /// - /// This is a screen-space technique, and therefore + /// This is a screen-space technique, and therefore works fine with greedy + /// meshing. Fxaa, /// Multisampling AA, up to 4 samples per pixel. /// @@ -135,7 +136,7 @@ pub enum CloudMode { /// clouds), we currently branch to see if we need to render the clouds in /// *every* fragment shader. For machines that can't optimize the check, /// this is absurdly expensive, so we should look at alternatives in the - /// future that player better iwth the GPU. + /// future that player better with the GPU. Regular, } @@ -180,14 +181,14 @@ pub enum LightingMode { /// physically plausible (to some extent) lighting distribution. /// /// This mdoel may not work as well with purely directional lighting, and is - /// more expensive than the otehr models. + /// more expensive than the other models. Ashikhmin, /// Standard Blinn-Phong shading, combing Lambertian diffuse reflections and /// specular highlights. BlinnPhong, /// Standard Lambertian lighting model, with only diffuse reflections. The /// cheapest lighting model by a decent margin, but the performance - /// dfifference between it and Blinn-Phong will probably only be + /// difference between it and Blinn-Phong will probably only be /// significant on low-end machines that are bottlenecked on fragment /// shading. Lambertian, @@ -200,9 +201,9 @@ impl Default for LightingMode { /// Shadow map settings. #[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)] pub struct ShadowMapMode { - /// Multiple of default resolution (default is currenttly the closest higher - /// power of two above the length of the longest diagonal of the screen - /// resolution, but this may change). + /// Multiple of default resolution (default, which is 1.0, is currently + /// the closest higher power of two above the length of the longest + /// diagonal of the screen resolution, but this may change). pub resolution: f32, } diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index ba2b061ed8..f45f660c61 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -49,7 +49,7 @@ const DAMAGE_FADE_COEFFICIENT: f64 = 5.0; const MOVING_THRESHOLD: f32 = 0.7; const MOVING_THRESHOLD_SQR: f32 = MOVING_THRESHOLD * MOVING_THRESHOLD; -/// camera data, fiigure LOD render distance. +/// camera data, figure LOD render distance. pub type CameraData<'a> = (&'a Camera, f32); /// Enough data to render a figure model. @@ -2622,7 +2622,7 @@ impl FigureColLights { } /// NOTE: Panics if the opaque model's length does not fit in a u32. - /// This is parto f the function contract. + /// This is part of the function contract. /// /// NOTE: Panics if the vertex range bounds are not in range of the opaque /// model stored in the BoneMeshes parameter. This is part of the @@ -2677,7 +2677,7 @@ impl FigureColLights { ..guillotiere::AllocatorOptions::default() }); // TODO: Consider using a single texture atlas to store all figures, much like - // we do for terrain chunks. We previoosly avoided this due to + // we do for terrain chunks. We previously avoided this due to // perceived performance degradation for the figure use case, but with a // smaller atlas size this may be less likely. /* let texture = renderer.create_texture_raw( diff --git a/voxygen/src/scene/lod.rs b/voxygen/src/scene/lod.rs index 2a40a34021..7ba32b2f72 100644 --- a/voxygen/src/scene/lod.rs +++ b/voxygen/src/scene/lod.rs @@ -42,10 +42,10 @@ impl Lod { pub fn set_detail(&mut self, detail: u32) { // Make sure the recorded detail is even. - self.data.tgt_detail = detail.max(100).min(2500) - self.data.tgt_detail % 2; + self.data.tgt_detail = detail.max(100).min(2500) - detail % 2; } - pub fn maintain(&mut self, renderer: &mut Renderer, _time_of_day: f64) { + pub fn maintain(&mut self, renderer: &mut Renderer) { if self .model .as_ref() diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index d465ea942b..6cf4da6de4 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -632,7 +632,7 @@ impl Scene { .expect("Failed to update global constants"); // Maintain LoD. - self.lod.maintain(renderer, time_of_day); + self.lod.maintain(renderer); // Maintain the terrain. let (_visible_bounds, visible_light_volume, visible_psr_bounds) = self.terrain.maintain( diff --git a/voxygen/src/scene/particle.rs b/voxygen/src/scene/particle.rs index 03a973a004..32f6ce5c49 100644 --- a/voxygen/src/scene/particle.rs +++ b/voxygen/src/scene/particle.rs @@ -70,15 +70,14 @@ impl ParticleMgr { ), ); - self.particles.resize( - self.particles.len() + 200, + self.particles.resize_with(self.particles.len() + 200, || { Particle::new( Duration::from_secs(4), time, ParticleMode::CampfireSmoke, *pos + Vec2::::zero().map(|_| rng.gen_range(-1.0, 1.0) * power), - ), - ); + ) + }); }, Outcome::ProjectileShot { .. } => {}, } diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index f9b4588099..a12398c265 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -686,8 +686,11 @@ impl PlayState for SessionState { // Generate debug info, if needed (it iterates through enough data that we might // as well avoid it unless we need it). - let debug_info = if global_state.settings.gameplay.toggle_debug { - Some(DebugInfo { + let debug_info = global_state + .settings + .gameplay + .toggle_debug + .then(|| DebugInfo { tps: global_state.clock.get_tps(), ping_ms: self.client.borrow().get_ping_ms_rolling_avg(), coordinates: self @@ -723,10 +726,7 @@ impl PlayState for SessionState { num_particles: self.scene.particle_mgr().particle_count() as u32, num_particles_visible: self.scene.particle_mgr().particle_count_visible() as u32, - }) - } else { - None - }; + }); // Extract HUD events ensuring the client borrow gets dropped. let mut hud_events = self.hud.maintain( @@ -1175,7 +1175,7 @@ fn under_cursor( let cam_dist = cam_ray.0; // The ray hit something, is it within range? - let (build_pos, select_pos) = if matches!(cam_ray.1, Ok(Some(_)) if + let (build_pos, select_pos) = if matches!(cam_ray.1, Ok(Some(_)) if player_pos.distance_squared(cam_pos + cam_dir * cam_dist) <= MAX_PICKUP_RANGE_SQR) { diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index b4cc2f5f9e..d49f610d4f 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -32,7 +32,9 @@ use vek::*; const fn initial_civ_count(map_size_lg: MapSizeLg) -> u32 { // NOTE: since map_size_lg's dimensions must fit in a u16, we can safely add - // them here. NOTE: N48 at "default" scale of 10 × 10 bits. + // them here. + // + // NOTE: 48 at "default" scale of 10 × 10 chunk bits (1024 × 1024 chunks). (3 << (map_size_lg.vec().x + map_size_lg.vec().y)) >> 16 }