- pass actors to calcChaseCamPos.

This commit is contained in:
Christoph Oelckers 2021-12-23 10:55:13 +01:00
parent 87894a5640
commit 6766a5922a
6 changed files with 18 additions and 33 deletions

View file

@ -33,7 +33,7 @@ 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, sectortype** psect, binangle ang, fixedhoriz horiz, double const smoothratio)
bool calcChaseCamPos(int* px, int* py, int* pz, DCoreActor* act, sectortype** psect, binangle ang, fixedhoriz horiz, double const smoothratio)
{
HitInfoBase hitinfo;
binangle daang;
@ -45,11 +45,11 @@ bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, sectortype** p
int ny = gi->chaseCamY(ang);
int nz = gi->chaseCamZ(horiz);
auto bakcstat = pspr->cstat;
pspr->cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
auto bakcstat = act->spr.cstat;
act->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
updatesectorz(*px, *py, *pz, psect);
hitscan({ *px, *py, *pz }, *psect, { nx, ny, nz }, hitinfo, CLIPMASK1);
pspr->cstat = bakcstat;
act->spr.cstat = bakcstat;
int hx = hitinfo.hitpos.X - *px;
int hy = hitinfo.hitpos.Y - *py;
@ -94,14 +94,14 @@ bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, sectortype** p
{
bakcstat = hit->spr.cstat;
hit->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
calcChaseCamPos(px, py, pz, pspr, psect, ang, horiz, smoothratio);
calcChaseCamPos(px, py, pz, act, psect, ang, horiz, smoothratio);
hit->spr.cstat = bakcstat;
return false;
}
else
{
// same as wall calculation.
daang = buildang(pspr->ang - 512);
daang = buildang(act->spr.ang - 512);
newdist = nx * daang.bsin() + ny * -daang.bcos();
if (abs(nx) > abs(ny))

View file

@ -116,7 +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, sectortype** psectnum, binangle ang, fixedhoriz horiz, double const smoothratio);
bool calcChaseCamPos(int* px, int* py, int* pz, DCoreActor* pspr, sectortype** psectnum, binangle ang, fixedhoriz horiz, double const smoothratio);
void PlanesAtPoint(const sectortype* sec, float dax, float day, float* ceilz, float* florz);
@ -199,21 +199,6 @@ inline DVector2 WallDelta(const walltype* wallnum)
return WallEnd(wallnum) - WallStart(wallnum);
}
inline double SpriteX(spritetype* spr)
{
return spr->pos.X * (1 / 16.);
}
inline double SpriteY(spritetype* spr)
{
return spr->pos.Y * (1 / -16.);
}
inline DVector2 SpritePos(spritetype* spr)
{
return { SpriteX(spr), SpriteY(spr) };
}
inline double PointOnLineSide(double x, double y, double linex, double liney, double deltax, double deltay)
{
return (x - linex) * deltay - (y - liney) * deltax;

View file

@ -381,7 +381,7 @@ int gLastPal = 0;
int32_t g_frameRate;
static void DrawMap(spritetype* pSprite)
static void DrawMap(DBloodActor* view)
{
int tm = 0;
if (windowxy1.X > 0)
@ -390,8 +390,8 @@ static void DrawMap(spritetype* pSprite)
tm = 1;
}
VIEW* pView = &gPrevView[gViewIndex];
int x = interpolatedvalue(pView->x, pSprite->pos.X, gInterpolate);
int y = interpolatedvalue(pView->y, pSprite->pos.Y, gInterpolate);
int x = interpolatedvalue(pView->x, view->spr.pos.X, gInterpolate);
int y = interpolatedvalue(pView->y, view->spr.pos.Y, gInterpolate);
int ang = (!SyncInput() ? gView->angle.sum() : gView->angle.interpolatedsum(gInterpolate)).asbuild();
DrawOverheadMap(x, y, ang, gInterpolate);
if (tm)
@ -475,7 +475,7 @@ void SetupView(int &cX, int& cY, int& cZ, binangle& cA, fixedhoriz& cH, sectorty
}
else
{
calcChaseCamPos((int*)&cX, (int*)&cY, (int*)&cZ, &gView->actor->spr, &pSector, cA, cH, gInterpolate);
calcChaseCamPos((int*)&cX, (int*)&cY, (int*)&cZ, gView->actor, &pSector, cA, cH, gInterpolate);
}
CheckLink((int*)&cX, (int*)&cY, (int*)&cZ, &pSector);
}
@ -711,7 +711,7 @@ void viewDrawScreen(bool sceneonly)
UpdateDacs(0, true); // keep the view palette active only for the actual 3D view and its overlays.
if (automapMode != am_off)
{
DrawMap (&gView->actor->spr);
DrawMap (gView->actor);
}
UpdateStatusBar();
int zn = ((gView->zWeapon-gView->zView-(12<<8))>>7)+220;

View file

@ -368,10 +368,10 @@ void displayrooms(int snum, double smoothratio)
cposz -= isRR() ? 3840 : 3072;
viewer = p->GetActor();
if (!calcChaseCamPos(&cposx, &cposy, &cposz, &viewer->spr, &sect, cang, choriz, smoothratio))
if (!calcChaseCamPos(&cposx, &cposy, &cposz, viewer, &sect, cang, choriz, smoothratio))
{
cposz += isRR() ? 3840 : 3072;
calcChaseCamPos(&cposx, &cposy, &cposz, &viewer->spr, &sect, cang, choriz, smoothratio);
calcChaseCamPos(&cposx, &cposy, &cposz, viewer, &sect, cang, choriz, smoothratio);
}
}

View file

@ -297,10 +297,10 @@ void DrawView(double smoothRatio, bool sceneonly)
if (bCamera)
{
viewz -= 2560;
if (!calcChaseCamPos(&playerX, &playerY, &viewz, pPlayerSprite, &pSector, nAngle, pan, smoothRatio))
if (!calcChaseCamPos(&playerX, &playerY, &viewz, pPlayerActor, &pSector, nAngle, pan, smoothRatio))
{
viewz += 2560;
calcChaseCamPos(&playerX, &playerY, &viewz, pPlayerSprite, &pSector, nAngle, pan, smoothRatio);
calcChaseCamPos(&playerX, &playerY, &viewz, pPlayerActor, &pSector, nAngle, pan, smoothRatio);
}
}
}

View file

@ -1520,10 +1520,10 @@ void drawscreen(PLAYERp pp, double smoothratio)
{
tz -= 8448;
if (!calcChaseCamPos(&tx, &ty, &tz, &pp->Actor()->s(), &tsect, tang, thoriz, smoothratio))
if (!calcChaseCamPos(&tx, &ty, &tz, pp->Actor(), &tsect, tang, thoriz, smoothratio))
{
tz += 8448;
calcChaseCamPos(&tx, &ty, &tz, &pp->Actor()->s(), &tsect, tang, thoriz, smoothratio);
calcChaseCamPos(&tx, &ty, &tz, pp->Actor(), &tsect, tang, thoriz, smoothratio);
}
}
else