- gamecontrol.h: Move getHalfLookAng() into PlayerAngle struct as look_anghalf().

* Uses internal struct variables at full BAM precision.
This commit is contained in:
Mitchell Richters 2020-11-26 16:37:37 +11:00
parent aac4fcefa2
commit b9e1cbb5de
12 changed files with 23 additions and 24 deletions

View file

@ -95,9 +95,9 @@ static void viewBurnTime(int gScale)
} }
void hudDraw(PLAYER *gView, VIEW *pView, int nSectnum, double bobx, double boby, double zDelta, int basepal, double smoothratio) void hudDraw(PLAYER *gView, int nSectnum, double bobx, double boby, double zDelta, int basepal, double smoothratio)
{ {
double look_anghalf = getHalfLookAng(pView->look_ang.asq16(), gView->angle.look_ang.asq16(), cl_syncinput, smoothratio); double look_anghalf = gView->angle.look_anghalf(smoothratio);
DrawCrosshair(kCrosshairTile, gView->pXSprite->health >> 4, -look_anghalf, 0, 2); DrawCrosshair(kCrosshairTile, gView->pXSprite->health >> 4, -look_anghalf, 0, 2);

View file

@ -972,7 +972,7 @@ void viewDrawScreen(bool sceneonly)
} }
} }
#endif #endif
hudDraw(gView, &gPrevView[gViewIndex], nSectnum, v4c, v48, zDelta, basepal, gInterpolate); hudDraw(gView, nSectnum, v4c, v48, zDelta, basepal, gInterpolate);
} }
UpdateDacs(0, true); // keep the view palette active only for the actual 3D view and its overlays. UpdateDacs(0, true); // keep the view palette active only for the actual 3D view and its overlays.
if (automapMode != am_off) if (automapMode != am_off)

View file

@ -141,7 +141,7 @@ extern LOCATION gPrevSpriteLoc[kMaxSprites];
extern int gLastPal; extern int gLastPal;
extern double gInterpolate; extern double gInterpolate;
void hudDraw(PLAYER* gView, VIEW *pView, int nSectnum, double bobx, double boby, double zDelta, int basepal, double smoothratio); void hudDraw(PLAYER* gView, int nSectnum, double bobx, double boby, double zDelta, int basepal, double smoothratio);
void viewInitializePrediction(void); void viewInitializePrediction(void);
void viewUpdatePrediction(InputPacket *pInput); void viewUpdatePrediction(InputPacket *pInput);
void viewCorrectPrediction(void); void viewCorrectPrediction(void);

View file

@ -226,14 +226,3 @@ extern int chatmodeon;
extern bool sendPause; extern bool sendPause;
extern int lastTic; extern int lastTic;
//---------------------------------------------------------------------------
//
// Return half player's q16look_ang directly or interpolated as required.
//
//---------------------------------------------------------------------------
inline double getHalfLookAng(fixed_t const oq16look_ang, fixed_t const q16look_ang, bool interpolate, double smoothratio)
{
return (!interpolate ? q16look_ang : oq16look_ang + fmulscale16(q16look_ang - oq16look_ang, smoothratio)) * (0.5 / FRACUNIT);
}

View file

@ -246,11 +246,22 @@ struct PlayerAngle
return bamang(prev + xs_CRoundToUInt(ratio * (((curr + dang - prev) & 0xFFFFFFFF) - dang))); return bamang(prev + xs_CRoundToUInt(ratio * (((curr + dang - prev) & 0xFFFFFFFF) - dang)));
} }
lookangle interpolatedlookang(double const smoothratio)
{
double const ratio = smoothratio * (1. / FRACUNIT);
return bamlook(olook_ang.asbam() + xs_CRoundToInt(ratio * (look_ang - olook_ang).asbam()));
}
lookangle interpolatedrotscrn(double const smoothratio) lookangle interpolatedrotscrn(double const smoothratio)
{ {
double const ratio = smoothratio * (1. / FRACUNIT); double const ratio = smoothratio * (1. / FRACUNIT);
return bamlook(orotscrnang.asbam() + xs_CRoundToInt(ratio * (rotscrnang - orotscrnang).asbam())); return bamlook(orotscrnang.asbam() + xs_CRoundToInt(ratio * (rotscrnang - orotscrnang).asbam()));
} }
double look_anghalf(double const smoothratio)
{
return (!cl_syncinput ? look_ang : interpolatedlookang(smoothratio)).asbam() * (0.5 / BAMUNIT); // Used within draw code for weapon and crosshair when looking left/right.
}
}; };
class FSerializer; class FSerializer;

View file

@ -90,11 +90,10 @@ void GameInterface::Render()
} }
double const smoothratio = calc_smoothratio(); double const smoothratio = calc_smoothratio();
double const look_anghalf = getHalfLookAng(PlayerList[nLocalPlayer].angle.olook_ang.asq16(), PlayerList[nLocalPlayer].angle.look_ang.asq16(), cl_syncinput, smoothratio);
DrawView(smoothratio); DrawView(smoothratio);
DrawStatusBar(); DrawStatusBar();
DrawCrosshair(MAXTILES, PlayerList[nLocalPlayer].nHealth >> 3, -look_anghalf, 0, 1); DrawCrosshair(MAXTILES, PlayerList[nLocalPlayer].nHealth >> 3, -PlayerList[nLocalPlayer].angle.look_anghalf(smoothratio), 0, 1);
if (paused && !M_Active()) if (paused && !M_Active())
{ {

View file

@ -983,7 +983,7 @@ void DrawWeapons(double smooth)
nShade = sprite[PlayerList[nLocalPlayer].nSprite].shade; nShade = sprite[PlayerList[nLocalPlayer].nSprite].shade;
} }
double const look_anghalf = getHalfLookAng(PlayerList[nLocalPlayer].angle.olook_ang.asq16(), PlayerList[nLocalPlayer].angle.look_ang.asq16(), cl_syncinput, smooth); double const look_anghalf = PlayerList[nLocalPlayer].angle.look_anghalf(smooth);
double const looking_arc = fabs(look_anghalf) / 4.5; double const looking_arc = fabs(look_anghalf) / 4.5;
xOffset -= look_anghalf; xOffset -= look_anghalf;

View file

@ -301,7 +301,7 @@ void drawoverlays(double smoothratio)
if (ps[myconnectindex].newOwner == nullptr && ud.cameraactor == nullptr) if (ps[myconnectindex].newOwner == nullptr && ud.cameraactor == nullptr)
{ {
DrawCrosshair(TILE_CROSSHAIR, ps[screenpeek].last_extra, -getHalfLookAng(pp->angle.olook_ang.asq16(), pp->angle.look_ang.asq16(), cl_syncinput, smoothratio), pp->over_shoulder_on ? 2.5 : 0, isRR() ? 0.5 : 1); DrawCrosshair(TILE_CROSSHAIR, ps[screenpeek].last_extra, -pp->angle.look_anghalf(smoothratio), pp->over_shoulder_on ? 2.5 : 0, isRR() ? 0.5 : 1);
} }
if (paused == 2) if (paused == 2)

View file

@ -282,7 +282,7 @@ void displayweapon_d(int snum, double smoothratio)
o = 0; o = 0;
horiz16th = get16thOfHoriz(snum, cl_syncinput, smoothratio); horiz16th = get16thOfHoriz(snum, cl_syncinput, smoothratio);
look_anghalf = getHalfLookAng(p->angle.olook_ang.asq16(), p->angle.look_ang.asq16(), cl_syncinput, smoothratio); look_anghalf = p->angle.look_anghalf(smoothratio);
looking_arc = fabs(look_anghalf) / 4.5; looking_arc = fabs(look_anghalf) / 4.5;
weapon_sway = p->oweapon_sway + fmulscale16(p->weapon_sway - p->oweapon_sway, smoothratio); weapon_sway = p->oweapon_sway + fmulscale16(p->weapon_sway - p->oweapon_sway, smoothratio);
kickback_pic = p->okickback_pic + fmulscale16(*kb - p->okickback_pic, smoothratio); kickback_pic = p->okickback_pic + fmulscale16(*kb - p->okickback_pic, smoothratio);

View file

@ -125,7 +125,7 @@ void displayweapon_r(int snum, double smoothratio)
o = 0; o = 0;
look_anghalf = getHalfLookAng(p->angle.olook_ang.asq16(), p->angle.look_ang.asq16(), cl_syncinput, smoothratio); look_anghalf = p->angle.look_anghalf(smoothratio);
looking_arc = fabs(look_anghalf) / 4.5; looking_arc = fabs(look_anghalf) / 4.5;
weapon_sway = p->oweapon_sway + fmulscale16((p->weapon_sway - p->oweapon_sway), smoothratio); weapon_sway = p->oweapon_sway + fmulscale16((p->weapon_sway - p->oweapon_sway), smoothratio);
TiltStatus = !cl_syncinput ? p->TiltStatus : p->oTiltStatus + fmulscale16((p->TiltStatus - p->oTiltStatus), smoothratio); TiltStatus = !cl_syncinput ? p->TiltStatus : p->oTiltStatus + fmulscale16((p->TiltStatus - p->oTiltStatus), smoothratio);

View file

@ -1259,7 +1259,7 @@ void DrawCrosshair(PLAYERp pp)
if (!(CameraTestMode)) if (!(CameraTestMode))
{ {
USERp u = User[pp->PlayerSprite]; USERp u = User[pp->PlayerSprite];
::DrawCrosshair(2326, u->Health, -getHalfLookAng(pp->angle.olook_ang.asq16(), pp->angle.look_ang.asq16(), cl_syncinput, smoothratio), TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE) ? 5 : 0, 2, shadeToLight(10)); ::DrawCrosshair(2326, u->Health, -pp->angle.look_anghalf(smoothratio), TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE) ? 5 : 0, 2, shadeToLight(10));
} }
} }

View file

@ -6929,8 +6929,8 @@ pDisplaySprites(PLAYERp pp, double smoothratio)
short ang; short ang;
int flags; int flags;
double look_anghalf = getHalfLookAng(pp->angle.olook_ang.asq16(), pp->angle.look_ang.asq16(), cl_syncinput, smoothratio); double const look_anghalf = pp->angle.look_anghalf(smoothratio);
double looking_arc = fabs(look_anghalf) / 4.5; double const looking_arc = fabs(look_anghalf) / 4.5;
TRAVERSE(&pp->PanelSpriteList, psp, next) TRAVERSE(&pp->PanelSpriteList, psp, next)
{ {