Commit graph

258 commits

Author SHA1 Message Date
Michael Alexsander
9ee82ebe1d
Fix tooltips behaving incorrectly on Tree nodes 2023-09-28 11:18:15 -03:00
Dario
057367bf4f Add FidelityFX Super Resolution 2.2 (FSR 2.2.1) support.
Introduces support for FSR2 as a new upscaler option available from the project settings. Also introduces an specific render list for surfaces that require motion and the ability to derive motion vectors from depth buffer and camera motion.
2023-09-25 10:37:47 -03:00
Rémi Verschelde
e73a4a382e
Merge pull request #79201 from Rindbee/fix-setup-state-not-cleared
Clear the previously set state when configuring for a new scene root node
2023-08-17 15:43:38 +02:00
Michael Alexsander
de27df5da3
Allow to get a list of visible embedded Windows 2023-08-16 10:42:08 -03:00
Markus Sauermann
59c13fea5d Fix nodes receiving mouse events in black bars of Window
Previously for InputEvents there was no distinction between
Window-area and Viewport-area.
This was problematic in cases where stretching was used and the Window
contained black bars at the sides of the Viewport.
This PR separates the area of Window and Viewport regarding InputEvents.
2023-08-09 12:34:22 +02:00
Rindbee
4795c3cdfa Clear the previously set state when configuring for a new scene root node
Saving a subscene causes the main scene to be re-instantiated. And the resource
instance in the main scene will be reused when the main scene is re-instantiated.
So for resources with `resource_local_to_scene` enabled, resetting state may be
necessary (at least for `ViewportTexture`).
2023-08-08 23:49:53 +08:00
Rémi Verschelde
1163dac9e3
Merge pull request #80215 from clayjohn/HDR-2D
Add option to enable HDR rendering in 2D
2023-08-08 16:57:33 +02:00
Rémi Verschelde
faaf27f284
Fix various typos with codespell
Also includes typo fixes from #79993, #80068, #80276, and #80303.

Co-authored-by: betalars <contact@betalars.de>
Co-authored-by: spaceyjase <429978+spaceyjase@users.noreply.github.com>
Co-authored-by: Swarkin <102416174+Swarkin@users.noreply.github.com>
Co-authored-by: Raul Santos <raulsntos@gmail.com>
2023-08-07 13:09:47 +02:00
clayjohn
57eb762bae Add option to enable HDR rendering in 2D
This is needed to allow 2D to fully make use of 3D effects (e.g. glow), and can be used to substantially improve quality of 2D rendering at the cost of performance

Additionally, the 2D rendering pipeline is done in linear space (we skip linear_to_srgb conversion in 3D tonemapping) so the entire Viewport can be kept linear.
This is necessary for proper HDR screen support in the future.
2023-08-07 11:24:03 +02:00
Markus Sauermann
1c3c17c608 Refactor mouse_entered and mouse_exited notifications
The previous implementation for signals mouse_entered and mouse_exited
had shortcomings that relate to focused windows and pressed mouse buttons.
For example a Control can be hovered by mouse, even if it is occluded by
an embedded window.

This patch changes the behavior, so that Control and Viewport send
their mouse-enter/exit-notifications based solely on mouse position,
visible area, and input restrictions and not on which window has
focus or which mouse buttons are pressed. This implicitly also
changes when the mouse_entered and mouse_exited signals are sent.

This functionality can not be implemented as a part of
Viewport::_gui_input_event, because of its interplay with Windows and
because Viewport::_gui_input_event is based on input and not on
visibility.
2023-08-01 13:28:49 +02:00
Markus Sauermann
a12627765f Embedded Popups store their safe_rect in their embedder
Storing it in the DisplayServer didn't make sense in this case,
because the embedded window is unknown to the DisplayServer.
2023-06-20 18:06:26 +02:00
Rémi Verschelde
8acf6b41a4
Merge pull request #77209 from Rindbee/ViewportTexture-not-change-RID
Don't change `RID` when changing `viewport_path` in `ViewportTexture`
2023-06-09 15:10:39 +02:00
Rindbee
7532b2d259 Don't change RID when changing viewport_path in ViewportTexture
When changing `viewport_path`, the `proxy`'s target is changed to a new placeholder.

Add a flag `vp_changed` to prevent calling `setup_local_to_scene` (mainly called by toggling `resource_local_to_scene`) when the target viewport has not changed.
2023-06-09 19:50:26 +08:00
Rémi Verschelde
2a8e83ccad
Merge pull request #78017 from Sauermann/fix-physics-passive-hovering
Fix passive mouse hovering for physics
2023-06-09 13:44:05 +02:00
Markus Sauermann
543fdc1490 Fix passive mouse hovering for physics
Currently mouse hovering doesn't update the state, when collision objects
or the camera move.
This PR fixes this problem by taking the mouse position from the viewport
and not from a nonexistent previous event.

