aboutsummaryrefslogtreecommitdiff
path: root/src/camera
diff options
context:
space:
mode:
Diffstat (limited to 'src/camera')
-rw-r--r--src/camera/film.rs14
-rw-r--r--src/camera/filter/mod.rs24
2 files changed, 26 insertions, 12 deletions
diff --git a/src/camera/film.rs b/src/camera/film.rs
index c4a65ce..e31b760 100644
--- a/src/camera/film.rs
+++ b/src/camera/film.rs
@@ -1,6 +1,7 @@
use crate::vector::{Vector2, Vector2f};
use crate::Float;
-use crate::bounding::Bound2i;
+use crate::bound;
+use bound::{Bound2i, Bound2f};
use super::filter::Filter;
#[derive(Clone)]
@@ -12,8 +13,7 @@ pub struct Film<'a> {
pub resolution: Vector2<usize>,
pixels: Vec<Pixel>,
- filter: &'a dyn Filter,
- filter_radius: Vector2f,
+ filter: &'a Filter,
}
pub struct FilmTile {
@@ -27,19 +27,23 @@ impl Pixel {
}
impl Film<'_> {
- fn new(resolution: Vector2<usize>, filter: & dyn Filter) -> Film {
+ fn new(resolution: Vector2<usize>, filter: & Filter) -> Film {
let area = resolution.x * resolution.y;
Film {
resolution,
pixels: vec![Pixel::new(); area],
filter,
- filter_radius: filter.radius()
}
}
fn get_tile(bound: &Bound2i) {
// Used to calculate descrete coordinates into continues
let halfpixel = Vector2f::from_xy(0.5, 0.5);
+ let fbound = Bound2f::from(bound);
+
+
+
+ //let tilebound = bound::intersect(bound,
}
fn splat(&mut self, point: &Vector2<usize>, pixel: &Pixel) {
diff --git a/src/camera/filter/mod.rs b/src/camera/filter/mod.rs
index 93c6fc5..bfa17bb 100644
--- a/src/camera/filter/mod.rs
+++ b/src/camera/filter/mod.rs
@@ -1,22 +1,32 @@
use crate::vector::Vector2f;
use crate::Float;
-pub trait Filter {
+trait Eval {
fn eval(&self, point: &Vector2f) -> Float;
- fn radius(&self) -> Vector2f;
}
-pub struct BoxFilter {
- radius: Vector2f,
+pub struct Filter {
+ eval: Box<dyn Eval>,
+ pub radius: Vector2f,
}
+struct BoxFilter {}
+
// The same a no filter, and can give aliasing in final image
-impl Filter for BoxFilter {
+impl Eval for BoxFilter {
fn eval(&self, _: &Vector2f) -> Float {
1.0
}
+}
+
+impl Eval for Filter {
+ fn eval(&self, point: &Vector2f) -> Float {
+ self.eval.eval(point)
+ }
+}
- fn radius(&self) -> Vector2f {
- self.radius
+impl Filter {
+ fn new_box(radius: &Vector2f) -> Filter {
+ Filter { radius: radius.clone(), eval: Box::new(BoxFilter {}) }
}
}