mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'zesterer/lod-test-world-fix' into 'master'
Fixed LoD on test worlds See merge request veloren/veloren!3371
This commit is contained in:
commit
07239c3056
@ -1,18 +1,23 @@
|
|||||||
|
#[cfg(not(feature = "worldgen"))]
|
||||||
|
use crate::test_world::{IndexRef, World};
|
||||||
use common::lod;
|
use common::lod;
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use vek::*;
|
use vek::*;
|
||||||
use world::World;
|
#[cfg(feature = "worldgen")]
|
||||||
|
use world::{IndexRef, World};
|
||||||
|
|
||||||
static EMPTY_ZONE: lod::Zone = lod::Zone {
|
static EMPTY_ZONE: lod::Zone = lod::Zone {
|
||||||
objects: Vec::new(),
|
objects: Vec::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Lod {
|
pub struct Lod {
|
||||||
pub zones: HashMap<Vec2<i32>, lod::Zone>,
|
pub zones: HashMap<Vec2<i32>, lod::Zone>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Lod {
|
impl Lod {
|
||||||
pub fn from_world(world: &World, index: world::IndexRef) -> Self {
|
#[cfg(feature = "worldgen")]
|
||||||
|
pub fn from_world(world: &World, index: IndexRef) -> Self {
|
||||||
let mut zones = HashMap::new();
|
let mut zones = HashMap::new();
|
||||||
|
|
||||||
let zone_sz = (world.sim().get_size() + lod::ZONE_SIZE - 1) / lod::ZONE_SIZE;
|
let zone_sz = (world.sim().get_size() + lod::ZONE_SIZE - 1) / lod::ZONE_SIZE;
|
||||||
@ -27,6 +32,9 @@ impl Lod {
|
|||||||
Self { zones }
|
Self { zones }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "worldgen"))]
|
||||||
|
pub fn from_world(world: &World, index: IndexRef) -> Self { Self::default() }
|
||||||
|
|
||||||
pub fn zone(&self, zone_pos: Vec2<i32>) -> &lod::Zone {
|
pub fn zone(&self, zone_pos: Vec2<i32>) -> &lod::Zone {
|
||||||
self.zones.get(&zone_pos).unwrap_or(&EMPTY_ZONE)
|
self.zones.get(&zone_pos).unwrap_or(&EMPTY_ZONE)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user