Custom colliders support
Currently the plugin uses only Rapier colliders for calculating the navigation. But it would be great to make this integration optional for games that does not use physics like mine. I would like to suggest to add support for using AABB and mesh for path navigation calculation.
So I proposing to turn NavMeshAffector into enum with the following fields:
enum NavMeshAffector {
#[cfg(feature = "rapier")]
RapierCollider,
Mesh,
Aabb,
}
This is definitely something on my roadmap.
Especially important with the release of bevy_xpbd.
I came up with something that might work for this. https://github.com/TheGrimsey/oxidized_navigation/pull/14
It changes the internals from using bevy_rapier3d to using parry3d, and uses a generic on plugin creation to know what Collider to query for.
The Collider is just a thin wrapper around a parry collider, but it should be possible for people/crates that aren't using parry3d to create a wrapper that converts their collider type to a parry3d collider.
bevy_xpbd support only required
impl Collider for XpbdCollider {
fn into_typed_shape(&self) -> TypedShape {
self.as_typed_shape()
}
fn t_compute_local_aabb(&self) -> Aabb {
self.compute_local_aabb()
}
}
Could work, but I think that the suggested enum is a better solution, it could work even without physics. There is no reason to depend on parry for navigation crate.
I quite like @Elabajaba's solution for being generic over colliders.
Seems to me it should be possible to combine it with the enum but simply have a generic collider variant instead (for example):
enum NavMeshAffector {
#[cfg(any(feature = "rapier", feature = "xpbd"))]
Collider,
Mesh,
Aabb,
}
Parry dependency should also then be optional behind any of the physics features.
You are right, this does makes sense.
I originally tried something similar to the NavMeshAffector enum, but on Collider, and it got really ugly very quickly and ended up with a lot of duplicated code and #[cfg(feature="...")] everywhere, so I dropped it and just moved to parry+generics since it would let you use it without a physics engine.