Skip to main content

MapData

Struct MapData 

Source
pub struct MapData { /* private fields */ }
Expand description

Parsed unit-sphere geometry for a globe wireframe with land fill.

Implementations§

Source§

impl MapData

Source

pub fn load(geo_dir: &Path) -> Result<Self>

Load geometry from a directory containing land_positions.gl, land_contour_indices.gl, and land_triangle_indices.gl (the layout of mullvadvpn-app/dist-assets/geo/).

Source

pub fn embedded() -> Self

Load the geometry that ships in this repository’s assets/geo/ directory, baked into the binary at compile time. Positions are stored as i16 (axis values quantized from [-1, 1]) and all three buffers are zstd-compressed by build.rs; we decode and dequantize once here.

Examples found in repository?
examples/smoke.rs (line 11)
10fn main() {
11    let map = MapData::embedded();
12    let area = Rect::new(0, 0, 80, 30);
13    for yaw in [0.0_f32, 1.0, 2.0, 3.0] {
14        let camera = Camera {
15            yaw,
16            ..Camera::default()
17        };
18        let mut buf = Buffer::empty(area);
19        Globe::new(&map, camera).render(area, &mut buf);
20        println!("--- yaw = {yaw:.2} rad ---");
21        for y in 0..area.height {
22            let mut line = String::new();
23            for x in 0..area.width {
24                let sym = buf[(x, y)].symbol();
25                line.push(if sym == " " || sym.is_empty() {
26                    ' '
27                } else {
28                    '#'
29                });
30            }
31            println!("{}", line.trim_end());
32        }
33        println!();
34    }
35}
Source

pub fn vertex_count(&self) -> usize

Number of vertices on the sphere.

Source

pub fn contour_index_count(&self) -> usize

Number of LINE_STRIP indices including synthesized restart markers.

Source

pub fn triangle_count(&self) -> usize

Number of land triangles (one per three indices).

Trait Implementations§

Source§

impl Clone for MapData

Source§

fn clone(&self) -> MapData

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 MapData

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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