Skip to main content

euv_core/game/engine3d/vehicles/
struct.rs

1use super::*;
2
3/// Local-space wheel hub coordinates and nominal rolling radius for mounting dynamic spinning and steering wheel meshes onto a wheel-less vehicle chassis.
4#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
5pub struct VehicleWheelLayout3D {
6    /// Local-space front-left wheel hub center (`-X`, `-Z`).
7    #[get(type(copy))]
8    pub(crate) front_left: Vec3,
9    /// Local-space front-right wheel hub center (`+X`, `-Z`).
10    #[get(type(copy))]
11    pub(crate) front_right: Vec3,
12    /// Local-space rear-left wheel hub center (`-X`, `+Z`).
13    #[get(type(copy))]
14    pub(crate) rear_left: Vec3,
15    /// Local-space rear-right wheel hub center (`+X`, `+Z`).
16    #[get(type(copy))]
17    pub(crate) rear_right: Vec3,
18    /// Nominal rolling outer tire radius in meters matching ground contact at `y = 0`.
19    #[get(type(copy))]
20    pub(crate) wheel_radius_m: f32,
21}
22
23/// Longitudinal cross-section control station defining curved automotive bodywork along local `Z`.
24#[derive(Clone, Copy, Debug, Getter, PartialEq)]
25pub(crate) struct BodyStation {
26    /// Longitudinal coordinate from front nose (`-Z`) to rear tail (`+Z`).
27    #[get(type(copy))]
28    pub(crate) z: f32,
29    /// Aerodynamic underbody floor elevation.
30    #[get(type(copy))]
31    pub(crate) y_bottom: f32,
32    /// Outer lower rocker sill elevation.
33    #[get(type(copy))]
34    pub(crate) y_rocker: f32,
35    /// Widest beltline and fender shoulder elevation.
36    #[get(type(copy))]
37    pub(crate) y_belt: f32,
38    /// Upper fender crest and deck edge elevation.
39    #[get(type(copy))]
40    pub(crate) y_deck_edge: f32,
41    /// Centerline spine elevation across the hood, cowl, or rear deck.
42    #[get(type(copy))]
43    pub(crate) y_crown: f32,
44    /// Half-width of the flat aerodynamic underbody floor.
45    #[get(type(copy))]
46    pub(crate) half_w_bottom: f32,
47    /// Half-width of the curved lower rocker sill.
48    #[get(type(copy))]
49    pub(crate) half_w_rocker: f32,
50    /// Maximum body half-width at the sculpted fender or door beltline.
51    #[get(type(copy))]
52    pub(crate) half_w_belt: f32,
53    /// Half-width of the upper hood crest or rear deck shoulder.
54    #[get(type(copy))]
55    pub(crate) half_w_deck: f32,
56    /// Centerline hood/deck curvature offset (`> 0` power bulge dome, `< 0` aerodynamic valley crease).
57    #[get(type(copy))]
58    pub(crate) crown_bulge: f32,
59    /// Inward mid-flank side sculpting depth for air intake coves or Coke-bottle door tuck.
60    #[get(type(copy))]
61    pub(crate) side_scoop_depth: f32,
62}
63
64/// Longitudinal cross-section control station defining a curved wrap-around glass canopy and roof dome.
65#[derive(Clone, Copy, Debug, Getter, PartialEq)]
66pub(crate) struct CanopyStation {
67    /// Longitudinal coordinate from windshield cowl (`-Z`) to rear fastback deck (`+Z`).
68    #[get(type(copy))]
69    pub(crate) z: f32,
70    /// Lower glass sill elevation where the canopy merges cleanly into the bodywork.
71    #[get(type(copy))]
72    pub(crate) y_base: f32,
73    /// Upper cantrail elevation where side windows curve smoothly into the roof arch.
74    #[get(type(copy))]
75    pub(crate) y_cantrail: f32,
76    /// Domed centerline roof or glass spine elevation.
77    #[get(type(copy))]
78    pub(crate) y_crown: f32,
79    /// Half-width at the lower canopy beltline sill.
80    #[get(type(copy))]
81    pub(crate) half_w_base: f32,
82    /// Half-width at the tapered upper roof cantrail.
83    #[get(type(copy))]
84    pub(crate) half_w_cantrail: f32,
85    /// Material slot for the upper panel (glass windshield/rear deck or painted/carbon roof).
86    #[get(type(copy))]
87    pub(crate) top_slot: u16,
88    /// Material slot for the side flank panel (side glass or painted C-pillar sail).
89    #[get(type(copy))]
90    pub(crate) side_slot: u16,
91}
92
93/// Wheel axle geometry and sculpted fender-well clearance parameters for one axle pair.
94#[derive(Clone, Copy, Debug, Getter, New, PartialEq)]
95pub(crate) struct WheelArchSpec {
96    /// Positive half-track center distance from vehicle centerline (`X = ±center_x`).
97    #[get(type(copy))]
98    pub(crate) center_x: f32,
99    /// Longitudinal axle coordinate along `Z`.
100    #[get(type(copy))]
101    pub(crate) center_z: f32,
102    /// Outer rubber tire radius (wheel hub center sits at `Y = tire_radius`).
103    #[get(type(copy))]
104    pub(crate) tire_radius: f32,
105    /// Forged alloy rim barrel radius.
106    #[get(type(copy))]
107    pub(crate) rim_radius: f32,
108    /// Total tire section width along `X`.
109    #[get(type(copy))]
110    pub(crate) tire_width: f32,
111    /// Sculpted outward fender lip flare thickness wrapping over the wheel arch.
112    #[get(type(copy))]
113    pub(crate) arch_flare_width: f32,
114    /// Radial clearance gap between the tire outer tread and the curved wheel-well cutout.
115    #[get(type(copy))]
116    pub(crate) arch_clearance: f32,
117}
118
119/// Accumulator for building multi-material smooth-shaded sculpted vehicle meshes with zero runtime allocations after construction.
120#[derive(Clone, Data, Debug, Default, PartialEq)]
121pub(crate) struct VehicleMeshBuilder {
122    /// Accumulated 64-byte aligned vertices with smooth averaged normals and clean `[0, 1]` UVs.
123    pub(crate) vertices: Vec<Vertex3D>,
124    /// Outward CCW triangle index triplets.
125    pub(crate) indices: Vec<[u32; 3]>,
126    /// Per-triangle sub-material slot indices (`0` = primary body clearcoat paint).
127    pub(crate) tri_materials: Vec<u16>,
128}