ft: moved random scene code to function; cleaned up tri/quad/cube hit logic; made camera attributes private
This commit is contained in:
@@ -17,7 +17,15 @@ pub struct Hit {
|
||||
}
|
||||
|
||||
impl Hit {
|
||||
pub fn new(t: f32, p: Vec3, n: Vec3, mat: Arc<dyn Material>, front_face: bool, u: f32, v: f32) -> Self {
|
||||
pub fn new(
|
||||
t: f32,
|
||||
p: Vec3,
|
||||
n: Vec3,
|
||||
mat: Arc<dyn Material>,
|
||||
front_face: bool,
|
||||
u: f32,
|
||||
v: f32,
|
||||
) -> Self {
|
||||
Self {
|
||||
t,
|
||||
p,
|
||||
@@ -25,7 +33,26 @@ impl Hit {
|
||||
mat,
|
||||
front_face,
|
||||
u,
|
||||
v
|
||||
v,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_minimal(
|
||||
mh: MinimalHit,
|
||||
n: Vec3,
|
||||
mat: Arc<dyn Material>,
|
||||
front_face: bool,
|
||||
u: f32,
|
||||
v: f32,
|
||||
) -> Self {
|
||||
Self {
|
||||
t: mh.t,
|
||||
p: mh.p,
|
||||
n,
|
||||
mat,
|
||||
front_face,
|
||||
u,
|
||||
v,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,3 +96,22 @@ impl Hit {
|
||||
closest
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MinimalHit {
|
||||
t: f32,
|
||||
p: Vec3,
|
||||
}
|
||||
|
||||
impl MinimalHit {
|
||||
pub fn new(t: f32, p: Vec3) -> Self {
|
||||
Self { t, p }
|
||||
}
|
||||
|
||||
pub fn t(&self) -> f32 {
|
||||
self.t
|
||||
}
|
||||
|
||||
pub fn p(&self) -> &Vec3 {
|
||||
&self.p
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user