Skip to main content

euv_engine/raytracing/
struct.rs

1use super::*;
2
3/// A 3D ray carrying the parameters needed for traversal and depth tracking.
4#[derive(Clone, Data, Debug, PartialEq)]
5pub struct Ray {
6    /// The world-space origin of the ray.
7    #[get(type(copy))]
8    pub(crate) origin: Vector3D,
9    /// The unit direction of the ray.
10    #[get(type(copy))]
11    pub(crate) direction: Vector3D,
12    /// The minimum acceptable `t` value for valid intersections.
13    #[get(type(copy))]
14    pub(crate) t_min: f64,
15    /// The maximum `t` value before the ray escapes the scene.
16    #[get(type(copy))]
17    pub(crate) t_max: f64,
18    /// The current recursion depth (used to terminate recursive bounces).
19    #[get(type(copy))]
20    pub(crate) depth: u32,
21}
22
23/// The result of a ray-object intersection.
24#[derive(Clone, Data, Debug, PartialEq)]
25pub struct Hit {
26    /// The ray parameter at the hit point.
27    #[get(type(copy))]
28    pub(crate) t: f64,
29    /// The world-space hit position.
30    #[get(type(copy))]
31    pub(crate) position: Vector3D,
32    /// The outward unit normal at the hit point.
33    #[get(type(copy))]
34    pub(crate) normal: Vector3D,
35    /// The material of the hit surface.
36    pub(crate) material: Material,
37}
38
39/// A ray-traceable geometric surface with an attached material.
40#[derive(Clone, Data, Debug, PartialEq)]
41pub struct Occluder {
42    /// The geometric shape represented by this occluder.
43    #[get(type(copy))]
44    pub(crate) kind: OccluderKind,
45    /// For spheres: the center. For AABBs: the minimum corner.
46    #[get(type(copy))]
47    pub(crate) center: Vector3D,
48    /// For spheres: `.x` is the radius. For AABBs: the maximum corner.
49    #[get(type(copy))]
50    pub(crate) extent: Vector3D,
51    /// The surface material.
52    pub(crate) material: Material,
53}