diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-08-11 22:09:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-11 22:09:52 +0200 |
commit | d2fc0a8057901620db4aeb1b1072c644a742d339 (patch) | |
tree | 76926043c2a79155e85bd3fe83c48d4143f681fc /scene | |
parent | 974cc68fb420768a244c14dfd7a59da73f2330bd (diff) | |
parent | b35a2516a0b72fb55faf6183fe1411bb47c905c4 (diff) |
Merge pull request #51527 from KoBeWi/minmax
Improve CapsuleShape2D size clamping
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/capsule_shape_2d.cpp | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp index 8f7f3edc28..596fa70f15 100644 --- a/scene/resources/capsule_shape_2d.cpp +++ b/scene/resources/capsule_shape_2d.cpp @@ -59,10 +59,7 @@ void CapsuleShape2D::_update_shape() { } void CapsuleShape2D::set_radius(real_t p_radius) { - radius = p_radius; - if (radius > height * 0.5) { - height = radius * 2; - } + radius = MIN(p_radius, height * 0.5); _update_shape(); } @@ -71,11 +68,7 @@ real_t CapsuleShape2D::get_radius() const { } void CapsuleShape2D::set_height(real_t p_height) { - height = p_height; - if (radius > height * 0.5) { - height = radius * 2; - } - + height = MAX(p_height, radius * 2); _update_shape(); } |