-
-
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
Curve3D get_closest_point broken #69220
Comments
Can confirm it works properly in v4.0.beta6.official [7f8ecff] and incorrectly in [68e3f49]. cc @xiongyaohua who made #69043. |
My bad. Should be fixed by #69239 |
I'm sorry, this fix is definitely an improvement, but the results are still weirdly discrete. If I change my test case to this:
then the output looks like:
Internally it is interpolating a dot product along the length of a straight line segment and while I expect to see floating point rounding errors I don't expect it to "step" in chunks of over 0.5. There's something weird going on. |
Increasing the bake interval from the default 0.2 to 1.0 improves the results a bit, although they still have repeating results at the 0,50,0 point, but it shows something else weird as well - I don't know if this helps:
The result for y=49.6 is closer to 49.7 than the result found for 49.7. That can't be right. Infact, I'm pretty sure I should be getting almost exactly equal Y values for both of these. |
According to the docs
seems to be a bug as (0, 49.67346, 0) is indeed closer to (0.2, 49.7, 0) than (0, 49.78468, 0) is. Approximately: |(0.2, 49.7, 0) - (0, 49.67346, 0)| = 0.201753 |
hmmm ... well, the code definitely tries to interpolate between the baked points, and I'm pretty sure it used to succeed because I used to get smoother surfaces, but fair enough. |
@kleonc - I think throughout 3.x I agree with @Skwint that using it resulted in a smooth output in 3.x (and possibly early 4.0 betas). On a similar vein I think Maybe there could be a Related to this, in Beta 7 I also came across a bug with
Not sure if I should open another bug report for this? (Apologies it's my first post). @xiongyaohua Thanks for your work on Curves/Paths, I have been following along eagerly awaiting the changes! |
I think the offset is the fractional distance along the curve, starting at 0.0 and ending at 1.0, rather than the absolute distance in space, but in that case it should print 0.5 in your case. That could be the same bug as this. |
Ah good point! The docs aren't too clear on it, but I think that in 3.x it was the equivalent of the PathFollow |
I'd hold off until this one is merged and then see, but it doesn't really hurt. If you do raise it, link this one to make the devs life a bit easier. |
Hi, I think these two problems are caused by my PR which introduce a new baking method. There is an subtile behaviour change. Bake interval "0.2" no longer produce points exactly "0.2" apart, but more or less "0.2" apart. This change is for simpler code and better baking performance. I am also quite new to godot code so I don't realize it create problems for other parts. Sorry. I think the proper fix is instead of finding the closest baked point, these two
Thanks for your appreciation 😄.
That is strange. I suspect it is an old bug in the |
Found some time, and fix the problem(again). Hope I get it right this time. Turns out the original After this fix, the test code
produces this result
|
@Skwint @CousCous4 Actually after rethinking I guess it's probably
@xiongyaohua So I agree with that. The docs needs to be clarified of course (it's fine in your PR).
For reference it was changed in #63394. |
Completely agree with your points @kleonc and @xiongyaohua ! While we are on the subject - I think another really useful function for a curve would be something like "get_tangent_at_offset", or equivalently "get_direction_at_offset", which returns the mathematical tangent of the curve at a given offset (or an approximation of it if that's not possible). I imagine that this is already calculated somewhere as the PathFollow inherits the rotation of the curve, and I think when we have both the position and tangent (i.e. direction) of the path at a given offset I think using the curve on its own without a PathFollow becomes quite powerful. |
Yes, the old doc was misleading. These methods actually find point on baked polyline. So I updated the doc in my PR.
Not yet. I think the backporting needs to wait for now, because the Curve refactoring is still in progress. After the release of 4.0 I'll look into backport if there is enough demand.
That is exactly why I started the whole refactoring effort. Now there is a method called |
I think backporting should wait until the refactor is finished |
Godot version
4.0.dev commit f9fa182
System information
windows 7 and windows 11
Issue description
The Curve3D.get_closest_point function now returns weirdly discrete answers, instead of the closest points.
Steps to reproduce
Make a node with a script and put this in the ready function.
The curve is just a straight line so it should return points with a Y value matching the Y value of the query.
Instead what you get is:
I'm 99% sure the commit f9fa182 introduced this one.
Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered: