Fixed light cap

This commit is contained in:
Joshua Barretto 2019-07-21 16:37:41 +01:00
parent b34d22565e
commit 16c8ecec66
2 changed files with 3 additions and 1 deletions

View File

@ -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)
}

View File

@ -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::<Vec<_>>();
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");