fix compiler warning

This commit is contained in:
Alug committed 2024-02-02 02:59:08 +01:00
1 parent 5195caa3c6
commit 86712c2c48
1 file changed
+31 -18
+31 -18
View File
@@ -435,25 +435,38 @@ FUNCINLINE ATTRINLINE angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT
0;
}
angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y)
{
// Note: float won't work here as it's less precise than the BAM values being passed as parameters
double vecx = (double)x - viewx;
double vecy = (double)y - viewy;
//
// R_PointToPseudoAngle
// ! Returns the pseudoangle between the line p1 to (infinity, p1.y) and the
// line from p1 to p2. The pseudoangle has the property that the ordering of
// points by true angle anround p1 and ordering of points by pseudoangle are the
// same.
//
// For clipping exact angles are not needed. Only the ordering matters.
// This is about as fast as the fixed point R_PointToAngle2 but without
// the precision issues associated with that function.
//
if (vecx == 0 && vecy == 0)
{
return 0;
}
else
{
double result = vecy / (fabs(vecx) + fabs(vecy));
if (vecx < 0)
{
result = 2.0 - result;
}
return (angle_t)xs_CRoundToInt(result * (1 << 30));
}
angle_t R_PointToPseudoAngle(fixed_t x, fixed_t y)
{
// Note: float won't work here as it's less precise than the BAM values being passed as parameters
double vecx = (double)x - viewx;
double vecy = (double)y - viewy;
double epsilon = 1e-9;
if (fabs(vecx) < epsilon && fabs(vecy) < epsilon)
{
return 0;
}
else
{
double result = vecy / (fabs(vecx) + fabs(vecy));
if (vecx < 0)
{
result = 2.0 - result;
}
return (angle_t)xs_CRoundToInt(result * (1 << 30));
}
}
fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1)