Show an error when setting a negative size on a collision shape
This commit is contained in:
parent
499eec13a3
commit
9f048f4c4d
|
@ -77,6 +77,7 @@ bool BoxShape3D::_get(const StringName &p_name, Variant &r_property) const {
|
|||
#endif // DISABLE_DEPRECATED
|
||||
|
||||
void BoxShape3D::set_size(const Vector3 &p_size) {
|
||||
ERR_FAIL_COND_MSG(p_size.x < 0 || p_size.y < 0 || p_size.z < 0, "BoxShape3D size cannot be negative.");
|
||||
size = p_size;
|
||||
_update_shape();
|
||||
notify_change_to_owners();
|
||||
|
|
|
@ -59,6 +59,7 @@ void CapsuleShape2D::_update_shape() {
|
|||
}
|
||||
|
||||
void CapsuleShape2D::set_radius(real_t p_radius) {
|
||||
ERR_FAIL_COND_MSG(p_radius < 0, "CapsuleShape2D radius cannot be negative.");
|
||||
radius = p_radius;
|
||||
if (radius > height * 0.5) {
|
||||
height = radius * 2.0;
|
||||
|
@ -71,6 +72,7 @@ real_t CapsuleShape2D::get_radius() const {
|
|||
}
|
||||
|
||||
void CapsuleShape2D::set_height(real_t p_height) {
|
||||
ERR_FAIL_COND_MSG(p_height < 0, "CapsuleShape2D height cannot be negative.");
|
||||
height = p_height;
|
||||
if (radius > height * 0.5) {
|
||||
radius = height * 0.5;
|
||||
|
|
|
@ -79,6 +79,7 @@ void CapsuleShape3D::_update_shape() {
|
|||
}
|
||||
|
||||
void CapsuleShape3D::set_radius(float p_radius) {
|
||||
ERR_FAIL_COND_MSG(p_radius < 0, "CapsuleShape3D radius cannot be negative.");
|
||||
radius = p_radius;
|
||||
if (radius > height * 0.5) {
|
||||
height = radius * 2.0;
|
||||
|
@ -92,6 +93,7 @@ float CapsuleShape3D::get_radius() const {
|
|||
}
|
||||
|
||||
void CapsuleShape3D::set_height(float p_height) {
|
||||
ERR_FAIL_COND_MSG(p_height < 0, "CapsuleShape3D height cannot be negative.");
|
||||
height = p_height;
|
||||
if (radius > height * 0.5) {
|
||||
radius = height * 0.5;
|
||||
|
|
|
@ -43,6 +43,7 @@ void CircleShape2D::_update_shape() {
|
|||
}
|
||||
|
||||
void CircleShape2D::set_radius(real_t p_radius) {
|
||||
ERR_FAIL_COND_MSG(p_radius < 0, "CircleShape2D radius cannot be negative.");
|
||||
radius = p_radius;
|
||||
_update_shape();
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ void CylinderShape3D::_update_shape() {
|
|||
}
|
||||
|
||||
void CylinderShape3D::set_radius(float p_radius) {
|
||||
ERR_FAIL_COND_MSG(p_radius < 0, "CylinderShape3D radius cannot be negative.");
|
||||
radius = p_radius;
|
||||
_update_shape();
|
||||
notify_change_to_owners();
|
||||
|
@ -82,6 +83,7 @@ float CylinderShape3D::get_radius() const {
|
|||
}
|
||||
|
||||
void CylinderShape3D::set_height(float p_height) {
|
||||
ERR_FAIL_COND_MSG(p_height < 0, "CylinderShape3D height cannot be negative.");
|
||||
height = p_height;
|
||||
_update_shape();
|
||||
notify_change_to_owners();
|
||||
|
|
|
@ -58,6 +58,7 @@ bool RectangleShape2D::_get(const StringName &p_name, Variant &r_property) const
|
|||
#endif // DISABLE_DEPRECATED
|
||||
|
||||
void RectangleShape2D::set_size(const Vector2 &p_size) {
|
||||
ERR_FAIL_COND_MSG(p_size.x < 0 || p_size.y < 0, "RectangleShape2D size cannot be negative.");
|
||||
size = p_size;
|
||||
_update_shape();
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ void SphereShape3D::_update_shape() {
|
|||
}
|
||||
|
||||
void SphereShape3D::set_radius(float p_radius) {
|
||||
ERR_FAIL_COND_MSG(p_radius < 0, "SphereShape3D radius cannot be negative.");
|
||||
radius = p_radius;
|
||||
_update_shape();
|
||||
notify_change_to_owners();
|
||||
|
|
Loading…
Reference in New Issue