Skip to main content

euv_core/game/engine3d/city_eco/
struct.rs

1use super::*;
2
3/// Live state tracking one intersection traffic signal's three animated emissive lenses.
4#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
5pub struct TrafficSignalUnit3D {
6    /// Owning scene object index for the upper crimson-red lens.
7    #[get(type(copy))]
8    pub(crate) red_obj_idx: usize,
9    /// Owning scene object index for the middle amber-gold lens.
10    #[get(type(copy))]
11    pub(crate) amber_obj_idx: usize,
12    /// Owning scene object index for the lower emerald-green lens.
13    #[get(type(copy))]
14    pub(crate) green_obj_idx: usize,
15    /// Time offset in seconds staggering orthogonal intersection signal timing.
16    #[get(type(copy))]
17    pub(crate) phase_offset_secs: f32,
18    /// Most recently applied traffic signal phase.
19    #[get(type(copy))]
20    pub(crate) active_phase: TrafficLightPhase3D,
21}
22
23/// Live animation state for a drifting 3D volumetric cumulus cloud cluster.
24#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
25pub struct CumulusCloudInstance3D {
26    /// Owning dynamic scene object index inside `World3D::objects`.
27    #[get(type(copy))]
28    pub(crate) object_index: usize,
29    /// Current world-space position wrapped cleanly inside map ground bounds.
30    #[get(type(copy))]
31    pub(crate) position: Vec3,
32    /// Steady trade-wind horizontal drift velocity in meters per second.
33    #[get(type(copy))]
34    pub(crate) drift_velocity: Vec3,
35    /// Base non-uniform scale `(sx, sy, sz)` of this cloud cluster.
36    #[get(type(copy))]
37    pub(crate) base_scale: Vec3,
38    /// Horizontal orientation yaw in radians.
39    #[get(type(copy))]
40    pub(crate) yaw_rad: f32,
41    /// Buoyancy oscillation phase offset in radians.
42    #[get(type(copy))]
43    pub(crate) bob_phase: f32,
44}
45
46/// Live articulated state for a soaring, flapping 3D flocking bird driven by `BoidsFlockSolver`.
47#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
48pub struct FlockingBirdInstance3D {
49    /// Corresponding agent index inside `CityEcosystemState3D::bird_flock`.
50    #[get(type(copy))]
51    pub(crate) boid_index: usize,
52    /// Owning dynamic scene object index for the streamlined bird body mesh.
53    #[get(type(copy))]
54    pub(crate) body_obj_idx: usize,
55    /// Owning dynamic scene object index for the articulated left wing mesh.
56    #[get(type(copy))]
57    pub(crate) left_wing_obj_idx: usize,
58    /// Owning dynamic scene object index for the articulated right wing mesh.
59    #[get(type(copy))]
60    pub(crate) right_wing_obj_idx: usize,
61    /// Wingbeat frequency in cycles per second.
62    #[get(type(copy))]
63    pub(crate) flap_hz: f32,
64    /// Wingbeat phase offset in radians.
65    #[get(type(copy))]
66    pub(crate) flap_phase: f32,
67    /// Uniform scale factor differentiating larger seagulls from agile swifts.
68    #[get(type(copy))]
69    pub(crate) scale: f32,
70}
71
72/// Live gentle wind-sway state for a dynamic riverbank reed or ornamental flora accent.
73#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
74pub struct WindSwayProp3D {
75    /// Owning dynamic scene object index inside `World3D::objects`.
76    #[get(type(copy))]
77    pub(crate) object_index: usize,
78    /// Anchored world-space base position.
79    #[get(type(copy))]
80    pub(crate) base_position: Vec3,
81    /// Anchored Y-axis yaw orientation in radians.
82    #[get(type(copy))]
83    pub(crate) base_yaw_rad: f32,
84    /// Anchored non-uniform scale.
85    #[get(type(copy))]
86    pub(crate) base_scale: Vec3,
87    /// Phase offset in radians staggering breeze waves across the riverbank.
88    #[get(type(copy))]
89    pub(crate) sway_phase: f32,
90    /// Maximum wind tilt amplitude in radians.
91    #[get(type(copy))]
92    pub(crate) sway_amplitude: f32,
93}
94
95/// Aggregated inventory telemetry summarizing populated city ecosystem, street furniture, and perimeter skyline counts.
96#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
97pub struct CityEcosystemSummary3D {
98    /// Number of dense perimeter and horizon skyline buildings placed.
99    #[get(type(copy))]
100    pub(crate) perimeter_building_count: usize,
101    /// Number of rolling green coastal horizon hills placed.
102    #[get(type(copy))]
103    pub(crate) coastal_hill_count: usize,
104    /// Number of live cycling traffic light assemblies placed.
105    #[get(type(copy))]
106    pub(crate) traffic_light_count: usize,
107    /// Number of overhead highway directional gantries placed.
108    #[get(type(copy))]
109    pub(crate) directional_gantry_count: usize,
110    /// Number of roadside traffic and wayfinding signs placed.
111    #[get(type(copy))]
112    pub(crate) roadside_sign_count: usize,
113    /// Number of sidewalk trash cans, benches, bollards, hydrants, bus shelters, and promenade lamps placed.
114    #[get(type(copy))]
115    pub(crate) street_furniture_count: usize,
116    /// Number of drifting volumetric 3D cumulus cloud clusters placed.
117    #[get(type(copy))]
118    pub(crate) cumulus_cloud_count: usize,
119    /// Number of articulated `BoidsFlockSolver`-driven flocking birds placed.
120    #[get(type(copy))]
121    pub(crate) flocking_bird_count: usize,
122    /// Number of sculpted river bridge assemblies and embankments placed.
123    #[get(type(copy))]
124    pub(crate) river_structure_count: usize,
125    /// Number of animated shimmering river surface ribbons placed.
126    #[get(type(copy))]
127    pub(crate) river_water_ribbon_count: usize,
128    /// Number of distinct multi-species 3D trees added (Oak, Cypress, Willow, Cherry Blossom, Pine).
129    #[get(type(copy))]
130    pub(crate) tree_count: usize,
131    /// Number of distinct botanical tree species instantiated in the city (including Coastal Palms).
132    #[get(type(copy))]
133    pub(crate) distinct_tree_species_count: usize,
134    /// Number of layered shrubs and manicured boxwood hedges placed.
135    #[get(type(copy))]
136    pub(crate) shrub_and_hedge_count: usize,
137    /// Number of multi-color flowerbeds placed.
138    #[get(type(copy))]
139    pub(crate) flowerbed_count: usize,
140    /// Number of riverside reeds, smooth boulders, and tufted grass clumps placed.
141    #[get(type(copy))]
142    pub(crate) ground_flora_and_boulder_count: usize,
143}
144
145/// Persistent per-world state driving zero-allocation live animation of traffic signals, drifting clouds, `BoidsFlockSolver` birds, river shimmer, and wind sway.
146#[derive(Clone, Data, Debug)]
147pub struct CityEcosystemState3D {
148    /// Whether `populate_city_ecosystem_and_furniture` has already populated this world.
149    #[get(type(copy))]
150    pub(crate) populated: bool,
151    /// Live cycling intersection traffic signal assemblies.
152    pub(crate) traffic_signals: Vec<TrafficSignalUnit3D>,
153    /// Drifting volumetric 3D cumulus cloud clusters.
154    pub(crate) clouds: Vec<CumulusCloudInstance3D>,
155    /// Cohesive 3D bird flocking solver accelerated by `SpatialHashGrid3D`.
156    pub(crate) bird_flock: BoidsFlockSolver,
157    /// Articulated flapping 3D bird scene handles aligned 1:1 with `bird_flock.agents`.
158    pub(crate) birds: Vec<FlockingBirdInstance3D>,
159    /// Gentle wind-swaying riverbank reeds and foliage accents.
160    pub(crate) wind_sway_props: Vec<WindSwayProp3D>,
161    /// Dynamic shimmering river surface ribbon object indices.
162    pub(crate) river_water_objects: Vec<usize>,
163    /// Populated object count summary for deterministic verification and telemetry.
164    #[get(type(copy))]
165    pub(crate) summary: CityEcosystemSummary3D,
166}
167
168/// Registered prototype mesh identifiers reused heavily across city ecosystem and furniture instances.
169#[derive(Clone, Copy, Data, Debug, Default)]
170pub(crate) struct CityEcoMeshKit3D {
171    /// Traffic light pole and mast arm mesh identifier.
172    #[get(type(copy))]
173    pub(crate) traffic_pole: usize,
174    /// Dynamic traffic light emissive lens mesh identifier.
175    #[get(type(copy))]
176    pub(crate) traffic_lens: usize,
177    /// Highway directional gantry vertical support leg mesh identifier.
178    #[get(type(copy))]
179    pub(crate) gantry_leg: usize,
180    /// Highway directional gantry overhead signboard mesh identifier.
181    #[get(type(copy))]
182    pub(crate) gantry_sign: usize,
183    /// Octagonal STOP sign mesh identifier.
184    #[get(type(copy))]
185    pub(crate) sign_stop: usize,
186    /// Yellow diamond crosswalk sign mesh identifier.
187    #[get(type(copy))]
188    pub(crate) sign_crosswalk: usize,
189    /// Rectangular white speed-limit sign mesh identifier.
190    #[get(type(copy))]
191    pub(crate) sign_speed: usize,
192    /// Green avenue and park wayfinding sign mesh identifier.
193    #[get(type(copy))]
194    pub(crate) sign_wayfinding: usize,
195    /// Metallic urban trash and recycling bin mesh identifier.
196    #[get(type(copy))]
197    pub(crate) trash_bin: usize,
198    /// Wooden-slat park bench mesh identifier.
199    #[get(type(copy))]
200    pub(crate) park_bench: usize,
201    /// Steel sidewalk bollard mesh identifier.
202    #[get(type(copy))]
203    pub(crate) bollard: usize,
204    /// Sculpted red fire hydrant mesh identifier.
205    #[get(type(copy))]
206    pub(crate) fire_hydrant: usize,
207    /// Glass-and-steel transit bus shelter mesh identifier.
208    #[get(type(copy))]
209    pub(crate) bus_shelter: usize,
210    /// Dual-arm park and promenade streetlamp mesh identifier.
211    #[get(type(copy))]
212    pub(crate) promenade_lamp: usize,
213    /// Arched river bridge parapet and steel truss rib mesh identifier.
214    #[get(type(copy))]
215    pub(crate) bridge_parapet: usize,
216    /// Elevated arched pedestrian footbridge mesh identifier.
217    #[get(type(copy))]
218    pub(crate) footbridge: usize,
219    /// Stepped mossy stone river embankment block mesh identifier.
220    #[get(type(copy))]
221    pub(crate) river_embankment: usize,
222    /// Shimmering animated river surface accent ribbon mesh identifier.
223    #[get(type(copy))]
224    pub(crate) river_ribbon: usize,
225    /// Mid-rise brick residential block mesh identifier.
226    #[get(type(copy))]
227    pub(crate) midrise_brick: usize,
228    /// Terraced limestone commercial block mesh identifier.
229    #[get(type(copy))]
230    pub(crate) terrace_stone: usize,
231    /// Distant rolling green coastal hill mesh identifier.
232    #[get(type(copy))]
233    pub(crate) coastal_hill: usize,
234    /// Broad-leaf oak canopy tree mesh identifier.
235    #[get(type(copy))]
236    pub(crate) tree_oak: usize,
237    /// Slender dark-emerald Italian cypress tree mesh identifier.
238    #[get(type(copy))]
239    pub(crate) tree_cypress: usize,
240    /// Graceful weeping willow tree mesh identifier.
241    #[get(type(copy))]
242    pub(crate) tree_willow: usize,
243    /// Ornamental pink cherry-blossom tree mesh identifier.
244    #[get(type(copy))]
245    pub(crate) tree_cherry: usize,
246    /// Layered coastal conifer pine tree mesh identifier.
247    #[get(type(copy))]
248    pub(crate) tree_pine: usize,
249    /// Rounded multi-lobe garden shrub mesh identifier.
250    #[get(type(copy))]
251    pub(crate) shrub: usize,
252    /// Manicured boxwood hedge planter mesh identifier.
253    #[get(type(copy))]
254    pub(crate) boxwood_hedge: usize,
255    /// Multi-blossom urban flowerbed mesh identifier.
256    #[get(type(copy))]
257    pub(crate) flowerbed: usize,
258    /// Riverside tufted cattail reed cluster mesh identifier.
259    #[get(type(copy))]
260    pub(crate) river_reeds: usize,
261    /// Smooth mossy granite river boulder mesh identifier.
262    #[get(type(copy))]
263    pub(crate) river_boulder: usize,
264    /// Organic tufted meadow grass clump mesh identifier.
265    #[get(type(copy))]
266    pub(crate) grass_clump: usize,
267    /// Large multi-lobe volumetric cumulus cloud cluster mesh identifier.
268    #[get(type(copy))]
269    pub(crate) cloud_large: usize,
270    /// Compact fair-weather cumulus cloud puff cluster mesh identifier.
271    #[get(type(copy))]
272    pub(crate) cloud_puff: usize,
273    /// Soaring seagull and city bird fuselage body mesh identifier.
274    #[get(type(copy))]
275    pub(crate) bird_body: usize,
276    /// Curved articulated left bird wing mesh identifier.
277    #[get(type(copy))]
278    pub(crate) bird_wing_left: usize,
279    /// Curved articulated right bird wing mesh identifier.
280    #[get(type(copy))]
281    pub(crate) bird_wing_right: usize,
282}
283
284/// Spatial occupancy tracker enforcing mathematically zero static 3D AABB overlaps and clear vehicle corridors during city population.
285#[derive(Clone, Data, Debug, Default)]
286pub(crate) struct CityOccupancyTracker3D {
287    /// Cached world-space AABBs of every static solid object currently placed in the world.
288    pub(crate) occupied_boxes: Vec<AxisAlignedBox3D>,
289    /// Horizontal ground bounds `(min_x, max_x, min_z, max_z)` kept strictly enforced for all spawned objects.
290    #[get(type(copy))]
291    pub(crate) ground_bounds: (f32, f32, f32, f32),
292}