Module plexus::ordered
[−]
[src]
Ordering and hashing for floating point data.
This module provides tools to ease the creation of geometry data that can
be ordered and hashed. For Plexus, this is most useful for quickly
identifying unique geometry in an iterator expression or Mesh
, such as
using a HashIndexer
.
This code is best used with the derivative crate, which can be used to specify a particular hashing function for a given field. See the ordered-float crate for details about the hashing strategy.
Examples
Creating a basic vertex type that can be used for rendering and implements
Hash
:
use plexus::ordered; #[derive(Derivative)] #[derivative(Hash)] pub struct Vertex { #[derivative(Hash(hash_with = "ordered::hash_float_array"))] pub position: [f32; 3], }
Converting generator types into a hashable type via HashConjugate
:
use plexus::generate::HashIndexer; use plexus::generate::cube::Cube; use plexus::prelude::*; let (indeces, positions) = Cube::<f32>::with_unit_width() .polygons_with_position() .map_vertices(|position| position.into_hash()) // Convert to hashable type. .triangulate() .index_vertices(HashIndexer::default());
Structs
OrderedFloat |
A wrapper around Floats providing an implementation of Ord and Hash. |
Traits
HashConjugate |
Provides conversion to and from a conjugate type that can be hashed. |
HashFloatArray |
Functions
hash_float |
Hashes a floating point value. |
hash_float_array |
Hashes an array of floating point values. |
hash_float_slice |
Hashes a slice of floating point values. |
Type Definitions
NotNan | |
r32 | |
r64 |