From 4999b31bf55b162e2dfe7dc2f9e87ae09412639a Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Wed, 31 Jul 2019 06:45:45 +0900 Subject: [PATCH] Bare beginnings of adding bilinear patches. Mainly as a simple test-case for split-and-dice. --- src/surface/bilinear_patch.rs | 39 +++++++++++++++++++++++++++++++++++ src/surface/mod.rs | 6 ++++++ 2 files changed, 45 insertions(+) create mode 100644 src/surface/bilinear_patch.rs diff --git a/src/surface/bilinear_patch.rs b/src/surface/bilinear_patch.rs new file mode 100644 index 0000000..dcacdf9 --- /dev/null +++ b/src/surface/bilinear_patch.rs @@ -0,0 +1,39 @@ +use super::Splitable; +use crate::math::Point; + +#[derive(Debug, Copy, Clone)] +pub struct BilinearPatch<'a> { + time_sample_count: usize, + + // The control points are stored in clockwise order, like this: + // u -----> + // v 0 1 + // | 3 2 + // \/ + control_points: &'a [[Point; 4]], + + // Indicates if any of the edges *must* be split, for example if there + // are adjacent patches that were split for non-dicing reasons. + // + // Matching the ascii graph above, the edges are: + // + // 0 + // ------- + // 3 | | 1 + // ------- + // 2 + must_split: [bool; 4], +} + +#[derive(Debug, Copy, Clone)] +pub struct BilinearSubPatch<'a> { + original: &'a BilinearPatch<'a>, + clip: [(f32, f32); 4], + must_split: [bool; 4], +} + +impl<'a> Splitable for BilinearSubPatch<'a> { + fn split(&self /* TODO: splitting criteria. */) -> Option<(Self, Self)> { + unimplemented!() + } +} diff --git a/src/surface/mod.rs b/src/surface/mod.rs index 956cb25..65d9114 100644 --- a/src/surface/mod.rs +++ b/src/surface/mod.rs @@ -1,6 +1,7 @@ #![allow(dead_code)] // pub mod micropoly_batch; +pub mod bilinear_patch; pub mod micropoly_batch; pub mod triangle; pub mod triangle_mesh; @@ -26,6 +27,11 @@ pub trait Surface: Boundable + Debug + Sync { ); } +pub trait Splitable: Copy { + /// Splits the surface into two pieces if necessary. + fn split(&self /* TODO: splitting criteria. */) -> Option<(Self, Self)>; +} + #[derive(Debug, Copy, Clone)] #[allow(clippy::large_enum_variant)] pub enum SurfaceIntersection {