Function forsyth::order_triangles_inplace[][src]

pub fn order_triangles_inplace<Index>(
    indices: &mut [Index],
    vertex_cache_size: u16
) -> Result<&[Index], Error> where
    Index: TryInto<usize> + TryFrom<usize> + Clone + Default + PartialEq + Copy
Expand description

Orders a slice of triangle indices in place.

The slice indices is assumed to contain the index triples making up the triangles to be ordered.

vertex_cache_size controls the size of the simulated LRU cache that is used to drive the optimization, with often-used value of 32.

Smaller cache sizes result in faster but worse ordering, whereas larger size increase hit rates at the cost of runtime. This size-performance-relationship may be sub-linear The size is clamped internally to implementation-specific ranges.

Returns a reference to indices

use forsyth::order_triangles_inplace;

let mut indices = [0_u16, 1, 2, 3, 2, 0, 0, 1, 3, 0, 1, 4, 0, 1, 5];
assert!(
    order_triangles_inplace(&mut indices, 32) ==
    Ok(&[0_u16, 1, 4, 0, 1, 5, 0, 1, 2, 3, 2, 0, 0, 1, 3])
);