- Cleanup of render draw code to use new angle getter.

This commit is contained in:
Mitchell Richters 2022-12-05 16:09:43 +11:00 committed by Christoph Oelckers
parent 599a375d67
commit 25de63ffb5
11 changed files with 85 additions and 135 deletions

View file

@ -101,6 +101,11 @@ public:
return interpolatedvalue(PrevAngles.Yaw, spr.Angles.Yaw, interpfrac);
}
DRotator interpolatedangles(double const interpfrac)
{
return interpolatedvalue(PrevAngles, spr.Angles, interpfrac);
}
void backupz()
{
opos.Z = spr.pos.Z;

View file

@ -38,12 +38,12 @@ constexpr double MAXCLIPDISTF = 64;
double cameradist, cameraclock;
bool calcChaseCamPos(DVector3& ppos, DCoreActor* act, sectortype** psect, DAngle ang, DAngle horiz, double const interpfrac, double const backamp)
bool calcChaseCamPos(DVector3& ppos, DCoreActor* act, sectortype** psect, const DRotator& angles, double const interpfrac, double const backamp)
{
if (!*psect) return false;
// Calculate new pos to shoot backwards
DVector3 npos = -DVector3(ang.ToVector() * horiz.Cos(), horiz.Sin()) * backamp;
DVector3 npos = -DVector3(angles) * backamp;
HitInfoBase hitinfo;
auto bakcstat = act->spr.cstat;
@ -79,7 +79,7 @@ bool calcChaseCamPos(DVector3& ppos, DCoreActor* act, sectortype** psect, DAngle
{
bakcstat = hitinfo.hitActor->spr.cstat;
hitinfo.hitActor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
calcChaseCamPos(ppos, act, psect, ang, horiz, interpfrac, backamp);
calcChaseCamPos(ppos, act, psect, angles, interpfrac, backamp);
hitinfo.hitActor->spr.cstat = bakcstat;
return false;
}

View file

@ -245,7 +245,7 @@ extern double cameradist, cameraclock;
void loaddefinitionsfile(const char* fn, bool cumulative = false, bool maingrp = false);
bool calcChaseCamPos(DVector3& ppos, DCoreActor* pspr, sectortype** psectnum, DAngle ang, DAngle horiz, double const interpfrac, double const backamp);
bool calcChaseCamPos(DVector3& ppos, DCoreActor* pspr, sectortype** psectnum, const DRotator& angles, double const interpfrac, double const backamp);
int getslopeval(sectortype* sect, const DVector3& pos, double bazez);
bool cansee(const DVector3& start, sectortype* sect1, const DVector3& end, sectortype* sect2);
double intersectSprite(DCoreActor* actor, const DVector3& start, const DVector3& direction, DVector3& result, double maxfactor);

View file

@ -35,6 +35,16 @@ struct PlayerAngles
void backupViewAngles() { PrevViewAngles = ViewAngles; }
void setActor(DCoreActor* const actor) { pActor = actor; }
// Angle getters.
DRotator lerpViewAngles(const double interpfrac)
{
return interpolatedvalue(PrevViewAngles, ViewAngles, interpfrac);
}
DRotator getRenderAngles(const double interpfrac)
{
return (!SyncInput() ? pActor->spr.Angles : pActor->interpolatedangles(interpfrac)) + lerpViewAngles(interpfrac);
}
// Pitch methods.
void lockPitch() { AngleLocks.Set(PITCH); }
void unlockPitch() { AngleLocks.Clear(PITCH); }

View file

@ -192,18 +192,18 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float
//
//===========================================================================
FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int sectnum, DAngle angle, DAngle horizon, DAngle rollang, float fov = -1)
FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int sectnum, const DRotator& angles, float fov = -1)
{
FRenderViewpoint r_viewpoint{};
r_viewpoint.CameraActor = cam;
r_viewpoint.SectNums = nullptr;
r_viewpoint.SectCount = sectnum;
r_viewpoint.Pos = { position.X, -position.Y, -position.Z };
r_viewpoint.HWAngles.Yaw = FAngle::fromDeg(-90.f + (float)angle.Degrees());
r_viewpoint.HWAngles.Pitch = FAngle::fromDeg(ClampViewPitch(horizon).Degrees());
r_viewpoint.HWAngles.Roll = FAngle::fromDeg((float)rollang.Degrees());
r_viewpoint.HWAngles.Yaw = FAngle::fromDeg(-90.f + (float)angles.Yaw.Degrees());
r_viewpoint.HWAngles.Pitch = FAngle::fromDeg(ClampViewPitch(angles.Pitch).Degrees());
r_viewpoint.HWAngles.Roll = FAngle::fromDeg((float)angles.Roll.Degrees());
r_viewpoint.FieldOfView = FAngle::fromDeg(fov > 0? fov : (float)r_fov);
r_viewpoint.RotAngle = angle.BAMs();
r_viewpoint.RotAngle = angles.Yaw.BAMs();
double FocalTangent = tan(r_viewpoint.FieldOfView.Radians() / 2);
DAngle an = DAngle::fromDeg(270. - r_viewpoint.HWAngles.Yaw.Degrees());
r_viewpoint.TanSin = FocalTangent * an.Sin();
@ -305,7 +305,7 @@ static void CheckTimer(FRenderState &state, uint64_t ShaderStartTime)
void animatecamsprite(double s);
void render_drawrooms(DCoreActor* playersprite, const DVector3& position, sectortype* sect, DAngle angle, DAngle horizon, DAngle rollang, double interpfrac, float fov)
void render_drawrooms(DCoreActor* playersprite, const DVector3& position, sectortype* sect, const DRotator& angles, double interpfrac, float fov)
{
checkRotatedWalls();
@ -319,7 +319,7 @@ void render_drawrooms(DCoreActor* playersprite, const DVector3& position, sector
ResetProfilingData();
// Get this before everything else
FRenderViewpoint r_viewpoint = SetupViewpoint(playersprite, position, sectindex(sect), angle, horizon, rollang, fov);
FRenderViewpoint r_viewpoint = SetupViewpoint(playersprite, position, sectindex(sect), angles, fov);
r_viewpoint.TicFrac = !cl_capfps ? interpfrac : 1.;
screen->mLights->Clear();
@ -359,7 +359,7 @@ void render_drawrooms(DCoreActor* playersprite, const DVector3& position, sector
All.Unclock();
}
void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortype* sect, DAngle angle, DAngle horizon, DAngle rollang, FGameTexture* camtex, IntRect& rect, double interpfrac)
void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortype* sect, const DRotator& angles, FGameTexture* camtex, IntRect& rect, double interpfrac)
{
updatesector(position, &sect);
if (!sect) return;
@ -369,7 +369,7 @@ void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortyp
// now render the main view
float ratio = camtex->GetDisplayWidth() / camtex->GetDisplayHeight();
FRenderViewpoint r_viewpoint = SetupViewpoint(playersprite, position, sectindex(sect), angle, horizon, rollang);
FRenderViewpoint r_viewpoint = SetupViewpoint(playersprite, position, sectindex(sect), angles);
r_viewpoint.TicFrac = !cl_capfps ? interpfrac : 1.;
RenderViewpoint(r_viewpoint, &rect, r_viewpoint.FieldOfView.Degrees(), ratio, ratio, false, false);

View file

@ -5,8 +5,8 @@
class FSerializer;
struct IntRect;
void render_drawrooms(DCoreActor* playersprite, const DVector3& position, sectortype* sectnum, DAngle angle, DAngle horizon, DAngle rollang, double interpfrac, float fov = -1);
void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortype* sect, DAngle angle, DAngle horizon, DAngle rollang, FGameTexture* camtex, IntRect& rect, double interpfrac);
void render_drawrooms(DCoreActor* playersprite, const DVector3& position, sectortype* sectnum, const DRotator& angles, double interpfrac, float fov = -1);
void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortype* sect, const DRotator& angles, FGameTexture* camtex, IntRect& rect, double interpfrac);
struct PortalDesc
{

View file

@ -405,15 +405,15 @@ void viewUpdateDelirium(PLAYER* pPlayer)
//
//---------------------------------------------------------------------------
void viewUpdateShake(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, DAngle& cH, double& pshakeX, double& pshakeY)
void viewUpdateShake(PLAYER* pPlayer, DVector3& cPos, DRotator& cAngles, double& pshakeX, double& pshakeY)
{
auto doEffect = [&](const int& effectType)
{
if (effectType)
{
int nValue = ClipHigh(effectType * 8, 2000);
cH -= maphoriz(QRandom2F(nValue * (1. / 256.)));
cA += DAngle::fromDeg(QRandom2F(nValue * (360. / 524288.)));
cAngles.Pitch -= maphoriz(QRandom2F(nValue * (1. / 256.)));
cAngles.Yaw += DAngle::fromDeg(QRandom2F(nValue * (360. / 524288.)));
cPos.X += QRandom2F(nValue * maptoworld) * maptoworld;
cPos.Y += QRandom2F(nValue * maptoworld) * maptoworld;
cPos.Z += QRandom2F(nValue) * zmaptoworld;
@ -424,7 +424,7 @@ void viewUpdateShake(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, DAngle& cH, do
doEffect(pPlayer->flickerEffect);
doEffect(pPlayer->quakeEffect);
cH -= DAngle::fromDeg((1 - BobVal((pPlayer->tiltEffect << 2) + 512)) * 13.2);
cAngles.Pitch -= DAngle::fromDeg((1 - BobVal((pPlayer->tiltEffect << 2) + 512)) * 13.2);
}
@ -458,7 +458,7 @@ static void DrawMap(PLAYER* pPlayer, const double interpfrac)
//
//---------------------------------------------------------------------------
static void SetupView(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, DAngle& cH, sectortype*& pSector, double& zDelta, double& shakeX, double& shakeY, DAngle& rotscrnang, const double interpfrac)
static void SetupView(PLAYER* pPlayer, DVector3& cPos, DRotator& cAngles, sectortype*& pSector, double& zDelta, double& shakeX, double& shakeY, const double interpfrac)
{
double bobWidth, bobHeight;
@ -478,57 +478,46 @@ static void SetupView(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, DAngle& cH, s
if (!SyncInput())
{
cA = bamang(predict.angle.asbam() + predict.look_ang.asbam());
cH = predict.horiz + predict.horizoff;
rotscrnang = predict.rotscrnang;
cAngles.Yaw = bamang(predict.angle.asbam() + predict.look_ang.asbam());
cAngles.Pitch = predict.horiz + predict.horizoff;
cAngles.Roll = predict.cAngles.Roll;
}
else
{
cA = interpolatedvalue(predictOld.angle + predictOld.look_ang, predict.angle + predict.look_ang, interpfrac);
cH = interpolatedvalue(predictOld.horiz + predictOld.horizoff, predict.horiz + predict.horizoff, interpfrac);
rotscrnang = interpolatedvalue(predictOld.rotscrnang, predict.rotscrnang, interpfrac);
cAngles.Yaw = interpolatedvalue(predictOld.angle + predictOld.look_ang, predict.angle + predict.look_ang, interpfrac);
cAngles.Pitch = interpolatedvalue(predictOld.horiz + predictOld.horizoff, predict.horiz + predict.horizoff, interpfrac);
cAngles.Roll = interpolatedvalue(predictOld.rotscrnang, predict.rotscrnang, interpfrac);
}
}
else
#endif
{
cPos = pPlayer->actor->getRenderPos(interpfrac);
cAngles = pPlayer->Angles.getRenderAngles(interpfrac);
zDelta = interpolatedvalue(pPlayer->ozWeapon, pPlayer->zWeapon - pPlayer->zView - 12, interpfrac);
bobWidth = interpolatedvalue(pPlayer->obobWidth, pPlayer->bobWidth, interpfrac);
bobHeight = interpolatedvalue(pPlayer->obobHeight, pPlayer->bobHeight, interpfrac);
shakeX = interpolatedvalue(pPlayer->oswayWidth, pPlayer->swayWidth, interpfrac);
shakeY = interpolatedvalue(pPlayer->oswayHeight, pPlayer->swayHeight, interpfrac);
if (!SyncInput())
{
cA = pPlayer->Angles.angSUM(interpfrac);
cH = pPlayer->Angles.horizSUM(interpfrac);
}
else
{
cA = pPlayer->Angles.angLERPSUM(interpfrac);
cH = pPlayer->Angles.horizLERPSUM(interpfrac);
}
rotscrnang = pPlayer->Angles.angLERPROTSCRN(interpfrac);
}
viewUpdateShake(pPlayer, cPos, cA, cH, shakeX, shakeY);
viewUpdateShake(pPlayer, cPos, cAngles, shakeX, shakeY);
if (gViewPos == 0)
{
if (cl_viewhbob)
{
cPos.XY() -= cA.ToVector().Rotated90CW() * bobWidth;
cPos.XY() -= cAngles.Yaw.ToVector().Rotated90CW() * bobWidth;
}
if (cl_viewvbob)
{
cPos.Z += bobHeight;
}
cPos.Z -= interpolatedvalue(0., 10., cH / DAngle90);
cPos.Z -= interpolatedvalue(0., 10., cAngles.Pitch / DAngle90);
}
else
{
calcChaseCamPos(cPos, pPlayer->actor, &pSector, cA, cH, interpfrac, 80.);
calcChaseCamPos(cPos, pPlayer->actor, &pSector, cAngles, interpfrac, 80.);
}
if (pSector != nullptr)
CheckLink(cPos, &pSector);
@ -649,11 +638,11 @@ void viewDrawScreen(bool sceneonly)
UpdateBlend(pPlayer);
DVector3 cPos;
DAngle cA, rotscrnang, cH;
DRotator cAngles;
sectortype* pSector;
double zDelta;
double shakeX, shakeY;
SetupView(pPlayer, cPos, cA, cH, pSector, zDelta, shakeX, shakeY, rotscrnang, interpfrac);
SetupView(pPlayer, cPos, cAngles, pSector, zDelta, shakeX, shakeY, interpfrac);
DAngle tilt = interpolatedvalue(gScreenTiltO, gScreenTilt, interpfrac);
bool bDelirium = powerupCheck(pPlayer, kPwUpDeliriumShroom) > 0;
@ -662,7 +651,7 @@ void viewDrawScreen(bool sceneonly)
uint8_t otherview = powerupCheck(pPlayer, kPwUpCrystalBall) > 0;
if (tilt.Degrees() || bDelirium)
{
rotscrnang = -tilt;
cAngles.Roll = -tilt;
}
else if (otherview && gNetPlayers > 1)
{
@ -704,7 +693,7 @@ void viewDrawScreen(bool sceneonly)
}
}
g_relvisibility = (int32_t)(ClipLow(gVisibility - 32 * pPlayer->visibility - brightness, 0)) - g_visibility;
cA += interpolatedvalue(deliriumTurnO, deliriumTurn, interpfrac);
cAngles.Yaw += interpolatedvalue(deliriumTurnO, deliriumTurn, interpfrac);
if (pSector != nullptr)
{
@ -732,11 +721,12 @@ void viewDrawScreen(bool sceneonly)
}
}
if (!sceneonly) hudDraw(pPlayer, pSector, shakeX, shakeY, zDelta, rotscrnang, basepal, interpfrac);
if (!sceneonly) hudDraw(pPlayer, pSector, shakeX, shakeY, zDelta, cAngles.Roll, basepal, interpfrac);
DAngle deliriumPitchI = interpolatedvalue(maphoriz(deliriumPitchO), maphoriz(deliriumPitch), interpfrac);
auto bakCstat = pPlayer->actor->spr.cstat;
pPlayer->actor->spr.cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP;
render_drawrooms(pPlayer->actor, cPos, pSector, cA, cH - deliriumPitchI, rotscrnang, interpfrac);
cAngles.Pitch -= deliriumPitchI;
render_drawrooms(pPlayer->actor, cPos, pSector, cAngles, interpfrac);
pPlayer->actor->spr.cstat = bakCstat;
bDeliriumOld = bDelirium && gDeliriumBlur;
@ -761,7 +751,7 @@ void viewDrawScreen(bool sceneonly)
int v8 = byte_1CE5C2 > 0 && (sector[tmpSect].ceilingstat & CSTAT_SECTOR_SKY);
if (gWeather.at12d8 > 0 || v8)
{
gWeather.Draw(cX, cY, cZ, cA.Tan() * (1 << 23), cH.Tan() * (1 << 23) + deliriumPitch, gWeather.at12d8);
gWeather.Draw(cX, cY, cZ, cAngles.Yaw.Tan() * (1 << 23), cAngles.Pitch.Tan() * (1 << 23) + deliriumPitch, gWeather.at12d8);
if (v8)
{
gWeather.at12d8 = ClipRange(delta * 8 + gWeather.at12d8, 0, 4095);

View file

@ -89,7 +89,7 @@ void GameInterface::UpdateCameras(double smoothratio)
display_mirror = 1; // should really be 'display external view'.
auto cstat = camera->spr.cstat;
camera->spr.cstat = CSTAT_SPRITE_INVISIBLE;
render_camtex(camera, camera->spr.pos, camera->sector(), camera->interpolatedyaw(smoothratio), maphoriz(-camera->spr.shade), nullAngle, tex, rect, smoothratio);
render_camtex(camera, camera->spr.pos, camera->sector(), DRotator(maphoriz(-camera->spr.shade), camera->interpolatedyaw(smoothratio), nullAngle), tex, rect, smoothratio);
camera->spr.cstat = cstat;
display_mirror = 0;
});
@ -217,7 +217,7 @@ static int getdrugmode(player_struct *p, int oyrepeat)
void displayrooms(int snum, double interpfrac, bool sceneonly)
{
DVector3 cpos;
DAngle cang, rotscrnang, choriz;
DRotator cangles;
player_struct* p = &ps[snum];
@ -253,9 +253,7 @@ void displayrooms(int snum, double interpfrac, bool sceneonly)
else if (viewer->spr.yint > 199) viewer->spr.yint = 300;
cpos = viewer->spr.pos.plusZ(-4);
cang = viewer->interpolatedyaw(interpfrac);
choriz = maphoriz(-viewer->spr.yint);
rotscrnang = nullAngle;
cangles = DRotator(maphoriz(-viewer->spr.yint), viewer->interpolatedyaw(interpfrac), nullAngle);
sect = viewer->sector();
}
else
@ -270,53 +268,26 @@ void displayrooms(int snum, double interpfrac, bool sceneonly)
// The setting here will be carried over to the rendering of the weapon sprites, but other 2D content will always default to the main palette.
setgamepalette(setpal(p));
// set screen rotation.
rotscrnang = p->Angles.angLERPROTSCRN(interpfrac);
// use player's actor initially.
viewer = p->GetActor();
if ((snum == myconnectindex) && (numplayers > 1))
{
cpos = interpolatedvalue(omypos, mypos, interpfrac);
if (SyncInput())
{
choriz = interpolatedvalue(omyhoriz + omyhorizoff, myhoriz + myhorizoff, interpfrac);
cang = interpolatedvalue(omyang, myang, interpfrac);
}
else
{
cang = myang;
choriz = myhoriz + myhorizoff;
}
cangles = DRotator(interpolatedvalue(omyhoriz + omyhorizoff, myhoriz + myhorizoff, interpfrac), interpolatedvalue(omyang, myang, interpfrac), nullAngle);
}
else
{
cpos = viewer->getRenderPos(interpfrac);
if (SyncInput())
{
// Original code for when the values are passed through the sync struct
cang = p->Angles.angLERPSUM(interpfrac);
choriz = p->Angles.horizLERPSUM(interpfrac);
}
else
{
// This is for real time updating of the view direction.
cang = p->Angles.angSUM(interpfrac);
choriz = p->Angles.horizSUM(interpfrac);
}
cangles = p->Angles.getRenderAngles(interpfrac);
}
if (p->newOwner != nullptr)
{
viewer = p->newOwner;
cang = viewer->interpolatedyaw(interpfrac);
choriz = maphoriz(-viewer->spr.shade);
cpos = viewer->spr.pos;
cangles = DRotator(maphoriz(-viewer->spr.shade), viewer->interpolatedyaw(interpfrac), nullAngle);
sect = viewer->sector();
rotscrnang = nullAngle;
interpfrac = 1.;
camview = true;
}
@ -329,10 +300,10 @@ void displayrooms(int snum, double interpfrac, bool sceneonly)
auto adjustment = isRR() ? 15 : 12;
cpos.Z -= adjustment;
if (!calcChaseCamPos(cpos, viewer, &sect, cang, choriz, interpfrac, 64.))
if (!calcChaseCamPos(cpos, viewer, &sect, cangles, interpfrac, 64.))
{
cpos.Z += adjustment;
calcChaseCamPos(cpos, viewer, &sect, cang, choriz, interpfrac, 64.);
calcChaseCamPos(cpos, viewer, &sect, cangles, interpfrac, 64.);
}
}
@ -342,7 +313,7 @@ void displayrooms(int snum, double interpfrac, bool sceneonly)
if (earthquaketime > 0 && p->on_ground == 1)
{
cpos.Z += 1 - (((earthquaketime) & 1) * 2.);
cang += DAngle::fromBuild((2 - ((earthquaketime) & 2)) << 2);
cangles.Yaw += DAngle::fromBuild((2 - ((earthquaketime) & 2)) << 2);
}
if (p->GetActor()->spr.pal == 1) cpos.Z -= 18;
@ -362,7 +333,7 @@ void displayrooms(int snum, double interpfrac, bool sceneonly)
auto cstat = viewer->spr.cstat;
if (camview) viewer->spr.cstat = CSTAT_SPRITE_INVISIBLE;
if (!sceneonly) drawweapon(interpfrac);
render_drawrooms(viewer, cpos, sect, cang, choriz, rotscrnang, interpfrac, fov);
render_drawrooms(viewer, cpos, sect, cangles, interpfrac, fov);
viewer->spr.cstat = cstat;
//GLInterface.SetMapFog(false);

View file

@ -191,8 +191,7 @@ void DrawView(double interpfrac, bool sceneonly)
DExhumedActor* pEnemy = nullptr;
int nEnemyPal = -1;
sectortype* pSector = nullptr;
DAngle nCameraang, rotscrnang;
DAngle nCamerapan = nullAngle;
DRotator nCameraangles{};
DoInterpolations(interpfrac);
@ -207,8 +206,7 @@ void DrawView(double interpfrac, bool sceneonly)
nCamerapos = pActor->spr.pos;
pSector = pActor->sector();
nCameraang = pActor->spr.Angles.Yaw;
rotscrnang = nullAngle;
nCameraangles.Yaw = pActor->spr.Angles.Yaw;
SetGreenPal();
@ -232,18 +230,7 @@ void DrawView(double interpfrac, bool sceneonly)
updatesector(nCamerapos, &pSector);
if (pSector == nullptr) pSector = PlayerList[nLocalPlayer].pPlayerViewSect;
if (!SyncInput())
{
nCamerapan = PlayerList[nLocalPlayer].Angles.horizSUM(interpfrac);
nCameraang = PlayerList[nLocalPlayer].Angles.angSUM(interpfrac);
}
else
{
nCamerapan = PlayerList[nLocalPlayer].Angles.horizLERPSUM(interpfrac);
nCameraang = PlayerList[nLocalPlayer].Angles.angLERPSUM(interpfrac);
}
rotscrnang = PlayerList[nLocalPlayer].Angles.angLERPROTSCRN(interpfrac);
nCameraangles = PlayerList[nLocalPlayer].Angles.getRenderAngles(interpfrac);
if (!bCamera)
{
@ -259,20 +246,20 @@ void DrawView(double interpfrac, bool sceneonly)
if (nSnakeCam >= 0 && !sceneonly)
{
nCamerapan = nullAngle;
nCameraangles.Pitch = nullAngle;
}
else
{
nCamerapos.Z = min(nCamerapos.Z + nQuake[nLocalPlayer], pPlayerActor->sector()->floorz);
nCameraang += DAngle::fromDeg(fmod(nQuake[nLocalPlayer], 16.) * (45. / 128.));
nCameraangles.Yaw += DAngle::fromDeg(fmod(nQuake[nLocalPlayer], 16.) * (45. / 128.));
if (bCamera)
{
nCamerapos.Z -= 10;
if (!calcChaseCamPos(nCamerapos, pPlayerActor, &pSector, nCameraang, nCamerapan, interpfrac, 96.))
if (!calcChaseCamPos(nCamerapos, pPlayerActor, &pSector, nCameraangles, interpfrac, 96.))
{
nCamerapos.Z += 10;
calcChaseCamPos(nCamerapos, pPlayerActor, &pSector, nCameraang, nCamerapan, interpfrac, 96.);
calcChaseCamPos(nCamerapos, pPlayerActor, &pSector, nCameraangles, interpfrac, 96.);
}
}
}
@ -315,7 +302,7 @@ void DrawView(double interpfrac, bool sceneonly)
if (!nFreeze && !sceneonly)
DrawWeapons(interpfrac);
render_drawrooms(nullptr, nCamerapos, pSector, nCameraang, nCamerapan, rotscrnang, interpfrac);
render_drawrooms(nullptr, nCamerapos, pSector, nCameraangles, interpfrac);
if (HavePLURemap())
{
@ -343,7 +330,7 @@ void DrawView(double interpfrac, bool sceneonly)
pPlayerActor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
auto ang2 = nCameraang - pPlayerActor->spr.Angles.Yaw;
auto ang2 = nCameraangles.Yaw - pPlayerActor->spr.Angles.Yaw;
if (ang2.Degrees() < 0)
ang2 = -ang2;

View file

@ -1224,9 +1224,6 @@ void RestorePortalState()
void drawscreen(PLAYER* pp, double interpfrac, bool sceneonly)
{
DAngle tang, trotscrnang, thoriz;
sectortype* tsect;
// prediction player if prediction is on, else regular player
PLAYER* camerapp = (PredictionOn && CommEnabled && pp == Player+myconnectindex) ? ppp : pp;
@ -1242,18 +1239,8 @@ void drawscreen(PLAYER* pp, double interpfrac, bool sceneonly)
// Get initial player position, interpolating if required.
DVector3 tpos = camerapp->actor->getRenderPos(interpfrac);
if (SyncInput() || pp != Player+myconnectindex)
{
tang = camerapp->Angles.angLERPSUM(interpfrac);
thoriz = camerapp->Angles.horizLERPSUM(interpfrac);
}
else
{
tang = pp->Angles.angSUM(interpfrac);
thoriz = pp->Angles.horizSUM(interpfrac);
}
trotscrnang = camerapp->Angles.angLERPROTSCRN(interpfrac);
tsect = camerapp->cursector;
DRotator tangles = camerapp->Angles.getRenderAngles(interpfrac);
sectortype* tsect = camerapp->cursector;
updatesector(tpos, &tsect);
@ -1262,16 +1249,16 @@ void drawscreen(PLAYER* pp, double interpfrac, bool sceneonly)
if (pp->sop_control && (!cl_sointerpolation || (CommEnabled && !pp->sop_remote)))
{
tpos = pp->actor->getPosWithOffsetZ();
tang = pp->Angles.ZzANGLE();
tangles.Yaw = pp->actor->spr.Angles.Yaw;
}
tsect = pp->cursector;
updatesectorz(tpos, &tsect);
}
pp->si = tpos.plusZ(-pp->actor->getOffsetZ());
pp->siang = tang;
pp->siang = tangles.Yaw;
QuakeViewChange(camerapp, tpos, tang);
QuakeViewChange(camerapp, tpos, tangles.Yaw);
int vis = g_visibility;
VisViewChange(camerapp, &vis);
g_relvisibility = vis - g_visibility;
@ -1279,17 +1266,17 @@ void drawscreen(PLAYER* pp, double interpfrac, bool sceneonly)
if (pp->sop_remote)
{
DSWActor* ractor = pp->remoteActor;
tang = TEST_BOOL1(ractor) ? ractor->spr.Angles.Yaw : (pp->sop_remote->pmid.XY() - tpos.XY()).Angle();
tangles.Yaw = TEST_BOOL1(ractor) ? ractor->spr.Angles.Yaw : (pp->sop_remote->pmid.XY() - tpos.XY()).Angle();
}
if (pp->Flags & (PF_VIEW_FROM_OUTSIDE))
{
tpos.Z -= 33;
if (!calcChaseCamPos(tpos, pp->actor, &tsect, tang, thoriz, interpfrac, 128.))
if (!calcChaseCamPos(tpos, pp->actor, &tsect, tangles, interpfrac, 128.))
{
tpos.Z += 33;
calcChaseCamPos(tpos, pp->actor, &tsect, tang, thoriz, interpfrac, 128.);
calcChaseCamPos(tpos, pp->actor, &tsect, tangles, interpfrac, 128.);
}
}
@ -1301,7 +1288,7 @@ void drawscreen(PLAYER* pp, double interpfrac, bool sceneonly)
}
// recoil only when not in camera
thoriz -= interpolatedvalue(pp->recoil_ohorizoff, pp->recoil_horizoff, interpfrac);
tangles.Pitch -= interpolatedvalue(pp->recoil_ohorizoff, pp->recoil_horizoff, interpfrac);
}
if (automapMode != am_full)
@ -1314,7 +1301,7 @@ void drawscreen(PLAYER* pp, double interpfrac, bool sceneonly)
UpdatePanel(interpfrac);
UpdateWallPortalState();
render_drawrooms(pp->actor, tpos, tsect, tang, thoriz, trotscrnang, interpfrac);
render_drawrooms(pp->actor, tpos, tsect, tangles, interpfrac);
RestorePortalState();
if (sceneonly)
@ -1340,7 +1327,7 @@ void drawscreen(PLAYER* pp, double interpfrac, bool sceneonly)
}
}
}
DrawOverheadMap(tpos.XY(), tang, interpfrac);
DrawOverheadMap(tpos.XY(), tangles.Yaw, interpfrac);
}
SWSpriteIterator it;

View file

@ -408,7 +408,7 @@ void drawroomstotile(const DVector3& pos, DAngle ang, DAngle horiz, sectortype*
screen->RenderTextureView(canvas, [=](IntRect& rect)
{
render_camtex(nullptr, pos, dacursect, ang, horiz, nullAngle, tileGetTexture(tilenume), rect, smoothratio);
render_camtex(nullptr, pos, dacursect, DRotator(horiz, ang, nullAngle), tileGetTexture(tilenume), rect, smoothratio);
});
}