Fixes to 2D viewport
* Editor 2D viewport now uses embedded subwindows (windows no longer pop up) * Restored the ability to disable 3D on the 2D viewport (makes 3D not display on 2D when there is a camera on the scene)
This commit is contained in:
parent
916c37de09
commit
d07f7c8d25
8 changed files with 35 additions and 2 deletions
|
@ -208,6 +208,9 @@
|
|||
<member name="debug_draw" type="int" setter="set_debug_draw" getter="get_debug_draw" enum="Viewport.DebugDraw" default="0">
|
||||
The overlay mode for test rendered geometry in debug purposes.
|
||||
</member>
|
||||
<member name="disable_3d" type="bool" setter="set_disable_3d" getter="is_3d_disabled" default="false">
|
||||
Disable 3D rendering (but keep 2D rendering).
|
||||
</member>
|
||||
<member name="global_canvas_transform" type="Transform2D" setter="set_global_canvas_transform" getter="get_global_canvas_transform">
|
||||
The global canvas transform of the viewport. The canvas transform is relative to this.
|
||||
</member>
|
||||
|
|
|
@ -6116,7 +6116,8 @@ EditorNode::EditorNode() {
|
|||
scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
|
||||
scene_root = memnew(SubViewport);
|
||||
//scene_root->set_usage(Viewport::USAGE_2D); canvas BG mode prevents usage of this as 2D
|
||||
scene_root->set_embed_subwindows_hint(true);
|
||||
scene_root->set_disable_3d(true);
|
||||
|
||||
RenderingServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true);
|
||||
scene_root->set_disable_input(true);
|
||||
|
|
|
@ -929,6 +929,15 @@ bool Viewport::is_audio_listener_2d() const {
|
|||
return audio_listener_2d;
|
||||
}
|
||||
|
||||
void Viewport::set_disable_3d(bool p_disable) {
|
||||
disable_3d = p_disable;
|
||||
RenderingServer::get_singleton()->viewport_set_disable_3d(viewport, disable_3d);
|
||||
}
|
||||
|
||||
bool Viewport::is_3d_disabled() const {
|
||||
return disable_3d;
|
||||
}
|
||||
|
||||
void Viewport::enable_canvas_transform_override(bool p_enable) {
|
||||
if (override_canvas_transform == p_enable) {
|
||||
return;
|
||||
|
@ -3516,6 +3525,9 @@ void Viewport::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_as_audio_listener_2d", "enable"), &Viewport::set_as_audio_listener_2d);
|
||||
ClassDB::bind_method(D_METHOD("is_audio_listener_2d"), &Viewport::is_audio_listener_2d);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_disable_3d", "disable"), &Viewport::set_disable_3d);
|
||||
ClassDB::bind_method(D_METHOD("is_3d_disabled"), &Viewport::is_3d_disabled);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_mouse_position"), &Viewport::get_mouse_position);
|
||||
ClassDB::bind_method(D_METHOD("warp_mouse", "to_position"), &Viewport::warp_mouse);
|
||||
|
||||
|
@ -3582,6 +3594,7 @@ void Viewport::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_2d_transforms_to_pixel"), "set_snap_2d_transforms_to_pixel", "is_snap_2d_transforms_to_pixel_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_2d_vertices_to_pixel"), "set_snap_2d_vertices_to_pixel", "is_snap_2d_vertices_to_pixel_enabled");
|
||||
ADD_GROUP("Rendering", "");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_3d"), "set_disable_3d", "is_3d_disabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa", PROPERTY_HINT_ENUM, "Disabled (Fastest),2x (Fast),4x (Average),8x (Slow),16x (Slower)"), "set_msaa", "get_msaa");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "screen_space_aa", PROPERTY_HINT_ENUM, "Disabled (Fastest),FXAA (Fast)"), "set_screen_space_aa", "get_screen_space_aa");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_debanding"), "set_use_debanding", "is_using_debanding");
|
||||
|
|
|
@ -288,6 +288,8 @@ private:
|
|||
void _update_listener();
|
||||
void _update_listener_2d();
|
||||
|
||||
bool disable_3d = false;
|
||||
|
||||
void _propagate_enter_world(Node *p_node);
|
||||
void _propagate_exit_world(Node *p_node);
|
||||
void _propagate_viewport_notification(Node *p_node, int p_what);
|
||||
|
@ -503,6 +505,9 @@ public:
|
|||
void set_as_audio_listener_2d(bool p_enable);
|
||||
bool is_audio_listener_2d() const;
|
||||
|
||||
void set_disable_3d(bool p_disable);
|
||||
bool is_3d_disabled() const;
|
||||
|
||||
void update_canvas_items();
|
||||
|
||||
Rect2 get_visible_rect() const;
|
||||
|
|
|
@ -122,7 +122,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport, uint32_t p_view_coun
|
|||
}
|
||||
}
|
||||
|
||||
bool can_draw_3d = RSG::scene->is_camera(p_viewport->camera);
|
||||
bool can_draw_3d = RSG::scene->is_camera(p_viewport->camera) && !p_viewport->disable_3d;
|
||||
|
||||
if (p_viewport->clear_mode != RS::VIEWPORT_CLEAR_NEVER) {
|
||||
if (p_viewport->transparent_bg) {
|
||||
|
@ -812,6 +812,13 @@ void RendererViewport::viewport_set_disable_environment(RID p_viewport, bool p_d
|
|||
viewport->disable_environment = p_disable;
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_set_disable_3d(RID p_viewport, bool p_disable) {
|
||||
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
|
||||
viewport->disable_3d = p_disable;
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_attach_camera(RID p_viewport, RID p_camera) {
|
||||
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
|
|
|
@ -71,6 +71,7 @@ public:
|
|||
bool hide_scenario;
|
||||
bool hide_canvas;
|
||||
bool disable_environment;
|
||||
bool disable_3d = false;
|
||||
bool measure_render_time;
|
||||
|
||||
bool snap_2d_transforms_to_pixel;
|
||||
|
@ -220,6 +221,7 @@ public:
|
|||
void viewport_set_hide_scenario(RID p_viewport, bool p_hide);
|
||||
void viewport_set_hide_canvas(RID p_viewport, bool p_hide);
|
||||
void viewport_set_disable_environment(RID p_viewport, bool p_disable);
|
||||
void viewport_set_disable_3d(RID p_viewport, bool p_disable);
|
||||
|
||||
void viewport_attach_camera(RID p_viewport, RID p_camera);
|
||||
void viewport_set_scenario(RID p_viewport, RID p_scenario);
|
||||
|
|
|
@ -585,6 +585,7 @@ public:
|
|||
FUNC2(viewport_set_hide_scenario, RID, bool)
|
||||
FUNC2(viewport_set_hide_canvas, RID, bool)
|
||||
FUNC2(viewport_set_disable_environment, RID, bool)
|
||||
FUNC2(viewport_set_disable_3d, RID, bool)
|
||||
|
||||
FUNC2(viewport_attach_camera, RID, RID)
|
||||
FUNC2(viewport_set_scenario, RID, RID)
|
||||
|
|
|
@ -799,6 +799,7 @@ public:
|
|||
virtual void viewport_set_hide_scenario(RID p_viewport, bool p_hide) = 0;
|
||||
virtual void viewport_set_hide_canvas(RID p_viewport, bool p_hide) = 0;
|
||||
virtual void viewport_set_disable_environment(RID p_viewport, bool p_disable) = 0;
|
||||
virtual void viewport_set_disable_3d(RID p_viewport, bool p_disable) = 0;
|
||||
|
||||
virtual void viewport_attach_camera(RID p_viewport, RID p_camera) = 0;
|
||||
virtual void viewport_set_scenario(RID p_viewport, RID p_scenario) = 0;
|
||||
|
|
Loading…
Reference in a new issue