De-boxed many uses of Hit and Material.
Use of generic parameter directly where possible in structures instead of Box'd values. Added Material implementations for Box<Material> and Arc<Material> to aid in the automatic conversion when necessary to use a Sized value for Material. Implement From trait for [f32;3] to Vec3 to make some APIs Into<Vec3> which is a bit nicer to use.
This commit is contained in:
@@ -3,17 +3,26 @@ use hitable::Hit;
|
||||
use hitable::HitRecord;
|
||||
use ray::Ray;
|
||||
|
||||
pub struct FlipNormals {
|
||||
hitable: Box<Hit>,
|
||||
pub struct FlipNormals<H>
|
||||
where
|
||||
H: Hit,
|
||||
{
|
||||
hitable: H,
|
||||
}
|
||||
|
||||
impl FlipNormals {
|
||||
pub fn new(hitable: Box<Hit>) -> FlipNormals {
|
||||
impl<H> FlipNormals<H>
|
||||
where
|
||||
H: Hit,
|
||||
{
|
||||
pub fn new(hitable: H) -> FlipNormals<H> {
|
||||
FlipNormals { hitable }
|
||||
}
|
||||
}
|
||||
|
||||
impl Hit for FlipNormals {
|
||||
impl<H> Hit for FlipNormals<H>
|
||||
where
|
||||
H: Hit,
|
||||
{
|
||||
fn hit(&self, r: Ray, t_min: f32, t_max: f32) -> Option<HitRecord> {
|
||||
if let Some(rec) = self.hitable.hit(r, t_min, t_max) {
|
||||
return Some(HitRecord {
|
||||
|
||||
Reference in New Issue
Block a user