-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NavigationAgents - schedule pathfinds to prevent performance blips #62745
Conversation
1a7b8ce
to
90a3bab
Compare
90a3bab
to
396c3e5
Compare
Adds a simple method to limit pathfinds per physics tick, 2D and 3D.
396c3e5
to
0800fdd
Compare
I like the overall idea, but I don't like the implementation:
IMO, the much better way would be to implement the solution within the navigation server (something like async |
All these are easy to change.
Yes, as I said here in the notes:
Writing async version will probably require some major rework from the navigation maintainers to get working without causing stalls (if anyone wants to volunteer for this? 😁 ). In the meantime, although 4.x is in beta, 3.x is expected to be used in production, and imo it is better to have a stop gap solution that works than nothing at all, so people can continue to ship games. Essentially, 3.5 stable is right around the corner so if possible it would be good to clear up the major problems with the navigation asap (robustness and performance), and have a usable solution - bearing in mind we don't have time for another long series of betas for async pathfinding. |
IMO it will not. I tend to think it would be actually much easier and more readable. Also, what's the point of adding a feature we would like to get rid of in the next increment? Once users start using above implementation it will be much harder to push for the proper one. |
Then maybe you can add it? 👍
In terms of project setting we could probably just have a toggle for |
Actually, I'm busy rewriting the entire navigation system using Recast/Detour/Crowd as a plugin/module :) Nevertheless, having a feature switch I'd just call to split Ofc. Feel free to disagree :) Maybe @smix8 can give some thoughts as well. |
I think the idea of this pr to slice the updates over multiple frames is good but I think we should implement this differently. Navigation timeslice as a feature is needed, no doubt. The current NavigationAgent navigation leads to frame spikes that could be easily avoided if not all NavigationAgents node would call for updates in the same frame. I think that change is not time critical for Godot 3.5. In my tests performance is not really worse than old navigation in <3.5 before the NavigationServer backports. We can give us some time to figure things out properly for something that works in both Godot 4.0 and 3.5.1 or 3.6. I think this should be implemented in Godot 4.0 first and later backported. With the many recent updates and backports for Godot 3.5 we have near identical navigation code in 3.5 and 4.0 now. This was a struggle to achieve. Every addition, if not very specific for Godot 3.5 codebase, should be made for Godot 4.0 first and then backported to Godot 3.5, if it works. I think navigation features like timeslicing path queries here should not be made NavigationAgent node exclusive. Navigation features should work with pure NavigationServer API use first and then be added to any node that uses said API functions cause not everyone wants to and should use the NavigationAgent node as it is very restricting. This means this feature needs to be added on the NavigationServer and not on the NavigationAgent node, e.g. with a queue on the NavigationServer like Scony suggested. Async/Deferred/WhateverMode path queries should never be a bool toggle for the entire project. Some actors are just more important than others and some situations need instant updates while others are more performance aware. So this should be a parameter on the actual path query. Could still add a funnel on the node like in this pr but the time slice should be in the hands of the NavigationServer and not some random node. My prefered way to add a "deferred" parameter for path queries would be with the NavigationPathQueryParameters3D objects from pr #62429. Could easily add a property like NavigationPathQueryParameters3D.path_callback = "method_name" to it. When a callback is available the NavigationServer will process the path query not immediately but only when it has time. I would prefer shifting to such Parameter objects like physics does as it makes it so much easier to add / rework features in the backend without breaking compatibility and add class documentation. I think settings like those discussed should be part of the NavigationServer and changeable at any time from scripts not a "hardcoded" projectsetting that is only updated at the start. In general I prefer to move navigation related properties/settings to the NavigationServer for those that depend on a Godot navigation build anyway. My pr #62601 for navigation debug already tried to clean the SceneTree from as much navigation stuff as possible and move it to the NavigationServer so everything navigation related is in one place. @Scony If you manage to integrate Detour/Crowd in Godot with the current NavigationServer that would be definitly a feature for a core module in my opinion as it would solve some annoying limitations with the current navigation system. Let me know if you make it available for testing e.g. with a branch. |
Closing as stale. |
Adds a simple method to limit pathfinds per physics tick.
Pathfinds in the navigation server are currently synchronous, and can cause performance blips and dropped frames if several agents do a pathfind simultaneously. This PR enables simply limiting the number of pathfinds per physics tick.
Notes
navigation/common/pathfinding/paths_per_tick
. This can either be positive, 0 (unlimited), or negative, indicating a single pathfind every nth tick.