StaticIcosphere

Struct StaticIcosphere 

Source
pub struct StaticIcosphere<T: IcosphereVertex> {
    pub vertices: Vec<T>,
    pub triangles: Vec<[u32; 3]>,
    pub neighbors: HashMap<usize, HashSet<usize>>,
    pub binning_depth: usize,
    /* private fields */
}
Expand description

A sphere-like shape constructed by subdividing a regular icosahedron and normalizing the resulting coordinates.

All vertices and triangles are constructed for the entire shape upon creation. This can take huge amounts of memory at high subdivisions. If you want to construct the triangles and vertices on-the-fly to save memory, use a SparseIcosphere.

Fields§

§vertices: Vec<T>

The vertices may be in any order, don’t rely on the order of this list.

§triangles: Vec<[u32; 3]>

Starting from the triangles of the regular icosahedron, each subdivision splits these triangles into groups of four. These four triangles are always contiguous and are indexed by the index of the parent icosahedron. For example, given the index parent_triangle, the four child triangles are located at parent_triangle..parent_triangle + 4.

When rendering, if chunks are necessary, treat these groups of triangles as chunks.

§neighbors: HashMap<usize, HashSet<usize>>

For each vertex, this contains the five or six neighbor vertices.

§binning_depth: usize

Number of subdivisions from the regular icosahedron

Implementations§

Source§

impl<T: IcosphereVertex> StaticIcosphere<T>

Source

pub fn regular() -> Self

The regular icosahedron of binning depth 0.

Source

pub fn nth(binning_depth: usize) -> Self

Trait Implementations§

Source§

impl<T: Clone + IcosphereVertex> Clone for StaticIcosphere<T>

Source§

fn clone(&self) -> StaticIcosphere<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + IcosphereVertex> Debug for StaticIcosphere<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: IcosphereVertex> Icosphere<T> for StaticIcosphere<T>

Source§

fn subdivide_chunk(&mut self, _previous: &Self, _parent_index: usize) -> bool

Doesn’t do anything because static icospheres are already fully subdivided.

Source§

fn create(binning_depth: usize) -> Self

A constructor. If the icosphere is sparse, this may create an empty one
Source§

fn binning_depth(&self) -> usize

The number of subdivisions from the regular icosahedron.
Source§

fn triangle(&self, triangle_index: usize) -> [u32; 3]

Triangle at the given index.
Source§

fn vertices(&self) -> &[T]

List of vertices.
Source§

fn total_triangle_count(&self) -> usize

The total possible triangle count in an icosphere with the current binning depth.
Source§

fn total_vertex_count(&self) -> usize

The total possible vertex count in an icosphere with the current binning depth.
Source§

fn subdivide(&self) -> Self

Subdivide the entire icosphere.
Source§

fn allocated_triangle_count(&self) -> usize

The amount of triangles actually in memory. If this icosphere is not sparse, this is equal to the total triangle count.
Source§

fn allocated_vertex_count(&self) -> usize

The amount of vertices actually in memory. If this is icosphere is not sparse, this is equal to the total vertex count.
Source§

fn approximate_triangle_surface_area(&self, radius: f32) -> f32

Approximates the surface area of a triangle by dividing the sphere’s surface area with the number of triangles.

Auto Trait Implementations§

§

impl<T> Freeze for StaticIcosphere<T>

§

impl<T> RefUnwindSafe for StaticIcosphere<T>
where T: RefUnwindSafe,

§

impl<T> Send for StaticIcosphere<T>
where T: Send,

§

impl<T> Sync for StaticIcosphere<T>
where T: Sync,

§

impl<T> Unpin for StaticIcosphere<T>
where T: Unpin,

§

impl<T> UnwindSafe for StaticIcosphere<T>
where T: UnwindSafe,

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