1#![cfg_attr(not(debug_assertions), deny(warnings))]
4#![deny(clippy::all, rust_2018_idioms)]
5#![warn(
6 missing_docs,
7 missing_debug_implementations,
8 trivial_casts,
9 trivial_numeric_casts,
10 unsafe_code,
11 unstable_features,
12 unused_import_braces,
13 unused_qualifications
14)]
15
16use array_macro::array;
17use serde::{Deserialize, Serialize};
18
19pub mod base {
21 pub use monstertruck_core::{
22 assert_near, assert_near2, bounding_box::BoundingBox, cgmath64::*, hash, hash::HashGen,
23 prop_assert_near, prop_assert_near2, tolerance::*,
24 };
25 pub use monstertruck_traits::*;
26}
27pub use base::*;
28
29pub trait Attributes<V> {
31 type Output;
33 fn get(&self, vertex: V) -> Option<Self::Output>;
35}
36
37pub trait TransformedAttributes: Clone {
39 fn transform_by(&mut self, trans: Matrix4);
41 fn transformed(&self, trans: Matrix4) -> Self;
43}
44
45#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
47pub struct StandardAttributes {
48 pub positions: Vec<Point3>,
50 pub uv_coords: Vec<Vector2>,
52 pub normals: Vec<Vector3>,
54}
55
56#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
58pub struct StandardAttribute {
59 pub position: Point3,
61 pub uv_coord: Option<Vector2>,
63 pub normal: Option<Vector3>,
65}
66
67#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug, Serialize, Deserialize)]
69pub struct StandardVertex {
70 pub pos: usize,
72 pub uv: Option<usize>,
74 pub nor: Option<usize>,
76}
77
78#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
83pub struct Faces<V = StandardVertex> {
84 tri_faces: Vec<[V; 3]>,
85 quad_faces: Vec<[V; 4]>,
86 other_faces: Vec<Vec<V>>,
87}
88
89#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
95pub struct PolygonMesh<V = StandardVertex, A = StandardAttributes> {
96 attributes: A,
97 faces: Faces<V>,
98}
99
100#[derive(Clone, Debug, Serialize)]
102pub struct StructuredMesh {
103 positions: Vec<Vec<Point3>>,
104 uv_division: Option<(Vec<f64>, Vec<f64>)>,
105 normals: Option<Vec<Vec<Vector3>>>,
106}
107
108#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
110pub struct PolylineCurve<P>(pub Vec<P>);
111
112impl<S> ParameterBoundary2D<S> for PolylineCurve<Point3> {}
113
114impl<P: monstertruck_core::DeterministicContentHash> monstertruck_core::DeterministicContentHash
115 for PolylineCurve<P>
116{
117 fn content_hash<H: std::hash::Hasher>(&self, state: &mut H) { self.0.content_hash(state); }
118}
119
120mod attributes;
121pub mod errors;
123mod expand;
124pub mod faces;
126mod meshing_shape;
127pub mod obj;
129pub mod polygon_mesh;
131pub mod polyline_curve;
133pub mod stl;
135mod structured_mesh;