Skip to main content

HeightGrid

Struct HeightGrid 

Source
pub struct HeightGrid<'a> {
    pub width: usize,
    pub heights: &'a [i16],
}
Expand description

The heights of a map as a save stores them, for queries and for the mesh: width² values, row by row (see Generator::heights).

Fields§

§width: usize

The number of samples on each side, 2n + 1.

§heights: &'a [i16]

The heights, height × 256.

Implementations§

Source§

impl HeightGrid<'_>

Source

pub fn normal(&self, x: i32, y: i32) -> [f32; 3]

Normal from integer central differences.

Original: FUN_1400b3740.

Source

pub fn vertex(&self, x: i32, y: i32, size: i32) -> TerrainVertex

The vertex at grid point (x, y) of a terrain of size cells.

Original: FUN_1400b1d50.

Source§

impl HeightGrid<'_>

Source

pub fn intersect( &self, origin: [f32; 3], direction: [f32; 3], maximum: f32, ) -> Option<(f32, [f32; 3])>

Where a ray first hits the ground, no farther than maximum: the distance and the point. The game uses it to stop picking at the ground.

Deviation: the port tests every cell in the rectangle the ray crosses, where the original walks the cells along the ray.

Original: FUN_1400afef0; its walk along the ray is FUN_1400afa00.

Source

pub fn normal_below(&self, x: f32, y: f32, top: f32, length: f32) -> [f32; 3]

The normal of the ground under (x, y): a ray straight down from height top, at most length long. It is zero when the ray hits nothing.

Original: FUN_1400afef0.

Source

pub fn ground(&self, x: f32, y: f32, normal: &mut [f32; 3]) -> f32

Ground height at a map position (0 when no triangle is hit). normal receives the hit triangle’s normal and is left unchanged otherwise.

Original: FUN_1400b6460.

Source

pub fn natural_cell_type(&self, map_size: usize, index: usize) -> CellType

The natural type of gameplay map cell index (row-major over map_size²). The gameplay map is n × n cells centred on the 2n-cell terrain.

Original: FUN_1400a3790.

Auto Trait Implementations§

§

impl<'a> Freeze for HeightGrid<'a>

§

impl<'a> RefUnwindSafe for HeightGrid<'a>

§

impl<'a> Send for HeightGrid<'a>

§

impl<'a> Sync for HeightGrid<'a>

§

impl<'a> Unpin for HeightGrid<'a>

§

impl<'a> UnsafeUnpin for HeightGrid<'a>

§

impl<'a> UnwindSafe for HeightGrid<'a>

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> 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, 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.