Skip to content
Snippets Groups Projects
Commit 83e35102 authored by Ashnal's avatar Ashnal
Browse files

Fixed FV2_Magnitude

to not overflow as much by just using FixedHypot internally
parent 39d664ec
Branches
No related tags found
No related merge requests found
......@@ -223,9 +223,7 @@ fixed_t FV2_Distance(const vector2_t *p1, const vector2_t *p2)
fixed_t FV2_Magnitude(const vector2_t *a_normal)
{
fixed_t xs = FixedMul(a_normal->x, a_normal->x);
fixed_t ys = FixedMul(a_normal->y, a_normal->y);
return FixedSqrt(xs + ys);
return FixedHypot(a_normal->x, a_normal->y); // Much less prone to overflowing
}
// Also returns the magnitude
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment