euv_core/game/engine3d/raytrace/accel/enum.rs
1use super::*;
2
3/// Analytic geometric primitive intersected directly without triangle tessellation.
4#[derive(Clone, Copy, Debug, PartialEq)]
5pub enum RtPrimitiveShape {
6 /// Solid sphere centered at `center` with positive `radius`.
7 Sphere {
8 /// World-space sphere center.
9 center: Vec3,
10 /// Sphere radius in meters.
11 radius: f32,
12 },
13 /// Infinite plane passing through `point` with unit outward `normal`.
14 Plane {
15 /// Reference point lying on the plane.
16 point: Vec3,
17 /// Unit plane normal.
18 normal: Vec3,
19 },
20 /// Axis-aligned solid box bounded by `[min, max]`.
21 Box {
22 /// Minimum box corner.
23 min: Vec3,
24 /// Maximum box corner.
25 max: Vec3,
26 },
27 /// Planar circular disk centered at `center` with unit `normal` and `radius`.
28 Disk {
29 /// World-space disk center.
30 center: Vec3,
31 /// Unit disk surface normal.
32 normal: Vec3,
33 /// Disk radius in meters.
34 radius: f32,
35 },
36 /// Parallelogram or rectangular quad defined by `corner` and spanning edges `edge_u` and `edge_v`.
37 Quad {
38 /// Reference corner position in world space.
39 corner: Vec3,
40 /// First spanning edge vector from `corner`.
41 edge_u: Vec3,
42 /// Second spanning edge vector from `corner`.
43 edge_v: Vec3,
44 },
45 /// Y-axis aligned finite cylinder centered at `center` with `radius`, `half_height`, and optional endcaps.
46 Cylinder {
47 /// World-space cylinder center.
48 center: Vec3,
49 /// Cylinder radius in the XZ plane.
50 radius: f32,
51 /// Half-height along the Y axis.
52 half_height: f32,
53 /// Whether top and bottom circular caps are closed.
54 capped: bool,
55 },
56}
57
58/// Signed distance field (SDF) primitive or constructive solid geometry (CSG) operator node.
59#[derive(Clone, Copy, Debug, PartialEq)]
60pub enum RtSdfOp {
61 /// Sphere SDF centered at `center` with `radius`.
62 Sphere {
63 /// Sphere center in world space.
64 center: Vec3,
65 /// Sphere radius.
66 radius: f32,
67 },
68 /// Rounded axis-aligned box SDF centered at `center`.
69 Box {
70 /// Box center in world space.
71 center: Vec3,
72 /// Positive half-extents along `(X, Y, Z)`.
73 half_extents: Vec3,
74 /// Corner rounding radius (`0.0` for sharp box).
75 rounding: f32,
76 },
77 /// Torus SDF lying in the XZ plane around `center`.
78 Torus {
79 /// Torus center in world space.
80 center: Vec3,
81 /// Distance from torus center to tube centerline.
82 major_radius: f32,
83 /// Tube cross-section radius.
84 minor_radius: f32,
85 },
86 /// Capsule SDF between endpoints `start` and `end` with `radius`.
87 Capsule {
88 /// First segment endpoint.
89 start: Vec3,
90 /// Second segment endpoint.
91 end: Vec3,
92 /// Capsule radius.
93 radius: f32,
94 },
95 /// Exact CSG union (`min(left, right)`).
96 Union {
97 /// Index of the left child node in `SdfSphereTracer::ops`.
98 left: u32,
99 /// Index of the right child node in `SdfSphereTracer::ops`.
100 right: u32,
101 },
102 /// Exact CSG subtraction (`max(base, -cutout)`).
103 Subtract {
104 /// Index of the base solid node.
105 base: u32,
106 /// Index of the subtracted volume node.
107 cutout: u32,
108 },
109 /// Exact CSG intersection (`max(left, right)`).
110 Intersect {
111 /// Index of the left child node.
112 left: u32,
113 /// Index of the right child node.
114 right: u32,
115 },
116 /// Polynomial smooth minimum union blending `left` and `right` with radius `smoothness`.
117 SmoothUnion {
118 /// Index of the left child node.
119 left: u32,
120 /// Index of the right child node.
121 right: u32,
122 /// Positive blend radius.
123 smoothness: f32,
124 },
125 /// Polynomial smooth subtraction carving `cutout` from `base` with radius `smoothness`.
126 SmoothSubtract {
127 /// Index of the base solid node.
128 base: u32,
129 /// Index of the subtracted volume node.
130 cutout: u32,
131 /// Positive blend radius.
132 smoothness: f32,
133 },
134}