Commit graph

1763 commits

Author SHA1 Message Date
lawnjelly
e4f252d94f Physics Interpolation - fix continuous updating in unmoving objects
Adds instances to the transform update list as well as the interpolate update list when unhiding them. This ensures that the system auto-detects non-moving objects, and removes them from the interpolate update list on the next tick, preventing unnecessary updates.
2022-06-19 11:26:13 +01:00
Marcel Admiraal
b257d552e7 Cleanup AudioEffectRecord thread_active variable 2022-06-17 08:52:20 +01:00
Rémi Verschelde
4e7363cac7
Merge pull request #61996 from smix8/navigation_bp_update_3.x
[3.5] Update NavigationServer backport
2022-06-16 00:17:16 +02:00
Rémi Verschelde
17e472fb9b
Merge pull request #61995 from Calinou/gles3-shader-compilation-default-asynchronous-cache
Enable asynchronous shader compilation + cache by default in GLES3
2022-06-16 00:13:43 +02:00
lawnjelly
991687cc10 Physics Interpolation - fix stale interpolation data when unhiding
A previous optimization prevented instances being added to the interpolation lists when hidden to save processing. This caused a regression when unhiding nodes outside of the physics tick - the interpolated transforms would be stale until the next physics tick, causing a glitch.

This PR readds instances immediately to the interpolation lists when they are unhidden, preventing this glitch.
2022-06-14 10:25:23 +01:00
smix8
8bd7c6188b [3.5] Update NavigationServer backport
Backports features and bugfixes from current Godot 4.0 to 3.5 and brings functions and codebase of both version largely in sync to make tutorials more compatible and future backports easier.
2022-06-14 05:55:14 +02:00
Pedro J. Estébanez
f46d7583ff Add INFO_SHADER_COMPILES_IN_FRAME to GL ES 3 render info 2022-06-13 18:53:15 +02:00
Hugo Locurcio
70d8e71b0e
Enable asynchronous shader compilation + cache by default in GLES3
This reduces stuttering when a material is displayed for the first
time, and prevents stuttering from occurring entirely after the
project is restarted when a similar situation is encountered.
2022-06-13 16:32:19 +02:00
lawnjelly
f8df04ed50 More low priority redraw request cases
Some more cases of textures etc causing continuous updates in vital updates only mode are fixed.
2022-06-12 06:44:59 +01:00
Markus Grafen
16517ecb3d visual instance layers are regarded during shadow culling
todo: setting Camera cull_mask should mark affected shadows dirty somehow
2022-06-09 09:02:43 +02:00
Hugo Locurcio
46b7133967 Add a 3D suffix to relevant physics profiler categories
2D physics categories already had a 2D suffix: "Physics 2D"

(cherry picked from commit 36428305a6)
2022-06-01 00:29:46 +02:00
lawnjelly
e7a73579e3 Portals - force full check on adding moving object
Moving objects being added during instance_moving_create() were incorrectly not forcing a full check to find which room they were within. This could result in moving objects being re-added not correctly identifying their current room, and thus culling incorrectly. This PR forces a full check on calling instance_moving_create.
2022-05-29 15:53:25 +01:00
Haoyu Qiu
067e738cb8 Fix various typos 2022-05-19 19:07:45 +08:00
Haoyu Qiu
b657d0c76c Add dedicated macros for property name extraction
* Replace case-by-case extraction with PNAME & GNAME
* Fix group handling when group hint begins with property name
* Exclude properties that are PROPERTY_USAGE_NOEDITOR
2022-05-19 11:31:35 +08:00
smix8
3977eb9107 Add NavigationServer2D/3D API functions to find missing RID info
Utility functions for NavigationServer2D/3D to find missing RID information when working with Server API directly. e.g. from map to regions and agents, from agent or region to map, from region to map and agents and so on ....

Requirement to work with NavigationServer API exklusive without SceneTree nodes and when juggling agents and regions between multiple navigation maps.

(cherry picked from commit 371054e3e5)
2022-05-16 21:10:36 +02:00
Rémi Verschelde
5e693b6d84 Fix warnings found by Emscripten 3.1.10
Fix `-Wunused-but-set-variable`, `-Wunqualified-std-cast-call`, and
`-Wliteral-range` warnings.

