Skip to content

Add bake state info and MultiNodeEdit support for NavigationRegion3D #104210

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

Merged
merged 1 commit into from
Jun 10, 2025

Conversation

smix8
Copy link
Contributor

@smix8 smix8 commented Mar 15, 2025

Adds bake state info and MultiNodeEdit support for NavigationRegion3D.

Resolves #104116

Allows to select multiple nodes inside the editor and (re)bake or clear all selected navigation region nodes with one button click.

Adds a new bake dialog that shows how many unique navmeshes need to be baked and how many navigation regions are selected. Revives the old bake state info text that was disabled due to old editor process being broken with threads.

navmesh_bake_dialog

Can't add for NavigationRegion2D because the 2d version depends on the AbstractPolygon2DEditorPlugin. That editor has no support for multi node edit. It is also shared with many other 2d polygon editors so can't be easily modified.

Copy link
Contributor

@MJacred MJacred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with simple setups from my Navgiation Area tests. Worked like a charm.

If possible, show a dialog with a message such as "You're attempting to bake multiple NavigationRegion3D nodes. This can freeze the Editor temporarily." Continue | Cancel.
But only if Godot has such a function such as showing a checkbutton between the message and the dialog buttons stating "Don't show this warning again."

The best case would be a queue on a separate thread to prevent potential Editor freezing… Could this be easily achievable with WorkerThreadPool?

@smix8
Copy link
Contributor Author

smix8 commented Mar 16, 2025

Added a new bake dialog. It now processed the regions in a queue with the threaded baking.

The warning and exklusive popup Window hopefully enough to keep users from messing up the editor in the meantime.

Sorry but we cant allow users editing the scene while the baking runs. Doing edits in the middle of the node parsing is an easy way to cause crashes or data corruption. Switching scenes alone is trouble as the editor does too much problematic stuff in the background with the nodes on a scene switch. We also cant do all the parsing at the begin because that is also an easy way to run into memory crashes later.

@smix8 smix8 force-pushed the navmesh_multiedit branch 2 times, most recently from 5e53b51 to 92ef751 Compare March 16, 2025 13:42
@smix8 smix8 changed the title Add MultiNodeEdit support for NavigationRegion3D Add bake state info and MultiNodeEdit support for NavigationRegion3D Mar 16, 2025
@smix8
Copy link
Contributor Author

smix8 commented Mar 16, 2025

Now that we have a new Window dialog added back in the bake state for the steps of the navmesh baking process.

@smix8 smix8 force-pushed the navmesh_multiedit branch 2 times, most recently from 133463c to 499c5dc Compare March 16, 2025 17:23
@smix8 smix8 force-pushed the navmesh_multiedit branch 2 times, most recently from ecc0cfa to 2f3a73d Compare March 16, 2025 19:13
@smix8 smix8 force-pushed the navmesh_multiedit branch from 2f3a73d to f655932 Compare March 17, 2025 10:44
Copy link
Contributor

@MJacred MJacred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing edits in the middle of the node parsing is an easy way to cause crashes or data corruption

Yeah… w/o reliable locking of said resources (+ the visual feedback), this is not advisable. And that would be cumbersome effort


bug: cannot bake (multiple) regions/navmeshes after cancelling once

reproduction steps

  1. select multiple regions with different navmeshes
  2. click "Bake NavigationMesh"
  3. instead of baking, cancel the dialog
  4. click "Bake NavigationMesh" again
  5. Nothing happens. De-selecting and re-selecting does not fix the issue

@smix8 smix8 force-pushed the navmesh_multiedit branch from f655932 to 8ebbeab Compare March 20, 2025 12:09
@smix8 smix8 force-pushed the navmesh_multiedit branch 2 times, most recently from 2b83af5 to dcde4bd Compare April 2, 2025 19:02
@smix8 smix8 force-pushed the navmesh_multiedit branch 2 times, most recently from a3ac6d7 to 77b791e Compare May 15, 2025 20:46
@akien-mga akien-mga requested a review from MJacred May 15, 2025 20:56
Copy link
Contributor

@MJacred MJacred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with two planes of the size 1000x1000 with 100 subdivisions, in order to slow down the generation.

bugs

  • Clicking "cancel" in the dialog only closes the dialog, it does not cancel the current baking The navmeshes still show up
  • the bug I mentioned previously is still there: #104210 (review)

Just something I noticed…
As far as I can tell, NavMeshGeneratorTask3D::TaskStatus::BAKING_FAILED is never used. Anywhere in the engine.
e.g. NavMeshGenerator3D::generator_bake_from_source_geometry_data could return that value, which could be used in the calling func NavMeshGenerator3D::generator_thread_bake to update generator_task->status

@smix8 smix8 force-pushed the navmesh_multiedit branch from 77b791e to 98da839 Compare May 18, 2025 16:55
@smix8
Copy link
Contributor Author

smix8 commented May 18, 2025

cannot bake (multiple) regions/navmeshes after cancel

That the baking does no longer work after cancelling once at the very begin should be fixed now.

Clicking "cancel" in the dialog only closes the dialog, it does not cancel the current baking The navmeshes still show up

The cancel can only cancel queued navmeshes after the currently baked navmesh. There is currently to way to cancel a navmesh bake that has already started. There is no API for it on either node, server or thirdparty lib. That would be a lot of work not in scope of this PR.

Copy link
Contributor

@MJacred MJacred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That the baking does no longer work after cancelling once at the very begin should be fixed now.

Fix is confirmed.

The cancel can only cancel queued navmeshes after the currently baked navmesh

You're right, I mixed that up with my tests on non-unique nav regions. Sorry for the confusion.


refinement suggestions:

  • adding to the dialog the note: "Cancelling takes effect after the currently baking region is finished." (or sth. along the lines)
  • change button text from "Cancel" to "Close" when there's only 1 unique navmesh, as actually cancelling is impossible in that context

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YOLO approved.

Adds MultiNodeEdit support for NavigationRegion3D.
@smix8 smix8 force-pushed the navmesh_multiedit branch from 98da839 to 7ae2c0a Compare June 10, 2025 14:59
@akien-mga akien-mga merged commit f0d11e4 into godotengine:master Jun 10, 2025
20 checks passed
@akien-mga
Copy link
Member

Thanks!

@smix8 smix8 deleted the navmesh_multiedit branch June 11, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Navigation] [Editor] Cannot bake/clear navigation maps with the editor, if a second node is selected
4 participants