ncollide3d/procedural/path/path.rs
1use na::RealField;
2
3use crate::math::{Point, Vector};
4use crate::procedural::TriMesh;
5
6/// A sample point and its associated tangent.
7pub enum PathSample<N: RealField + Copy> {
8 /// A point that starts a new path.
9 StartPoint(Point<N>, Vector<N>),
10 /// A point that is inside of the path currently generated.
11 InnerPoint(Point<N>, Vector<N>),
12 /// A point that ends the path currently generated.
13 EndPoint(Point<N>, Vector<N>),
14 /// Used when the sampler does not have any other points to generate.
15 EndOfSample,
16}
17
18/// A curve sampler.
19pub trait CurveSampler<N: RealField + Copy> {
20 /// Returns the next sample point.
21 fn next(&mut self) -> PathSample<N>;
22}
23
24/// A pattern that is replicated along a path.
25///
26/// It is responsible of the generation of the whole mesh.
27pub trait StrokePattern<N: RealField + Copy> {
28 /// Generates the mesh using this pattern and the curve sampled by `sampler`.
29 fn stroke<C: CurveSampler<N>>(&mut self, sampler: &mut C) -> TriMesh<N>;
30}