Since previous events could potentially be a long time ago, their
modifier-key state might be outdated. This PR fetches the current
status of modifier-keys from `Input`.

These changes allow the removal of some class-variables and making
additional simplifications.
2023-06-09 12:51:10 +02:00
Rémi Verschelde
0cee1e0d4f
Merge pull request #77923 from Sauermann/fix-mouse-position-with-screen-transform
Fix mouse position with screen transform
2023-06-09 12:15:56 +02:00
Markus Sauermann
d1fa284e65 Fix mouse position with screen transform
When a Viewport is not directly attached to the screen, the
function `Viewport::get_mouse_position` can't rely on
`get_screen_transform`, because that function is ambiguous in
these situations.
In these cases it is necessary to use the mouse position from
the most recent mouse IputEvent.
2023-06-09 11:29:43 +02:00
Markus Sauermann
f00f4a0209 Fix input handling of unfocusable embedded Windows
InputEvents get in some cases sent to the wrong Window.
fix `Viewport::_sub_windows_forward_input`- console error spam
2023-06-06 17:51:19 +02:00
Aaron Franke
8b42297d7c
Make Viewport::gui_get_focus_owner const 2023-06-02 12:36:10 -05:00
Markus Sauermann
6d490ce8de Deprecate push_unhandled_input
The functionality of `push_unhandled_input` has changed so that it no
longer propagates input events to SubViewports.
This makes it less predictable and it should be deprecated in favor of
`push_input` which provides the same functionality and more.

Also this deprecation simplifies the Viewport-API by reducing the methods
for pushing input events, so that users don't need to worry about when
to use which function in order to insert input events.
2023-05-31 19:07:04 +02:00
Markus Sauermann
ce10ca6979 Create a virtual mouse move event after moving child nodes
This updates mouse cursor and mouse-over-states without the need
for additional mouse movements.
2023-05-29 22:46:19 +02:00
Rindbee
af58f1e854 Improve the UX of ViewportTexture in the editor
The associated `ViewportTexture`s will update the `viewport_path`
in time when the `Viewport`'s nodepath is changed (caused by renaming
the node names or moving in the SceneTree dock).

If the target `Viewport` is changed by resetting the `viewport_path`,
the `ViewportTexture`s will be re-setup and emit `changed` signal in
time.
2023-05-10 09:13:43 +08:00
Rémi Verschelde
15f9ac9458
Merge pull request #75751 from KoBeWi/eradicate_ViewportTexture_errors_entirely_and_surely
Prevent errors when using ViewportTexture
2023-05-08 16:40:10 +02:00
Rémi Verschelde
bbe05b60c8
Merge pull request #57179 from spacechase0/notify-world2d-changed-master
Propagate previously unused NOTIFICATION_WORLD_2D_CHANGED, make CanvasItem/CollisionObject2D use it
2023-05-08 16:40:00 +02:00
kobewi
1b9802fa8c Prevent errors when using ViewportTexture 2023-05-08 15:56:16 +02:00
Chase Warrington
46e06ee1e6 Propogate previously unused NOTIFICATION_WORLD_2D_CHANGED, make CanvasItem/CollisionObject2D use it 2023-05-01 18:26:55 -04:00
Juan Linietsky
104392ef4e Remove NOTIFICATION_MOVED_IN_PARENT
* This notification makes node children management very inefficient.
* Replaced by a NOTIFICATION_CHILDREN_CHANGED (and children_changed signal).
* Changed Canvas code (and similar) to use the above signal, to perform more efficiently.

This PR breaks compatibility (although this notification was very rarely used, even within the engine), but provides an alternate way to do the same.
It is required for the changes in #75627 to be entirely effective.
2023-04-06 13:57:13 +02:00
Markus Sauermann
34a7fc7447 Fix some ways to create inconsistent Viewport sizes
In the editor, it was possible to set the size of a `SubViewport` even
in cases where a parent `SubViewportContainer` had stretch enabled.

This PR disables editing a `SubViewport.size` while the parent disallows
it and it makes necessary adjustments during `NOTIFICATION_ENTER_TREE`.
2023-02-13 08:19:00 +01:00
Markus Sauermann
5312d83f3b Fix Viewport::get_mouse_position for SubViewports
SubViewports don't have a cached mouse position available.
This PR calculates the mouse position from the screen position of
the mouse cursor.
2023-02-07 13:54:47 +01:00
Rémi Verschelde
82ff7b4bce
Merge pull request #68492 from Sauermann/fix-picking-sort
Fix propagation order for 2D physics picking events
2023-02-06 15:38:38 +01:00
Markus Sauermann
6e855e3820 Fix propagation order for 2D physics picking events
This patch adds a viewport-configuration-option for sorting
physics-picking events by the Z-Index and the scene tree position
of the collision objects.
2023-02-04 22:44:36 +01:00
Markus Sauermann
e3e9da78e8 Remove Viewport::_get_input_pre_xform
This function is only relevant for `Window`. So this PR moves
the functionality to the `Window`-class.
2023-02-02 22:03:52 +01:00
Markus Sauermann
6743ac34d3 Simplify Viewport::_set_size
`Viewport.to_screen_rect` is used only in a single location to compare it
to `Rect2i()`.

When called from `SubViewport`, `to_screen_rect` is always equal to `Rect2i()`.
When called from `Window`, `to_screen_rect` is always different from `Rect2i()`.

So the comparison `to_screen_rect != Rect2i()` can be replaced by
`Object::cast_to<Window>(this)`.

This allows the removal of `Viewport.to_screen_rect` and the simplification of
`Viewport::_set_size`.
2023-02-02 19:09:14 +01:00
Markus Sauermann
8182f29d40 Fix stretch transform when resizing SubViewports
Move calculation of stretch transform from outside to inside
of `Viewport::_set_size` function.
2023-02-01 08:34:40 +01:00
Rémi Verschelde
51414fc987
Merge pull request #66906 from Sauermann/fix-prohibit-inconsistent-size-state
Prohibit inconsistent size state for SubViewport
2023-02-01 07:26:00 +01:00
Markus Sauermann
decbda68d7 Prohibit inconsistent size state for SubViewport
Prohibit size changes of SubViewports with parent SubViewportContainers that have stretch mode enabled.
2023-01-31 22:53:43 +01:00
Rémi Verschelde
14a4408e02
Merge pull request #65698 from KoBeWi/cameraman
Rework how current Camera2D is determined
2023-01-31 18:56:20 +01:00
Rémi Verschelde
13e20fed99
Merge pull request #68627 from Sauermann/fix-tooltip-position
Fix position of Tooltips
2023-01-26 16:00:14 +01:00
Markus Sauermann
c4ed247f5f Fix position of Tooltips
CanvasItem::get_screen_transform returns a transform from the CanvasItem
to the coordinate system, where a Popup - created as a child of the
CanvasItem - should be opened.
get_screen_transform makes some simplifications, that work well, when used
in the editor, but not in general cases.

Since Popups like Tooltips are now used more commonly in projects,
it becomes necessary to correct these simplifications.

This solution introduces Viewport::get_popup_base_transform, which makes
the necessary calculations.
2023-01-26 15:15:14 +01:00
Markus Sauermann
0d6d5e6421 Calculate the mouse focus inverse transform only when needed
Revival of #49158

Co-authored-by: Marcel Admiraal <madmiraal@users.noreply.github.com>
2023-01-09 21:35:38 +01:00
Juan Linietsky
2b815df3c1 Use BitField<> in core type masks
* All core types masks are now correctly marked as bitfields.
* The enum hacks in MouseButtonMask and many other types are gone. This ensures that binders to other languages non C++ can actually implement type safe bitmasks.
* Most bitmask operations replaced by functions in BitField<>
* Key is still a problem because its enum and mask at the same time. While it kind of works in C++, this most likely can't be implemented safely in other languages and will have to be changed at some point. Mostly left as-is.
* Documentation and API dump updated to reflect bitfields in core types.
2023-01-08 22:17:40 +01:00
Rémi Verschelde
d95794ec8a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
kobewi
7e2a8afb57 Rework how current Camera2D is determined 2022-12-02 00:05:02 +01:00
Fredia Huya-Kouadio
3ff7dd2aa4 Fix routing of InputEventScreenDrag events to Control nodes 2022-11-30 14:06:41 -08:00
Rémi Verschelde
438b2e2d02
Merge pull request #59801 from Sauermann/fix-node2d-viewport-root-order
Fix Viewport root order after Node2D raise
2022-11-28 08:21:10 +01:00
Markus Sauermann
226044b944 Allow canceling Drag and Drop with the Escape-Key
This patch implements the functionality to cancel Drag and Drop
by using the escape key or more general, the ui_cancel action.

Since this would be the third location, where the finalization of
Drag and Drop would have to be implemented, that functionality was
put into the private function _perform_drop.

Simplified gui.drag_data.get_type() != Variant::NIL to gui.dragging
because they are equivalent.
2022-11-08 19:10:16 +01:00
Markus Sauermann
022d24a9ae Fix Viewport root order after Node2D raise 2022-11-02 21:45:00 +01:00
BimDav
fcb9be66a2 Viewport canvas cull mask feature
Co-authored-by: Valentin Zagura <puthre@gmail.com>
2022-10-31 14:09:49 +01:00
Rindbee
9a05ea231a Make sure to reset the tooltip of its gui_parent when the viewport is removed 2022-10-04 11:58:02 +08:00
Marc Gilleron
aed3822a93 Change return type of get_configuration_warnings to PackedStringArray 2022-09-19 16:43:15 +01:00