dimforge / bevy_rapier

Official Rapier plugin for the Bevy game engine.
https://rapier.rs
Apache License 2.0
1.2k stars 257 forks source link

Publish `bevy_rapier` #52

Closed joshuajbouw closed 3 years ago

joshuajbouw commented 3 years ago

Only two flavours are available for bevy_rapier as 2D and 3D which is fine however, if a library is depending on the crate and also has an optional 2D or 3D varient, it becomes awkward to forward the features.

Which ends up looking like the below:

# 2D
dim2 = []
dim2-enhanced-determinism = ["bevy_rapier2d/enhanced-determinism"]
dim2-parallel = ["bevy_rapier2d/parallel"]
dim2-serde-serialize = ["bevy_rapier2d/serde-serialize"]
dim2-simd-nightly = ["bevy_rapier2d/simd-nightly"]
dim2-simd-stable = ["bevy_rapier2d/simd-stable"]
dim2-wasm-bindgen = ["bevy_rapier2d/wasm-bindgen"]

# 3D
dim3 = []
dim3-enhanced-determinism = ["bevy_rapier3d/enhanced-determinism"]
dim3-parallel = ["bevy_rapier3d/parallel"]
dim3-serde-serialize = ["bevy_rapier3d/serde-serialize"]
dim3-simd-nightly = ["bevy_rapier3d/simd-nightly"]
dim3-simd-stable = ["bevy_rapier3d/simd-stable"]
dim3-wasm-bindgen = ["bevy_rapier3d/wasm-bindgen"]

A solution would be simply just to publish bevy_rapier which allows people to conditionally feature gate it as they wish given context. Its just so much cleaner.

Then simply would end up looking like:

dim2 = []
dim3 = []
enhanced-determinism = ["bevy_rapier/enhanced-determinism"]
parallel = ["bevy_rapier/parallel"]
serde-serialize = ["bevy_rapier/serde-serialize"]
simd-nightly = ["bevy_rapier/simd-nightly"]
simd-stable = ["bevy_rapier/simd-stable"]
wasm-bindgen = ["bevy_rapier/wasm-bindgen"]
sebcrozet commented 3 years ago

Hi! I'm not sure how bevy_rapier itself would do this. Basically the bevy_rapier crate would have to optionally depend on both bevy_rapier2d and bevy_rapier3d, and it will end up having the exact same problem as you regarding transitively enabling features.

Also I'm not sure why you need to have these transitive features in the first place. The end-user can do this for example:

[dependencies]
your_crate = { version = "...",  features = [ "dim2" ] }
bevy_rapier2d = { version = "...", features = ["parallel", "simd-nightly"] }

Which would achieve the same effect as the transitive features.

joshuajbouw commented 3 years ago

Oh hey, good to know. That I wasn't too sure about, great to hear that Rust handles that.