From 16c8ecec6605c67391a19bfd5a42d5c06cf81a98 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 21 Jul 2019 16:37:41 +0100 Subject: [PATCH] Fixed light cap --- server/src/lib.rs | 1 + voxygen/src/scene/mod.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/lib.rs b/server/src/lib.rs index db753cb97f..b7c2389c68 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -172,6 +172,7 @@ impl Server { .with(comp::Vel(Vec3::zero())) .with(comp::Ori(Vec3::unit_y())) .with(comp::Body::Object(object)) + //.with(comp::Stats::new("Objecty McObjectface".to_string())) .with(comp::ActionState::default()) .with(comp::ForceUpdate) } diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 68b5d5a4e9..68e2460b6b 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -18,6 +18,7 @@ use vek::*; // TODO: Don't hard-code this. const CURSOR_PAN_SCALE: f32 = 0.005; +const MAX_LIGHT_COUNT: usize = 32; const LIGHT_DIST_RADIUS: f32 = 64.0; // The distance beyond which lights may not be visible struct Skybox { @@ -145,11 +146,11 @@ impl Scene { }) .map(|(pos,)| pos.0) .map(|pos| Light::new(pos + Vec3::unit_z(), Rgb::broadcast(1.0), 100.0)) // TODO: Don't add 1 to z! - .take(32) .collect::>(); lights.sort_by_key(|light| { Vec3::from(Vec4::from(light.pos)).distance_squared(player_pos) as i32 }); + lights.truncate(MAX_LIGHT_COUNT); renderer .update_consts(&mut self.lights, &lights) .expect("Failed to update light constants");