pub struct MapData { /* private fields */ }Expand description
Parsed unit-sphere geometry for a globe wireframe with land fill.
Implementations§
Source§impl MapData
impl MapData
Sourcepub fn load(geo_dir: &Path) -> Result<Self>
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/).
Sourcepub fn embedded() -> Self
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}Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Number of vertices on the sphere.
Sourcepub fn contour_index_count(&self) -> usize
pub fn contour_index_count(&self) -> usize
Number of LINE_STRIP indices including synthesized restart markers.
Sourcepub fn triangle_count(&self) -> usize
pub fn triangle_count(&self) -> usize
Number of land triangles (one per three indices).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MapData
impl RefUnwindSafe for MapData
impl Send for MapData
impl Sync for MapData
impl Unpin for MapData
impl UnsafeUnpin for MapData
impl UnwindSafe for MapData
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
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>
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 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>
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