-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
Reimplement slerp
on Vector3
#316
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-316 |
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 a lot! Just minor comments.
Here's the link to your method documentation, by the way 🙂
/// Length is also interpolated in the case that the input vectors have different lengths. If both | ||
/// input vectors have zero length or are collinear to each other, the method instead behaves like | ||
/// and directly calls [`Vector3::lerp`]. |
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.
The "directly calls" is an implementation detail (and makes the sentence more complicated to read), no need to mention that.
Instead, it would be nice if you added such comments in the code itself, e.g. in each if
branch, to explain why this is equivalent to lerp
.
This update was an attempt at explaining the if statements (and the other fixes) and I hope it was sufficient. I wonder though, could the line 315 if check be moved one statement before to instead check directly for a zero Vector3 since only that can produce a length of zero (right?), saving the |
That's correct, you could do if axis == Vector3::ZERO { Thanks for the comments! |
Regarding the test cases, are they from Godot? Otherwise, one thing we could do is see if |
No, it's not. I will replace it with the Godot ones then. It's also getting really late so expect it tomorrow. |
No rush here! 😊 I also think the tests are fine as-is. We might automate some integration-testing against Godot in the future, so it can still be good to have some unit tests. Those also make ensure that the engine is not required to run. |
Uh oh, I think I found a difference in the checks by the repo's clippy and the local When I ran the repo clippy command locally however, it also found the excessive precision issue. For reference, the repo clippy command is: While the If this is a real issue I could open an issue about it (pun not intended). |
On another note, I ported the Godot tests :D. |
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 for the note about clippy, I can adjust the local check.sh
to match CI. In case of doubt, CI is always the source of truth.
bors r+
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
Reimplemented the
slerp
method on Vector3 with the addition of documentation and several tests on it. Addresses part of #310 to (possibly?) complete Vector3 methods (leaving the lacking documentations aside).A notable change from the original Godot calculations is just directly using
.normalized()
onaxis
forunit_axis
than manually doing it byaxis / axis_length_sq.sqrt()
on line 314.