Hey All,
Since my previous post: link I have made a lot of progress, I think I have map generation figured out + runtime per chunk updating of regions. However I had a question on something which @smix8 touched on. He mentioned all the debug display is done by nodes. Since I am updating an Rid through the server I have no way of viewing the resulting navmesh to ensure it is 100% correct.
When simply generating the initial map I can use new Region2D() + addChild instead of server.CreateRegion() to debug(see the reference image below for an example of that). However when updating through the Server that is no longer usable. The manually created regions don’t respond to my NavigationServer2D.RegionSetNavigationPolygon call. Is there no way to view NavRegions visually when making all your changes through the NavigationServer2D?
Thanks for your time,
M
For reference here is my current map status after the initial generation:
64 regions lined up and merged without using edge connections and updated individually using async baking + callbacks. Baking rects have a 2 tile overlap to ensure edges are generated properly.
The nav regions seem correct when switching from the manual region creation to only using NavigationServer2D and calling my region update function as my test unit goes around the new obstructions. I’d like to visually confirm though.
PS. Another shoutout to smix8, that baking rect + border size PR made this work fun and easy once I had all the info.
The only way to get debug for purely NavigationServer usage is to render your debug manually in scripts with the RenderingServer or Node2D.draw() API but that adds a lot of complexity.
That change to make the NavigationServer render the debug is actually a lot more complex to do as it looks first. So much in Godot rendering is build around the assumption that a node exists as a base. As soon as there are no nodes involved you run into a lot of troubles keeping things updated correctly when things change in scenes. E.g. there is not even an API function to get the current camera of a Viewport from the RenderingServer, so if you dont keep track manually of the currently used Viewport nodes and cameras you are totally screwed when a users switches scenes or change things. Also the NavigationServer syncs on physics step so that also needs to be entirely reworked else you always have visual stutters on updates because it does not run in sync with the frame rate. There are many other issues that need to be solved first like this.
For the time being I would just use NavigationRegion2D nodes for your chunks to have debug while keeping things simple. The NavigationRegion nodes while kept static do not really add a performance cost that matters compared to using a pure NavigationServer region. Like place all of those region nodes at the world origin and you can easily switch them out for server only use when the debug gets changed. The only constrain with nodes is with threads as you can only really update them on the main thread. You can still do all your other stuff like updating your navmesh as you did before, you just need to (re)set the navigation polygon resource again on the region on the main thread so it can update its debug with the changed data.
Ok thanks smix, I appreciate the detail you always provide. I’ll bookmark that issue for future reference. I think I’ll give drawing the polygons a try then switch to nodes temporarily if that is too awkward.