pub struct Sky {
pub pixels: Vec<i32>,
pub xsiz: i32,
pub ysiz: i32,
pub bpl: i32,
pub lng: Vec<[f32; 2]>,
pub lat: Vec<i32>,
pub lng_mul: f32,
}Expand description
Sky texture + precomputed angle-lookup tables.
pixels are voxlap-style packed BGRA i32s (low byte = blue,
high byte = brightness/alpha) — same layout as voxel records.
xsiz × ysiz is the texture’s pixel extent.
Fields§
§pixels: Vec<i32>Texture pixels, row-major, length xsiz * ysiz.
xsiz: i32Texel columns. Stored as the post-decrement value (= one
less than the physical column count), matching voxlap’s
skyxsiz global state after loadsky. The lookup table
Self::lat still has xsiz + 1 entries, with lat[0] = 0
as the asm-search lower-bound sentinel.
ysiz: i32Texel rows.
bpl: i32Bytes per row (= (xsiz + 1) * 4, matching voxlap’s
skybpl).
lng: Vec<[f32; 2]>Per-row (cos, sin) of the longitude angle. Length
ysiz. Voxlap: skylng[y].x = cos(y·2π/ysiz + π),
skylng[y].y = sin(...).
lat: Vec<i32>Per-column packed (xoff << 16) | (-yoff & 0xffff), both
16-bit. Length xsiz + 1 (= original column count).
Voxlap: lat[x] = (xoff<<16) | ((-yoff) & 0xffff) where
xoff = cos(((2x - xsiz)·π/(2·xsiz))·32767) and
yoff = sin(...). lat[0] = 0 is voxlap’s “make sure
assembly index never goes < 0” hack.
lng_mul: f32ysiz / (2π) — converts a longitude angle in radians into
a row index. Used by gline’s first-ray atan2 path.
Implementations§
Source§impl Sky
impl Sky
Sourcepub fn from_pixels(pixels: Vec<i32>, original_xsiz: u32, ysiz: u32) -> Self
pub fn from_pixels(pixels: Vec<i32>, original_xsiz: u32, ysiz: u32) -> Self
Build a Sky from a row-major BGRA pixel grid. Computes
the lng / lat lookup tables; mirror of voxlap5.c:3946-
3970 (the post-kpzload table init in loadsky).
pixels.len() must equal original_xsiz * ysiz.
original_xsiz is the pre-decrement column count
(what voxlap reads from the loaded texture before stamping
skyxsiz--). The returned Sky holds xsiz = original_xsiz - 1.
§Panics
Panics if pixels.len() != original_xsiz * ysiz or if
original_xsiz < 2 or ysiz < 1.
Sourcepub fn blue_gradient() -> Self
pub fn blue_gradient() -> Self
Voxlap’s “BLUE” fallback sky (voxlap5.c:3920-3944). A
512×1 horizon-gradient texture: dark blue at the horizon
fading up to lighter blue, then to a pale top. Useful as a
default when no .png is loaded.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sky
impl RefUnwindSafe for Sky
impl Send for Sky
impl Sync for Sky
impl Unpin for Sky
impl UnsafeUnpin for Sky
impl UnwindSafe for Sky
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more