diff --git a/voxygen/src/mesh/terrain.rs b/voxygen/src/mesh/terrain.rs index b3d479a672..d3543d7aad 100644 --- a/voxygen/src/mesh/terrain.rs +++ b/voxygen/src/mesh/terrain.rs @@ -104,8 +104,8 @@ impl + ReadVol + Debug, S: VolSize + Clone> .map(|vox| block_shadow_density(vox.kind())) .unwrap_or((0.0, 0.0)); - neighbour_light[0][i][j] = - (neighbour_light[0][i][j] * (1.0 - density)).max(cap); + neighbour_light[0][i][j] = (neighbour_light[0][i][j] * (1.0 - density)) + .max(cap.min(neighbour_light[1][i][j])); } } diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 22e9d530e4..c0a2283620 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -410,7 +410,7 @@ impl<'a> ZCache<'a> { } } -impl<'a> SamplerMut for BlockGen<'a> { +impl<'a> SamplerMut<'static> for BlockGen<'a> { type Index = Vec3; type Sample = Option; diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index 3ea1df255e..5240bdb713 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -121,7 +121,7 @@ impl<'a> ColumnGen<'a> { } } -impl<'a> Sampler for ColumnGen<'a> { +impl<'a> Sampler<'a> for ColumnGen<'a> { type Index = Vec2; type Sample = Option>; diff --git a/world/src/generator/mod.rs b/world/src/generator/mod.rs new file mode 100644 index 0000000000..021235916a --- /dev/null +++ b/world/src/generator/mod.rs @@ -0,0 +1,10 @@ +mod town; + +// Reexports +pub use self::town::TownGen; + +use crate::util::Sampler; +use common::terrain::Block; +use vek::*; + +pub trait Generator<'a, T: 'a>: Sampler<'a, Index = (&'a T, Vec3), Sample = Block> {} diff --git a/world/src/generator/town.rs b/world/src/generator/town.rs new file mode 100644 index 0000000000..effe803c4b --- /dev/null +++ b/world/src/generator/town.rs @@ -0,0 +1,19 @@ +use super::Generator; +use crate::util::Sampler; +use common::terrain::Block; +use vek::*; + +pub struct TownState; + +pub struct TownGen; + +impl<'a> Sampler<'a> for TownGen { + type Index = (&'a TownState, Vec3); + type Sample = Block; + + fn get(&self, (town, pos): Self::Index) -> Self::Sample { + unimplemented!() + } +} + +impl<'a> Generator<'a, TownState> for TownGen {} diff --git a/world/src/lib.rs b/world/src/lib.rs index 5a58627c9c..69bd984cdd 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -10,6 +10,7 @@ mod all; mod block; mod column; pub mod config; +pub mod generator; pub mod sim; pub mod util; diff --git a/world/src/util/random.rs b/world/src/util/random.rs index ece87a30ce..7cb106e06c 100644 --- a/world/src/util/random.rs +++ b/world/src/util/random.rs @@ -11,7 +11,7 @@ impl RandomField { } } -impl Sampler for RandomField { +impl Sampler<'static> for RandomField { type Index = Vec3; type Sample = u32; @@ -46,7 +46,7 @@ impl RandomPerm { } } -impl Sampler for RandomPerm { +impl Sampler<'static> for RandomPerm { type Index = u32; type Sample = u32; diff --git a/world/src/util/sampler.rs b/world/src/util/sampler.rs index 921ffc7f33..14a720949e 100644 --- a/world/src/util/sampler.rs +++ b/world/src/util/sampler.rs @@ -1,13 +1,13 @@ -pub trait Sampler: Sized { - type Index; - type Sample; +pub trait Sampler<'a>: Sized { + type Index: 'a; + type Sample: 'a; fn get(&self, index: Self::Index) -> Self::Sample; } -pub trait SamplerMut: Sized { - type Index; - type Sample; +pub trait SamplerMut<'a>: Sized { + type Index: 'a; + type Sample: 'a; fn get(&mut self, index: Self::Index) -> Self::Sample; } diff --git a/world/src/util/structure.rs b/world/src/util/structure.rs index 512acd671d..6c2e570c49 100644 --- a/world/src/util/structure.rs +++ b/world/src/util/structure.rs @@ -21,7 +21,7 @@ impl StructureGen2d { } } -impl Sampler for StructureGen2d { +impl Sampler<'static> for StructureGen2d { type Index = Vec2; type Sample = [(Vec2, u32); 9]; diff --git a/world/src/util/unit_chooser.rs b/world/src/util/unit_chooser.rs index c5c0203090..882126e0da 100644 --- a/world/src/util/unit_chooser.rs +++ b/world/src/util/unit_chooser.rs @@ -24,7 +24,7 @@ impl UnitChooser { } } -impl Sampler for UnitChooser { +impl Sampler<'static> for UnitChooser { type Index = u32; type Sample = (Vec2, Vec2);