jcornaz / heron

[DISCONTINUED] An ergonomic physics API for bevy games
MIT License
292 stars 44 forks source link

Make tuple fields on ColliderHandle and RigidBodyHandle pub, or provide accessors? #174

Closed edisno closed 2 years ago

edisno commented 2 years ago

I use rapier3d::prelude::NarrowPhase directly and its method contact_pair needs access to the inner ColliderHandle. Could we accommodate for this?

--- a/rapier/src/lib.rs
+++ b/rapier/src/lib.rs
@@ -56,14 +56,14 @@ pub struct RapierPlugin;
 /// It is automatically inserted and removed by heron.
 /// It is only useful for advanced, direct access to the rapier world
 #[derive(Debug, Copy, Clone, Eq, PartialEq, Component)]
-pub struct RigidBodyHandle(dynamics::RigidBodyHandle);
+pub struct RigidBodyHandle(pub dynamics::RigidBodyHandle);

 /// Component that holds a reference to the rapier collider
 ///
 /// It is automatically inserted and removed by heron.
 /// It is only useful for advanced, direct access to the rapier world
 #[derive(Debug, Copy, Clone, Eq, PartialEq, Component)]
-pub struct ColliderHandle(geometry::ColliderHandle);
+pub struct ColliderHandle(pub geometry::ColliderHandle);
jcornaz commented 2 years ago

Hi.

There is a conversion available: https://docs.rs/heron/1.0.1-rc.1/heron/rapier_plugin/struct.ColliderHandle.html#impl-IntoRapier%3CColliderHandle%3E-1

let rapier_handle: rapier3d::ColliderHandle = heron_handle.into_rapier();

I cannot make the inner field directly public, nor can i implement Deref because the actual rapier type can change depending the feature flags used.