#![doc = include_str!("../README.md")]
#![deny(missing_docs)]
pub use cam;
pub mod color;
pub mod consume;
pub mod cube;
pub mod frustrum;
pub mod mask;
pub mod math;
pub mod produce;
pub mod quad;
pub mod ray;
pub mod tile;
pub mod triangle;
pub mod prelude {
pub use crate::{
*,
cam::*,
color::*,
consume::*,
cube::*,
frustrum::*,
math::*,
produce::*,
quad::*,
ray::*,
tile::*,
triangle::*,
};
}
pub type Rgb<T = f32> = [T; 3];
pub type Rgba<T = f32> = [T; 4];
pub type Uv<T = f32> = [T; 2];
pub type Circle<T = f32> = (Uv<T>, T);
pub type Point<T = f32> = [T; 3];
pub type Vector<T = f32> = [T; 3];
pub type Plane<T = f32> = (Point<T>, T);
pub type Sphere<T = f32> = (Point<T>, T);
pub type Triangle<T = f32> = (Point<T>, Point<T>, Point<T>);
pub type Quad<T = f32> = [Point<T>; 4];
pub type Cube<T = f32> = [Point<T>; 8];
pub type PixelPos<T = u32> = [T; 2];
pub type TilePos<T = u32> = [T; 2];
pub type Matrix4<T = f32> = [[T; 4]; 4];
pub type Line<T = f32> = (Point<T>, Point<T>);
pub type Ray<T = f32> = (Point<T>, Vector<T>);
pub type Aabb<T = f32> = (Point<T>, Point<T>);
pub type UvAabb<T = f32> = (Uv<T>, Uv<T>);
pub type RayHit<T = f32> = Option<(T, usize)>;
pub type Chunk<T> = [T; 64];
pub type Consume<T, U> = fn(&mut T, U);
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_mask() {
let mut masks = mask::CompressedMasks::new();
masks.push(0);
masks.push(0);
masks.push(1);
masks.push(0);
masks.push(0);
masks.push(0);
masks.push(2);
masks.push(3);
masks.push(!0);
masks.push(!0);
let mut iter = masks.iter();
assert_eq!(iter.next(), Some((2, 1)));
assert_eq!(iter.next(), Some((6, 2)));
assert_eq!(iter.next(), Some((7, 3)));
assert_eq!(iter.next(), Some((8, !0)));
assert_eq!(iter.next(), Some((9, !0)));
}
#[test]
fn test_triangle_chunk() {
let list: Vec<Triangle> = vec![([0.0; 3], [0.0; 3], [0.0; 3]); 72];
let a = triangle::triangle_chunk(&list, 0);
let b = triangle::triangle_chunk(&list[64..], 0);
assert_eq!(a.1, 0xffffffffffffffff);
assert_eq!(b.1, 0xff);
}
}