mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added Generator trait, fixed ocean lighting
This commit is contained in:
parent
75f5419571
commit
1fcb4a0313
@ -104,8 +104,8 @@ impl<V: BaseVol<Vox = Block> + 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]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ impl<'a> ZCache<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> SamplerMut for BlockGen<'a> {
|
||||
impl<'a> SamplerMut<'static> for BlockGen<'a> {
|
||||
type Index = Vec3<i32>;
|
||||
type Sample = Option<Block>;
|
||||
|
||||
|
@ -121,7 +121,7 @@ impl<'a> ColumnGen<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Sampler for ColumnGen<'a> {
|
||||
impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
type Index = Vec2<i32>;
|
||||
type Sample = Option<ColumnSample<'a>>;
|
||||
|
||||
|
10
world/src/generator/mod.rs
Normal file
10
world/src/generator/mod.rs
Normal file
@ -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<i32>), Sample = Block> {}
|
19
world/src/generator/town.rs
Normal file
19
world/src/generator/town.rs
Normal file
@ -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<i32>);
|
||||
type Sample = Block;
|
||||
|
||||
fn get(&self, (town, pos): Self::Index) -> Self::Sample {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Generator<'a, TownState> for TownGen {}
|
@ -10,6 +10,7 @@ mod all;
|
||||
mod block;
|
||||
mod column;
|
||||
pub mod config;
|
||||
pub mod generator;
|
||||
pub mod sim;
|
||||
pub mod util;
|
||||
|
||||
|
@ -11,7 +11,7 @@ impl RandomField {
|
||||
}
|
||||
}
|
||||
|
||||
impl Sampler for RandomField {
|
||||
impl Sampler<'static> for RandomField {
|
||||
type Index = Vec3<i32>;
|
||||
type Sample = u32;
|
||||
|
||||
@ -46,7 +46,7 @@ impl RandomPerm {
|
||||
}
|
||||
}
|
||||
|
||||
impl Sampler for RandomPerm {
|
||||
impl Sampler<'static> for RandomPerm {
|
||||
type Index = u32;
|
||||
type Sample = u32;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ impl StructureGen2d {
|
||||
}
|
||||
}
|
||||
|
||||
impl Sampler for StructureGen2d {
|
||||
impl Sampler<'static> for StructureGen2d {
|
||||
type Index = Vec2<i32>;
|
||||
type Sample = [(Vec2<i32>, u32); 9];
|
||||
|
||||
|
@ -24,7 +24,7 @@ impl UnitChooser {
|
||||
}
|
||||
}
|
||||
|
||||
impl Sampler for UnitChooser {
|
||||
impl Sampler<'static> for UnitChooser {
|
||||
type Index = u32;
|
||||
type Sample = (Vec2<i32>, Vec2<i32>);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user