aboutsummaryrefslogtreecommitdiff
path: root/src/camera
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-01-29 00:58:32 +0100
committerJulian T <julian@jtle.dk>2021-01-29 00:58:32 +0100
commitfdb3e8cb8d53449c107388e143345beae162f95e (patch)
tree7a04102eb2722d2fddeefd0b2e1fa0e8a4e995f3 /src/camera
parentf467334b26f31b19ebbd222de2b4167b1538ccee (diff)
Finish get_tile on Film
Diffstat (limited to 'src/camera')
-rw-r--r--src/camera/film.rs44
-rw-r--r--src/camera/filter/mod.rs4
-rw-r--r--src/camera/mod.rs4
3 files changed, 32 insertions, 20 deletions
diff --git a/src/camera/film.rs b/src/camera/film.rs
index e31b760..6661529 100644
--- a/src/camera/film.rs
+++ b/src/camera/film.rs
@@ -1,23 +1,28 @@
-use crate::vector::{Vector2, Vector2f};
+use crate::vector::*;
use crate::Float;
use crate::bound;
+use crate::spectrum::Spectrum;
+
use bound::{Bound2i, Bound2f};
use super::filter::Filter;
+use std::rc::Rc;
#[derive(Clone)]
pub struct Pixel {
pub rgb: [Float; 3],
}
-pub struct Film<'a> {
- pub resolution: Vector2<usize>,
+pub struct Film {
+ pub resolution: Vector2i,
+ drawingBound: Bound2i,
pixels: Vec<Pixel>,
- filter: &'a Filter,
+ filter: Rc<Filter>,
}
pub struct FilmTile {
-
+ pub bounds: Bound2i,
+ filter: Rc<Filter>,
}
impl Pixel {
@@ -26,30 +31,37 @@ impl Pixel {
}
}
-impl Film<'_> {
- fn new(resolution: Vector2<usize>, filter: & Filter) -> Film {
+impl Film {
+ pub fn new(resolution: Vector2i, filter: Rc<Filter>) -> Film {
let area = resolution.x * resolution.y;
Film {
resolution,
- pixels: vec![Pixel::new(); area],
+ drawingBound: Bound2i::new(&Vector2::new(0), &resolution),
+ pixels: vec![Pixel::new(); area as usize],
filter,
}
}
- fn get_tile(bound: &Bound2i) {
+ pub fn get_tile(&self, bound: &Bound2i) -> FilmTile {
// Used to calculate descrete coordinates into continues
- let halfpixel = Vector2f::from_xy(0.5, 0.5);
+ let halfpixel = Vector2f::new_xy(0.5, 0.5);
let fbound = Bound2f::from(bound);
+ let p0 = Vector2i::from((fbound.min - halfpixel - self.filter.radius).ceil());
+ let p1 = Vector2i::from((fbound.min - halfpixel + self.filter.radius).floor());
+ let tilebound = bound::intersect(&Bound2i::new(&p0, &p1), &self.drawingBound);
- //let tilebound = bound::intersect(bound,
- }
-
- fn splat(&mut self, point: &Vector2<usize>, pixel: &Pixel) {
- let index = point.x + point.y * self.resolution.x;
+ FilmTile {
+ bounds: tilebound,
+ filter: self.filter.clone(),
+ }
- self.pixels[index] = pixel.clone();
}
}
+impl FilmTile {
+ fn add_sample(point: &Vector2f, c: Spectrum) {
+
+ }
+}
diff --git a/src/camera/filter/mod.rs b/src/camera/filter/mod.rs
index bfa17bb..01d094c 100644
--- a/src/camera/filter/mod.rs
+++ b/src/camera/filter/mod.rs
@@ -26,7 +26,7 @@ impl Eval for Filter {
}
impl Filter {
- fn new_box(radius: &Vector2f) -> Filter {
- Filter { radius: radius.clone(), eval: Box::new(BoxFilter {}) }
+ pub fn new_box(radius: Vector2f) -> Filter {
+ Filter { radius: radius, eval: Box::new(BoxFilter {}) }
}
}
diff --git a/src/camera/mod.rs b/src/camera/mod.rs
index bba95f7..8aed4bf 100644
--- a/src/camera/mod.rs
+++ b/src/camera/mod.rs
@@ -1,2 +1,2 @@
-mod film;
-mod filter;
+pub mod film;
+pub mod filter;