Skip to content

Commit e5e9edb

Browse files
committed
Speed up NavigationServer3D synchronizations
Speeds up NavigationServer3D synchronizations by removing unnecessary command queue delays for navmesh related updates.
1 parent 3f5b871 commit e5e9edb

File tree

12 files changed

+229
-108
lines changed

12 files changed

+229
-108
lines changed

doc/classes/NavigationServer3D.xml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,13 @@
355355
Create a new link between two positions on a map.
356356
</description>
357357
</method>
358+
<method name="link_force_update">
359+
<return type="void" />
360+
<param index="0" name="link" type="RID" />
361+
<description>
362+
Forces an immediate main thread synchronization of the specified navigation [param link] [RID]. Requires a navigation map synchronization afterwards as well to full register. Be aware that forcing a main thread synchronization can cause severe performance problems on more complex navigation setups.
363+
</description>
364+
</method>
358365
<method name="link_get_enabled" qualifiers="const">
359366
<return type="bool" />
360367
<param index="0" name="link" type="RID" />
@@ -504,14 +511,11 @@
504511
Create a new map.
505512
</description>
506513
</method>
507-
<method name="map_force_update" deprecated="This method is no longer supported, as it is incompatible with asynchronous updates. It can only be used in a single-threaded context, at your own risk.">
514+
<method name="map_force_update">
508515
<return type="void" />
509516
<param index="0" name="map" type="RID" />
510517
<description>
511-
This function immediately forces synchronization of the specified navigation [param map] [RID]. By default navigation maps are only synchronized at the end of each physics frame. This function can be used to immediately (re)calculate all the navigation meshes and region connections of the navigation map. This makes it possible to query a navigation path for a changed map immediately and in the same frame (multiple times if needed).
512-
Due to technical restrictions the current NavigationServer command queue will be flushed. This means all already queued update commands for this physics frame will be executed, even those intended for other maps, regions and agents not part of the specified map. The expensive computation of the navigation meshes and region connections of a map will only be done for the specified map. Other maps will receive the normal synchronization at the end of the physics frame. Should the specified map receive changes after the forced update it will update again as well when the other maps receive their update.
513-
Avoidance processing and dispatch of the [code]safe_velocity[/code] signals is unaffected by this function and continues to happen for all maps and agents at the end of the physics frame.
514-
[b]Note:[/b] With great power comes great responsibility. This function should only be used by users that really know what they are doing and have a good reason for it. Forcing an immediate update of a navigation map requires locking the NavigationServer and flushing the entire NavigationServer command queue. Not only can this severely impact the performance of a game but it can also introduce bugs if used inappropriately without much foresight.
518+
Forces an immediate main thread synchronization for the navigation mesh part of the specified navigation [param map] [RID]. Pending changes to regions or links need to be synchronized before map synchronization. Be aware that forcing a main thread synchronization can cause severe performance problems on more complex navigation setups.
515519
</description>
516520
</method>
517521
<method name="map_get_agents" qualifiers="const">
@@ -933,6 +937,13 @@
933937
Creates a new region.
934938
</description>
935939
</method>
940+
<method name="region_force_update">
941+
<return type="void" />
942+
<param index="0" name="region" type="RID" />
943+
<description>
944+
Forces an immediate main thread synchronization of the specified navigation [param region] [RID]. Requires a navigation map synchronization afterwards as well to full register. Be aware that forcing a main thread synchronization can cause severe performance problems on more complex navigation setups.
945+
</description>
946+
</method>
936947
<method name="region_get_bounds" qualifiers="const">
937948
<return type="AABB" />
938949
<param index="0" name="region" type="RID" />

0 commit comments

Comments
 (0)