-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
#310 Quaternion Function Completeness #565
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-565 |
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.
As discussed on Discord, I would vote for 2) panic -- reasoning is here. It should have a # Panic
section.
Option 1) is bad because it hides logic errors, and 3) doesn't seem that useful because not normalizing inputs is almost always a bug and not something to react meaningfully at runtime.
I agree. Are you alright with maintaining the overloading pattern called out in that doc here. One panicking method and one that returns optional/result? |
Unlike for |
I understand. Yeah there really isn't a path for recovery. If you have hit that error you obviously have a bug. 👍 Based on that |
a196c08
to
31d7c7d
Compare
31d7c7d
to
d65adfa
Compare
d65adfa
to
ad34119
Compare
/// Performs slerp | ||
/// | ||
/// # Panics | ||
/// If either quaternion is not normalized | ||
pub fn slerp(self, to: Self, weight: real) -> Self { |
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.
Abandoned the hand-rolled solution when I discovered that it didn't handle non-normalized vectors by erroring as it should.
/// Performs slerpni | ||
/// | ||
/// # Panics | ||
/// If either quaternion is not normalized | ||
pub fn slerpni(self, to: Self, weight: real) -> Self { |
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.
Same story as slerp. Abandoned because it did not appropriately error on non-normalized vectors.
As an aside. I'm personally not a fan of how the scope of this kept expanding between review cycles. I'll look to mitigate that going forward as it strikes me as an unfair burden to reviewers (aka @Bromeon 😂) |
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! Great tests as well 🙂
I'll look to mitigate that going forward as it strikes me as an unfair burden to reviewers
I see it as an unfair burden for authors to get extra work on their plate 😅
But yes, maybe don't add anymore (like constructors) in this PR. It also makes it a bit harder to see what's already reviewed and what's new.
pub fn normalized(self) -> Self { | ||
self / self.length() | ||
let length = self.length(); | ||
assert!(!length.approx_eq(&0.0), "Quaternion has length 0"); |
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.
Note to self: we could maybe consider a method ApproxEq::approx_zero(&self)
. But not in this PR 😉
ad34119
to
4c2d189
Compare
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!
Several tests failed in release mode: |
I'll take a look. Sorry I've been caught up in stuff this week. I'll get those changes as well. |
Related error. Panics are not happening within release mode for linux only. |
Digging suggests it only tests release mode on linux. I run linux so I can replicate that locally. |
bbde3cd
to
3a1e061
Compare
Hunch is release mode handles quaternion error states differently. Evaluating. |
Ugh. So it returns The solution of checking |
3a1e061
to
fd68cb1
Compare
Godot does that, right? I'm glad I introduced release builds to CI, was only a month ago! Thanks a lot for fixing it! |
Implements
Quaternion
functions for #310.Added tests for
from_angle_axis()
. Discoveredfrom_angle_axis()
was inconsistent with gdscript.See discord thread.
We may want to alter the entire
quaternion
API surface based on thread resolution.Thread has more context, but in short:
default
when functions or initialization failWhat should we do?
Possible solutions:
optional
/result
Current implementation opts for
1
but I'd prefer3
.