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

Broad phase pair filters cannot access body information #273

Open
neachdainn opened this issue Jul 8, 2020 · 2 comments
Open

Broad phase pair filters cannot access body information #273

neachdainn opened this issue Jul 8, 2020 · 2 comments

Comments

@neachdainn
Copy link
Contributor

neachdainn commented Jul 8, 2020

The current API for the broad phase pair filter cannot access any information about the bodies that are colliding. The filter has access to the handles via the BroadPhasePairFilter trait but there is not way to retrieve the body information from the set due to the fact that MechanicalWorld::step, which calls the filter, requires mutable access to the body set. Utilizing the user data on the collider is sufficient for cases where the information does not change during each step (e.g., parent information) but cannot be used for information about a body that may have been updated.

@neachdainn
Copy link
Contributor Author

neachdainn commented Jul 8, 2020

I investigated having nphysics define its own BroadPhasePairFilter trait but almost 100% of the collision logic happens in ncollide (unsurprisingly). So it looks like this will have to be a change within ncollide.


I suspect the best approach would be to modify the BroadPhasePairFilter to the following:

pub trait BroadPhasePairFilter<N: RealField, Object, Handle, Set>: Any  + Send + Sync {
    fn is_pair_valid(&self, b1: &Object, b2: &Object, h1: Handle, h2: Handle, set: &Set) -> bool;
}

where Set becomes the BodySet in nphysics. This will require a change at every step between nphysics and ncollide's src/pipeline/glue/update.rs, so it's a fairly sizable change. I'll wait to start working on this until I get input.

@neachdainn
Copy link
Contributor Author

Alternatives discussed on Discord:

  • Using an associated type with a default and implementing a default fn is_pair_valid_in_set.
  • Creating a new trait BroadPhasePairSetFilter that is auto-implemented for (or auto-implements) BroadPhasePairFilter

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

No branches or pull requests

1 participant