(cherry picked from commit d8935b27a9)
2022-05-16 16:38:26 +02:00
lawnjelly
ec9a17cfad Physics Interpolation - optimize hidden nodes
In order to prevent glitches when unhiding nodes, set_transform() is still called to the VisualServer even for hidden nodes when the node is interpolated. This activates a lot of logic which is not necessary just to keep the previous transform updated.

This PR adds an early out which misses out on the unnecessary logic when instances are invisible.
2022-05-10 08:59:34 +01:00
Cory Petkovsek
2be0738304 Visual/Physics/Navigation Servers validate RIDs with documentation update 2022-05-06 03:39:06 +08:00
lawnjelly
f1bef3c592 Physics Interpolation - improve warnings with NodePath
It has been pointed out to me that it is far more useful to display the NodePath in the warning than the name of the node, as there may be lots of nodes sharing the same name in a project. This PR fixes this.
2022-05-04 18:46:14 +01:00
Rémi Verschelde
f06e68f2a2
Merge pull request #54682 from smix8/textureproxy 2022-04-28 19:47:20 +02:00
smix8
ca1216fcef Expose VisualServer.texture_set_proxy() to GDScript
Expose VisualServer.texture_set_proxy() to GDScript
2022-04-28 18:53:29 +02:00
Rémi Verschelde
4cfc96fea7
Merge pull request #60531 from lawnjelly/fti_usage_warnings 2022-04-28 12:00:49 +02:00
lawnjelly
ad9b2b3794 Physics Interpolation - add helper warnings
When physics interpolation is active on a node, it is essential that transforms are updated during "_physics_process()" rather than "_process()" calls, for the interpolation to give the correct result.

This PR adds optional warnings for instances, cameras and multimeshes which can flag updates being incorrectly called, and thus make these problems much easier to fix.
2022-04-26 13:56:02 +01:00
Rémi Verschelde
d063bc4277
Merge pull request #60381 from clayjohn/3.x-sorting
[3.x] Sort based on camera position when using perspective camera
2022-04-26 12:26:31 +02:00
Rémi Verschelde
24307bd074 MultiMesh: Fix potential crash found by fuzzing
Fixes #58293.
2022-04-25 16:55:54 +02:00
clayjohn
76ff41cad1 Sort based on camera position when using perspective camera 2022-04-19 14:54:51 -07:00
tdetoy
8e57aae57d mesh_surface_get_format_offset and mesh_surface_get_format_stride will now provide an error with an invalid array index 2022-04-19 00:36:59 -04:00
Rémi Verschelde
e1eb3c2fb1
Merge pull request #60147 from lawnjelly/interpolation_out_of_scenario 2022-04-13 17:08:08 +02:00
lawnjelly
d2b1d29634 Physics interpolation - Move out of Scenario
Move VisualServer interpolation data out of Scenario and into VisualServerScene, so the interpolation data and enabled status is now common to all Scenarios.

