Skip to main content

Sky

Struct Sky 

Source
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: i32

Texel 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: i32

Texel rows.

§bpl: i32

Bytes 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: f32

ysiz / (2π) — converts a longitude angle in radians into a row index. Used by gline’s first-ray atan2 path.

Implementations§

Source§

impl Sky

Source

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.

Source

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§

Source§

impl Clone for Sky

Source§

fn clone(&self) -> Sky

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Sky

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.