Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Document how to access rapier's RigidBody and RigidBodyBuilder methods #43

Open
ufReitter opened this issue Mar 1, 2021 · 6 comments
Open
Labels
documentation Changes to the documentation up-for-grabs Good for newcomers

Comments

@ufReitter
Copy link

By easy to set or well documented exposure of i.e. mass_properties or external forces (at point) the user can do full fledged flight/boat simulation from the get go.

@jcornaz
Copy link
Owner

jcornaz commented Mar 1, 2021

Yes, I aggree it isn't well documented. I'll write something about that.

In short:

  • The RigidBodySet and ColliderSet are registerd in the resources
  • Every rigid body managed by heron has a BodyHandle component that contains two handles (one for the rigid body, and one for the collider)
  • The rapier library is reexported under heron::rapier_plugin::rapier

With that you should be able to get and manipulate the bodies from the RigidBodySet at your will.

@jcornaz jcornaz added the documentation Changes to the documentation label Mar 1, 2021
@jcornaz jcornaz changed the title Exposing rapiers RigidBody and RigidBodyBuilder methods Document how to access rapier's RigidBody and RigidBodyBuilder methods Mar 1, 2021
@MGlolenstine
Copy link
Contributor

How would one access the RigidBodyBuilder method?
I'm trying to give an object just one axis to rotate around.
(i.e Player can change their Yaw, not Pitch or Roll)

@jcornaz
Copy link
Owner

jcornaz commented Mar 6, 2021

How would one access the RigidBodyBuilder method?

For now you have to use rapier directly. So basically, call RigidBodyBuilder and ColliderBuilder to create the body and collider and add them to the RigidBodySet and ColliderSet resources.

Then if you want to have heron to be aware of theses manually created rapier entities (so that you can use heron's Velocity for instance, and have the transform updated) add a BodyHandle component that contains both the rigid body handle and collider handle.

I'm trying to give an object just one axis to rotate around.

Thanks for sharing the use-case 😊. I created an issue to provide first-class support of axis-locking: #53

@MGlolenstine
Copy link
Contributor

How would one create a BodyHandle manually?

/// Components automatically register, by the plugin that references the body in rapier's world
///
/// It can be used to get direct access to rapier's world.
#[derive(Debug, Copy, Clone)]
pub struct BodyHandle {
    rigid_body: RigidBodyHandle,
    collider: ColliderHandle,
}

I've tried directly creating the struct, but the fields are private and I can't set them.

@jcornaz
Copy link
Owner

jcornaz commented Mar 6, 2021

I've tried directly creating the struct, but the fields are private and I can't set them.

Ah, oups, sorry. I'll fix that.

@MGlolenstine
Copy link
Contributor

I did make a #54, waiting for the Clippy to finish.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Changes to the documentation up-for-grabs Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants