Skip to content
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

Remove rest_length field from DistanceJoint. #517

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

shanecelis
Copy link
Contributor

@shanecelis shanecelis commented Sep 22, 2024

Objective

Remove rest_length from DistanceJoint which is ignored if length_limits is present.

Problem

I was using distance joints as muscles, changing their rest length to exert them. However, when I set the length_limits, nothing worked anymore. I looked into the code and saw my error: rest_length is ignored when length_limits is set, which seems like a foot gun to me. A TODO in the code said "Remove rest_length" and after surveying the code, I agreed.

Solution

I removed rest_length and with_rest_length() from DistanceJoint.

I changed the name and arguments of with_limits() to with_length_limits(). I think this makes it clearer that it's associated with the length_limits field. And I altered the arguments to accept Into<DistanceLimit>, so that it can be set with a Scalar, a pair of Scalars, or a DistanceLimit. My hope was that with_length_limits() could serve in place of both with_limits() and with_rest_length().

Auxillary Changes

Some doc tests weren't passing. I added the necessary ampersands (&) to make them pass.


Changelog

  • Added: From<Scalar> and From<(Scalar, Scalar)> for DistanceLimit.
  • Changed: Method name with_limits to with_length_limits for DistanceJoint.
  • Changed: Removed rest_length field from DistanceJoint.
  • Changed: Removed with_rest_length() method from DistanceJoint.

Migration Guide

  • Replace with_rest_length(1.0) with with_length_limits(1.0).
  • Replace joint.rest_length = 1.0 with joint.length_limits = 1.0.into()`.
  • Replace with_limits(0.0, 1.0) with with_length_limits((0.0, 1.0)).

Just added a '&' where needed.
Add From<Scalar> and From<(Scalar, Scalar)> for DistanceLimit.
she's trying to help you out."--Hansel, Zoolander (2001)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant