Improve CapsuleShape2D size clamping

This commit is contained in:
kobewi 2021-08-11 21:39:18 +02:00
parent 974cc68fb4
commit b35a2516a0

View file

@ -59,10 +59,7 @@ void CapsuleShape2D::_update_shape() {
} }
void CapsuleShape2D::set_radius(real_t p_radius) { void CapsuleShape2D::set_radius(real_t p_radius) {
radius = p_radius; radius = MIN(p_radius, height * 0.5);
if (radius > height * 0.5) {
height = radius * 2;
}
_update_shape(); _update_shape();
} }
@ -71,11 +68,7 @@ real_t CapsuleShape2D::get_radius() const {
} }
void CapsuleShape2D::set_height(real_t p_height) { void CapsuleShape2D::set_height(real_t p_height) {
height = p_height; height = MAX(p_height, radius * 2);
if (radius > height * 0.5) {
height = radius * 2;
}
_update_shape(); _update_shape();
} }