Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bevy 0.15 #35

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[profile.ci]
fail-fast = false

[profile.ci.junit]
path = "junit.xml"
store-success-output = true
store-failure-output = true
64 changes: 64 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CI

on:
workflow_dispatch:
pull_request:
branches: [ "master", "dev" ]

env:
CARGO_TERM_COLOR: always

jobs:
checks:
name: Lints
runs-on: ubuntu-22.04
steps:
- uses: olix0r/cargo-action-fmt/setup@v2
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Run cargo fmt
run: cargo fmt --all -- --check
- name: Run cargo check
if: always()
run: cargo check --lib --all-features --message-format json | cargo-action-fmt
- name: Run cargo clippy
if: always()
run: cargo clippy --all-features --no-deps --message-format json -- -D warnings | cargo-action-fmt

tests:
name: Test Suite
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
backend:
- feature: parry3d
artifact_key: benches
test_arg: --benches
- feature: parry3d
artifact_key: parry3d
test_arg: --test parry3d
- feature: avian
artifact_key: avian
test_arg: --test avian
- feature: rapier
artifact_key: rapier3d
test_arg: --test rapier3d
steps:
- name: Checkout repository code.
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.backend.artifact_key }}
- name: Install alsalib headers
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
- uses: taiki-e/install-action@nextest
- name: Test with nextest
run: cargo nextest run --no-default-features --features "${{ matrix.backend.feature }}" ${{ matrix.backend.test_arg }} --profile ci
- name: Upload Test Report
uses: actions/upload-artifact@v4
if: always()
with:
name: junit-test-results-${{ matrix.backend.artifact_key }}
path: target/nextest/**/*.xml
retention-days: 1
21 changes: 0 additions & 21 deletions .github/workflows/test_avian.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/test_parry.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/test_rapier.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
/Cargo.lock
/.idea
56 changes: 31 additions & 25 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,69 +14,72 @@ documentation = "https://docs.rs/crate/oxidized_navigation"
keywords = ["gamedev", "navmesh", "navmesh-generation", "bevy"]
categories = ["game-development"]

[lib]
bench = false

[features]
default = ["parry_016"]
rapier = ["bevy_rapier3d", "parry_016"]
avian = ["avian3d", "parry_015"]
debug_draw = ["bevy/bevy_gizmos", "bevy/bevy_render"]
default = ["parry3d"]
rapier = ["bevy_rapier3d", "parry3d"]
avian = ["avian3d", "parry3d"]
debug_draw = ["bevy/bevy_gizmos", "bevy/bevy_render", "bevy_rapier3d?/debug-render-3d", "avian3d?/debug-plugin"]
trace = []

parry_016 = ["parry3d_016"]
parry_015 = ["parry3d_015"]

[[example]]
name = "rapier3d"
required-features = ["debug_draw", "rapier"]
required-features = ["rapier", "debug_draw"]

[[example]]
name = "rapier3d_heightfield"
required-features = ["debug_draw", "rapier"]
required-features = ["rapier", "debug_draw"]

[[example]]
name = "rapier3d_multi_floor"
required-features = ["debug_draw", "rapier"]
required-features = ["rapier", "debug_draw"]

[[example]]
name = "avian"
required-features = ["debug_draw", "avian"]
required-features = ["avian", "debug_draw"]

[[example]]
name = "avian_multi_floor"
required-features = ["avian", "debug_draw"]

[[example]]
name = "parry3d"
required-features = ["parry_016", "debug_draw"]
required-features = ["parry3d", "debug_draw"]

[[test]]
name = "rapier3d"
required-features = ["rapier"]


[[test]]
name = "avian"
required-features = ["avian"]

[[test]]
name = "parry3d"
required-features = ["parry_016"]
required-features = ["parry3d"]

[dependencies]
bevy = { version = "0.14", default-features = false, features = ["multi_threaded"] }
bevy = { version = "0.15", default-features = false, features = ["multi_threaded"] }

# parry3d doesn't expose the convert-glam feature, so we need to add nalgebra to enable the feature
nalgebra = { version = "0.33", features = ["convert-glam027"] }
nalgebra = { version = "0.33", features = ["convert-glam029"] }

parry3d_016 = { package = "parry3d", version = "0.16", optional = true }
parry3d_015 = { package = "parry3d", version = "0.15", optional = true }
parry3d = { version = "0.17", optional = true }

bevy_rapier3d = { version = "0.27", optional = true, default-features = false, features = ["dim3"] }
avian3d = { version = "0.1", optional = true, default-features = false, features = ["3d", "f32", "parry-f32"] }
bevy_rapier3d = { version = "0.28", optional = true, default-features = false, features = ["dim3"] }
avian3d = { version = "0.1", optional = true, default-features = false, features = ["3d", "f32", "parry-f32"] }

smallvec = { version = "1.13", features = ["union"] }
cfg-if = "1.0.0"
cfg-if = "1.0"

[dev-dependencies]
bevy = { version = "0.14.0", default-features = false, features = [
bevy = { version = "0.15", default-features = false, features = [
"bevy_asset",
"bevy_pbr",
"bevy_render",
"bevy_window",
"bevy_winit",
"x11",
"ktx2",
Expand All @@ -88,13 +91,16 @@ criterion = { version = "0.5" }
[[bench]]
name = "simple_geometry"
harness = false
required-features = [ "parry_016" ]
required-features = ["parry3d"]

[[bench]]
name = "simple_navigation"
harness = false
required-features = [ "parry_016" ]
required-features = ["parry3d"]

[package.metadata.docs.rs]
# Compile docs.rs docs with debug_draw so docs for it appear.
features = [ "debug_draw" ]
features = ["debug_draw"]

[patch.crates-io]
avian3d = { git = "https://github.com/Jondolf/avian.git", branch = "main" }
73 changes: 31 additions & 42 deletions examples/avian.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//! A simple example showing how to use oxidized_navigation with Avian3d.
//! Press M to draw nav-mesh.
//! Press X to spawn or despawn red cube.
use bevy::{math::primitives, prelude::*};
use avian3d::prelude::{Collider, PhysicsPlugins};
use bevy::{math::primitives, prelude::*};
use oxidized_navigation::{
debug_draw::{DrawNavMesh, OxidizedNavigationDebugDrawPlugin},
NavMeshAffector, NavMeshSettings, OxidizedNavigationPlugin,
Expand All @@ -27,16 +29,15 @@ fn main() {
.add_systems(Startup, setup)
.add_systems(
Update,
(toggle_nav_mesh_system, spawn_or_despawn_affector_system),
(toggle_nav_mesh_debug_draw, spawn_or_despawn_affector_system),
)
.run();
}

//
// Toggle drawing Nav-mesh.
// Press M to toggle drawing the navmesh.
//
fn toggle_nav_mesh_system(keys: Res<ButtonInput<KeyCode>>, mut show_navmesh: ResMut<DrawNavMesh>) {
fn toggle_nav_mesh_debug_draw(
keys: Res<ButtonInput<KeyCode>>,
mut show_navmesh: ResMut<DrawNavMesh>,
) {
if keys.just_pressed(KeyCode::KeyM) {
show_navmesh.0 = !show_navmesh.0;
}
Expand All @@ -49,53 +50,44 @@ fn setup(
) {
print_controls();

commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(10.0, 10.0, 15.0)
.looking_at(Vec3::new(0.0, 2.0, 0.0), Vec3::Y),
..default()
});
// Camera
commands.spawn((
Camera3d::default(),
Transform::from_xyz(10.0, 10.0, 15.0).looking_at(Vec3::new(0.0, 2.0, 0.0), Vec3::Y),
));

commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
// Directional light
commands.spawn((
DirectionalLight {
shadows_enabled: true,
..default()
},
transform: Transform::from_rotation(Quat::from_euler(EulerRot::XYZ, -1.0, -0.5, 0.0)),
..default()
});
Transform::from_rotation(Quat::from_euler(EulerRot::XYZ, -1.0, -0.5, 0.0)),
));

// Plane
// Ground plane
commands.spawn((
PbrBundle {
mesh: meshes.add(primitives::Rectangle::from_size(Vec2::new(50.0, 50.0))),
material: materials.add(Color::srgb(0.3, 0.5, 0.3)),
transform: Transform::IDENTITY,
..default()
},
Mesh3d(meshes.add(Plane3d::default().mesh().size(25.0, 25.0))),
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
Transform::IDENTITY,
Collider::cuboid(25.0, 0.1, 25.0),
NavMeshAffector, // Only entities with a NavMeshAffector component will contribute to the nav-mesh.
));

// Cube
commands.spawn((
PbrBundle {
mesh: meshes.add(primitives::Cuboid::new(2.5, 2.5, 2.5)),
material: materials.add(Color::srgb(0.1, 0.1, 0.5)),
transform: Transform::from_xyz(-5.0, 0.8, -5.0),
..default()
},
Mesh3d(meshes.add(primitives::Cuboid::new(2.5, 2.5, 2.5))),
MeshMaterial3d(materials.add(Color::srgb(0.1, 0.1, 0.5))),
Transform::from_xyz(-5.0, 0.8, -5.0),
Collider::cuboid(1.25, 1.25, 1.25),
NavMeshAffector, // Only entities with a NavMeshAffector component will contribute to the nav-mesh.
));

// Thin wall
commands.spawn((
PbrBundle {
mesh: meshes.add(Mesh::from(primitives::Cuboid::new(0.1, 0.1, 0.1))),
material: materials.add(Color::srgb(0.1, 0.1, 0.5)),
transform: Transform::from_xyz(-3.0, 0.8, 5.0).with_scale(Vec3::new(50.0, 15.0, 1.0)),
..default()
},
Mesh3d(meshes.add(Mesh::from(primitives::Cuboid::new(0.1, 0.1, 0.1)))),
MeshMaterial3d(materials.add(Color::srgb(0.1, 0.1, 0.5))),
Transform::from_xyz(-3.0, 0.8, 5.0).with_scale(Vec3::new(50.0, 15.0, 1.0)),
Collider::cuboid(0.05, 0.05, 0.05),
NavMeshAffector, // Only entities with a NavMeshAffector component will contribute to the nav-mesh.
));
Expand All @@ -118,12 +110,9 @@ fn spawn_or_despawn_affector_system(
} else {
let entity = commands
.spawn((
PbrBundle {
mesh: meshes.add(primitives::Cuboid::new(2.5, 2.5, 2.5)),
material: materials.add(Color::srgb(1.0, 0.1, 0.5)),
transform: Transform::from_xyz(5.0, 0.8, 0.0),
..default()
},
Mesh3d(meshes.add(primitives::Cuboid::new(2.5, 2.5, 2.5))),
MeshMaterial3d(materials.add(Color::srgb(1.0, 0.1, 0.5))),
Transform::from_xyz(5.0, 0.8, 0.0),
Collider::cuboid(2.5, 2.5, 2.5),
NavMeshAffector, // Only entities with a NavMeshAffector component will contribute to the nav-mesh.
))
Expand Down
Loading