dimforge / parry

2D and 3D collision-detection library for Rust.
https://parry.rs
Apache License 2.0
565 stars 100 forks source link

Composable QueryDispatcher #218

Open Neo-Zhixing opened 3 months ago

Neo-Zhixing commented 3 months ago

Resolves #8

Implements @Ralith 's suggestion regarding composable QueryDispatcher.

End-user ergonomics could be preserved by relegating the root_dispatcher argument to a trait for use only by shape implementers, and turning QueryDispatcher into a blanket-implemented trait that encapsulates the self.query(self, ...) dance, and provides a chain helper for composition.

I prefer this solution over the one suggested by @sebcrozet because @Ralith 's solution allows external crates to composably define shapes that need to dispatch recursively.

Ralith commented 3 months ago

Thanks for building this out! This does look like what I had in mind. I didn't pursue it because I didn't have a pressing need, but I do think something like this is the right long term solution.

Neo-Zhixing commented 2 months ago

@sebcrozet Can you give this a review?