- Exhumed: Replace original chasecam code with calcChaseCamPos() within game.

This commit is contained in:
Mitchell Richters 2021-02-18 22:14:32 +11:00
parent cff97c9cf3
commit 1d48ac537a
3 changed files with 36 additions and 34 deletions

View file

@ -254,6 +254,9 @@ struct GameInterface : ::GameInterface
int playerKeyMove() override { return 6; }
void WarpToCoords(int x, int y, int z, int a, int h) override;
void ToggleThirdPerson() override;
int chaseCamX(binangle ang) { return -ang.bcos() / 12; }
int chaseCamY(binangle ang) { return -ang.bsin() / 12; }
int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() / 384; }
::GameStats getStats() override;
};

View file

@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "input.h"
#include "cheathandler.h"
#include "gamestate.h"
#include "gamefuncs.h"
#include "mmulti.h"
BEGIN_PS_NS
@ -108,6 +109,8 @@ void GameInterface::ToggleThirdPerson()
if (bCamera)
{
GrabPalette();
cameradist = 0;
cameraclock = INT_MIN;
}
}
}

View file

@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ns.h"
#include "compat.h"
#include "engine.h"
#include "gamefuncs.h"
#include "names.h"
#include "view.h"
#include "status.h"
@ -247,11 +248,13 @@ void DrawView(double smoothRatio, bool sceneonly)
if (!SyncInput())
{
pan = PlayerList[nLocalPlayer].horizon.sum();
nAngle = PlayerList[nLocalPlayer].angle.sum();
rotscrnang = PlayerList[nLocalPlayer].angle.rotscrnang;
}
else
{
pan = PlayerList[nLocalPlayer].horizon.interpolatedsum(smoothRatio);
nAngle = PlayerList[nLocalPlayer].angle.interpolatedsum(smoothRatio);
rotscrnang = PlayerList[nLocalPlayer].angle.interpolatedrotscrn(smoothRatio);
}
@ -261,51 +264,44 @@ void DrawView(double smoothRatio, bool sceneonly)
sprite[nPlayerSprite].cstat |= CSTAT_SPRITE_INVISIBLE;
sprite[nDoppleSprite[nLocalPlayer]].cstat |= CSTAT_SPRITE_INVISIBLE;
}
else
{
sprite[nPlayerSprite].cstat |= CSTAT_SPRITE_TRANSLUCENT;
sprite[nDoppleSprite[nLocalPlayer]].cstat |= CSTAT_SPRITE_INVISIBLE;
}
renderSetRollAngle(rotscrnang.asbuildf());
pan = q16horiz(clamp(pan.asq16(), gi->playerHorizMin(), gi->playerHorizMax()));
}
nCameraa = nAngle;
if (!bCamera || nFreeze || sceneonly)
if (nSnakeCam >= 0 && !sceneonly)
{
if (nSnakeCam >= 0 && !sceneonly)
{
pan = q16horiz(0);
viewz = playerZ;
}
else
{
viewz = playerZ + nQuake[nLocalPlayer];
int floorZ = sector[sprite[nPlayerSprite].sectnum].floorz;
if (!SyncInput())
{
pan = PlayerList[nLocalPlayer].horizon.sum();
}
else
{
pan = PlayerList[nLocalPlayer].horizon.interpolatedsum(smoothRatio);
}
if (viewz > floorZ)
viewz = floorZ;
nCameraa += buildang((nQuake[nLocalPlayer] >> 7) % 31);
}
}
else
{
clipmove_old((int32_t*)&playerX, (int32_t*)&playerY, (int32_t*)&playerZ, &nSector,
-2000 * nAngle.bcos(),
-2000 * nAngle.bsin(),
4, 0, 0, CLIPMASK1);
pan = q16horiz(0);
viewz = playerZ;
}
else
{
viewz = playerZ + nQuake[nLocalPlayer];
int floorZ = sector[sprite[nPlayerSprite].sectnum].floorz;
pan = q16horiz(clamp(pan.asq16(), gi->playerHorizMin(), gi->playerHorizMax()));
if (viewz > floorZ)
viewz = floorZ;
nCameraa += buildang((nQuake[nLocalPlayer] >> 7) % 31);
if (bCamera)
{
viewz -= 2560;
if (!calcChaseCamPos(&playerX, &playerY, &viewz, &sprite[nPlayerSprite], &nSector, nAngle, pan, smoothRatio))
{
viewz += 2560;
calcChaseCamPos(&playerX, &playerY, &viewz, &sprite[nPlayerSprite], &nSector, nAngle, pan, smoothRatio);
}
}
}
nCamerax = playerX;
nCameray = playerY;