diff --git a/.github/workflows/test_xpbd.yml b/.github/workflows/test_xpbd.yml index 4914851..f3b4bdd 100644 --- a/.github/workflows/test_xpbd.yml +++ b/.github/workflows/test_xpbd.yml @@ -18,4 +18,4 @@ jobs: - name: Install alsalib headers run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev - name: Run tests for repository. - run: cargo test --features "xpbd" + run: cargo test --no-default-features --features "xpbd" diff --git a/Cargo.toml b/Cargo.toml index 8c987b7..05b3e48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,6 +70,7 @@ bevy_rapier3d = { version = "0.27", optional = true, default-features = false, f bevy_xpbd_3d = { version = "0.5", optional = true, default-features = false, features = ["3d", "f32", "parry-f32"] } smallvec = { version = "1.13", features = ["union"] } +cfg-if = "1.0.0" [dev-dependencies] bevy = { version = "0.14.0", default-features = false, features = [ diff --git a/README.md b/README.md index 072a1e4..1d7cce0 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,12 @@ Takes in [Parry3d](https://crates.io/crates/parry3d) colliders that implement th You need to use `OxidizedNavigationPlugin::::new(NavMeshSettings {...}`, where `Collider` is either a rapier or xpbd `Collider`, or your own custom collider that implements the `OxidizedCollider` trait. This is necessary to allow us to be generic over different `Collider` components. +> When enabling XPBD, I get the error "You must pick a single parry3d feature." + +You need to disable the default `parry_016` feature as XPBD uses a different version of `Parry3d`. + +*A version of `Parry3d` needs to be enabled by default for the crate to be compilable & publishable.* + > I don't want to use the Rapier3d or XPBD3d physics engines just to generate a navmesh. How do I create my own `parry3d` wrapper component? You need to create a component that contains a parry3d `SharedShape`, then implement the `OxidizedCollider` trait. See the [parry3d example](./examples/parry3d.rs) for a basic example. diff --git a/src/parry.rs b/src/parry.rs index 5d9d152..6fc5aec 100644 --- a/src/parry.rs +++ b/src/parry.rs @@ -1,12 +1,12 @@ -#[cfg(feature = "parry_016")] -pub use parry3d_016 as parry3d; - -#[cfg(feature = "parry_015")] -pub use parry3d_015 as parry3d; - -#[cfg(all(feature = "parry_016", feature = "parry_015"))] -compile_error!("You must pick a single parry3d feature."); - -#[cfg(all(not(feature = "parry_016"), not(feature = "parry_015")))] -compile_error!("You must enabled a Parry3d feature matching your version. Either 0.16 or 0.15."); +cfg_if::cfg_if! { + if #[cfg(all(feature = "parry_016", feature = "parry_015"))] { + compile_error!("You must pick a single parry3d feature."); + } else if #[cfg(feature = "parry_015")] { + pub use parry3d_015 as parry3d; + } else if #[cfg(feature = "parry_016")] { + pub use parry3d_016 as parry3d; + } else { + compile_error!("You must enabled either the `parry_015` or `parry_016` feature matching, whichever matches your Parry3d version."); + } +}