-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Check for Infinity and NaN values in calculations #3613
Comments
One detail: instead of, for example, checking for infinity afterward, we generally want to add a conditional to detect divide by zero beforehand. |
👍 good call |
Sylvain wrote a nifty tool years ago that would modify .NET code to automatically insert a "check for NaN and infinity and throw" after each floating point arithmetic statement. It always felt a bit like overkill to me, but maybe something to consider. Also:
I don't agree with this, because it's unreliable. In |
OK with me. |
Discussed in #3605
"We should start adding validation like this (within debug pragmas) in many more places. Basically, throw as soon as any calculation anywhere produces a NaN. This would help to work to finally track down the dreaded "invalid array length" in the frustum code, which is where all NaNs eventually end up crashing currently."
Few examples I stumbled across:
In barycentricCoordinates:
var q = 1.0 / (dot00 * dot11 - dot01 * dot01);
In GeometryPipeline.computeBinormalAndTangent:
var r = 1.0 / ((st[i12] - wx) * t2 - (st[i22] - wx) * t1);
Because
1 / 0 = Infinity
The text was updated successfully, but these errors were encountered: