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}
54
55/// An owned ray-tracing scene with precomputed shadow data.
56///
57/// `RayTraceScene` bundles the occluder list together with the
58/// `(center, radius)` shadow bounding spheres consumed by
59/// [`soft_shadow_factor`], computing them exactly once at construction.
60/// Tracing through [`RayTraceScene::trace`] performs no heap allocation
61/// per ray or per bounce, making the scene the single canonical entry
62/// point for tracing many rays against a static scene.
63#[derive(Clone, Data, Debug, PartialEq)]
64pub struct RayTraceScene {
65 /// All occluding surfaces in the scene.
66 #[get_mut(skip)]
67 #[set(skip)]
68 pub(crate) occluders: Vec<Occluder>,
69 /// Precomputed `(center, radius)` shadow bounding spheres, one per
70 /// occluder, in the same order as `occluders`.
71 #[get(skip)]
72 #[get_mut(skip)]
73 #[set(skip)]
74 pub(crate) shadow_points: Vec<(Vector3D, f64)>,
75}