Struct veloren_world::sim::WorldSim
source · pub struct WorldSim {
pub seed: u32,
map_size_lg: MapSizeLg,
pub max_height: f32,
pub(crate) chunks: Vec<SimChunk>,
pub(crate) _locations: Vec<Location>,
pub(crate) gen_ctx: GenCtx,
pub rng: ChaChaRng,
pub(crate) calendar: Option<Calendar>,
}
Fields§
§seed: u32
§map_size_lg: MapSizeLg
Base 2 logarithm of the map size.
max_height: f32
Maximum height above sea level of any chunk in the map (not including post-erosion warping, cliffs, and other things like that).
chunks: Vec<SimChunk>
§_locations: Vec<Location>
§gen_ctx: GenCtx
§rng: ChaChaRng
§calendar: Option<Calendar>
Implementations§
source§impl WorldSim
impl WorldSim
pub fn generate( seed: u32, opts: WorldOpts, threadpool: &ThreadPool, stage_report: &dyn Fn(WorldSimStage), ) -> Self
pub const fn map_size_lg(&self) -> MapSizeLg
pub fn get_size(&self) -> Vec2<u32>
pub fn get_aabr(&self) -> Aabr<i32>
pub fn generate_oob_chunk(&self) -> TerrainChunk
pub fn approx_chunk_terrain_normal( &self, chunk_pos: Vec2<i32>, ) -> Option<Vec3<f32>>
sourcepub fn get_map(
&self,
index: IndexRef<'_>,
calendar: Option<&Calendar>,
) -> WorldMapMsg
pub fn get_map( &self, index: IndexRef<'_>, calendar: Option<&Calendar>, ) -> WorldMapMsg
Draw a map of the world based on chunk information. Returns a buffer of u32s.
pub fn generate_cliffs(&mut self)
sourcepub fn seed_elements(&mut self)
pub fn seed_elements(&mut self)
Prepare the world for simulation
pub fn get(&self, chunk_pos: Vec2<i32>) -> Option<&SimChunk>
pub fn get_gradient_approx(&self, chunk_pos: Vec2<i32>) -> Option<f32>
sourcepub fn get_surface_alt_approx(&self, wpos: Vec2<i32>) -> f32
pub fn get_surface_alt_approx(&self, wpos: Vec2<i32>) -> f32
Get the altitude of the surface, could be water or ground.
pub fn get_alt_approx(&self, wpos: Vec2<i32>) -> Option<f32>
pub fn get_wpos(&self, wpos: Vec2<i32>) -> Option<&SimChunk>
pub fn get_mut(&mut self, chunk_pos: Vec2<i32>) -> Option<&mut SimChunk>
pub fn get_base_z(&self, chunk_pos: Vec2<i32>) -> Option<f32>
pub fn get_interpolated<T, F>(&self, pos: Vec2<i32>, f: F) -> Option<T>
sourcepub fn get_interpolated_monotone<T, F>(&self, pos: Vec2<i32>, f: F) -> Option<T>
pub fn get_interpolated_monotone<T, F>(&self, pos: Vec2<i32>, f: F) -> Option<T>
M. Steffen splines.
A more expensive cubic interpolation function that can preserve monotonicity between points. This is useful if you rely on relative differences between endpoints being preserved at all interior points. For example, we use this with riverbeds (and water height on along rivers) to maintain the invariant that the rivers always flow downhill at interior points (not just endpoints), without needing to flatten out the river.
sourcepub fn get_interpolated_bilinear<T, F>(&self, pos: Vec2<i32>, f: F) -> Option<T>
pub fn get_interpolated_bilinear<T, F>(&self, pos: Vec2<i32>, f: F) -> Option<T>
Bilinear interpolation.
Linear interpolation in both directions (i.e. quadratic interpolation).
pub fn get_nearest_ways<'a, M: Clone + Lerp<Output = M>>( &'a self, wpos: Vec2<i32>, get_way: &'a impl Fn(&SimChunk) -> Option<(Way, M)>, ) -> impl Iterator<Item = NearestWaysData<M, impl FnOnce() -> Vec2<f32>>> + 'a
sourcepub fn get_nearest_way<M: Clone + Lerp<Output = M>>(
&self,
wpos: Vec2<i32>,
get_way: impl Fn(&SimChunk) -> Option<(Way, M)>,
) -> Option<(f32, Vec2<f32>, M, Vec2<f32>)>
pub fn get_nearest_way<M: Clone + Lerp<Output = M>>( &self, wpos: Vec2<i32>, get_way: impl Fn(&SimChunk) -> Option<(Way, M)>, ) -> Option<(f32, Vec2<f32>, M, Vec2<f32>)>
Return the distance to the nearest way in blocks, along with the closest point on the way, the way metadata, and the tangent vector of that way.
pub fn get_nearest_path( &self, wpos: Vec2<i32>, ) -> Option<(f32, Vec2<f32>, Path, Vec2<f32>)>
pub fn get_nearest_cave( &self, wpos: Vec2<i32>, ) -> Option<(f32, Vec2<f32>, Cave, Vec2<f32>)>
sourcepub fn make_forest_lottery(
&self,
wpos: Vec2<i32>,
) -> Lottery<Option<ForestKind>>
pub fn make_forest_lottery( &self, wpos: Vec2<i32>, ) -> Lottery<Option<ForestKind>>
Create a [Lottery<Option<ForestKind>>
] that generates ForestKind
s
according to the conditions at the given position. If no or fewer
trees are appropriate for the conditions, None
may be generated.
sourcepub fn get_near_trees(
&self,
wpos: Vec2<i32>,
) -> impl Iterator<Item = TreeAttr> + '_
pub fn get_near_trees( &self, wpos: Vec2<i32>, ) -> impl Iterator<Item = TreeAttr> + '_
WARNING: Not currently used by the tree layer. Needs to be reworked. Return an iterator over candidate tree positions (note that only some of these will become trees since environmental parameters may forbid them spawning).
pub fn get_area_trees( &self, wpos_min: Vec2<i32>, wpos_max: Vec2<i32>, ) -> impl Iterator<Item = TreeAttr> + '_
Auto Trait Implementations§
impl Freeze for WorldSim
impl !RefUnwindSafe for WorldSim
impl Send for WorldSim
impl Sync for WorldSim
impl Unpin for WorldSim
impl !UnwindSafe for WorldSim
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
§impl<Context> SubContext<Context> for Context
impl<Context> SubContext<Context> for Context
fn sub_context(self) -> Context
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.