Struct hexasphere::Subdivided

source ·
pub struct Subdivided<T, S: BaseShape> { /* private fields */ }
Expand description

A progressively subdivided shape which can record the indices of the points and list out the individual triangles of the resulting shape.

All base triangles specified by S in BaseShape are expected to be in counter clockwise winding.

Points are preferably stored with coordinates less than or equal to 1.0. This is why all default shapes lie on the unit sphere.

Implementations§

source§

impl<T> Subdivided<T, IcoSphereBase>

source

pub fn radius_shapes(&self) -> f32

Calculate distance from the center of a shape (pentagon or hexagon) to one of the vertices of the shape.

In other words, the radius of the circumscribed circle.

source§

impl<T, S: BaseShape + Default> Subdivided<T, S>

source

pub fn new(subdivisions: usize, generator: impl FnMut(Vec3A) -> T) -> Self

source§

impl<T, S: BaseShape> Subdivided<T, S>

source

pub fn new_custom_shape( subdivisions: usize, generator: impl FnMut(Vec3A) -> T, shape: S ) -> Self

Creates the base shape from S and subdivides it.

  • subdivisions specifies the number of times a subdivision will be created. In other terms, this is the number of auxiliary points between the vertices on the original shape.

  • generator is a function run once all the subdivisions are applied and its values are stored in an internal Vec.

source

pub fn subdivide(&mut self)

Subdivides all triangles. calculate signals whether or not to recalculate vertices (To not calculate vertices between many subdivisions).

source

pub fn raw_points(&self) -> &[Vec3A]

The raw points created by the subdivision process.

source

pub fn get_indices(&self, triangle: usize, buffer: &mut Vec<u32>)

Appends the indices for the triangle into buffer.

The specified triangle is a main triangle on the base shape. The range of this should be limited to the number of triangles in the base shape.

Alternatively, use get_all_indices to get all the indices.

source

pub fn get_all_indices(&self) -> Vec<u32>

Gets the indices for all main triangles in the shape.

source

pub fn get_line_indices( &self, buffer: &mut Vec<u32>, triangle: usize, delta: usize, breaks: impl FnMut(&mut Vec<u32>) )

Gets the wireframe indices for the contents of a specified triangle.

delta is added to all of the indices pushed into the buffer, and is generally intended to be used to have a NaN vertex at zero. Set to zero to produce the indices as if there was no NaN vertex.

breaks is run every time there is a necessary break in the line strip. Use this to, for example, swap out the buffer using std::mem::swap, or push a NaN index into the buffer.

source

pub fn get_major_edge_line_indices( &self, edge: usize, buffer: &mut Vec<u32>, delta: usize )

Gets the wireframe indices for the specified edge of the base shape.

See Self::get_line_indices for more on delta.

source

pub fn get_all_line_indices( &self, delta: usize, breaks: impl FnMut(&mut Vec<u32>) ) -> Vec<u32>

Gets the wireframe indices for all main triangles in the shape, as well as all edges.

See Self::get_line_indices for more on delta, and breaks.

source

pub fn subdivisions(&self) -> usize

Returns the number of subdivisions applied when this shape was created.

source

pub fn raw_data(&self) -> &[T]

Returns the custom data created by the generator function.

source

pub fn indices_per_main_triangle(&self) -> usize

Calculate the number of indices which each main triangle will add to the vertex buffer.

Equation
(subdivisions + 1)²
source

pub fn vertices_per_main_triangle_shared(&self) -> usize

Calculate the number of vertices contained within each main triangle including the vertices which are shared with another main triangle.

Equation
(subdivisions + 1) * (subdivisions + 2) / 2
source

pub fn vertices_per_main_triangle_unique(&self) -> usize

Calculate the number of vertices contained within each main triangle excluding the ones that are shared with other main triangles.

Equation
{
{ subdivisions < 2  : 0
{
{ subdivisions >= 2 : (subdivisions - 1) * subdivisions / 2
{
source

pub fn shared_vertices(&self) -> usize

Calculate the number of vertices along the edges of the main triangles and the vertices of the main triangles.

Equation
subdivisions * EDGES + INITIAL_POINTS
source

pub fn linear_distance(&self, p1: u32, p2: u32, radius: f32) -> f32

Linear distance between two points on this shape.

Auto Trait Implementations§

§

impl<T, S> RefUnwindSafe for Subdivided<T, S>

§

impl<T, S> Send for Subdivided<T, S>
where S: Send, T: Send,

§

impl<T, S> Sync for Subdivided<T, S>
where S: Sync, T: Sync,

§

impl<T, S> Unpin for Subdivided<T, S>
where S: Unpin, T: Unpin,

§

impl<T, S> UnwindSafe for Subdivided<T, S>
where S: UnwindSafe, 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> 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>,

§

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

§

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.