Bare beginnings of adding bilinear patches.

Mainly as a simple test-case for split-and-dice.
This commit is contained in:
Nathan Vegdahl 2019-07-31 06:45:45 +09:00
parent f021def789
commit 4999b31bf5
2 changed files with 45 additions and 0 deletions

View File

@ -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!()
}
}

View File

@ -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 {