- Edited
xyz I haven't found any problems with the code (yet).
Not sure I completely understood what you say, maybe I should try to explain what I did (for example, I did no explicit ==
comparison). I don't understand this "seemlingly match": I don't choose randomly the main points coordinates, they come directly from Godot. The same for the baked array. So, I pass the function a point coming from get_point_position
and I'm quite sure the point is inside the baked array (and this lets me find
its index, etc.). For sure the function lacks some code for when the coordinate is not found, anyway.
So, my situation was:
I had the (main) points coordinates as vectors and I needed to convert the vectors to "the progress_ratio at these points" (a float);
I found
get_baked_length()
that returns the entire length of the path (maybe doing at a low level the same thing I do, since I get about the same length by running my code. In the first test, the length returned byget_baked_length
was 2453.138671875, while my code returned 2453.13806445297);I found the curve is represented internally by an array of cached vectors (you could make the vector even more dense, by adding more points, but I decided not to do it);
I applied the classical distance formula to get the distance to any point I choose, and I got the distance from the start to my custom point;
since I knew the total length of the curve, it was easy to derive the
progress_ratio
;
I must study your code (because of my incompetence, I can't understand it on the fly) :-)