mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Early light filter
This commit is contained in:
parent
cda6c031b8
commit
79ad06ab60
@ -6,7 +6,7 @@ use crate::{
|
||||
mesh::{
|
||||
greedy::{GreedyMesh, SpriteAtlasAllocator},
|
||||
segment::generate_mesh_base_vol_sprite,
|
||||
terrain::{generate_mesh, SUNLIGHT_INV},
|
||||
terrain::{generate_mesh, SUNLIGHT, SUNLIGHT_INV},
|
||||
},
|
||||
render::{
|
||||
pipelines::{self, ColLights},
|
||||
@ -777,13 +777,18 @@ impl<V: RectRasterableVol> Terrain<V> {
|
||||
.get(&chunk_pos)
|
||||
.into_iter()
|
||||
.flat_map(|c| c.blocks_of_interest.lights.iter())
|
||||
.map(move |(lpos, level)| {
|
||||
(
|
||||
Vec3::<i32>::from(
|
||||
chunk_pos * TerrainChunk::RECT_SIZE.map(|e| e as i32),
|
||||
) + *lpos,
|
||||
level,
|
||||
)
|
||||
.filter_map(move |(lpos, level)| {
|
||||
if (*lpos - wpos_chunk).map(|e| e.abs()).reduce_min() < SUNLIGHT as i32 + 2
|
||||
{
|
||||
Some((
|
||||
Vec3::<i32>::from(
|
||||
chunk_pos * TerrainChunk::RECT_SIZE.map(|e| e as i32),
|
||||
) + *lpos,
|
||||
level,
|
||||
))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
})
|
||||
.fold(
|
||||
|
@ -184,7 +184,6 @@ impl BlocksOfInterest {
|
||||
// TODO: Come up with a better way to prune many light sources: grouping them
|
||||
// into larger lights with k-means clustering, perhaps?
|
||||
const MAX_MINOR_LIGHTS: usize = 64;
|
||||
let minor_light_count = minor_lights.len();
|
||||
lights.extend(
|
||||
minor_lights
|
||||
.choose_multiple(&mut rng, MAX_MINOR_LIGHTS)
|
||||
|
Loading…
Reference in New Issue
Block a user