use std::{num::NonZeroU16, time::Duration}; use bevy::prelude::*; use oxidized_navigation::{ colliders::OxidizedCollider, query::find_path, ActiveGenerationTasks, NavMesh, NavMeshAffector, NavMeshSettings, OxidizedNavigationPlugin, }; use parry3d_016::shape::SharedShape; const TIMEOUT_DURATION: Duration = Duration::new(15, 0); const SLEEP_DURATION: Duration = Duration::from_millis(2); #[derive(Component)] struct MyParryCollider { collider: SharedShape, } impl OxidizedCollider for MyParryCollider { fn oxidized_into_typed_shape(&self) -> parry3d_016::shape::TypedShape { self.collider.as_typed_shape() } fn oxidized_compute_local_aabb(&self) -> parry3d_016::bounding_volume::Aabb { self.collider.compute_local_aabb() } } fn setup_world_system(mut commands: Commands) { // Plane commands.spawn(( TransformBundle::IDENTITY, MyParryCollider { collider: SharedShape::cuboid(25.0, 0.1, 25.0), }, NavMeshAffector, )); // Cube commands.spawn(( TransformBundle::from_transform(Transform::from_xyz(-5.0, 0.8, -5.0)), MyParryCollider { collider: SharedShape::cuboid(1.25, 1.25, 1.25), }, NavMeshAffector, )); // Tall Cube commands.spawn(( TransformBundle::from_transform( Transform::from_xyz(-0.179, 18.419, -27.744).with_scale(Vec3::new(15.0, 15.0, 15.0)), ), MyParryCollider { collider: SharedShape::cuboid(1.25, 1.25, 1.25), }, NavMeshAffector, )); // Thin wall commands.spawn(( TransformBundle::from_transform( Transform::from_xyz(-3.0, 0.8, 5.0).with_scale(Vec3::new(50.0, 15.0, 1.0)), ), MyParryCollider { collider: SharedShape::cuboid(0.05, 0.05, 0.05), }, NavMeshAffector, )); } fn setup_app(app: &mut App) { app.add_plugins(( MinimalPlugins, TransformPlugin, OxidizedNavigationPlugin::::new(NavMeshSettings { cell_width: 0.25, cell_height: 0.1, tile_width: 100, world_half_extents: 250.0, world_bottom_bound: -100.0, max_traversable_slope_radians: (40.0_f32 - 0.1).to_radians(), walkable_height: 20, walkable_radius: 1, step_height: 3, min_region_area: 100, max_region_area_to_merge_into: 500, max_contour_simplification_error: 1.1, max_edge_length: 80, max_tile_generation_tasks: NonZeroU16::new(8), // Github Actions are limited to 7 GB. }), )); } fn wait_for_generation_to_finish(app: &mut App) { loop { app.update(); if app.world().resource::().is_empty() { break; } else if app.world().resource::