Rect in primitives, collect the tests
There's the rectangle! Also the tests. Cargo doesn't complain, but my YcmCompleter (so rust-analyze, I think) does. The tests are all one big slab again.
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -5,7 +5,7 @@ mod material;
|
||||
mod hittable;
|
||||
mod thread_utils;
|
||||
|
||||
use crate::primitives::{Vec3, Ray};
|
||||
use crate::primitives::{Vec3, Ray, Rect};
|
||||
use crate::hittable::Hittable;
|
||||
use crate::material::Material;
|
||||
use crate::camera::Camera;
|
||||
@@ -176,14 +176,6 @@ fn sample_pixel(x: i32, y: i32, small_rng: &mut SmallRng, context: &RenderContex
|
||||
)
|
||||
}
|
||||
|
||||
#[derive (Copy, Clone)]
|
||||
struct Rect {
|
||||
x: i32,
|
||||
y: i32,
|
||||
w: i32,
|
||||
h: i32,
|
||||
}
|
||||
|
||||
/* Iterable that produces pixels left-to-right, top-to-bottom.
|
||||
* `Tile`s represent the render space, not the finished image.
|
||||
* There is no internal pixel buffer
|
||||
|
||||
@@ -288,6 +288,26 @@ impl Display for Vec3 {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Ray{
|
||||
pub orig: Vec3,
|
||||
pub dir: Vec3,
|
||||
}
|
||||
|
||||
impl Ray{
|
||||
pub fn at(&self, t: f32) -> Vec3 {
|
||||
self.orig + self.dir*t
|
||||
}
|
||||
}
|
||||
|
||||
#[derive (Copy, Clone)]
|
||||
pub struct Rect {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub w: i32,
|
||||
pub h: i32,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test{
|
||||
use super::*;
|
||||
@@ -547,23 +567,6 @@ mod test{
|
||||
eprintln!("Diff: {}", diff);
|
||||
assert!(Vec3::near_zero(&diff));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Ray{
|
||||
pub orig: Vec3,
|
||||
pub dir: Vec3,
|
||||
}
|
||||
|
||||
impl Ray{
|
||||
pub fn at(&self, t: f32) -> Vec3 {
|
||||
self.orig + self.dir*t
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test{
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn check_lerp(){
|
||||
|
||||
Reference in New Issue
Block a user