Merge pull request #42872 from dreamsComeTrue/better-camera2d-zoom

Fix camera2d zoom when set to zero (affine_invert: Condition ' det == 0 ' is true)
This commit is contained in:
Rémi Verschelde 2020-12-17 08:56:37 +01:00 committed by GitHub
commit 933cf114d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -77,6 +77,9 @@ void Camera2D::_update_process_mode() {
} }
void Camera2D::set_zoom(const Vector2 &p_zoom) { void Camera2D::set_zoom(const Vector2 &p_zoom) {
// Setting zoom to zero causes 'affine_invert' issues
ERR_FAIL_COND_MSG(Math::is_zero_approx(p_zoom.x) || Math::is_zero_approx(p_zoom.y), "Zoom level must be different from 0 (can be negative).");
zoom = p_zoom; zoom = p_zoom;
Point2 old_smoothed_camera_pos = smoothed_camera_pos; Point2 old_smoothed_camera_pos = smoothed_camera_pos;
_update_scroll(); _update_scroll();