adrien-bon / bevy_ecs_tiled

Helpers for working with 2D tilemaps created with the Tiled map editor
MIT License
34 stars 8 forks source link

Add Avian2D Support #20

Closed giusdp closed 3 months ago

giusdp commented 3 months ago

Close #14

This PR adds physics/avian.rs as an alternative to rapier. Avian2D was added as another optional feature and all the #[cfg(feature = "rapier")] were either updated to #[cfg(any(feature = "rapier", feature = "avian"))] or the avian conditional was added right after. All the rapier examples were replicated with the avian version as well.

In the properties/event.rs the function spawn_rapier_collider was generalized to spawn_collider since now it can either be rapier or avian.

adrien-bon commented 3 months ago

Seems very good, thank you so much! :) I'll have a closer look tonight and merge + release if it's OK

adrien-bon commented 3 months ago

Code seems to work, however CI does not like having the same public functions being defined twice :( (and I'm not sure why I had to manually trigger it)

Would it be possible to rename public functions in src/physics/rapier.rs to insert_XXX_rapier_colliders and public functions in src/physics/avian.rs to insert_XXX_avian_colliders ? We could then define functions insert_object_colliders and insert_tile_colliders in ./src/physics/mod.rs which will call either backend based upon feature flags (simple pass-through functions). This way, you won't have to rename everything in the other places.

Also, could you please add the new examples in examples/README.md ?

Thanks!

giusdp commented 3 months ago

Code seems to work, however CI does not like having the same public functions being defined twice :( (and I'm not sure why I had to manually trigger it)

Would it be possible to rename public functions in src/physics/rapier.rs to insert_XXX_rapier_colliders and public functions in src/physics/avian.rs to insert_XXX_avian_colliders ? We could then define functions insert_object_colliders and insert_tile_colliders in ./src/physics/mod.rs which will call either backend based upon feature flags (simple pass-through functions). This way, you won't have to rename everything in the other places.

Also, could you please add the new examples in examples/README.md ?

Thanks!

Working on it!

giusdp commented 3 months ago

Clippy now was happy locally @adrien-bon

adrien-bon commented 3 months ago

Seems good! I'll merge and do the release. Thank you very much! :)