mirror of
https://github.com/godotengine/godot.git
synced 2025-01-22 10:32:54 -05:00
Merge pull request #99942 from kitbdev/fix-invisible-subviewport-editor
Fix selecting and editing invisble items in SubViewports
This commit is contained in:
commit
26fec37389
8 changed files with 87 additions and 3 deletions
|
@ -260,6 +260,11 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
|
|||
return false;
|
||||
}
|
||||
|
||||
Viewport *vp = _get_node()->get_viewport();
|
||||
if (vp && !vp->is_visible_subviewport()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
Ref<InputEventMouseButton> mb = p_event;
|
||||
|
||||
|
@ -501,6 +506,11 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
|
|||
return;
|
||||
}
|
||||
|
||||
Viewport *vp = _get_node()->get_viewport();
|
||||
if (vp && !vp->is_visible_subviewport()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_screen_transform();
|
||||
// All polygon points are sharp, so use the sharp handle icon
|
||||
const Ref<Texture2D> handle = get_editor_theme_icon(SNAME("EditorPathSharpHandle"));
|
||||
|
|
|
@ -618,6 +618,9 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no
|
|||
if (CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node)) {
|
||||
xform = cl->get_transform();
|
||||
} else if (Viewport *vp = Object::cast_to<Viewport>(p_node)) {
|
||||
if (!vp->is_visible_subviewport()) {
|
||||
return;
|
||||
}
|
||||
xform = vp->get_popup_base_transform();
|
||||
if (!vp->get_visible_rect().has_point(xform.xform_inv(p_pos))) {
|
||||
return;
|
||||
|
@ -718,6 +721,9 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n
|
|||
if (CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node)) {
|
||||
xform = cl->get_transform();
|
||||
} else if (Viewport *vp = Object::cast_to<Viewport>(p_node)) {
|
||||
if (!vp->is_visible_subviewport()) {
|
||||
return;
|
||||
}
|
||||
xform = vp->get_popup_base_transform();
|
||||
if (!vp->get_visible_rect().intersects(xform.xform_inv(p_rect))) {
|
||||
return;
|
||||
|
@ -797,6 +803,10 @@ List<CanvasItem *> CanvasItemEditor::_get_edited_canvas_items(bool p_retrieve_lo
|
|||
CanvasItem *ci = Object::cast_to<CanvasItem>(E.key);
|
||||
if (ci) {
|
||||
if (ci->is_visible_in_tree() && (p_retrieve_locked || !_is_node_locked(ci))) {
|
||||
Viewport *vp = ci->get_viewport();
|
||||
if (vp && !vp->is_visible_subviewport()) {
|
||||
continue;
|
||||
}
|
||||
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci);
|
||||
if (se) {
|
||||
selection.push_back(ci);
|
||||
|
@ -3819,6 +3829,9 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans
|
|||
parent_xform = Transform2D();
|
||||
canvas_xform = cl->get_transform();
|
||||
} else if (Viewport *vp = Object::cast_to<Viewport>(p_node)) {
|
||||
if (!vp->is_visible_subviewport()) {
|
||||
return;
|
||||
}
|
||||
parent_xform = Transform2D();
|
||||
canvas_xform = vp->get_popup_base_transform();
|
||||
}
|
||||
|
@ -3947,10 +3960,15 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p
|
|||
|
||||
if (ci && !ci->is_set_as_top_level()) {
|
||||
parent_xform = parent_xform * ci->get_transform();
|
||||
} else {
|
||||
CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node);
|
||||
} else if (CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node)) {
|
||||
parent_xform = Transform2D();
|
||||
canvas_xform = cl ? cl->get_transform() : p_canvas_xform;
|
||||
canvas_xform = cl->get_transform();
|
||||
} else if (Viewport *vp = Object::cast_to<Viewport>(p_node)) {
|
||||
if (!vp->is_visible_subviewport()) {
|
||||
return;
|
||||
}
|
||||
parent_xform = Transform2D();
|
||||
canvas_xform = vp->get_popup_base_transform();
|
||||
}
|
||||
|
||||
for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "editor/editor_undo_redo_manager.h"
|
||||
#include "scene/2d/physics/ray_cast_2d.h"
|
||||
#include "scene/2d/physics/shape_cast_2d.h"
|
||||
#include "scene/main/viewport.h"
|
||||
|
||||
void Cast2DEditor::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
|
@ -59,6 +60,11 @@ bool Cast2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
Viewport *vp = node->get_viewport();
|
||||
if (vp && !vp->is_visible_subviewport()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_screen_transform();
|
||||
|
||||
Ref<InputEventMouseButton> mb = p_event;
|
||||
|
@ -114,6 +120,11 @@ void Cast2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
|||
return;
|
||||
}
|
||||
|
||||
Viewport *vp = node->get_viewport();
|
||||
if (vp && !vp->is_visible_subviewport()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_screen_transform();
|
||||
|
||||
const Ref<Texture2D> handle = get_editor_theme_icon(SNAME("EditorHandle"));
|
||||
|
|
|
@ -348,6 +348,11 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
|
|||
return false;
|
||||
}
|
||||
|
||||
Viewport *vp = node->get_viewport();
|
||||
if (vp && !vp->is_visible_subviewport()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (shape_type == -1) {
|
||||
return false;
|
||||
}
|
||||
|
@ -481,6 +486,11 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
|
|||
return;
|
||||
}
|
||||
|
||||
Viewport *vp = node->get_viewport();
|
||||
if (vp && !vp->is_visible_subviewport()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (shape_type == -1) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "editor/editor_undo_redo_manager.h"
|
||||
#include "scene/main/viewport.h"
|
||||
#include "servers/navigation_server_3d.h"
|
||||
|
||||
void NavigationLink2DEditor::_notification(int p_what) {
|
||||
|
@ -59,6 +60,11 @@ bool NavigationLink2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
|
|||
return false;
|
||||
}
|
||||
|
||||
Viewport *vp = node->get_viewport();
|
||||
if (vp && !vp->is_visible_subviewport()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
real_t grab_threshold = EDITOR_GET("editors/polygon_editor/point_grab_radius");
|
||||
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_screen_transform();
|
||||
|
||||
|
@ -142,6 +148,11 @@ void NavigationLink2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
|
|||
return;
|
||||
}
|
||||
|
||||
Viewport *vp = node->get_viewport();
|
||||
if (vp && !vp->is_visible_subviewport()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_screen_transform();
|
||||
Vector2 global_start_position = gt.xform(node->get_start_position());
|
||||
Vector2 global_end_position = gt.xform(node->get_end_position());
|
||||
|
|
|
@ -71,6 +71,11 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
Viewport *vp = node->get_viewport();
|
||||
if (vp && !vp->is_visible_subviewport()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (node->get_curve().is_null()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -393,6 +398,11 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
|||
return;
|
||||
}
|
||||
|
||||
Viewport *vp = node->get_viewport();
|
||||
if (vp && !vp->is_visible_subviewport()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_screen_transform();
|
||||
|
||||
const Ref<Texture2D> path_sharp_handle = get_editor_theme_icon(SNAME("EditorPathSharpHandle"));
|
||||
|
|
|
@ -3899,6 +3899,16 @@ bool Viewport::get_canvas_cull_mask_bit(uint32_t p_layer) const {
|
|||
return (canvas_cull_mask & (1 << p_layer));
|
||||
}
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
bool Viewport::is_visible_subviewport() const {
|
||||
if (!is_sub_viewport()) {
|
||||
return true;
|
||||
}
|
||||
SubViewportContainer *container = Object::cast_to<SubViewportContainer>(get_parent());
|
||||
return container && container->is_visible_in_tree();
|
||||
}
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
void Viewport::_update_audio_listener_2d() {
|
||||
if (AudioServer::get_singleton()) {
|
||||
AudioServer::get_singleton()->notify_listener_changed();
|
||||
|
|
|
@ -672,6 +672,10 @@ public:
|
|||
void set_canvas_cull_mask_bit(uint32_t p_layer, bool p_enable);
|
||||
bool get_canvas_cull_mask_bit(uint32_t p_layer) const;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
bool is_visible_subviewport() const;
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
virtual bool is_size_2d_override_stretch_enabled() const { return true; }
|
||||
|
||||
Transform2D get_screen_transform() const;
|
||||
|
|
Loading…
Reference in a new issue