euv_core/game/engine3d/world/struct.rs
1use super::*;
2
3/// Gimbal-lock-free 3D world-space transform backed by a unit Hamilton quaternion (`position`, `rotation`, `scale`).
4#[derive(Clone, Copy, Data, Debug, PartialEq)]
5pub struct Transform3D {
6 /// World-space translation `(x, y, z)`.
7 #[get(type(copy))]
8 pub(crate) position: Vec3,
9 /// Unit Hamilton quaternion orientation `(x, y, z, w)`.
10 #[get(type(copy))]
11 pub(crate) rotation: Quat,
12 /// Scale multiplier along `(x, y, z)`.
13 #[get(type(copy))]
14 pub(crate) scale: Vec3,
15}
16
17/// Multi-camera scene registry entry supporting both Perspective and Orthographic Blender/glTF cameras.
18#[derive(Clone, Data, Debug, PartialEq)]
19pub struct SceneCamera3D {
20 /// Human-readable camera label.
21 pub(crate) name: String,
22 /// Optional owning node index inside `World3D::scene_graph`.
23 #[get(type(copy))]
24 pub(crate) node_id: Option<u32>,
25 /// World-space camera eye position.
26 #[get(type(copy))]
27 pub(crate) position: Vec3,
28 /// World-space camera orientation quaternion (glTF camera looks along local `-Z`, up `+Y`).
29 #[get(type(copy))]
30 pub(crate) rotation: Quat,
31 /// Perspective or orthographic projection parameters.
32 #[get(type(copy))]
33 pub(crate) projection: GltfCameraProjection,
34}
35
36/// Fluent descriptor for spawning a `SceneObject3D` into `World3D`.
37#[derive(Clone, Data, Debug, PartialEq)]
38pub struct SpawnObjectDesc {
39 /// Human-readable object label.
40 pub(crate) name: String,
41 /// Registered mesh identifier from `World3D::register_mesh`.
42 #[get(type(copy))]
43 pub(crate) mesh_id: usize,
44 /// World-space TRS transform.
45 #[get(type(copy))]
46 pub(crate) transform: Transform3D,
47 /// Surface PBR material.
48 #[get(type(copy))]
49 pub(crate) material: PbrMaterial,
50 /// Whether this object casts ray-traced shadows and appears in BVH reflections.
51 #[get(type(copy))]
52 pub(crate) ray_trace_caster: bool,
53 /// Whether this object participates in solid vehicle and camera collision detection.
54 #[get(type(copy))]
55 pub(crate) solid_collider: bool,
56 /// Continuous spin speed in radians/sec.
57 #[get(type(copy))]
58 pub(crate) spin_speed: f32,
59 /// Whether this object moves dynamically and belongs in the incrementally refitted dynamic BVH.
60 #[get(type(copy))]
61 pub(crate) is_dynamic: bool,
62}
63
64/// Fluent descriptor for importing a 3D `.obj` or `.gltf` model into `World3D`.
65#[derive(Clone, Data, Debug, PartialEq)]
66pub struct ImportModelDesc {
67 /// Source model interchange format.
68 #[get(type(copy))]
69 pub(crate) format: ModelFormat,
70 /// Raw `.obj` or `.gltf` text content.
71 pub(crate) source: String,
72 /// World-space placement transform.
73 #[get(type(copy))]
74 pub(crate) transform: Transform3D,
75 /// Fallback PBR material when source omits material definitions.
76 #[get(type(copy))]
77 pub(crate) fallback_material: PbrMaterial,
78 /// Optional continuous Y-spin speed in radians/sec.
79 #[get(type(copy))]
80 pub(crate) spin_speed: f32,
81}
82
83/// Instanced 3D scene object placed inside an open-world chunk.
84#[derive(Clone, Data, Debug, PartialEq)]
85pub struct SceneObject3D {
86 /// Human-readable object label.
87 pub(crate) name: String,
88 /// Index into `World3D::mesh_library` enabling GPU instancing batching.
89 #[get(type(copy))]
90 pub(crate) mesh_id: usize,
91 /// World-space TRS transform.
92 #[get(type(copy))]
93 pub(crate) transform: Transform3D,
94 /// Material override (or default mesh material).
95 #[get(type(copy))]
96 pub(crate) material: PbrMaterial,
97 /// Cached world-space axis-aligned bounding box for O(1) frustum culling and chunk streaming.
98 #[get(type(copy))]
99 pub(crate) world_bounds: AxisAlignedBox3D,
100 /// Spatial open-world chunk coordinate `(chunk_x, chunk_z)`.
101 #[get(type(copy))]
102 pub(crate) chunk_coord: (i32, i32),
103 /// Whether this object casts ray-traced shadows and appears in BVH reflections.
104 #[get(type(copy))]
105 pub(crate) ray_trace_caster: bool,
106 /// Whether this object participates in solid vehicle and camera collision detection.
107 #[get(type(copy))]
108 pub(crate) solid_collider: bool,
109 /// Continuous spin speed in radians/sec for animated hero models or props.
110 #[get(type(copy))]
111 pub(crate) spin_speed: f32,
112 /// Whether this object belongs to the dynamic incrementally-refitted BVH rather than the static world BVH.
113 #[get(type(copy))]
114 pub(crate) is_dynamic: bool,
115 /// Discontinuity counter incremented on teleports so snapshot interpolation snaps cleanly.
116 #[get(type(copy))]
117 pub(crate) teleport_epoch: u32,
118 /// Optional owning hierarchical node index inside `World3D::scene_graph`.
119 #[get(type(copy))]
120 pub(crate) node_id: Option<u32>,
121 /// Optional index into `World3D::principled_materials` for full Principled BSDF shading.
122 #[get(type(copy))]
123 pub(crate) principled_material_id: Option<u32>,
124 /// Optional index into `World3D::skins` for armature LBS/DQS vertex deformation.
125 #[get(type(copy))]
126 pub(crate) skin_id: Option<u32>,
127}
128
129/// Primary sun/moon directional light and atmospheric sky parameters.
130#[derive(Clone, Copy, Data, Debug, PartialEq)]
131pub struct DirectionalLight3D {
132 /// Normalized direction pointing toward the sun.
133 #[get(type(copy))]
134 pub(crate) direction: Vec3,
135 /// Linear HDR sun radiance color.
136 #[get(type(copy))]
137 pub(crate) color: Vec3,
138 /// Ambient sky zenith color.
139 #[get(type(copy))]
140 pub(crate) sky_zenith: Vec3,
141 /// Ambient sky horizon and volumetric fog color.
142 #[get(type(copy))]
143 pub(crate) sky_horizon: Vec3,
144 /// Time of day in `[0.0, 24.0]` hours.
145 #[get(type(copy))]
146 pub(crate) time_of_day: f32,
147}
148
149/// Oriented bounding box in 3D space used for tight rotated collider narrow-phase tests.
150#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
151pub struct OrientedBox3D {
152 /// Box center position in target coordinate space.
153 #[get(type(copy))]
154 pub(crate) center: Vec3,
155 /// Orthonormal local X, Y, and Z basis axes.
156 #[get(type(copy))]
157 pub(crate) axes: [Vec3; 3],
158 /// Positive half-extents along each local axis.
159 #[get(type(copy))]
160 pub(crate) half_extents: Vec3,
161}
162
163/// Real-mesh narrow-phase collision contact reported against a solid `SceneObject3D` triangle.
164#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
165pub struct MeshCollisionHit3D {
166 /// Colliding obstacle index inside `World3D::objects`.
167 #[get(type(copy))]
168 pub(crate) object_index: usize,
169 /// Unit world-space separation normal pointing toward the moving collider.
170 #[get(type(copy))]
171 pub(crate) normal: Vec3,
172 /// Positive penetration depth along `normal` in meters.
173 #[get(type(copy))]
174 pub(crate) penetration: f32,
175 /// World-space contact point on the colliding triangle surface.
176 #[get(type(copy))]
177 pub(crate) contact_point: Vec3,
178}
179
180/// Interactive raycast scene picking result returned by `World3D::pick_object_ray`.
181#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
182pub struct ScenePickHit3D {
183 /// Picked object index inside `World3D::objects`.
184 #[get(type(copy))]
185 pub(crate) object_index: usize,
186 /// Registered mesh identifier of the picked object.
187 #[get(type(copy))]
188 pub(crate) mesh_id: usize,
189 /// Ray distance from the camera origin to the intersection point in meters.
190 #[get(type(copy))]
191 pub(crate) distance: f32,
192 /// World-space intersection point on the picked object.
193 #[get(type(copy))]
194 pub(crate) world_position: Vec3,
195 /// Outward world-space surface normal at the intersection point.
196 #[get(type(copy))]
197 pub(crate) world_normal: Vec3,
198}
199
200/// Object-space raytracing instance descriptor enabling exact interpolated dynamic shadows and reflections with zero BVH rebuilds per VSync.
201#[derive(Clone, Copy, Debug)]
202pub(crate) struct DynamicRayInstance {
203 /// Owning scene object index in `World3D::objects`.
204 pub(crate) obj_idx: usize,
205 /// Registered mesh index referencing `World3D::mesh_local_bvhs`.
206 pub(crate) mesh_id: usize,
207 /// World-space axis-aligned bounding box for O(1) miss rejection before transforming rays into object space.
208 pub(crate) world_bounds: AxisAlignedBox3D,
209 /// Exact analytical inverse model matrix (`S^-1 * R^T * T^-1`) mapping world rays to local space.
210 pub(crate) inv_model: Mat4,
211 /// Inverse-transpose 3x3 normal basis mapping local hit normals back to world space.
212 pub(crate) normal_basis: [Vec3; 3],
213 /// Surface PBR material override for this instance.
214 pub(crate) material: PbrMaterial,
215}
216
217/// Complete open-world 3D scene graph with mesh instancing library, chunk streaming, and BVH acceleration.
218#[derive(Clone, Data, Debug)]
219pub struct World3D {
220 /// Shared LOD mesh asset library referenced by `SceneObject3D::mesh_id`.
221 pub(crate) mesh_library: Vec<MeshLodChain>,
222 /// All world objects partitioned into open-world chunks.
223 pub(crate) objects: Vec<SceneObject3D>,
224 /// Active 3D perspective camera.
225 #[get(type(copy))]
226 pub(crate) camera: Camera3D,
227 /// Active directional sun/sky lighting.
228 #[get(type(copy))]
229 pub(crate) sun: DirectionalLight3D,
230 /// Flat BVH built over static world-space ray-trace casters (rebuilt only on static geometry edits).
231 pub(crate) bvh: Bvh3D,
232 /// Separate flat BVH over moving/dynamic ray-trace casters supporting O(N) incremental bottom-up refits.
233 pub(crate) dynamic_bvh: Bvh3D,
234 /// Lazily constructed local-space BVH4/BVH8 cache indexed by `mesh_id` for zero-rebuild object-space dynamic raytracing.
235 #[get(skip)]
236 #[get_mut(skip)]
237 #[set(skip)]
238 pub(crate) mesh_local_bvhs: Vec<Option<Bvh3D>>,
239 /// Active object-space dynamic raytracing instances updated via inverse interpolated `Mat4` without BVH rebuilds.
240 #[get(skip)]
241 #[get_mut(skip)]
242 #[set(skip)]
243 pub(crate) dynamic_instances: Vec<DynamicRayInstance>,
244 /// Dirty flag triggering static BVH rebuild when static casters are added or modified.
245 #[get(type(copy))]
246 pub(crate) bvh_dirty: bool,
247 /// Dirty flag triggering dynamic BVH incremental refit or rebuild when moving casters update.
248 #[get(type(copy))]
249 pub(crate) dynamic_bvh_dirty: bool,
250 /// Topology change flag forcing a fresh dynamic BVH SAH build rather than an in-place refit.
251 #[get(type(copy))]
252 pub(crate) dynamic_topology_dirty: bool,
253 /// Total static BVH full rebuilds executed.
254 #[get(type(copy))]
255 pub(crate) static_bvh_rebuilds: u64,
256 /// Total zero-allocation incremental dynamic BVH refits executed.
257 #[get(type(copy))]
258 pub(crate) dynamic_bvh_refits: u64,
259 /// Total full dynamic BVH rebuilds executed (topology changes or SAH quality resets).
260 #[get(type(copy))]
261 pub(crate) dynamic_bvh_rebuilds: u64,
262 /// Monotonic revision incremented only when 3D world transforms, camera, or lighting change (isolated from HUD dirtiness).
263 #[get(type(copy))]
264 pub(crate) world_revision: u64,
265 /// Monotonic simulation step counter incremented once per `step_simulation` call for parity-invariant particle emission.
266 #[get(type(copy))]
267 pub(crate) sim_tick: u64,
268 /// Reusable scratch buffer holding transformed dynamic caster triangles during incremental BVH refits.
269 #[get(skip)]
270 #[get_mut(skip)]
271 #[set(skip)]
272 pub(crate) dynamic_tris_scratch: Vec<BvhTriangle>,
273 /// Open-world chunk size in meters (`64.0m` per city block).
274 #[get(type(copy))]
275 pub(crate) chunk_size: f32,
276 /// Index of the drivable player vehicle object if spawned.
277 #[get(skip)]
278 pub(crate) player_vehicle_index: Option<usize>,
279 /// Active hero supercar bodywork archetype (`AventadorV12` or `ShelbyCobra`).
280 #[get(type(copy))]
281 #[set(skip)]
282 #[get_mut(skip)]
283 pub(crate) hero_vehicle_style: HeroVehicleStyle,
284 /// Pre-registered `(mesh_id, signature_material)` handles indexed by `HeroVehicleStyle` for zero-allocation live car switching.
285 #[get(skip)]
286 #[get_mut(skip)]
287 #[set(skip)]
288 pub(crate) hero_vehicle_meshes: [Option<(usize, PbrMaterial)>; 2],
289 /// Total imported external 3D models (`.obj` / `.gltf`).
290 #[get(type(copy))]
291 pub(crate) imported_model_count: usize,
292 /// Active 3D camera mode index (`0=Chase`, `1=Hood`, `2=Orbit`, `3=Aerial`, `4=FreeFly`, `5=CinematicDolly`).
293 #[get(type(copy))]
294 pub(crate) camera_mode: u8,
295 /// Continuous orbit angle in radians used for `Orbit` and `CinematicDolly` modes.
296 #[get(type(copy))]
297 pub(crate) camera_orbit_rad: f32,
298 /// Dynamic world-space omnidirectional point lights binned by `LightClusterGrid3D`.
299 pub(crate) point_lights: Vec<PointLight3D>,
300 /// Dynamic world-space spotlights (vehicle headlights, streetlamps) binned by `LightClusterGrid3D`.
301 pub(crate) spot_lights: Vec<SpotLight3D>,
302 /// Zero-allocation 3D Niagara particle system for sparks, exhaust trails, and atmospheric effects.
303 pub(crate) niagara: NiagaraSystem3D,
304 /// Active atmospheric mood preset (`0=Sunset, 1=RainyNight, 2=Noon, 3=Midnight`).
305 #[get(type(copy))]
306 pub(crate) atmosphere_preset: u8,
307 /// Dynamic rigid-body autonomous NPC vehicles supporting boulevard cruising, off-road plaza free-roaming, and momentum-transfer impacts.
308 #[get(skip)]
309 #[get_mut(skip)]
310 #[set(skip)]
311 pub(crate) traffic_vehicles: Vec<NpcVehicle3D>,
312 /// Persistent player chassis dynamics state (velocity, slip angle, drift, nitro boost, suspension pitch/roll, camera feedback).
313 #[get(skip)]
314 #[get_mut(skip)]
315 #[set(skip)]
316 pub(crate) player_physics: PlayerVehiclePhysics3D,
317 /// Monotonic simulation clock in seconds driving continuous animated ocean waves, caustics, and shoreline foam.
318 #[get(type(copy))]
319 pub(crate) world_time_secs: f32,
320 /// Hierarchical Blender/glTF scene graph with topological propagation and 64-bit Collections visibility.
321 pub(crate) scene_graph: SceneGraph3D,
322 /// Full 1:1 Blender Principled BSDF materials referenced by `SceneObject3D::principled_material_id`.
323 pub(crate) principled_materials: Vec<PrincipledMaterial3D>,
324 /// Mipmapped 2D texture pool referenced by `PrincipledMaterial3D` slots.
325 pub(crate) textures: Vec<Texture2D3D>,
326 /// Active armature skins evaluated against `scene_graph` joint world matrices.
327 pub(crate) skins: Vec<Skin3D>,
328 /// Multi-layer glTF/NLA animation mixer ticking directly into `scene_graph`.
329 pub(crate) animation_mixer: AnimationMixer3D,
330 /// Optional precomputed SH9 + octahedral specular + BRDF LUT IBL environment.
331 #[get(skip)]
332 #[get_mut(skip)]
333 #[set(skip)]
334 pub(crate) environment_ibl: Option<EnvironmentIbl3D>,
335 /// Physically based rectangular and disk Blender area lights.
336 pub(crate) area_lights: Vec<AreaLight3D>,
337 /// Imported and user-registered multi-camera list supporting Perspective and Orthographic projections.
338 pub(crate) scene_cameras: Vec<SceneCamera3D>,
339 /// Optional active camera index inside `scene_cameras` (`None` uses primary `camera`).
340 #[get(skip)]
341 #[get_mut(skip)]
342 #[set(skip)]
343 pub(crate) active_scene_camera: Option<usize>,
344 /// Mapping from `scene_graph` node index to spawned `World3D::objects` index for O(1) transform synchronization.
345 #[get(skip)]
346 #[get_mut(skip)]
347 #[set(skip)]
348 pub(crate) node_object_map: Vec<Option<usize>>,
349 /// Reusable pre-allocated skinning and shape-key scratch arena for zero steady-state heap allocations.
350 #[get(skip)]
351 #[get_mut(skip)]
352 #[set(skip)]
353 pub(crate) skin_scratch: SkinPaletteScratch3D,
354 /// Per-object deformed mesh cache aligned with `objects` holding live morphed and skinned vertices.
355 #[get(skip)]
356 #[get_mut(skip)]
357 #[set(skip)]
358 pub(crate) deformed_meshes: Vec<Option<Mesh3D>>,
359 /// Selects Blender AgX filmic view transform (`true`) or ACES Filmic (`false`) during CPU/GPU tonemapping.
360 #[get(type(copy))]
361 pub(crate) use_agx_tonemap: bool,
362 /// Persistent flat scratch buffers eliminating per-frame `Vec<Vec<_>>` allocations and O(N*M) pose scans during GPU pass building.
363 #[get(skip)]
364 #[get_mut(skip)]
365 #[set(skip)]
366 pub(crate) gpu_pass_scratch: World3dGpuPassScratch,
367 /// Persistent quantized geometry cache, batcher scratch, and progressive mip upload watermark reused by `build_gpu_pbr_scene_pass_into`.
368 #[get(skip)]
369 #[get_mut(skip)]
370 #[set(skip)]
371 pub(crate) pbr_pass_scratch: World3dPbrPassScratch,
372}
373
374/// Persistent flat scratch buffers reused by `World3D::build_gpu_scene_pass_into` for zero-allocation O(N) instanced batch building.
375#[derive(Clone, Debug, Default)]
376pub(crate) struct World3dGpuPassScratch {
377 /// Generation-stamped dense lookup epochs indexed directly by `object_index` for O(1) dynamic pose lookup and O(1) clear.
378 pub(crate) dynamic_pose_epochs: Vec<u32>,
379 /// Interpolated dynamic transforms aligned 1:1 with `dynamic_pose_epochs`.
380 pub(crate) dynamic_pose_transforms: Vec<Transform3D>,
381 /// Monotonic epoch counter incremented per pass (`0` triggers full reset on wrap).
382 pub(crate) current_epoch: u32,
383 /// Per-mesh visible instance counts indexed by `mesh_id`.
384 pub(crate) mesh_counts: Vec<u32>,
385 /// Per-mesh scatter write cursors indexed by `mesh_id`.
386 pub(crate) mesh_cursors: Vec<u32>,
387 /// Flat single-allocation gather buffer holding visible `(mesh_id, instance)` pairs before O(N) counting-sort scatter.
388 pub(crate) visible_scratch: Vec<(u32, GpuWorld3dInstance)>,
389}
390
391/// Per-LOD quantized index range and quantization bounds cached inside `World3dPbrPassScratch`.
392#[derive(Clone, Copy, Debug, Default)]
393pub(crate) struct CachedPbrLodRange {
394 /// Starting index inside `GpuPbrMeshBuffer::indices`.
395 pub(crate) index_start: u32,
396 /// Number of triangle indices in this LOD level.
397 pub(crate) index_count: u32,
398 /// Local quantization AABB minimum `[min_x, min_y, min_z, 0.0]`.
399 pub(crate) bounds_min: [f32; 4],
400 /// Local quantization AABB extent `[ext_x, ext_y, ext_z, 0.0]`.
401 pub(crate) bounds_extent: [f32; 4],
402 /// Whether this LOD level contains morph target deltas.
403 pub(crate) has_morphs: bool,
404}
405
406/// Persistent quantized mesh cache and reusable sorting scratch enabling zero-allocation `World3D::build_gpu_pbr_scene_pass_into`.
407#[derive(Clone, Debug, Default)]
408pub(crate) struct World3dPbrPassScratch {
409 /// Cached `Arc`-shared 24-byte quantized geometry buffer rebuilt only when `mesh_library` changes.
410 pub(crate) cached_mesh_buffer: Arc<GpuPbrMeshBuffer>,
411 /// Structural fingerprint `(mesh_count, total_vertices, total_indices)` detecting mesh library mutations.
412 pub(crate) cached_signature: (usize, usize, usize),
413 /// Cached `LOD0..LOD3` index ranges and quantization bounds indexed by `mesh_id`.
414 pub(crate) cached_lod_ranges: Vec<[CachedPbrLodRange; 4]>,
415 /// Reusable 64-bit sort and hardware instancing coalescer arena.
416 pub(crate) batcher: GpuPbrBatcherScratch3D,
417 /// Lowest uploaded mipmap level (`0 = FullRes`, `u8::MAX = Unloaded`) per `World3D::textures` slot.
418 pub(crate) uploaded_texture_min_mip: Vec<u8>,
419}
420
421/// Persistent zero-allocation player vehicle chassis dynamics state for `World3D`.
422#[derive(Clone, Copy, Data, Debug, PartialEq)]
423pub(crate) struct PlayerVehiclePhysics3D {
424 /// World-space horizontal chassis velocity vector `(vx, 0.0, vz)` in meters per second.
425 #[get(type(copy))]
426 pub(crate) vel: Vec3,
427 /// Active yaw angular velocity around the vertical Y axis in radians per second.
428 #[get(type(copy))]
429 pub(crate) yaw_rate: f32,
430 /// Smoothly damped visual chassis lateral body roll angle in radians.
431 #[get(type(copy))]
432 pub(crate) body_roll_rad: f32,
433 /// Smoothly damped visual chassis longitudinal pitch angle in radians (squat/dive).
434 #[get(type(copy))]
435 pub(crate) body_pitch_rad: f32,
436 /// Whether Shift nitro boost is currently delivering extra thrust.
437 #[get(type(copy))]
438 pub(crate) boost_active: bool,
439 /// Normalized remaining nitro boost charge in `[0.0, 1.0]`.
440 #[get(type(copy))]
441 pub(crate) boost_charge: f32,
442 /// Whether Space handbrake powerslide drift is currently active.
443 #[get(type(copy))]
444 pub(crate) drift_active: bool,
445 /// Signed lateral chassis slip angle `atan2(v_lateral, |v_forward|)` in radians.
446 #[get(type(copy))]
447 pub(crate) drift_slip_angle: f32,
448 /// Accumulated continuous drift duration in seconds for exit-drift boost kick qualification.
449 #[get(type(copy))]
450 pub(crate) drift_duration: f32,
451 /// Peak absolute slip angle reached during the active drift window in radians.
452 #[get(type(copy))]
453 pub(crate) drift_peak_slip: f32,
454 /// Smoothly damped dynamic chase-camera vertical FOV boost in degrees.
455 #[get(type(copy))]
456 pub(crate) camera_fov_boost: f32,
457 /// Smoothly decaying impact camera shake amplitude in `[0.0, 1.0]`.
458 #[get(type(copy))]
459 pub(crate) camera_shake: f32,
460}
461
462/// Full dynamic rigid-body state for an autonomous NPC vehicle capable of boulevard cruising, off-road plaza free-roaming, and momentum-transfer impacts.
463#[derive(Clone, Copy, Data, Debug, PartialEq)]
464pub(crate) struct NpcVehicle3D {
465 /// Owning scene object index inside `World3D::objects`.
466 #[get(type(copy))]
467 pub(crate) object_index: usize,
468 /// World-space horizontal rigid-body velocity `(vx, 0.0, vz)` in meters per second.
469 #[get(type(copy))]
470 pub(crate) vel: Vec3,
471 /// Active angular spin rate around the vertical Y axis in radians per second.
472 #[get(type(copy))]
473 pub(crate) yaw_rate: f32,
474 /// Simulated vehicle mass in kilograms for 2-body collision impulse resolution.
475 #[get(type(copy))]
476 pub(crate) mass: f32,
477 /// Target cruising speed in meters per second when autonomous steering is active.
478 #[get(type(copy))]
479 pub(crate) cruise_speed: f32,
480 /// Remaining collision knockback recovery time in seconds during which the vehicle slides/spins freely under tire friction.
481 #[get(type(copy))]
482 pub(crate) recovery_timer: f32,
483 /// Whether this NPC freely roams open off-road plazas and city grounds rather than following the boulevard loop.
484 #[get(type(copy))]
485 pub(crate) free_roam_mode: bool,
486 /// Current progress along the 962m boulevard centerline in meters for loop-cruising NPCs.
487 #[get(type(copy))]
488 pub(crate) loop_arc_s: f32,
489 /// Target lateral offset on the boulevard in meters for undisturbed loop-cruising NPCs.
490 #[get(type(copy))]
491 pub(crate) loop_lane_u: f32,
492 /// Travel direction along the boulevard loop (`+1.0` clockwise, `-1.0` counter-clockwise).
493 #[get(type(copy))]
494 pub(crate) loop_dir: f32,
495 /// Active world-space navigation waypoint `(x, 0.0, z)` for free-roaming NPCs.
496 #[get(type(copy))]
497 pub(crate) nav_target: Vec3,
498 /// Current waypoint index inside the assigned open-city route.
499 #[get(type(copy))]
500 pub(crate) waypoint_idx: usize,
501 /// Open-city off-road route identifier (`0=InnerPlaza, 1=OuterWestPlaza, 2=CrossCourtyard`).
502 #[get(type(copy))]
503 pub(crate) route_id: u8,
504}
505
506/// Per-substep CCD stepping context carrying substep duration, optional playable ground bounds, and vehicle half-extent margin.
507#[derive(Clone, Copy, Debug)]
508pub(crate) struct VehicleCcdStepCtx3D {
509 /// Substep duration in seconds.
510 pub(crate) sub_dt: f32,
511 /// Optional playable horizontal `(min_x, max_x, min_z, max_z)` ground bounds.
512 pub(crate) ground_limits: Option<(f32, f32, f32, f32)>,
513 /// Vehicle horizontal boundary margin in meters.
514 pub(crate) ground_margin: f32,
515}
516
517/// Process-wide cached Vice Boulevard city template bundling pre-built meshes, BVHs, and static GPU vertex buffers for near-zero `/game3d` entry latency.
518#[derive(Clone, Debug)]
519pub(crate) struct OpenWorldCityTemplate3D {
520 /// Fully assembled open-world `World3D` with static and dynamic BVHs already constructed.
521 pub(crate) world: World3D,
522 /// Pre-baked static GPU vertex buffer shared across scene instances in O(1) via `Arc::clone`.
523 pub(crate) gpu_mesh_buffer: Arc<GpuWorld3dMeshBuffer>,
524 /// Per-mesh `(vertex_start, vertex_count)` table paired with `gpu_mesh_buffer`.
525 pub(crate) gpu_mesh_ranges: Vec<(u32, u32)>,
526}