Merge pull request #35073 from akien-mga/zero-scale-shall-not-pass

Control/Light2D: Preventing setting 0 as scale as for Node2D
This commit is contained in:
Rémi Verschelde 2020-01-13 13:38:08 +01:00 committed by GitHub
commit c72b5dc0bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View File

@ -189,6 +189,10 @@ float Light2D::get_energy() const {
void Light2D::set_texture_scale(float p_scale) {
_scale = p_scale;
// Avoid having 0 scale values, can lead to errors in physics and rendering.
if (_scale == 0) {
_scale = CMP_EPSILON;
}
VS::get_singleton()->canvas_light_set_scale(canvas_light, _scale);
item_rect_changed();
}

View File

@ -173,6 +173,7 @@ void Node2D::set_scale(const Size2 &p_scale) {
if (_xform_dirty)
((Node2D *)this)->_update_xform_values();
_scale = p_scale;
// Avoid having 0 scale values, can lead to errors in physics and rendering.
if (_scale.x == 0)
_scale.x = CMP_EPSILON;
if (_scale.y == 0)

View File

@ -2682,6 +2682,11 @@ Vector2 Control::get_pivot_offset() const {
void Control::set_scale(const Vector2 &p_scale) {
data.scale = p_scale;
// Avoid having 0 scale values, can lead to errors in physics and rendering.
if (data.scale.x == 0)
data.scale.x = CMP_EPSILON;
if (data.scale.y == 0)
data.scale.y = CMP_EPSILON;
update();
_notify_transform();
}