Fix physics interpolation in multithreaded mode by ensuring tick and pre-draw are called.
2022-04-11 15:04:24 +01:00
Haoyu Qiu
f24312380f Rename NavigationServer's free method to free_rid 2022-04-08 17:31:04 +08:00
Rémi Verschelde
21c3048397 Add missing argument names in bindings 2022-04-04 12:56:59 +02:00
Yuri Rubinsky
385515431b
Merge pull request #59775 from Chaosus/shader_fix_3.x 2022-04-01 21:37:47 +03:00
Bartłomiej T. Listwon
df39e0f472 Fix crash in AudioServer when switching audio devices with different audio channels count (connecting PS5 controller, bluetooth 5.1 headphones etc.) 2022-04-01 10:45:42 +02:00
Yuri Roubinsky
b5c5c2d52b Fix shader crashing when attempting to access length() at global space 2022-04-01 08:44:57 +03:00
Rémi Verschelde
3eee2f45a3
Merge pull request #57674 from RandomShaper/fix_ubershader_android
Improve ubershader compatibility
2022-03-13 00:53:48 +01:00
Rémi Verschelde
c63ab664d2 Revert "PitchShift effect quality and performance tweaks for different pitch scale values"
(cherry picked from commit dae0135ae5)
2022-03-02 12:02:37 +01:00
lawnjelly
036bace9e9 BVH - Fix area-area collision regression
Minimal approach to fixing regression whereby static areas where not detect dynamic areas.
2022-02-26 11:36:27 +00:00
Rémi Verschelde
6ca309e058
Merge pull request #58531 from rburing/area_call_queries_fix_premature_return
[3.x] Godot Physics `AreaSW` and `Area2DSW`: fix premature return in `call_queries`
2022-02-26 09:36:14 +01:00
Ricardo Buring
89ce63a84f AreaSW and Area2DSW: fix premature return in call_queries 2022-02-25 14:41:34 +01:00
Ricardo Buring
e6f1a44b4d In final phase of test_body_motion, move and cull AABB for body once instead of for every shape 2022-02-21 15:03:09 +01:00
Hugo Locurcio
cfba65fa23 Expose AudioServer.capture_device as a property
This is more consistent with `AudioServer.device` (for output),
which is already exposed as a property.

(cherry picked from commit 1d35b37499)
2022-02-19 15:57:36 +01:00
Rémi Verschelde
2dd545b512
Merge pull request #58141 from lawnjelly/occluder_shared_resources 2022-02-16 13:29:55 +01:00
lawnjelly
3c2df49832 Fix Occluder to properly share resources
In order to properly support the resource sharing paradigm, Occluders are split into Instances and Resources in the VisualServer. Instances are owned by a Scenario, and Resources are global. OccluderShape resources can now correctly be shared by multiple OccluderInstances.
2022-02-16 09:55:11 +00:00
lawnjelly
522bce1159 Fixed Timestep Interpolation (3D)
Adds fixed timestep interpolation to the visual server.
Switchable on and off with project setting.

This version does not add new API for set_transform etc, when nodes have the interpolated flag set they will always use interpolation.
2022-02-16 09:41:23 +00:00
Bartłomiej T. Listwon
51d028fce0
Audio quality improvements in PitchShift
(cherry picked from commit 29b6ed9283)
2022-02-15 12:30:17 +01:00
Bartłomiej T. Listwon
6471d0a57a
Pass audio samples untouched for pitch_scale around 1.0f
(cherry picked from commit c02e979dbf)
2022-02-15 12:28:31 +01:00
Rémi Verschelde
7a16bb2ee4
Fix typos with codespell
Using codespell 2.2-dev from current git.

Added `misc/scripts/codespell.sh` to make it easier to run it once in a
while and update the skip and ignore lists.

(cherry picked from commit 1bdb82c64e)
2022-02-11 09:50:59 +01:00
Jérémy Zurcher
f9fdd526d5 fix portal_occlusion_culler compilation with target=debug tools=no 2022-02-06 13:22:33 +01:00
Pedro J. Estébanez
0d1ec9a7cf Improve ubershader compatibility
- Prevent debug enforced use of ubershader on shaders not supporting it
- Use unsigned integer for ubershader flags
- Add project setting for disabling async shader compilation on mobile
- Stop sampling some textures through different kinds of samplers at the same time
2022-02-05 22:12:31 +01:00
Rémi Verschelde
689f59dca0
Merge pull request #53463 from lawnjelly/vital_redraws
Add editor vital redraws only option
2022-02-04 21:42:49 +01:00
Hugo Locurcio
92376633f3
Clamp Viewport shadow atlas sizes to improve usability
- Add a range hint to the Viewport `shadow_atlas_size` property.
- Add range steps to the shadow resolution project settings that
  match the lowest allowed values (since lower increments don't
  make sense).
2022-02-04 18:01:16 +01:00
Pawel Lampe
6c6e50bf0c Fix navigation merge errors, fixes #56786
- improved `detail/sample_max_error` default value
- improved floating point precision handling in cell key calculations
- improved `merge error` error message
- exposed `cell_height` of `nav_map` to the `Navigation`
- fixed cell key `y` calculation
2022-02-02 23:52:29 +01:00
lawnjelly
a0c6d16c90 Add editor vital redraws only option
When editor continuous redraws is switched off, the editor only redraws when a redraw_request was issued by an element in the scene. This works well in most situations, but when scenes have dynamic content they will continuously issue redraw_requests.

