Commit graph

189 commits

Author SHA1 Message Date
lawnjelly
d56d1ff4d2 Deprecate NOTIFICATION_MOVED_IN_PARENT
* NOTIFICATION_MOVED_IN_PARENT makes node children management very inefficient.
* Replaced by a NOTIFICATION_CHILD_ORDER_CHANGED (and children_changed signal).
* Most of the previous tasks carried out by NOTIFICATION_MOVED_IN_PARENT are now done not more than a single time per frame.

This PR breaks compatibility (although this notification was very rarely used, even within the engine), but provides an alternate way to do the same.
2024-04-20 07:52:05 +01:00
lawnjelly
bc607fb607 Fix signed distance field font rendering
This fix works in both GLES3 and GLES2.

The rendering formula in the shader was adjusted to further improve the
sharpness/antialiasing quality balance.

Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
2024-02-05 17:50:33 +00:00
lawnjelly
3e19cf834a CPUParticles2D - Add ability to follow physics interpolated target
Allows a non-interpolated particle system to closely follow an interpolated target without tracking ahead of the target, by performing fixed timestep interpolation on the particle system global transform, and using this for emission.
2023-09-18 16:05:03 +01:00
lawnjelly
723632a76a CPUParticles2D - fix interpolated transforms and culling
1) Physics interpolated particles in global mode are specified in global space. In VisualServer they should therefore ignore local transform.

2) Additionally, the expected final_transform should be passed on to children, rather than the identity transform used on the local item.

3) Local bounds in hierarchical culling are fixed for items using identity transform, by calculating their local bound in local space from the global space particles.
2023-08-22 12:57:54 +01:00
Rémi Verschelde
95877b8e1f
Merge pull request #80289 from lawnjelly/fti_2d_reset_on_enter
[3.x] Physics Interpolation 2D - reset on NOTIFICATION_ENTER_TREE
2023-08-08 14:28:23 +02:00
lawnjelly
bcfca5ec86 Physics Interpolation 2D - reset on NOTIFICATION_ENTER_TREE
As a convenience, physics interpolation is reset automatically on entering the tree. This will be desired in most situations, and saves the user having to write code for this explicitly.
2023-08-05 08:33:19 +01:00
lawnjelly
a117a3307a Physics Interpolation - add support for CPUParticles2D
Similar to the existing 3D CPUParticles physics interpolation.
2023-08-03 14:44:08 +01:00
lawnjelly
5162efbfe9 2D Fixed Timestep Interpolation
Adds support to canvas items and Camera2D.
2023-08-01 16:07:48 +01:00
lawnjelly
b777a9e5f9 Canvas item hierarchical culling
Adds optional hierarchical culling to the 2D rendering (within VisualServer).

Each canvas item maintains a bound in local space of the item itself and all child / grandchild items. This allows branches to be culled at once when they don't intersect a viewport.
2023-04-25 20:17:33 +01:00
Rémi Verschelde
1426cd3b3a
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".

Backported from #70885.
2023-01-10 15:26:54 +01:00
Markus Sauermann
608cbd8296 Include the follow-viewport-transform into CanvasLayer transform calculations
The follow-viewport-transform was missing from several calculations

3.x version of #59682
2022-12-19 19:18:54 +01:00
kobewi
2f13adbdb6 Remove error condition from get_global_transform()
(cherry picked from commit 2ff676a696)
2022-12-01 11:47:52 +08:00
kleonc
558b96f1b1 Fix CanvasItem not exiting its canvas group on canvas exit 2022-07-20 12:49:38 +02:00
Jason Knight
09e4672f0d Bind NOTIFICATION_LOCAL_TRANFORM_CHANGED 2022-03-20 11:34:29 -06:00
Haoyu Qiu
b76147ec16 Fix top level CanvasItem visibility
The editor gizmo fix from previously reverted
642591b6a9 is kept here.
2022-03-08 01:29:24 +08:00
Haoyu Qiu
d0901d4d55 Revert backport of "Rework CanvasItem visibility propagation"
This reverts part of commit f49ffe4bb0
2022-03-08 01:17:52 +08:00
Haoyu Qiu
ba0a17a458 Revert "Fix CanvasItem visibility propagation"
This reverts commit 642591b6a9.
2022-03-08 01:06:14 +08:00
kobewi
642591b6a9 Fix CanvasItem visibility propagation 2022-02-21 11:11:03 +01:00
Haoyu Qiu
85be83ebbb Fix typo in CanvasItem visibility propagation backport 2022-02-18 19:12:29 +08:00
Haoyu Qiu
f49ffe4bb0 Backport CanvasLayer visibility 2022-02-11 01:00:35 +08:00
lawnjelly
adf14bfdde Add nodiscard to core math classes to catch c++ errors.
A common source of errors is to call functions (such as round()) expecting them to work in place, but them actually being designed only to return the processed value. Not using the return value in this case in indicative of a bug, and can be flagged as a warning by using the [[nodiscard]] attribute.
2022-01-20 17:28:31 +00:00
Rémi Verschelde
a627cdafc5
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-13 15:54:13 +01:00
lawnjelly
3d981b8265 Add option to use handles to RID
Adds an option to compile an alternative implementation for RIDs, which allows checks for erroneous usage patterns as well as providing leak tests.
2021-12-06 14:43:34 +00:00
BrunoSXS
8fd0fe3d20
Fixes a game crash caused by instantiating Camera2D and sending a notification from it before adding it to the tree.
(cherry picked from commit eb2deabffe)
2021-11-18 12:21:28 +01:00
Metin Celik
edcb7b8129 Add half frame to floor() 2021-09-29 20:03:07 +02:00
Tom Coxon
9e9bac1549 Prevent shaders from generating code before the constructor finishes.
Fixes #43733: "creating SpatialMaterial in a separate thread creates invalid
shaders (temporarily)."

The bug occurred because various setters called in materials' constructors add
materials to queues that are processed on the main thread. This means that
when the materials are created in another thread, they can be processed on the
main thread before the constructor has finished.

The fix adds a flag to affected materials that prevents them from being added
to the queue until their constructors have finished initialising all the
members.
2021-09-21 11:47:51 +01:00
Hugo Locurcio
8dae2f9f00
Add a comment at the top of generated shaders
This comment is useful to determine the origin of ShaderMaterials
converted from built-in material types (such as CanvasItemMaterial
or SpatialMaterial).

The Godot version is also included in case the shader needs to be
regenerated with a newer engine version.
2021-08-16 18:46:55 +02:00
Rémi Verschelde
140350d767
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2021-05-05 15:02:01 +02:00
Rémi Verschelde
a828398655
Style: Replaces uses of 0/NULL by nullptr (C++11)
Using clang-tidy's `modernize-use-nullptr`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
2021-05-04 16:30:23 +02:00
Rémi Verschelde
b5e1e05ef2
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks 2021-05-04 14:45:16 +02:00
Rémi Verschelde
64a63e0861
Style: clang-format: Disable AllowShortCaseLabelsOnASingleLine 2021-05-04 14:45:15 +02:00
Pedro J. Estébanez
4ddcdc031b Modernize Mutex
- Based on C++11's `mutex`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
- `BinaryMutex` added for special cases as the non-recursive version
- `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`.
- `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same.
2021-02-18 11:58:08 +01:00
Rémi Verschelde
49646383f1
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆

(cherry picked from commit b5334d14f7)
2021-01-13 16:17:06 +01:00
Gilles Roudière
638e24684f
Fixes setting top_level not updating the global position
(cherry picked from commit 131a7b58c8)
2020-10-28 14:05:42 +01:00
Rémi Verschelde
4028414e0e
Revert "Made toplevel a property for Node3D and CanvasItem"
This reverts commit a726d011d5.
2020-10-19 16:58:56 +02:00
Duroxxigar
a726d011d5
Made toplevel a property for Node3D and CanvasItem
(cherry picked from commit 85a8dbb7b6)
2020-10-01 16:00:47 +02:00
Gilles Roudière
b5251eb00f Don't compile editor-only function when tools=no 2020-01-09 22:15:48 +01:00
Rémi Verschelde
a7f49ac9a1 Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
Rémi Verschelde
9e1be8f8aa
Merge pull request #32934 from ajweeks/fix-scale-origin
Fix 2D scale gizmo placement
2019-10-30 12:04:10 +01:00
Rémi Verschelde
3eb8bd08ec
Merge pull request #32657 from ptrojahn/lines
Fix draw_rect
2019-10-26 23:09:24 +02:00
AJ Weeks
fb7a4ce63e Fix canvas scale gizmo placement 2019-10-22 18:17:54 +01:00
AJ Weeks
59d2c71227 Add arcs to indicate angle being measured by ruler 2019-10-19 19:45:56 +01:00
Paul Trojahn
bdaedb601c Fix draw_rect
OpenGL uses the diamond exit rule to rasterize lines. If we don't shift
the points down and to the right by 0.5, the line can sometimes miss a
pixel when it shouldn't. The final fragment of a line isn't drawn. By
drawing the lines clockwise, we can avoid a missing pixel in the rectangle.
See section 3.4.1 in the OpenGL 1.5 specification.
Fixes #32279
2019-10-11 10:26:53 +02:00
qarmin
50be65bf43 Changed some code found by Clang Tidy and Coverity 2019-09-22 18:45:08 +02:00
Hugo Locurcio
8c8dc6f026
Call some CanvasItem property setters only if needed
The CanvasItem property setters `set_modulate`, `set_self_modulate`
and `set_light_mask` have some side effects that don't need to be run
if the value hasn't changed.

This closes #31777.
2019-08-31 21:53:02 +02:00
Tomasz Chabora
af5e0fff66 Remove ERR_EXPLAIN from scene/* code 2019-08-09 13:54:52 +02:00
Rémi Verschelde
9496e29326
Merge pull request #30451 from raphael10241024/fix_outline
Fix DynamicFont outline does not draw using draw_char
2019-07-10 13:38:20 +02:00
Hugo Locurcio
2491c87f86
Add width and antialiased parameters to CanvasItem draw_rect()
This also removes some duplicated editor code which is now obsoleted
by the new parameters in `draw_rect()`.
2019-07-09 20:30:18 +02:00
RaphaelHunter
e57d0c8e60 Fix DynamaicFont outline does not draw using draw_char 2019-07-09 12:42:59 +08:00
Furkan Türkal
7d8d337b2c fix some crashes 2019-07-01 14:28:29 +03:00