mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'imbris/light-fix' into 'master'
Fix lighting calc bug, lower meshing bench sample size See merge request veloren/veloren!734
This commit is contained in:
commit
595bc6c67a
@ -32,7 +32,7 @@ use common::{
|
||||
terrain::{block::Block, TerrainChunkSize, TerrainGrid},
|
||||
vol::{ReadVol, RectVolSize, Vox},
|
||||
};
|
||||
use log::{debug, error};
|
||||
use log::{debug, error, warn};
|
||||
use metrics::ServerMetrics;
|
||||
use rand::Rng;
|
||||
use specs::{
|
||||
@ -1221,14 +1221,20 @@ impl StateExt for State {
|
||||
let res = self.ecs_mut().delete_entity(entity);
|
||||
if res.is_ok() {
|
||||
if let (Some(uid), Some(pos)) = (maybe_uid, maybe_pos) {
|
||||
let region_key = self
|
||||
if let Some(region_key) = self
|
||||
.ecs()
|
||||
.read_resource::<common::region::RegionMap>()
|
||||
.find_region(entity, pos.0)
|
||||
.expect("Failed to find region containing entity during entity deletion");
|
||||
self.ecs()
|
||||
.write_resource::<DeletedEntities>()
|
||||
.record_deleted_entity(uid, region_key);
|
||||
{
|
||||
self.ecs()
|
||||
.write_resource::<DeletedEntities>()
|
||||
.record_deleted_entity(uid, region_key);
|
||||
} else {
|
||||
// Don't panic if the entity wasn't found in a region maybe it was just created
|
||||
// and then deleted before the region manager had a chance to assign it a
|
||||
// region
|
||||
warn!("Failed to find region containing entity during entity deletion, assuming it wasn't sent to any clients and so deletion doesn't need to be recorded for sync purposes");
|
||||
}
|
||||
}
|
||||
}
|
||||
res
|
||||
|
@ -12,6 +12,8 @@ const CENTER: Vec2<i32> = Vec2 { x: 512, y: 512 };
|
||||
const GEN_SIZE: i32 = 4;
|
||||
|
||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
// Lower sample size to save time
|
||||
c = c.sample_size(15);
|
||||
// Generate chunks here to test
|
||||
let mut terrain = TerrainGrid::new().unwrap();
|
||||
let world = World::generate(42);
|
||||
|
@ -64,7 +64,7 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
.map_or(false, |b| b.is_air())
|
||||
{
|
||||
light_map[lm_idx(x, y, z - 1)] = SUNLIGHT;
|
||||
prop_que.push_back(Vec3::new(x as u8, y as u8, z as u8));
|
||||
prop_que.push_back((x as u8, y as u8, z as u16));
|
||||
}
|
||||
SUNLIGHT
|
||||
} else {
|
||||
@ -89,7 +89,7 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
*dest = src - 1;
|
||||
// Can't propagate further
|
||||
if *dest > 1 {
|
||||
prop_que.push_back(Vec3::new(pos.x as u8, pos.y as u8, pos.z as u8));
|
||||
prop_que.push_back((pos.x as u8, pos.y as u8, pos.z as u16));
|
||||
}
|
||||
} else {
|
||||
*dest = OPAQUE;
|
||||
@ -98,7 +98,7 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
*dest = src - 1;
|
||||
// Can't propagate further
|
||||
if *dest > 1 {
|
||||
prop_que.push_back(Vec3::new(pos.x as u8, pos.y as u8, pos.z as u8));
|
||||
prop_que.push_back((pos.x as u8, pos.y as u8, pos.z as u16));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -106,7 +106,7 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
|
||||
// Propage light
|
||||
while let Some(pos) = prop_que.pop_front() {
|
||||
let pos = pos.map(|e| e as i32);
|
||||
let pos = Vec3::new(pos.0 as i32, pos.1 as i32, pos.2 as i32);
|
||||
let light = light_map[lm_idx(pos.x, pos.y, pos.z)];
|
||||
|
||||
// If ray propagate downwards at full strength
|
||||
@ -119,10 +119,10 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
.ok()
|
||||
.map_or((false, false), |b| (b.is_air(), b.is_fluid()));
|
||||
light_map[lm_idx(pos.x, pos.y, pos.z)] = if is_air {
|
||||
prop_que.push_back(Vec3::new(pos.x as u8, pos.y as u8, pos.z as u8));
|
||||
prop_que.push_back((pos.x as u8, pos.y as u8, pos.z as u16));
|
||||
SUNLIGHT
|
||||
} else if is_fluid {
|
||||
prop_que.push_back(Vec3::new(pos.x as u8, pos.y as u8, pos.z as u8));
|
||||
prop_que.push_back((pos.x as u8, pos.y as u8, pos.z as u16));
|
||||
SUNLIGHT - 1
|
||||
} else {
|
||||
OPAQUE
|
||||
|
Loading…
Reference in New Issue
Block a user