-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Curve: Check for finiteness before performing calculations in sample_baked()
functions
#98625
Curve: Check for finiteness before performing calculations in sample_baked()
functions
#98625
Conversation
This looks good to me One thing is that it might be better to put this change in the methods that call this Partially because it makes the error message more helpful (hard to figure out what you're doing wrong if it says It might also be good to check this earlier, before baking the curve if it isn't baked But this should be good as it is, but might be good to improve |
Thanks for the feedback! Yeah I initially thought putting the check in the |
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.
Looks good to me, needs to fix some formatting errors to run all the checks to make sure the tests don't need to be adjusted
But would be good to get a second pair of eyes on this just to confirm
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.
Looks good to me.
I suggest adding unit tests to cover this use case in tests/test_curve.h
, tests/test_curve_2d.h
and tests/test_curve3d.h
, so we can make sure this doesn't regress in the future. See Unit testing in the documentation. You'll need to use ERR_PRINT_OFF;
and ERR_PRINT_ON;
to silence errors before and after the calls that would return NaN otherwise.
@@ -479,6 +479,9 @@ void Curve::set_bake_resolution(int p_resolution) { | |||
} | |||
|
|||
real_t Curve::sample_baked(real_t p_offset) const { | |||
// Make sure that p_offset is finite. |
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.
IMO the comment is unnecessary, the code is self-explanatory.
At least there is no reason to repeat it in every method.
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.
Looks fine.
I noticed all existing error checks happen after bake()
. Doesn't seem important though.
sample_baked()
functions
Please squash your commits into one, see the interactive rebase for details |
…_baked()` functions
sample_baked()
functionssample_baked()
functions
0e5091a
to
33afdff
Compare
Did so myself to ease the process, so this should be ready to merge. |
Thanks! Congratulations on your first contribution! 🎉 |
Thanks for the assist! |
Prevented crash in Curve2D::_find_interval() and Curve3D::_find_interval() by checking for finiteness before performing any mathematical operations. Resolves #98372. This is my first time contributing, please let me know if anything needs to be changed.