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

Clean up and refactor joint logic #390

Merged
merged 2 commits into from
Jul 1, 2024
Merged

Clean up and refactor joint logic #390

merged 2 commits into from
Jul 1, 2024

Conversation

Jondolf
Copy link
Owner

@Jondolf Jondolf commented Jul 1, 2024

Objective

The joint code has a lot of ugly parts:

  • 2D joints are implemented as just 3D joints with Z as the rotation axis instead of being "true" 2D.
  • SphericalJoint exists in 2D even though it doesn't really work since it's a 3D joint.
  • Lagrange update computation often unnecessarily takes unit gradients. The gradients aren't needed if they have unit length, and in our case they do.
  • Some variable and method names are very vague, like delta_q or p instead of rotation_difference and impulse.
  • The 3D AngleLimit::compute_correction method has no comments or explanations for the angle magic it does.

Solution

Fix the issues :)

I also did some other small cleanup and fixed some intra-doc links.


Migration Guide

  • SphericalJoint no longer exists in 2D. Use RevoluteJoint instead.
  • AngleLimit properties alpha and beta are now named min and max.
  • apply_positional_correction has been renamed to apply_positional_lagrange_update. There is also an apply_positional_impulse method.
  • apply_angular_correction has been renamed to apply_angular_lagrange_update. There is also an apply_angular_impulse method.
  • compute_lagrange_update no longer takes a slice over gradients. For that, use compute_lagrange_update_with_gradients.
  • Joint::align_orientation has been moved to AngularConstraint.

@Jondolf Jondolf added A-Dynamics Relates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so on C-Breaking-Change This change removes or changes behavior or APIs, requiring users to adapt labels Jul 1, 2024
@Jondolf Jondolf merged commit 9e8512f into avian Jul 1, 2024
4 checks passed
@Jondolf Jondolf deleted the joint-clean-up branch July 1, 2024 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Dynamics Relates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so on C-Breaking-Change This change removes or changes behavior or APIs, requiring users to adapt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant