Shortcut function for getting angle difference, so that I don't need (INT32) in front of all of the angle_t's :V

This commit is contained in:
Sally Coolatta 2021-02-12 20:11:09 -05:00
parent 9ba3e07417
commit 4718c1993a
3 changed files with 11 additions and 3 deletions

View file

@ -782,7 +782,7 @@ void K_ObjectTracking(trackingResult_t *result, vector3_t *point, UINT8 cameraNu
player_t *player;
fixed_t viewpointX, viewpointY, viewpointZ;
INT32 viewpointAngle, viewpointAiming;
angle_t viewpointAngle, viewpointAiming;
INT32 screenWidth, screenHeight;
fixed_t screenHalfW, screenHalfH;
@ -873,7 +873,7 @@ void K_ObjectTracking(trackingResult_t *result, vector3_t *point, UINT8 cameraNu
// Determine viewpoint factors.
h = R_PointToDist2(point->x, point->y, viewpointX, viewpointY);
da = viewpointAngle - (INT32)(R_PointToAngle2(point->x, point->y, viewpointX, viewpointY));
da = AngleDifference(viewpointAngle, R_PointToAngle2(point->x, point->y, viewpointX, viewpointY));
// Set results!
result->x = screenHalfW + FixedMul(NEWTAN(da), fg);
@ -881,7 +881,7 @@ void K_ObjectTracking(trackingResult_t *result, vector3_t *point, UINT8 cameraNu
result->scale = FixedDiv(screenHalfW, h+1);
result->onScreen = ((abs(da) > ANG60) || (abs(viewpointAiming - R_PointToAngle2(0, 0, h, viewpointZ)) > ANGLE_45));
result->onScreen = ((abs(da) > ANG60) || (abs(AngleDifference(viewpointAiming, R_PointToAngle2(0, 0, h, viewpointZ))) > ANGLE_45));
if (encoremode)
{

View file

@ -167,6 +167,12 @@ angle_t FixedAngle(fixed_t fa)
return AngleAdj(cfa, cwf, ra);
}
INT32 AngleDifference(angle_t a1, angle_t a2)
{
// Silly but easy way to do it through integer conversion.
return (INT32)(a1) - (INT32)(a2);
}
#include "t_ftan.c"

View file

@ -99,6 +99,8 @@ FUNCMATH fixed_t AngleFixed(angle_t af);
FUNCMATH angle_t FixedAngle(fixed_t fa);
// and with a factor, with +factor for (fa/factor) and -factor for (fa*factor)
FUNCMATH angle_t FixedAngleC(fixed_t fa, fixed_t factor);
// difference between two angle_t
FUNCMATH INT32 AngleDifference(angle_t a1, angle_t a2);
/// The FixedAcos function
FUNCMATH angle_t FixedAcos(fixed_t x);