Wrap angles to (-pi, pi) in momentum calculation.

Fixes a bug that causes KinematicBody2Ds to produce too much angular
momentum when rotating beyond 180 degrees.

(cherry picked from commit e148338d42)
This commit is contained in:
Keegan Owsley 2020-08-25 19:00:23 -07:00 committed by Rémi Verschelde
parent 849dc87577
commit 777d90d7a1
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 1 additions and 1 deletions

View File

@ -485,7 +485,7 @@ void Body2DSW::integrate_forces(real_t p_step) {
linear_velocity = motion / p_step;
real_t rot = new_transform.get_rotation() - get_transform().get_rotation();
angular_velocity = rot / p_step;
angular_velocity = remainder(rot, 2.0 * Math_PI) / p_step;
do_motion = true;