Skip to content

Commit

Permalink
Merge pull request #58343 from aaronfranke/negative-shape-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Feb 22, 2022
2 parents f880414 + 9f048f4 commit 872e8a4
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions scene/resources/box_shape_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions scene/resources/capsule_shape_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions scene/resources/capsule_shape_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions scene/resources/circle_shape_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions scene/resources/cylinder_shape_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
1 change: 1 addition & 0 deletions scene/resources/rectangle_shape_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions scene/resources/sphere_shape_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 872e8a4

Please sign in to comment.