*** everything here is unfinished and not ready for production, and anything mentioned in the README may not be implemented yet. ***
GGMath - Generic Graphics Math
A graphics-math Rust crate with powerful generics that are truely zero-cost
- simple API
use *;
- powerful generics
use ;
- both column-major and row-major matricies
use *;
- 0-cost abstraction - fully optimized with SIMD on current stable Rust
restrictions:
- only supports static vectors (2, 3, 4) and matricies (2, 3, 4)x(2, 3, 4)
- won't support const-contexts until const-traits are stablized
Scalar
the Scalar
trait allows types to be put inside math types (vectors, matricies...) and has sub traits:
- operators:
ScalarAdd
,ScalarBitOr
... - num traits:
ScalarFloat
,ScalarSigned
...
Vector
the Vector
struct is generic over:
<const N: usize> where ScalarCount<N>: VecLen
- only 2, 3, and 4 are vector lengths<T: Scalar>
<A: VecAlignment>
- doesn't affect API, VecAligned is faster, VecPacked saves memory
don't want to be generic? use type aliases! Vec2<f32>
/FVec2
/IVec3
/BVec4
Matrix
the Matrix
struct is generic over:
<const C: usize> where ScalarCount<C>: VecLen
- column count<const R: usize> where ScalarCount<R>: VecLen
- row count<M: MatrixMajorAxis>
- internally row-major or column major?<T: Scalar>
<A: VecAlignment>
- a matrix is built off of vectors...
don't want to be generic? use column_major::Mat3<f32>
/row_major::FMat4x2
GPU integration
GGMath is built with GPU struct integration in mind.
when making Vertex structs, use VecPacked
to save space
when making Uniform structs, use VecAligned
which has size & alignment guarentees that uniforms require