-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rapier 0.20 feature: RevoluteJoint::angle
+ more detailed joints enum
#530
rapier 0.20 feature: RevoluteJoint::angle
+ more detailed joints enum
#530
Conversation
…ded from rapier 0.20.
…ecify a lot of systems/filters the generic path could be interesting when/if bevy supports trait queries, but currently I feel it's not worth it.
src/dynamics/joint.rs
Outdated
impl JointDescription { | ||
/// The underlying generic joint. | ||
pub fn generic_joint(&self) -> &GenericJoint { | ||
match self { | ||
JointDescription::FixedJoint(j) => &j.data, | ||
JointDescription::GenericJoint(j) => j, | ||
JointDescription::PrismaticJoint(j) => &j.data, | ||
JointDescription::RevoluteJoint(j) => j.data(), | ||
JointDescription::RopeJoint(j) => j.data(), | ||
#[cfg(feature = "dim3")] | ||
JointDescription::SphericalJoint(j) => j.data(), | ||
JointDescription::SpringJoint(j) => j.data(), | ||
} | ||
} | ||
/// The underlying generic joint. | ||
pub fn generic_joint_mut(&mut self) -> &mut GenericJoint { | ||
match self { | ||
JointDescription::FixedJoint(ref mut j) => &mut j.data, | ||
JointDescription::GenericJoint(ref mut j) => j, | ||
JointDescription::PrismaticJoint(ref mut j) => &mut j.data, | ||
JointDescription::RevoluteJoint(ref mut j) => &mut j.data, | ||
JointDescription::RopeJoint(ref mut j) => &mut j.data, | ||
#[cfg(feature = "dim3")] | ||
JointDescription::SphericalJoint(ref mut j) => &mut j.data, | ||
JointDescription::SpringJoint(ref mut j) => &mut j.data, | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could be AsRef
/AsMut
implementations instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, I'll do that.
For the story behind this explicit naming: ideally I would have liked to wrap our joints (bevy_rapier::FixedJoint
, etc...) around the correct joint from rapier (rapier::FixedJoint
, etc.), so a user could use the relevant functions from rapier if some functions were not exposed by bevy_rapier (it can easily be forgotten...), but I had difficulties, probably the builder had to be updated significantly so I dropped the idea.
See #529 for similar reasoning logic.
Co-authored-by: Sébastien Crozet <[email protected]>
RevoluteJoint::angle
RevoluteJoint::angle
+ more detailed joints enum
Co-authored-by: Sébastien Crozet <[email protected]>
add helper method to get the angle of a revolute joint ; from rapier 0.20.
We noticed a bug on joints because of rapier 0.20, so this builds up on #547.
I wanted to take the
ImpulseJointSet
as parameter but that doesn't work withMultibodyJointSet
so I settled to pass rigidbodies.I tried to implement a Generic
ImpulseJoint<JointDescription>
, but that proved very impractical for functions such assync removal
. we could revisit that if one day bevy supports trait queries, but currently I feel it's not worth it.Because we need both
ImpulseJoint
andRevoluteJoint
fromRapierContext
, I couldn't settle on a better place thanRapierContext
for thisangle_for_entity_impulse_revolute_joint
function.Failed improvements
I would have liked to make it more typed, but that's the best I could do.
I think it boils down to
bevy_rapier::ImpulseJoint
not exposing directlybody1
andbody2
, which are necessary to compute the angle. I imagine it's current entity +bevy_rapier::ImpulseJoint::parent
, but I went the route to get the data from rapier directly, it doesn't complicate the public facing API.I feel a method
angle(entity, entity)
would only be more difficult to follow invariants.