This can be fine on high power desktops but can be an annoyance on lower power machines.

This PR splits redraw requests into high and low priority requests, defaulting to high priority. Requests due to e.g. shaders using TIME are assigned low priority.

An extra editor setting is used to record the user preference and an extra option is added to the editor spinner menu, to allow the user to select between 3 modes:

* Continuous
* Update all changes
* Update vital changes
2022-02-02 11:26:45 +00:00
lawnjelly
8ea20f5fdd Add OccluderShapePolygon
Add OccluderShapePolygon, glue to Occluder and gizmos etc.
2022-02-01 11:31:06 +00:00
Rémi Verschelde
d62166f68f
Merge pull request #57186 from lawnjelly/gameplay_fix_ticks 2022-01-25 11:39:26 +01:00
lawnjelly
38240fd0c8 Portals - Fix gameplay monitor ticking
Due to an optimization to prevent processing except when camera rooms changed, the ticking synchronization and updating of previous and current lists could get out of sync for affected objects, leading to missing gameplay notifications.

This PR adds new paths to properly support and synchronize objects in this "room based" path.
2022-01-25 10:07:50 +00:00
Yuri Roubinsky
85deed9207 Backport some changes to 3.x shaders 2022-01-25 10:34:57 +03:00
Rémi Verschelde
6c0c0c4b29
Merge pull request #54165 from Calinou/directional-shadow-runtime-change-3.x
Allow changing directional shadow size at run-time
2022-01-22 15:25:09 +01:00
Rémi Verschelde
c6480e2166
Merge pull request #57033 from lawnjelly/gameplay_monitor_unload
Portals - fix gameplay monitor unloading
2022-01-21 18:33:50 +01:00
lawnjelly
dc14636e68 BVH templated mask checks and generic NUM_TREES
Refactors the BVH to make it more generic and customizable. Instead of hard coding the system of pairable_mask and pairable_type into the BVH, this information is no longer stored internally, and instead the BVH uses callbacks both for determining whether pairs of objects can pair with each other, and for filtering cull / intersection tests.

In addition, instead of hard coding the number of trees, the BVH now supports up to 32 trees, and each object can supply a tree collision mask to determine which trees it can collide against.

This enables the BVH to scale to either the two or 3 trees needed in physics, and the single tree used without pairing in Godot 4 render tree.
2022-01-21 10:08:29 +00:00
lawnjelly
6c1e243fa2 Portals - fix gameplay monitor unloading
The gameplay monitor wasn't being unloaded correctly in between levels. This meant that exit signals were not being sent, and entered signals for the new level were being missed.

This PR sends appropriate exit signals on unloading, and clear the data.
2022-01-21 09:38:48 +00:00
Haoyu Qiu
ac144e7e8c
Fix invalid read when using LightOccluder2D
(cherry picked from commit 7870cf24f2)
2022-01-19 16:02:54 +01: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
Rémi Verschelde
b197de6f5f
Fix typos with codespell
Using codespell 2.1.0.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
GIRD
leapyear
lod
merchantibility
nd
numer
ois
ony
que
readded
seeked
statics
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2022-01-07 00:14:54 +01:00
Jake Young
09bc9eb101
Backport NavigationServer with RVO2 to 3.x
Change the entire navigation system.
Remove editor prefix from nav mesh generator class. It is now used for baking
at runtime as well.
Navigation supports obstacle avoidance now with the RVO2 library.
Nav system will also automatically link all nav meshes together to form one
overall complete nav map.
2022-01-05 16:00:56 +01:00
Rémi Verschelde
25369acff9
Merge pull request #51708 from Calinou/viewport-add-32bpc-color-depth 2022-01-04 14:30:24 +01:00
Yuri Roubinsky
0c449befbf Allow pass varyings as out param to the function, when it's possible 2022-01-04 10:22:39 +03:00
Bastiaan Olij
4e4de3430e Fix size issue for ARVR managed viewport 2021-12-19 14:51:10 +11:00
Yuri Roubinsky
25e24f2d05 [3.x] Prevent writing incorrect shader hints 2021-12-16 10:22:01 +03:00
lawnjelly
cbb6dc35a1 Fix add_line width being too wide
The line width of thick lines was being applied on both sides of the line, resulting in a line that was twice as thick as requested.

This PR fixes this embarrassing oversight.
2021-12-14 12:35:02 +00:00
Rémi Verschelde
4ebee76370
Merge pull request #55822 from Chaosus/shader_fix_semicolon_3.x 2021-12-12 21:10:38 +01:00
Yuri Roubinsky
933fd6be75 [3.x] Restore shader parsing errors with lack of semicolon in a block 2021-12-11 18:05:49 +03:00
lawnjelly
26e93dc5c6 Fix lighting_dirty flag bug
In rare circumstances, changing the geometry data attached to an instance, there was the opporunity for the lighting_dirty flag to get out of sync, which could lead to access to a stale light RID, and warnings or worse.

This PR fixes the problem by ensuring the lighting is always updated on the instance when first adding GeometryData.
2021-12-11 11:27:21 +00:00
PouleyKetchoupp
e11662ad77
Handle test body motion with 0 margin
Margin needs to have a high enough value for test body motion to work
properly (separate using the margin, move without then gather rest info
with the margin again).

Fixes issues with test motion returning no collision in some cases with
margin equal to 0.

(cherry picked from commit 0c354047e1)
2021-12-10 11:16:35 +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
Yuri Roubinsky
de9205f72d Fix ^= operator in shaders 2021-12-03 10:34:56 +03:00
Rémi Verschelde
3be0f85e91
Merge pull request #54377 from lawnjelly/faster_editor_lines 2021-11-30 13:30:02 +01:00
Aaron Franke
1d8cef8236
[3.x] Backport some APIs in math structs 2021-11-27 01:19:45 -06:00
Yuri Roubinsky
5928cc90f8 [3.x] Prevent return statement from using in block in shader main func 2021-11-23 10:40:47 +03:00
Camille Mohr-Daurat
3970f28f67
Merge pull request #55096 from lawnjelly/bvh_expanded_leaf
BVH - add option for expanded AABBs in leaves
2021-11-22 09:37:16 -07:00
Rémi Verschelde
393c7959ef
Merge pull request #42929 from madmiraal/fix-42877-3.2 2021-11-20 10:23:06 +01:00
Marcel Admiraal
702529d63e Give each RigidBody its own DirectBodyState wrapper. 2021-11-20 08:17:04 +00:00
Marcel Admiraal
e900bac80b Add area to moved list when changing monitorable,
and only remove area from query when deleting pair if it was monitorable.
2021-11-20 06:54:36 +00:00
lawnjelly
211dc8cd2d BVH - add option for expanded AABBs in leaves
This PR adds a define BVH_EXPAND_LEAF_AABBS which is set, which stores expanded AABBs in the tree instead of exact AABBs.

This makes the logic less error prone when considering reciprocal collisions in the pairing, as all collision detect is now taking place between expanded AABB against expanded AABB, rather than expanded AABB against exact AABB.

The flip side of this is that the intersection tests will now be less exact when expanded margins are set.

All margins are now user customizable via project settings, and take account of collision pairing density to adjust the margin dynamically.
2021-11-20 06:45:12 +00:00
Hugo Locurcio
d7d35e4f73
Add const qualifier support for function arguments in shaders
This prevents the function argument from being reassigned within
the function.

Example:

    void test(const int t) {}
2021-11-19 21:20:23 +01:00
Marcel Admiraal
4d3690eba5 Remove unimplemented methods 2021-11-18 12:47:36 +00:00
Rémi Verschelde
45088780be
Merge pull request #54925 from nekomatata/bvh-fix-update-3.x 2021-11-16 21:23:11 +01:00
PouleyKetchoupp
e9fdf3e61f Fix physics BVH pairing for teleported or fast moving objects
Updating the broadphase to find new collision pairs was done after
checking for collision islands, so it was working in most cases due to
the pairing margin used in the BVH, but in case of teleported objects
the narrowphase collision could be skipped.

