summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-07-01 08:14:21 +0200
committerGitHub <noreply@github.com>2021-07-01 08:14:21 +0200
commit8a4cb96856ab786e7a70394c003b0fac2da1b287 (patch)
treeb7c7e1c5bb175a59829528d57f3d80cf606862ae /scene
parent5710adda72a08f81c4df00147f560eebacf3b473 (diff)
parent525ad7c37ee146658e948cffbc2cea1e9071fca2 (diff)
Merge pull request #49409 from ekumlin/issue-32596
Enable Camera2D smoothing on limit change
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/camera_2d.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 926997a715..f293081987 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -178,20 +178,23 @@ Transform2D Camera2D::get_camera_transform() {
}
Rect2 screen_rect(-screen_offset + ret_camera_pos, screen_size * zoom);
- if (screen_rect.position.x < limit[SIDE_LEFT]) {
- screen_rect.position.x = limit[SIDE_LEFT];
- }
- if (screen_rect.position.x + screen_rect.size.x > limit[SIDE_RIGHT]) {
- screen_rect.position.x = limit[SIDE_RIGHT] - screen_rect.size.x;
- }
+ if (!limit_smoothing_enabled) {
+ if (screen_rect.position.x < limit[SIDE_LEFT]) {
+ screen_rect.position.x = limit[SIDE_LEFT];
+ }
- if (screen_rect.position.y + screen_rect.size.y > limit[SIDE_BOTTOM]) {
- screen_rect.position.y = limit[SIDE_BOTTOM] - screen_rect.size.y;
- }
+ if (screen_rect.position.x + screen_rect.size.x > limit[SIDE_RIGHT]) {
+ screen_rect.position.x = limit[SIDE_RIGHT] - screen_rect.size.x;
+ }
+
+ if (screen_rect.position.y + screen_rect.size.y > limit[SIDE_BOTTOM]) {
+ screen_rect.position.y = limit[SIDE_BOTTOM] - screen_rect.size.y;
+ }
- if (screen_rect.position.y < limit[SIDE_TOP]) {
- screen_rect.position.y = limit[SIDE_TOP];
+ if (screen_rect.position.y < limit[SIDE_TOP]) {
+ screen_rect.position.y = limit[SIDE_TOP];
+ }
}
if (offset != Vector2()) {