diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-02-01 20:55:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-01 20:55:25 +0100 |
commit | d2e121650476af0a91bc24ea38253428e97f9695 (patch) | |
tree | 22b120a76f0430faa9e4a9383f7c0c83557616b6 /scene/resources/capsule_shape_2d.cpp | |
parent | 264504d76d2c1ea374d5508e6a2634e2b5002d84 (diff) | |
parent | 1d5042c9e265219dec8da7311879f12ef3ef698b (diff) |
Merge pull request #37547 from aaronfranke/tau
Use Math_TAU and deg2rad/etc in more places and optimize code
Diffstat (limited to 'scene/resources/capsule_shape_2d.cpp')
-rw-r--r-- | scene/resources/capsule_shape_2d.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp index 6041f4a8b0..63d90a8364 100644 --- a/scene/resources/capsule_shape_2d.cpp +++ b/scene/resources/capsule_shape_2d.cpp @@ -36,12 +36,13 @@ Vector<Vector2> CapsuleShape2D::_get_points() const { Vector<Vector2> points; + const real_t turn_step = Math_TAU / 24.0; for (int i = 0; i < 24; i++) { Vector2 ofs = Vector2(0, (i > 6 && i <= 18) ? -get_height() * 0.5 : get_height() * 0.5); - points.push_back(Vector2(Math::sin(i * Math_PI * 2 / 24.0), Math::cos(i * Math_PI * 2 / 24.0)) * get_radius() + ofs); + points.push_back(Vector2(Math::sin(i * turn_step), Math::cos(i * turn_step)) * get_radius() + ofs); if (i == 6 || i == 18) { - points.push_back(Vector2(Math::sin(i * Math_PI * 2 / 24.0), Math::cos(i * Math_PI * 2 / 24.0)) * get_radius() - ofs); + points.push_back(Vector2(Math::sin(i * turn_step), Math::cos(i * turn_step)) * get_radius() - ofs); } } |