From d530c29d987bc48c4116c55e14430e8a0b1f141f Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 11 May 2022 19:06:41 +0100 Subject: [PATCH] Fixed LoD on test worlds --- server/src/lod.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/src/lod.rs b/server/src/lod.rs index 8cfb1019ac..d65bd7cf32 100644 --- a/server/src/lod.rs +++ b/server/src/lod.rs @@ -1,18 +1,23 @@ +#[cfg(not(feature = "worldgen"))] +use crate::test_world::{IndexRef, World}; use common::lod; use hashbrown::HashMap; use vek::*; -use world::World; +#[cfg(feature = "worldgen")] +use world::{IndexRef, World}; static EMPTY_ZONE: lod::Zone = lod::Zone { objects: Vec::new(), }; +#[derive(Default)] pub struct Lod { pub zones: HashMap, lod::Zone>, } 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 zone_sz = (world.sim().get_size() + lod::ZONE_SIZE - 1) / lod::ZONE_SIZE; @@ -27,6 +32,9 @@ impl Lod { Self { zones } } + #[cfg(not(feature = "worldgen"))] + pub fn from_world(world: &World, index: IndexRef) -> Self { Self::default() } + pub fn zone(&self, zone_pos: Vec2) -> &lod::Zone { self.zones.get(&zone_pos).unwrap_or(&EMPTY_ZONE) }