Remove rest_length
field from DistanceJoint
.
#517
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Remove
rest_length
fromDistanceJoint
which is ignored iflength_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 whenlength_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
andwith_rest_length()
fromDistanceJoint
.I changed the name and arguments of
with_limits()
towith_length_limits()
. I think this makes it clearer that it's associated with thelength_limits
field. And I altered the arguments to acceptInto<DistanceLimit>
, so that it can be set with aScalar
, a pair ofScalar
s, or aDistanceLimit
. My hope was thatwith_length_limits()
could serve in place of bothwith_limits()
andwith_rest_length()
.Auxillary Changes
Some doc tests weren't passing. I added the necessary ampersands (&) to make them pass.
Changelog
From<Scalar>
andFrom<(Scalar, Scalar)>
forDistanceLimit
.with_limits
towith_length_limits
forDistanceJoint
.rest_length
field fromDistanceJoint
.with_rest_length()
method fromDistanceJoint
.Migration Guide
with_rest_length(1.0)
withwith_length_limits(1.0)
.joint.rest_length = 1.0
with joint.length_limits = 1.0.into()`.with_limits(0.0, 1.0)
withwith_length_limits((0.0, 1.0))
.