-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
Hello!
Maybe normalizesafe isn't that safe after all! ;)
Running
fpmath.normalizesafe(new fp2(0,0), new fp2(0,0));
causes a DivideByZeroException in fpmath.rsqrt.
It seems fpmath.select is what causes the call to fpmath.rsqrt.
If I replace the call to fpmath.select it works as intended, like so:
static public fp2 normalizesafe(fp2 x, fp2 defaultvalue = new fp2())
{
fp len = fpmath.dot(x, x);
// return fpmath.select(defaultvalue, x * fpmath.rsqrt(len), len > 0.00000001m);
return len > 0.00000001m ? x * fpmath.rsqrt(len) : defaultvalue;
}
Not sure if something can be done with fpmath.select or if my fix is an ok way to solve this?
Metadata
Metadata
Assignees
Labels
No labels