Now it's done before checking for collision islands, so we can ensure
that broadphase pairing has been done at the same time as objects are
marked as moved so their collision can be checked properly.

This issue didn't happen in the Octree/HashGrid because they do nothing
on update and trigger pairs directly when objects move instead.
2021-11-16 12:01:57 -07:00
Rémi Verschelde
4103b0b7d8
Merge pull request #50823 from fbcosentino/3d-material-overlay 2021-11-16 08:21:18 +01:00
Fernando Cosentino
cc8846bef6 Added material_overlay property to MeshInstance
Applying overlay materials into multi-surface meshes currently
requires adding a next pass material to all the surfaces, which
might be cumbersome when the material is to be applied to a range
of different geometries. This also makes it not trivial to use
AnimationPlayer to control the material in case of visual effects.
The material_override property is not an option as it works
replacing the active material for the surfaces, not adding a new pass.

This commit adds the material_overlay property to GeometryInstance
(and therefore MeshInstance), having the same reach as
material_override (that is, all surfaces) but adding a new material
pass on top of the active materials, instead of replacing them.

Implemented in rasterizer of both GLES2 and GLES3.
2021-11-15 23:50:34 +00:00
Rémi Verschelde
89792e5c49
Merge pull request #54921 from lawnjelly/portals_roaming_margin 2021-11-15 22:45:46 +01:00
Yuri Roubinsky
824183854c
Removed incorrect autocompletion of matrixes in shader
(cherry picked from commit 04a2053f9b)
2021-11-15 16:30:00 +01:00
Julian Adamse
7e5034958e
Fix the volume calculation for cylinders
(cherry picked from commit 03903fdeec)
2021-11-15 16:09:59 +01:00
lawnjelly
062406b555 [3.x] Add Basis helper functions for transforming normals
Correct transformation of normals that works with a Basis containing non-uniform scale is difficult to get correct for those not familiar with the maths, it is also rather verbose and hard to read in calling code. This PR adds helper functions which both standardize the approach and make it clearer in calling code what is being done and why.
2021-11-15 08:43:46 +00:00
lawnjelly
788f075b44 Portals - Allow user to set roaming expansion margin
Previously a crude metric was used to decide on the roaming expansion margin, but it created unexpected results in some scenarios. Instead this setting is exposed to the user via the RoomManager, allowing them to tailor it to the world size, room sizes, roaming objects sizes and the speeds of movement.
2021-11-12 15:46:04 +00:00
PouleyKetchoupp
b93aeec4a2 Fix errors in KinematicBody when floor is destroyed or removed
In all physics servers, body_get_direct_state() now silently returns
nullptr when the body has been already freed or is removed from space,
so the client code can detect this state and invalidate the body rid.

In 2D, there is no change in behavior (just no more errors).

In 3D, the Bullet server returned a valid direct body state when the
body was removed from the physics space, but in this case it didn't
make sense to use the information from the body state.
2021-11-09 15:15:40 -07:00
Rémi Verschelde
1f8497d281
Merge pull request #53411 from RandomShaper/ubershaders_3.x 2021-11-09 13:12:44 +01:00
Pedro J. Estébanez
4c710780d4 Implement async shader compilation plus caching for GL ES 3
Async. compilation via ubershader is currently available in the scene and particles shaders only.

Bonus:
- Use `#if defined()` syntax for not true conditionals, so they don't unnecessarily take a bit in the version flagset.
- Remove unused `ENABLE_CLIP_ALPHA` from scene shader.
- Remove unused `PARTICLES_COPY` from the particles shader.
- Remove unused uniform related code.
- Shader language/compiler: use ordered hash maps for deterministic code generation (needed for caching).
2021-11-09 12:19:12 +01:00
Rémi Verschelde
cfff7a9032
Merge pull request #54751 from NHodgesVFX/3.x 2021-11-09 00:15:49 +01:00
Rémi Verschelde
6b7c841e1b
Merge pull request #54111 from nekomatata/fix-rigid-body-update-collision-layer-3.x 2021-11-08 23:58:47 +01:00