summaryrefslogtreecommitdiff
path: root/scene/2d/camera_2d.cpp
diff options
context:
space:
mode:
authorEric <github.kuphar@aleeas.com>2021-06-07 15:42:48 -0700
committerEric <github.kuphar@aleeas.com>2021-06-30 16:21:29 -0700
commit525ad7c37ee146658e948cffbc2cea1e9071fca2 (patch)
treeb7c7e1c5bb175a59829528d57f3d80cf606862ae /scene/2d/camera_2d.cpp
parent5710adda72a08f81c4df00147f560eebacf3b473 (diff)
Enable Camera2D smoothing on limit change
Diffstat (limited to 'scene/2d/camera_2d.cpp')
-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()) {