mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-31 04:20:42 +00:00
- calcChaseCamPos.
This commit is contained in:
parent
a3f1821670
commit
40ae38c173
6 changed files with 29 additions and 28 deletions
|
@ -418,8 +418,17 @@ inline void updatesector(int const x, int const y, sectortype** const sectp)
|
|||
}
|
||||
void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int * const sectnum) ATTRIBUTE((nonnull(4)));
|
||||
|
||||
inline void updatesectorz(int32_t const x, int32_t const y, int32_t const z, sectortype** const sectp)
|
||||
{
|
||||
int sectno = *sectp ? sector.IndexOf(*sectp) : -1;
|
||||
updatesectorz(x, y, z, §no);
|
||||
*sectp = sectno == -1 ? nullptr : §or[sectno];
|
||||
}
|
||||
|
||||
|
||||
|
||||
void updatesectorneighbor(int32_t const x, int32_t const y, int * const sectnum, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(3)));
|
||||
void updatesectorneighborz(int32_t const x, int32_t const y, int32_t const z, int * const sectnum, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(4)));
|
||||
|
||||
|
||||
int findwallbetweensectors(int sect1, int sect2);
|
||||
|
||||
|
|
|
@ -32,15 +32,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
int cameradist, cameraclock;
|
||||
|
||||
bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, int *psectnum, binangle ang, fixedhoriz horiz, double const smoothratio)
|
||||
bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, sectortype** psect, binangle ang, fixedhoriz horiz, double const smoothratio)
|
||||
{
|
||||
hitdata_t hitinfo;
|
||||
binangle daang;
|
||||
short bakcstat;
|
||||
int newdist;
|
||||
|
||||
assert(validSectorIndex(*psectnum));
|
||||
|
||||
if (!*psect) return false;
|
||||
// Calculate new pos to shoot backwards, using averaged values from the big three.
|
||||
int nx = gi->chaseCamX(ang);
|
||||
int ny = gi->chaseCamY(ang);
|
||||
|
@ -49,27 +48,25 @@ bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, int *psectnum,
|
|||
vec3_t pvect = { *px, *py, *pz };
|
||||
bakcstat = pspr->cstat;
|
||||
pspr->cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
|
||||
updatesectorz(*px, *py, *pz, psectnum);
|
||||
hitscan(&pvect, *psectnum, nx, ny, nz, &hitinfo, CLIPMASK1);
|
||||
updatesectorz(*px, *py, *pz, psect);
|
||||
hitscan(&pvect, sectnum(*psect), nx, ny, nz, &hitinfo, CLIPMASK1);
|
||||
pspr->cstat = bakcstat;
|
||||
|
||||
int hx = hitinfo.pos.x - *px;
|
||||
int hy = hitinfo.pos.y - *py;
|
||||
|
||||
if (*psectnum < 0)
|
||||
if (*psect == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(validSectorIndex(*psectnum));
|
||||
|
||||
// If something is in the way, make pp->camera_dist lower if necessary
|
||||
if (abs(nx) + abs(ny) > abs(hx) + abs(hy))
|
||||
{
|
||||
if (hitinfo.wall >= 0)
|
||||
{
|
||||
// Push you a little bit off the wall
|
||||
*psectnum = hitinfo.sect;
|
||||
*psect = §or[hitinfo.sect];
|
||||
daang = bvectangbam(wall[wall[hitinfo.wall].point2].x - wall[hitinfo.wall].x,
|
||||
wall[wall[hitinfo.wall].point2].y - wall[hitinfo.wall].y);
|
||||
newdist = nx * daang.bsin() + ny * -daang.bcos();
|
||||
|
@ -82,7 +79,7 @@ bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, int *psectnum,
|
|||
else if (hitinfo.sprite < 0)
|
||||
{
|
||||
// Push you off the ceiling/floor
|
||||
*psectnum = hitinfo.sect;
|
||||
*psect = §or[hitinfo.sect];
|
||||
|
||||
if (abs(nx) > abs(ny))
|
||||
hx -= (nx >> 5);
|
||||
|
@ -98,7 +95,7 @@ bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, int *psectnum,
|
|||
{
|
||||
bakcstat = hspr->cstat;
|
||||
hspr->cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
|
||||
calcChaseCamPos(px, py, pz, pspr, psectnum, ang, horiz, smoothratio);
|
||||
calcChaseCamPos(px, py, pz, pspr, psect, ang, horiz, smoothratio);
|
||||
hspr->cstat = bakcstat;
|
||||
return false;
|
||||
}
|
||||
|
@ -142,7 +139,7 @@ bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, int *psectnum,
|
|||
cameraclock = myclock;
|
||||
|
||||
// Make sure psectnum is correct.
|
||||
updatesectorz(*px, *py, *pz, psectnum);
|
||||
updatesectorz(*px, *py, *pz, psect);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -116,14 +116,7 @@ extern int cameradist, cameraclock;
|
|||
|
||||
void loaddefinitionsfile(const char* fn, bool cumulative = false, bool maingrp = false);
|
||||
|
||||
bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, int *psectnum, binangle ang, fixedhoriz horiz, double const smoothratio);
|
||||
inline bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, sectortype** psectnum, binangle ang, fixedhoriz horiz, double const smoothratio)
|
||||
{
|
||||
int sectnum;
|
||||
bool res = calcChaseCamPos(px, py, pz, pspr, §num, ang, horiz, smoothratio);
|
||||
*psectnum = §or[sectnum];
|
||||
return res;
|
||||
}
|
||||
bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, sectortype** psectnum, binangle ang, fixedhoriz horiz, double const smoothratio);
|
||||
|
||||
void PlanesAtPoint(const sectortype* sec, int dax, int day, float* ceilz, float* florz);
|
||||
inline void PlanesAtPoint(const sectortype* sec, float dax, float day, float* ceilz, float* florz) // this is just for warning evasion.
|
||||
|
|
|
@ -472,7 +472,9 @@ void SetupView(int &cX, int& cY, int& cZ, binangle& cA, fixedhoriz& cH, int& nSe
|
|||
}
|
||||
else
|
||||
{
|
||||
calcChaseCamPos((int*)&cX, (int*)&cY, (int*)&cZ, gView->pSprite, &nSectnum, cA, cH, gInterpolate);
|
||||
auto pSect = §or[nSectnum];
|
||||
calcChaseCamPos((int*)&cX, (int*)&cY, (int*)&cZ, gView->pSprite, &pSect, cA, cH, gInterpolate);
|
||||
nSectnum = sectnum(pSect);
|
||||
}
|
||||
CheckLink((int*)&cX, (int*)&cY, (int*)&cZ, &nSectnum);
|
||||
}
|
||||
|
|
|
@ -299,13 +299,11 @@ void DrawView(double smoothRatio, bool sceneonly)
|
|||
if (bCamera)
|
||||
{
|
||||
viewz -= 2560;
|
||||
/* needs fixing.
|
||||
if (!calcChaseCamPos(&playerX, &playerY, &viewz, pPlayerSprite, &nSector, nAngle, pan, smoothRatio))
|
||||
if (!calcChaseCamPos(&playerX, &playerY, &viewz, pPlayerSprite, &pSector, nAngle, pan, smoothRatio))
|
||||
{
|
||||
viewz += 2560;
|
||||
calcChaseCamPos(&playerX, &playerY, &viewz, pPlayerSprite, &nSector, nAngle, pan, smoothRatio);
|
||||
calcChaseCamPos(&playerX, &playerY, &viewz, pPlayerSprite, &pSector, nAngle, pan, smoothRatio);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
nCamerax = playerX;
|
||||
|
|
|
@ -1542,11 +1542,13 @@ drawscreen(PLAYERp pp, double smoothratio)
|
|||
{
|
||||
tz -= 8448;
|
||||
|
||||
if (!calcChaseCamPos(&tx, &ty, &tz, &pp->Actor()->s(), &tsectnum, tang, thoriz, smoothratio))
|
||||
auto pSect = §or[tsectnum];
|
||||
if (!calcChaseCamPos(&tx, &ty, &tz, &pp->Actor()->s(), &pSect, tang, thoriz, smoothratio))
|
||||
{
|
||||
tz += 8448;
|
||||
calcChaseCamPos(&tx, &ty, &tz, &pp->Actor()->s(), &tsectnum, tang, thoriz, smoothratio);
|
||||
calcChaseCamPos(&tx, &ty, &tz, &pp->Actor()->s(), &pSect, tang, thoriz, smoothratio);
|
||||
}
|
||||
tsectnum = sectnum(pSect);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue