raytracer/hitdata.rs
1use std::sync::Arc;
2
3use crate::{
4 Material,
5 Vec3
6};
7
8
9
10/// Data struct that holds information about the [`Ray`] intersection with a [`Shape`].
11///
12/// [`Ray`]: ray/struct.Ray.html
13/// [`Shape`]: shape/trait.Shape.html
14#[derive(Clone)]
15pub struct HitData {
16 pub t: f32,
17 pub point: Vec3,
18 pub normal: Vec3,
19 pub material: Arc<dyn Material>
20}
21
22impl HitData {
23 /// HitData constructor.
24 pub fn new(t: f32, point: Vec3, normal: Vec3, material: Arc<dyn Material>) -> HitData {
25 HitData {
26 t,
27 point,
28 normal,
29 material
30 }
31 }
32}