dimforge / parry

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

Add bevy-components feature #57

Closed deontologician closed 2 years ago

deontologician commented 2 years ago

After https://github.com/bevyengine/bevy/pull/2254 there is a requirement that anything used as a component must derive Component explicitly.

From what I can tell, most of the data structures that are used as components in bevy_rapier are defined in rapier, but SharedShape is re-exported from parry, so the annotation has to go here.

I attempted to minimize the effect on parry by:

One thing I'm unsure of is specifying the version of bevy. I've included it as 0.5 here, because that's what's on crates.io right now, but this code won't actually work with that version, only with a particular branch of bevy in this PR (which will hopefully land soon):

https://github.com/bevyengine/bevy/pull/2305

MiniaczQ commented 2 years ago

I don't think a feature like this should belong in the main branch. It's only a temporary fix until we get better syntax to do it properly from only the interop crate.

Aceeri commented 2 years ago

@MiniaczQ I'm not sure there is much of an alternative to this currently (maybe doing just wrapper types in the interop crate?). I don't think we are getting better syntax for doing this anytime soon based on looking at https://github.com/rust-lang/rfcs/pull/2393.

deontologician commented 2 years ago

@MiniaczQ I'm not sure there is much of an alternative to this currently (maybe doing just wrapper types in the interop crate?). I don't think we are getting better syntax for doing this anytime soon based on looking at https://github.com/rust-lang/rfcs/pull/2393.

It sounds like wrappers in the interop crate is the way to go, but that requires the most knowledge of the innards. This change was relatively easy to make as an outsider without changing how bevy_rapier works internally.

sebcrozet commented 2 years ago

Thank you for this PR @deontologician! I’m closing it since I ended up using wrapper types instead: https://github.com/dimforge/bevy_rapier/pull/102.