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

Custom colliders support #9

Open
Shatur opened this issue May 5, 2023 · 7 comments
Open

Custom colliders support #9

Shatur opened this issue May 5, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@Shatur
Copy link

Shatur commented May 5, 2023

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,
}
@TheGrimsey TheGrimsey added the enhancement New feature or request label May 5, 2023
@TheGrimsey
Copy link
Owner

This is definitely something on my roadmap.

@Shatur
Copy link
Author

Shatur commented Jul 4, 2023

Especially important with the release of bevy_xpbd.

@Elabajaba
Copy link
Contributor

Elabajaba commented Jul 16, 2023

I came up with something that might work for this. #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()
    }
}

@Shatur
Copy link
Author

Shatur commented Jul 16, 2023

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.

@TheGrimsey
Copy link
Owner

TheGrimsey commented Jul 16, 2023

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.

@Shatur
Copy link
Author

Shatur commented Jul 16, 2023

You are right, this does makes sense.

@Elabajaba
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants