Add the traits I *want* to be there.
This commit is contained in:
parent
5b09bb780e
commit
4dcc256127
29
src/bin/flat/ifaces.rs
Normal file
29
src/bin/flat/ifaces.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
use crate::types::{Hit, Location, Ray};
|
||||||
|
use glam::Vec2;
|
||||||
|
|
||||||
|
pub trait Traceable {
|
||||||
|
/// Traces a ray from a given starting point. `ray` is relative to the camera.
|
||||||
|
///
|
||||||
|
/// Returns all objects the ray touched. `Hit::distance` is along the ray; it may be a rough estimate except, when two objects overlap the difference of corresponding `distance`s shall be correct.
|
||||||
|
fn trace(&self, camera: Location, ray: Ray) -> Vec<Hit>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait OptimizedTraceable: Traceable {
|
||||||
|
type State;
|
||||||
|
|
||||||
|
/// Prepares tracing from a given starting point. `ray` is relative to the camera.
|
||||||
|
fn init(&self, camera: Location, ray: Ray) -> Self::State;
|
||||||
|
|
||||||
|
/// Similar to [`Traceable::trace`] but allows stopping early.
|
||||||
|
fn trace(&self, state: Self::State) -> (Option<Self::State>, Vec<Hit>);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct RayPath {
|
||||||
|
pub points: Vec<Vec2>,
|
||||||
|
pub end_dir: Vec2,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait DebugTraceable: Traceable {
|
||||||
|
/// Identical to [`Traceable::trace`], except also returns the ray path.
|
||||||
|
fn trace_dbg(&self, camera: Location, ray: Ray) -> (Vec<Hit>, RayPath);
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,7 @@ use types::{Location, Object, Ray};
|
||||||
|
|
||||||
mod float_fun;
|
mod float_fun;
|
||||||
mod fns;
|
mod fns;
|
||||||
|
mod ifaces;
|
||||||
mod riemann;
|
mod riemann;
|
||||||
mod tube;
|
mod tube;
|
||||||
mod types;
|
mod types;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user