Skip to content

Commit

Permalink
Use cfg_if for parry version finding & enable parry_016 by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGrimsey committed Jul 15, 2024
1 parent ab1d177 commit 334ac4a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_xpbd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Takes in [Parry3d](https://crates.io/crates/parry3d) colliders that implement th
You need to use `OxidizedNavigationPlugin::<Collider>::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.
Expand Down
22 changes: 11 additions & 11 deletions src/parry.rs
Original file line number Diff line number Diff line change
@@ -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.");
}
}

0 comments on commit 334ac4a

Please sign in to comment.