retrofire_core/
geom.rs

1//! Basic geometric primitives.
2
3use crate::math::vec::{Vec2, Vec3};
4
5pub use mesh::Mesh;
6
7pub mod mesh;
8
9/// Vertex with a position and arbitrary other attributes.
10#[derive(Copy, Clone, Debug, Eq, PartialEq)]
11pub struct Vertex<P, A> {
12    pub pos: P,
13    pub attrib: A,
14}
15
16/// Triangle, defined by three vertices.
17#[derive(Copy, Clone, Debug, Eq, PartialEq)]
18#[repr(transparent)]
19pub struct Tri<V>(pub [V; 3]);
20
21/// Plane, defined by normal vector and offset from the origin
22#[derive(Copy, Clone, Debug, Eq, PartialEq)]
23#[repr(transparent)]
24pub struct Plane<V>(pub(crate) V);
25
26/// A surface normal.
27// TODO Use distinct type rather than alias
28pub type Normal3 = Vec3;
29pub type Normal2 = Vec2;
30
31pub const fn vertex<P, A>(pos: P, attrib: A) -> Vertex<P, A> {
32    Vertex { pos, attrib }
33}