-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix closest edge and face check in NavigationServer3D.map_get_closest_point_to_segment
#93227
Conversation
NavigationServer3D.map_get_closest_point_to_segment
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.
Thanks.
On a different note the NavigationServer3D documentation of that function should be improved to clarify what the collision parameter does.
When you've fixed the comment please squash your commits into one, see here And please also update the commit message to match the PR title to make it a bit clearer |
…st_point_to_segment
Sorry, my bad. Will follow pull-request guidelines properly next time. |
Thanks! And congrats for your first merged Godot contribution 🎉 |
This is incorrect statement (and hence this PR is incorrect as well). Counterexample: consider a face
|
@kleonc you're right, completely missed this, thanks! I still would like to try to implement a proper fix with your correction in mind. |
New PR yes, unsure about a report |
A bug report could be good so we make sure to track this for the 4.3 release, and ensure that we can either merge a fix up PR, or revert this one if it's incorrect, to revisit later. |
@oshman99 So any update on this / are you planning to open a PR? If you are not able to then please say so (in such case I'll address this myself). 🙂 |
@kleonc yeah you can go ahead and address this. Wanted to tackle it today, but life got in the way. If you don't mind, can you tag me in your PR, when you create one? |
@oshman99 Oh, I've asked kinda preemptively (seeing no update and just wanting to ensure it will be fixed for 4.3.stable). Aka haven't looked into this myself yet, maybe I'll do so tomorrow/Tuesday. So if you still want to open PR yourself feel free to do so (sorry if I made you not open a PR today etc.!); a simple fix ensuring correctness of the result would be fine for now (there's very likely a more optimal way to do the calculations as we're dealing with convex polygons / triangle fans and currently we're considering/checking each triangle separately). |
@kleonc oh, hahaha, sorry for causing confusion then. There is MOST DEFINITELY a more optimal way of doing things. My first instinct was to basically add a third shortest distance check, that would compare the current shortest distance with the distance to the edge (basically, a copy-paste of the previous implementation). It works fine, but that's a pretty naive solution. I'll create a PR today and ping you and @smix8 . Feel free to comment on any issues or suggest better ways of doing this :) |
If the line segment was not intersecting a face, Geometry3D::get_closest_points_between_segments was used. It calculated distance between the line segment and face's edges, instead of the distance between the line segment and face itself.
Since If the line segment is not itersecting a face, closest point to this face will be either beggining or end of this line segment, Face3::get_closest_point_to was used.
NavigationServer3D.map_get_closest_point_to_segment
only returns correct result if segment intersects nav mesh #93138