Merge pull request #105825 from Alex-Onceanu/playground
Fix `Camera2D` right and bottom limit to depend on bottom right corner
This commit is contained in:
commit
d9c8376fe0
1 changed files with 5 additions and 4 deletions
|
|
@ -272,16 +272,17 @@ Transform2D Camera2D::get_camera_transform() {
|
|||
Rect2 screen_rect(-screen_offset + ret_camera_pos, screen_size * zoom_scale);
|
||||
|
||||
if (limit_enabled && (!position_smoothing_enabled || !limit_smoothing_enabled)) {
|
||||
Point2 bottom_right_corner = Point2(screen_rect.position + 2.0 * (camera_pos - screen_rect.position));
|
||||
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 (bottom_right_corner.x > limit[SIDE_RIGHT]) {
|
||||
screen_rect.position.x = limit[SIDE_RIGHT] - (bottom_right_corner.x - screen_rect.position.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 (bottom_right_corner.y > limit[SIDE_BOTTOM]) {
|
||||
screen_rect.position.y = limit[SIDE_BOTTOM] - (bottom_right_corner.y - screen_rect.position.y);
|
||||
}
|
||||
|
||||
if (screen_rect.position.y < limit[SIDE_TOP]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue