소스 검색

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 e148338d428de9d23517c5410853a94dc72458ff)
Keegan Owsley 5 년 전
부모
커밋
777d90d7a1
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      servers/physics_2d/body_2d_sw.cpp

+ 1 - 1
servers/physics_2d/body_2d_sw.cpp

@@ -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;