-
-
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
Add NavigationServer random point queries #75098
Add NavigationServer random point queries #75098
Conversation
It looks like there's some setup each time queried, would it be worth it to allow batching this, requesting several points at once? |
@AThousandShips |
Agreed, saw after commenting that the area of the regions are cached which would be the only real performance bottleneck, when pondering possible implementation of this on the original proposal I was considering an idea where a query structure could be returned which contained the areas for weighted lookup (i.e. how you solve it here), but I don't think the complexity is worth it, I don't think you'd do queries like this that often |
1feecf8
to
cf55a9e
Compare
6f33e83
to
2652803
Compare
2652803
to
8734ed3
Compare
cbb5c76
to
a3d9697
Compare
Adds query functions to get random points on navigation mesh to the NavigationServer.
a3d9697
to
64a5624
Compare
Will test the code when I have the time but the code looks good to me |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good, unable to do any real runtime testing myself
Thanks! |
I needed this, thank you so much! |
Wow wow wow ❤️ Thanks to everyone involved! This was just the thing I was looking for. |
region_get_random_point() does return me a Vector3 but it's always of value (0, 0, 0), has this happened to anyone ? map_get_random_point() does work but only like half of the time, otherwise I also get the same value as region. edit: thanks @jadenrose for the assistance 🙏 |
I just ran into this issue as well! According to the docs, any procedural operations won't be ready to use until 1 physics frame after the NavigationServer is mounted, at least that's my understanding. To solve this, I deferred my call to the method that was querying the server, then at the top of that method, I waited for a Example:
I think what this does is ensures that 1) The method gets called on the 2nd process frame (or the end of the 1st, I'm rusty on the specifics) so all your nodes are already in the tree and 2) The method waits for the server to do its setup (which happens during the first physics frame after the initial render) before trying to query it. Presumably, you could also just wait for an arbitrary number of milliseconds before querying the first time, but I like this way because there's no possibility of a race condition. |
Adds query functions to get random points on navigation mesh to the NavigationServer.
Implements godotengine/godot-proposals#6181.
Random points can be queried per navigation map or per navigation region.
Random points can be queried uniformly (costs more performance) or not.