mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-30 13:21:04 +00:00
- Blood: Migrate game's slopetilting code to calcviewpitch()
.
This commit is contained in:
parent
3516e4c3b0
commit
532d128afd
4 changed files with 38 additions and 42 deletions
|
@ -36,6 +36,7 @@ BEGIN_BLD_NS
|
||||||
static InputPacket gInput;
|
static InputPacket gInput;
|
||||||
|
|
||||||
void UpdatePlayerSpriteAngle(PLAYER* pPlayer);
|
void UpdatePlayerSpriteAngle(PLAYER* pPlayer);
|
||||||
|
void doslopetilting(PLAYER* pPlayer, double const scaleAdjust);
|
||||||
|
|
||||||
void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
|
void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
|
||||||
{
|
{
|
||||||
|
@ -59,6 +60,7 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
|
||||||
{
|
{
|
||||||
applylook(&pPlayer->angle, input.avel, &pPlayer->input.actions, scaleAdjust);
|
applylook(&pPlayer->angle, input.avel, &pPlayer->input.actions, scaleAdjust);
|
||||||
sethorizon(&pPlayer->horizon.horiz, input.horz, &pPlayer->input.actions, scaleAdjust);
|
sethorizon(&pPlayer->horizon.horiz, input.horz, &pPlayer->input.actions, scaleAdjust);
|
||||||
|
doslopetilting(pPlayer, scaleAdjust);
|
||||||
}
|
}
|
||||||
|
|
||||||
pPlayer->angle.processhelpers(scaleAdjust);
|
pPlayer->angle.processhelpers(scaleAdjust);
|
||||||
|
|
|
@ -1292,6 +1292,21 @@ void UpdatePlayerSpriteAngle(PLAYER *pPlayer)
|
||||||
pSprite->ang = pPlayer->angle.ang.asbuild();
|
pSprite->ang = pPlayer->angle.ang.asbuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Player's slope tilting wrapper function function, called in ProcessInput() or from gi->GetInput() as required.
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void doslopetilting(PLAYER* pPlayer, double const scaleAdjust = 1)
|
||||||
|
{
|
||||||
|
auto* const pSprite = pPlayer->pSprite;
|
||||||
|
auto* const pXSprite = pPlayer->pXSprite;
|
||||||
|
int const florhit = gSpriteHit[pSprite->extra].florhit & 0xc000;
|
||||||
|
char const va = pXSprite->height < 16 && (florhit == 0x4000 || florhit == 0) ? 1 : 0;
|
||||||
|
calcviewpitch(pSprite->pos.vec2, &pPlayer->horizon.horizoff, buildang(pSprite->ang), va, sector[pSprite->sectnum].floorstat & 2, pSprite->sectnum, scaleAdjust);
|
||||||
|
}
|
||||||
|
|
||||||
void ProcessInput(PLAYER *pPlayer)
|
void ProcessInput(PLAYER *pPlayer)
|
||||||
{
|
{
|
||||||
enum
|
enum
|
||||||
|
@ -1545,32 +1560,11 @@ void ProcessInput(PLAYER *pPlayer)
|
||||||
// disable synchronised input if set by game.
|
// disable synchronised input if set by game.
|
||||||
resetForcedSyncInput();
|
resetForcedSyncInput();
|
||||||
|
|
||||||
int nSector = pSprite->sectnum;
|
if (SyncInput())
|
||||||
int florhit = gSpriteHit[pSprite->extra].florhit & 0xc000;
|
|
||||||
char va;
|
|
||||||
if (pXSprite->height < 16 && (florhit == 0x4000 || florhit == 0))
|
|
||||||
va = 1;
|
|
||||||
else
|
|
||||||
va = 0;
|
|
||||||
if (va && (sector[nSector].floorstat&2))
|
|
||||||
{
|
{
|
||||||
int z1 = getflorzofslope(nSector, pSprite->x, pSprite->y);
|
doslopetilting(pPlayer);
|
||||||
int x2 = pSprite->x+mulscale30(64, Cos(pSprite->ang));
|
|
||||||
int y2 = pSprite->y+mulscale30(64, Sin(pSprite->ang));
|
|
||||||
short nSector2 = nSector;
|
|
||||||
updatesector(x2, y2, &nSector2);
|
|
||||||
if (nSector2 == nSector)
|
|
||||||
{
|
|
||||||
int z2 = getflorzofslope(nSector2, x2, y2);
|
|
||||||
pPlayer->horizon.horizoff = q16horiz(interpolate(pPlayer->horizon.horizoff.asq16(), IntToFixed(z1-z2)>>3, 0x4000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pPlayer->horizon.horizoff = q16horiz(interpolate(pPlayer->horizon.horizoff.asq16(), 0, 0x4000));
|
|
||||||
if (klabs(pPlayer->horizon.horizoff.asq16()) < 4)
|
|
||||||
pPlayer->horizon.horizoff = q16horiz(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pPlayer->slope = -pPlayer->horizon.horiz.asq16() >> 9;
|
pPlayer->slope = -pPlayer->horizon.horiz.asq16() >> 9;
|
||||||
if (pInput->actions & SB_INVPREV)
|
if (pInput->actions & SB_INVPREV)
|
||||||
{
|
{
|
||||||
|
|
|
@ -548,7 +548,7 @@ void viewDrawScreen(bool sceneonly)
|
||||||
int cX, cY, cZ, v74, v8c;
|
int cX, cY, cZ, v74, v8c;
|
||||||
lookangle rotscrnang;
|
lookangle rotscrnang;
|
||||||
binangle cA;
|
binangle cA;
|
||||||
fixedhoriz cH, cOff;
|
fixedhoriz cH;
|
||||||
double zDelta, v4c, v48;
|
double zDelta, v4c, v48;
|
||||||
int nSectnum = gView->pSprite->sectnum;
|
int nSectnum = gView->pSprite->sectnum;
|
||||||
if (numplayers > 1 && gView == gMe && gPrediction && gMe->pXSprite->health > 0)
|
if (numplayers > 1 && gView == gMe && gPrediction && gMe->pXSprite->health > 0)
|
||||||
|
@ -558,7 +558,6 @@ void viewDrawScreen(bool sceneonly)
|
||||||
cY = interpolate(predictOld.at54, predict.at54, gInterpolate);
|
cY = interpolate(predictOld.at54, predict.at54, gInterpolate);
|
||||||
cZ = interpolate(predictOld.at38, predict.at38, gInterpolate);
|
cZ = interpolate(predictOld.at38, predict.at38, gInterpolate);
|
||||||
zDelta = finterpolate(predictOld.at34, predict.at34, gInterpolate);
|
zDelta = finterpolate(predictOld.at34, predict.at34, gInterpolate);
|
||||||
cOff = q16horiz(interpolate(predictOld.at28.asq16(), predict.at28.asq16(), gInterpolate));
|
|
||||||
v74 = interpolate(predictOld.atc, predict.atc, gInterpolate);
|
v74 = interpolate(predictOld.atc, predict.atc, gInterpolate);
|
||||||
v8c = interpolate(predictOld.at8, predict.at8, gInterpolate);
|
v8c = interpolate(predictOld.at8, predict.at8, gInterpolate);
|
||||||
v4c = finterpolate(predictOld.at1c, predict.at1c, gInterpolate);
|
v4c = finterpolate(predictOld.at1c, predict.at1c, gInterpolate);
|
||||||
|
@ -567,7 +566,7 @@ void viewDrawScreen(bool sceneonly)
|
||||||
if (!SyncInput())
|
if (!SyncInput())
|
||||||
{
|
{
|
||||||
cA = bamang(predict.at30.asbam() + predict.look_ang.asbam());
|
cA = bamang(predict.at30.asbam() + predict.look_ang.asbam());
|
||||||
cH = predict.at24;
|
cH = predict.at24 + predict.at28;
|
||||||
rotscrnang = predict.rotscrnang;
|
rotscrnang = predict.rotscrnang;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -575,7 +574,11 @@ void viewDrawScreen(bool sceneonly)
|
||||||
uint32_t oang = predictOld.at30.asbam() + predictOld.look_ang.asbam();
|
uint32_t oang = predictOld.at30.asbam() + predictOld.look_ang.asbam();
|
||||||
uint32_t ang = predict.at30.asbam() + predict.look_ang.asbam();
|
uint32_t ang = predict.at30.asbam() + predict.look_ang.asbam();
|
||||||
cA = interpolateangbin(oang, ang, gInterpolate);
|
cA = interpolateangbin(oang, ang, gInterpolate);
|
||||||
cH = q16horiz(interpolate(predictOld.at24.asq16(), predict.at24.asq16(), gInterpolate));
|
|
||||||
|
fixed_t ohoriz = (predictOld.at24 + predictOld.at28).asq16();
|
||||||
|
fixed_t horiz = (predict.at24 + predict.at28).asq16();
|
||||||
|
cH = q16horiz(interpolate(ohoriz, horiz, gInterpolate));
|
||||||
|
|
||||||
rotscrnang = interpolateanglook(predictOld.rotscrnang.asbam(), predict.rotscrnang.asbam(), gInterpolate);
|
rotscrnang = interpolateanglook(predictOld.rotscrnang.asbam(), predict.rotscrnang.asbam(), gInterpolate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -586,7 +589,6 @@ void viewDrawScreen(bool sceneonly)
|
||||||
cY = interpolate(pView->at54, gView->pSprite->y, gInterpolate);
|
cY = interpolate(pView->at54, gView->pSprite->y, gInterpolate);
|
||||||
cZ = interpolate(pView->at38, gView->zView, gInterpolate);
|
cZ = interpolate(pView->at38, gView->zView, gInterpolate);
|
||||||
zDelta = finterpolate(pView->at34, gView->zWeapon - gView->zView - (12 << 8), gInterpolate);
|
zDelta = finterpolate(pView->at34, gView->zWeapon - gView->zView - (12 << 8), gInterpolate);
|
||||||
cOff = q16horiz(interpolate(pView->at28.asq16(), gView->horizon.horizoff.asq16(), gInterpolate));
|
|
||||||
v74 = interpolate(pView->atc, gView->bobWidth, gInterpolate);
|
v74 = interpolate(pView->atc, gView->bobWidth, gInterpolate);
|
||||||
v8c = interpolate(pView->at8, gView->bobHeight, gInterpolate);
|
v8c = interpolate(pView->at8, gView->bobHeight, gInterpolate);
|
||||||
v4c = finterpolate(pView->at1c, gView->swayWidth, gInterpolate);
|
v4c = finterpolate(pView->at1c, gView->swayWidth, gInterpolate);
|
||||||
|
@ -595,13 +597,13 @@ void viewDrawScreen(bool sceneonly)
|
||||||
if (!SyncInput())
|
if (!SyncInput())
|
||||||
{
|
{
|
||||||
cA = gView->angle.sum();
|
cA = gView->angle.sum();
|
||||||
cH = gView->horizon.horiz;
|
cH = gView->horizon.sum();
|
||||||
rotscrnang = gView->angle.rotscrnang;
|
rotscrnang = gView->angle.rotscrnang;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cA = gView->angle.interpolatedsum(gInterpolate);
|
cA = gView->angle.interpolatedsum(gInterpolate);
|
||||||
cH = q16horiz(interpolate(pView->at24.asq16(), gView->horizon.horiz.asq16(), gInterpolate));
|
cH = gView->horizon.interpolatedsum(gInterpolate);
|
||||||
rotscrnang = gView->angle.interpolatedrotscrn(gInterpolate);
|
rotscrnang = gView->angle.interpolatedrotscrn(gInterpolate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -626,10 +628,6 @@ void viewDrawScreen(bool sceneonly)
|
||||||
{
|
{
|
||||||
cZ += v8c;
|
cZ += v8c;
|
||||||
}
|
}
|
||||||
if (cl_slopetilting)
|
|
||||||
{
|
|
||||||
cH += cOff;
|
|
||||||
}
|
|
||||||
cZ += xs_CRoundToInt(cH.asq16() / 6553.6);
|
cZ += xs_CRoundToInt(cH.asq16() / 6553.6);
|
||||||
cameradist = -1;
|
cameradist = -1;
|
||||||
cameraclock = gFrameClock +mulscale16(4, (int)gInterpolate);
|
cameraclock = gFrameClock +mulscale16(4, (int)gInterpolate);
|
||||||
|
|
|
@ -403,9 +403,11 @@ void calcviewpitch(vec2_t const pos, fixedhoriz* horizoff, binangle const ang, b
|
||||||
{
|
{
|
||||||
if (aimmode && canslopetilt) // If the floor is sloped
|
if (aimmode && canslopetilt) // If the floor is sloped
|
||||||
{
|
{
|
||||||
// Get a point, 512 units ahead of player's position
|
// Get a point, 512 (64 for Blood) units ahead of player's position
|
||||||
int x = pos.x + ang.bcos(-5);
|
bool const isBlood = g_gameType & GAMEFLAG_BLOOD;
|
||||||
int y = pos.y + ang.bsin(-5);
|
int const shift = -(isBlood ? 8 : 5);
|
||||||
|
int const x = pos.x + ang.bcos(shift);
|
||||||
|
int const y = pos.y + ang.bsin(shift);
|
||||||
int16_t tempsect = cursectnum;
|
int16_t tempsect = cursectnum;
|
||||||
updatesector(x, y, &tempsect);
|
updatesector(x, y, &tempsect);
|
||||||
|
|
||||||
|
@ -413,17 +415,17 @@ void calcviewpitch(vec2_t const pos, fixedhoriz* horizoff, binangle const ang, b
|
||||||
{
|
{
|
||||||
// Get the floorz as if the new (x,y) point was still in
|
// Get the floorz as if the new (x,y) point was still in
|
||||||
// your sector
|
// your sector
|
||||||
int j = getflorzofslope(cursectnum, pos.x, pos.y);
|
int const j = getflorzofslope(cursectnum, pos.x, pos.y);
|
||||||
int k = getflorzofslope(cursectnum, x, y);
|
int const k = getflorzofslope(tempsect, x, y);
|
||||||
|
|
||||||
// If extended point is in same sector as you or the slopes
|
// If extended point is in same sector as you or the slopes
|
||||||
// of the sector of the extended point and your sector match
|
// of the sector of the extended point and your sector match
|
||||||
// closely (to avoid accidently looking straight out when
|
// closely (to avoid accidently looking straight out when
|
||||||
// you're at the edge of a sector line) then adjust horizon
|
// you're at the edge of a sector line) then adjust horizon
|
||||||
// accordingly
|
// accordingly
|
||||||
if (cursectnum == tempsect || abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))
|
if (cursectnum == tempsect || (!isBlood && abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8)))
|
||||||
{
|
{
|
||||||
*horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * 160)));
|
*horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * (!isBlood ? 160 : 1408))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue