Merge pull request #40295 from RevoluPowered/revert-fix-camera-2d-incorrect-preview-bounds

Revert "Merge pull request #38341 from verdog/camera-bounds-fix"
This commit is contained in:
Rémi Verschelde 2020-07-11 20:38:38 +02:00 committed by GitHub
commit a474926aca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 15 deletions

View File

@ -456,6 +456,8 @@ void EditorNode::_notification(int p_what) {
editor_selection->update(); editor_selection->update();
//scene_root->set_size_override(true, Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height")));
{ //TODO should only happen on settings changed { //TODO should only happen on settings changed
int current_filter = GLOBAL_GET("rendering/canvas_textures/default_texture_filter"); int current_filter = GLOBAL_GET("rendering/canvas_textures/default_texture_filter");
if (current_filter != scene_root->get_default_canvas_item_texture_filter()) { if (current_filter != scene_root->get_default_canvas_item_texture_filter()) {

View File

@ -32,7 +32,6 @@
#include "core/engine.h" #include "core/engine.h"
#include "core/math/math_funcs.h" #include "core/math/math_funcs.h"
#include "editor/editor_node.h"
#include "scene/scene_string_names.h" #include "scene/scene_string_names.h"
#include "servers/rendering_server.h" #include "servers/rendering_server.h"
@ -57,7 +56,7 @@ void Camera2D::_update_scroll() {
viewport->set_canvas_transform(xform); viewport->set_canvas_transform(xform);
Size2 screen_size = get_camera_screen_size(); Size2 screen_size = viewport->get_visible_rect().size;
Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5) : Point2()); Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5) : Point2());
get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, group_name, "_camera_moved", xform, screen_offset); get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, group_name, "_camera_moved", xform, screen_offset);
@ -95,7 +94,7 @@ Transform2D Camera2D::get_camera_transform() {
ERR_FAIL_COND_V(custom_viewport && !ObjectDB::get_instance(custom_viewport_id), Transform2D()); ERR_FAIL_COND_V(custom_viewport && !ObjectDB::get_instance(custom_viewport_id), Transform2D());
Size2 screen_size = get_camera_screen_size(); Size2 screen_size = viewport->get_visible_rect().size;
Point2 new_camera_pos = get_global_transform().get_origin(); Point2 new_camera_pos = get_global_transform().get_origin();
Point2 ret_camera_pos; Point2 ret_camera_pos;
@ -275,7 +274,7 @@ void Camera2D::_notification(int p_what) {
} }
Transform2D inv_camera_transform = get_camera_transform().affine_inverse(); Transform2D inv_camera_transform = get_camera_transform().affine_inverse();
Size2 screen_size = get_camera_screen_size(); Size2 screen_size = get_viewport_rect().size;
Vector2 screen_endpoints[4] = { Vector2 screen_endpoints[4] = {
inv_camera_transform.xform(Vector2(0, 0)), inv_camera_transform.xform(Vector2(0, 0)),
@ -322,7 +321,7 @@ void Camera2D::_notification(int p_what) {
} }
Transform2D inv_camera_transform = get_camera_transform().affine_inverse(); Transform2D inv_camera_transform = get_camera_transform().affine_inverse();
Size2 screen_size = get_camera_screen_size(); Size2 screen_size = get_viewport_rect().size;
Vector2 margin_endpoints[4] = { Vector2 margin_endpoints[4] = {
inv_camera_transform.xform(Vector2((screen_size.width / 2) - ((screen_size.width / 2) * drag_margin[MARGIN_LEFT]), (screen_size.height / 2) - ((screen_size.height / 2) * drag_margin[MARGIN_TOP]))), inv_camera_transform.xform(Vector2((screen_size.width / 2) - ((screen_size.width / 2) * drag_margin[MARGIN_LEFT]), (screen_size.height / 2) - ((screen_size.height / 2) * drag_margin[MARGIN_TOP]))),
@ -470,7 +469,7 @@ void Camera2D::reset_smoothing() {
void Camera2D::align() { void Camera2D::align() {
ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id)); ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id));
Size2 screen_size = get_camera_screen_size(); Size2 screen_size = viewport->get_visible_rect().size;
Point2 current_camera_pos = get_global_transform().get_origin(); Point2 current_camera_pos = get_global_transform().get_origin();
if (anchor_mode == ANCHOR_MODE_DRAG_CENTER) { if (anchor_mode == ANCHOR_MODE_DRAG_CENTER) {
@ -508,14 +507,6 @@ Point2 Camera2D::get_camera_screen_center() const {
return camera_screen_center; return camera_screen_center;
} }
Size2 Camera2D::get_camera_screen_size() const {
// special case if the camera2D is in the root viewport
if (Engine::get_singleton()->is_editor_hint() && get_viewport() == EditorNode::get_singleton()->get_scene_root()) {
return Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"));
}
return get_viewport_rect().size;
}
void Camera2D::set_h_drag_enabled(bool p_enabled) { void Camera2D::set_h_drag_enabled(bool p_enabled) {
h_drag_enabled = p_enabled; h_drag_enabled = p_enabled;
} }

View File

@ -147,7 +147,6 @@ public:
Vector2 get_zoom() const; Vector2 get_zoom() const;
Point2 get_camera_screen_center() const; Point2 get_camera_screen_center() const;
Size2 get_camera_screen_size() const;
void set_custom_viewport(Node *p_viewport); void set_custom_viewport(Node *p_viewport);
Node *get_custom_viewport() const; Node *get_custom_viewport() const;