pub struct FogState {
pub width: u32,
pub height: u32,
pub metres_per_pixel: f64,
pub size_z: f64,
pub version: u64,
pub session: u64,
}Available on crate feature
unstable only.Expand description
The fog’s size, scale and how often it changed, as one read found it.
§Examples
use enshwick::map::FogState;
fn corner(state: FogState) -> Option<[u32; 2]> {
state.pixel_of([0.0, 0.0, state.size_z - 1.0])
}Fields§
§width: u32The image’s width in pixels.
height: u32The image’s height in pixels.
metres_per_pixel: f64The metres one pixel covers along each axis.
size_z: f64The world’s z size the fog covers, in metres.
version: u64Grows whenever pixels changed: a mod that compares it reads again only when it moved.
session: u64Changes with each world the client enters; the copy of a world is gone once the client leaves it.
Implementations§
Source§impl FogState
impl FogState
Sourcepub fn pixel_of(&self, position: [f64; 3]) -> Option<[u32; 2]>
pub fn pixel_of(&self, position: [f64; 3]) -> Option<[u32; 2]>
The pixel that holds position, in metres as
World::position gives it; None
outside the fog.
§Examples
use enshwick::map::FogState;
let state = FogState {
width: 1280,
height: 1280,
metres_per_pixel: 8.0,
size_z: 10_240.0,
version: 0,
session: 1,
};
assert_eq!(state.pixel_of([12.0, 50.0, 10_230.0]), Some([1, 1]));
assert_eq!(state.pixel_of([-1.0, 0.0, 0.0]), None);Trait Implementations§
impl Copy for FogState
impl StructuralPartialEq for FogState
Auto Trait Implementations§
impl Freeze for FogState
impl RefUnwindSafe for FogState
impl Send for FogState
impl Sync for FogState
impl Unpin for FogState
impl UnsafeUnpin for FogState
impl UnwindSafe for FogState
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
Mutably borrows from an owned value. Read more