[Navigation 2D] Fix sign of cross product#110815
Merged
Repiteo merged 1 commit intogodotengine:masterfrom Sep 23, 2025
Merged
Conversation
Regression from splitting the servers. Also replaces the method for getting the triangle area.
AThousandShips
commented
Sep 23, 2025
smix8
approved these changes
Sep 23, 2025
Contributor
smix8
left a comment
There was a problem hiding this comment.
Can confirm that this fixes the bug in the 2d corridor funnel path postprocessing. In a few tests I did this now yields the identical paths with all post processing options in both 2d and 3d when using the same navmesh.
(NavigationPolygon.get_navigation_mesh() can be used to convert any 2D navmesh to 3D)
Member
Author
|
(Updated the MRP to get around #110807) |
kiroxas
reviewed
Sep 23, 2025
Contributor
|
Thanks! |
Member
Author
|
Thank you! |
Contributor
|
Cherry-picked to 4.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Regression from splitting the servers. The original code effectively took the cross product using
Vector3(v0.x, 0, v0.y).cross(Vector3(v1.x, 0, v1.y)).y, but this is not equivalent to the 2D cross product which is equivalent toVector3(v0.x, v0.y, 0).cross(v1.x, v1.y, 0).z.The former gives
v1.x * v0.y - v0.x * v1.y, but the latter givesv0.x * v1.y - v1.x * v0.y.Fixed by negating the result in all places, verified against that the original 3D code is the plain cross product.
Also replaced the area formula, using
absinstead which was an oversight in the original code.Added minimal tests for the area formula and also for the closest point method, the latter can be removed if not necessary but wanted to make sure the area formula is correct, verified the area with conventional methods.
Minimal project from smix8 (note that due to #110807 you will need to open the main scene manually, as saving the main scene currently breaks things):
godot-4.5-path-corridorfunnel-bug.zip
Click in the red circle to confirm that the path no longer goes the wrong way
Related (but does not fix the entire issue):