- main view render function and dependencies.

This commit is contained in:
Christoph Oelckers 2021-11-24 01:55:55 +01:00
parent 0797e7ac90
commit 9388f839b6
6 changed files with 36 additions and 38 deletions

View file

@ -87,7 +87,7 @@ static void viewBurnTime(int gScale)
}
void hudDraw(PLAYER *gView, int nSectnum, double bobx, double boby, double zDelta, int basepal, double smoothratio)
void hudDraw(PLAYER *gView, sectortype* pSector, double bobx, double boby, double zDelta, int basepal, double smoothratio)
{
double look_anghalf = gView->angle.look_anghalf(smoothratio);
@ -116,7 +116,7 @@ void hudDraw(PLAYER *gView, int nSectnum, double bobx, double boby, double zDelt
{
cY += (-2048. / 128.);
}
int nShade = sector[nSectnum].floorshade;
int nShade = pSector->floorshade;
int nPalette = 0;
if (gView->pSprite->sector()->hasX()) {
sectortype* pSector = gView->pSprite->sector();

View file

@ -65,7 +65,7 @@ extern ZONE gStartZone[8];
void warpInit(void);
int CheckLink(DBloodActor *pSprite);
int CheckLink(int *x, int *y, int *z, int *nSector);
int CheckLink(int *x, int *y, int *z, sectortype** pSector);
int GetOctant(int x, int y);
void RotateVector(int *dx, int *dy, int nAngle);

View file

@ -1619,9 +1619,9 @@ void InitPath(sectortype* pSector, XSECTOR *pXSector)
evPostSector(pSector, 0, kCmdOn);
}
void LinkSector(int nSector, XSECTOR *pXSector, EVENT event)
void LinkSector(sectortype* pSector, EVENT event)
{
sectortype *pSector = &sector[nSector];
auto pXSector = &pSector->xs();
int nBusy = GetSourceBusy(event);
switch (pSector->type) {
case kSectorZMotionSprite:
@ -1758,7 +1758,7 @@ void trMessageSector(sectortype* pSector, EVENT event)
switch (event.cmd)
{
case kCmdLink:
LinkSector(sectnum(pSector), pXSector, event);
LinkSector(pSector, event);
break;
#ifdef NOONE_EXTENSIONS
case kCmdModernUse:
@ -1825,10 +1825,10 @@ void trMessageSprite(DBloodActor* actor, EVENT event)
void ProcessMotion(void)
{
sectortype *pSector;
int nSector;
for (pSector = &sector[0], nSector = 0; nSector < numsectors; nSector++, pSector++)
for(auto& sect : sectors())
{
sectortype* pSector = &sect;
if (!pSector->hasX()) continue;
XSECTOR* pXSector = &pSector->xs();
if (pXSector->bobSpeed != 0)
@ -1841,7 +1841,7 @@ void ProcessMotion(void)
pXSector->bobTheta += MulScale(pXSector->bobSpeed, pXSector->busy, 16);
int vdi = MulScale(Sin(pXSector->bobTheta), pXSector->bobZRange<<8, 30);
BloodSectIterator it(nSector);
BloodSectIterator it(pSector);
while (auto actor = it.Next())
{
auto pSprite = &actor->s();
@ -1857,7 +1857,7 @@ void ProcessMotion(void)
viewInterpolateSector(pSector);
pSector->floorz = pSector->baseFloor + vdi;
BloodSectIterator it(nSector);
BloodSectIterator it(pSector);
while (auto actor = it.Next())
{
auto pSprite = &actor->s();
@ -1881,7 +1881,7 @@ void ProcessMotion(void)
viewInterpolateSector(pSector);
pSector->ceilingz = pSector->baseCeil + vdi;
BloodSectIterator it(nSector);
BloodSectIterator it(pSector);
while (auto actor = it.Next())
{
auto pSprite = &actor->s();

View file

@ -399,11 +399,11 @@ static void DrawMap(spritetype* pSprite)
setViewport(hud_size);
}
void SetupView(int &cX, int& cY, int& cZ, binangle& cA, fixedhoriz& cH, int& nSectnum, double& zDelta, double& shakeX, double& shakeY, binangle& rotscrnang)
void SetupView(int &cX, int& cY, int& cZ, binangle& cA, fixedhoriz& cH, sectortype*& pSector, double& zDelta, double& shakeX, double& shakeY, binangle& rotscrnang)
{
int bobWidth, bobHeight;
nSectnum = gView->pSprite->sectnum;
pSector = gView->pSprite->sector();
#if 0
if (numplayers > 1 && gView == gMe && gPrediction && gMe->pXSprite->health > 0)
{
@ -476,11 +476,9 @@ void SetupView(int &cX, int& cY, int& cZ, binangle& cA, fixedhoriz& cH, int& nSe
}
else
{
auto pSect = &sector[nSectnum];
calcChaseCamPos((int*)&cX, (int*)&cY, (int*)&cZ, gView->pSprite, &pSect, cA, cH, gInterpolate);
nSectnum = sectnum(pSect);
calcChaseCamPos((int*)&cX, (int*)&cY, (int*)&cZ, gView->pSprite, &pSector, cA, cH, gInterpolate);
}
CheckLink((int*)&cX, (int*)&cY, (int*)&cZ, &nSectnum);
CheckLink((int*)&cX, (int*)&cY, (int*)&cZ, &pSector);
}
void renderCrystalBall()
@ -587,11 +585,11 @@ void viewDrawScreen(bool sceneonly)
int cX, cY, cZ;
binangle cA;
fixedhoriz cH;
int nSectnum;
sectortype* pSector;
double zDelta;
double shakeX, shakeY;
binangle rotscrnang;
SetupView(cX, cY, cZ, cA, cH, nSectnum, zDelta, shakeX, shakeY, rotscrnang);
SetupView(cX, cY, cZ, cA, cH, pSector, zDelta, shakeX, shakeY, rotscrnang);
binangle tilt = interpolatedangle(buildang(gScreenTiltO), buildang(gScreenTilt), gInterpolate);
bool bDelirium = powerupCheck(gView, kPwUpDeliriumShroom) > 0;
@ -646,12 +644,12 @@ void viewDrawScreen(bool sceneonly)
cA += interpolatedangle(buildang(deliriumTurnO), buildang(deliriumTurn), gInterpolate);
int ceilingZ, floorZ;
getzsofslope(nSectnum, cX, cY, &ceilingZ, &floorZ);
if ((cZ > floorZ - (1 << 8)) && (getLowerLink(nSectnum) == nullptr)) // clamp to floor
getzsofslopeptr(pSector, cX, cY, &ceilingZ, &floorZ);
if ((cZ > floorZ - (1 << 8)) && (pSector->upperLink == nullptr)) // clamp to floor
{
cZ = floorZ - (1 << 8);
}
if ((cZ < ceilingZ + (1 << 8)) && (getLowerLink(nSectnum) == nullptr)) // clamp to ceiling
if ((cZ < ceilingZ + (1 << 8)) && (pSector->lowerLink == nullptr)) // clamp to ceiling
{
cZ = ceilingZ + (1 << 8);
}
@ -674,13 +672,13 @@ void viewDrawScreen(bool sceneonly)
fixedhoriz deliriumPitchI = q16horiz(interpolatedvalue(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate));
int bakCstat = gView->pSprite->cstat;
gView->pSprite->cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANSLUCENT_INVERT;
render_drawrooms(gView->pSprite, { cX, cY, cZ }, nSectnum, cA, cH + deliriumPitchI, rotscrnang, gInterpolate);
render_drawrooms(gView->pSprite, { cX, cY, cZ }, sectnum(pSector), cA, cH + deliriumPitchI, rotscrnang, gInterpolate);
gView->pSprite->cstat = bakCstat;
}
else
{
renderSetRollAngle((float)rotscrnang.asbuildf());
render3DViewPolymost(nSectnum, cX, cY, cZ, cA, cH);
render3DViewPolymost(sectnum(pSector), cX, cY, cZ, cA, cH);
}
bDeliriumOld = bDelirium && gDeliriumBlur;
@ -695,7 +693,7 @@ void viewDrawScreen(bool sceneonly)
{
tmpSect = vf0 & (kMaxWalls - 1);
}
int v8 = byte_1CE5C2 > 0 && (sector[tmpSect].ceilingstat & 1);
int v8 = byte_1CE5C2 > 0 && (sector [tmpSect].ceilingstat & 1);
if (gWeather.at12d8 > 0 || v8)
{
gWeather.Draw(cX, cY, cZ, cA.asq16(), cH.asq16() + deliriumPitch, gWeather.at12d8);
@ -709,7 +707,7 @@ void viewDrawScreen(bool sceneonly)
}
}
#endif
hudDraw(gView, nSectnum, shakeX, shakeY, zDelta, basepal, gInterpolate);
hudDraw(gView, pSector, shakeX, shakeY, zDelta, basepal, gInterpolate);
}
UpdateDacs(0, true); // keep the view palette active only for the actual 3D view and its overlays.
if (automapMode != am_off)

View file

@ -138,7 +138,7 @@ extern int gShowFrameRate;
extern int gLastPal;
extern double gInterpolate;
void hudDraw(PLAYER* gView, int nSectnum, double bobx, double boby, double zDelta, int basepal, double smoothratio);
void hudDraw(PLAYER* gView, sectortype* pSector, double bobx, double boby, double zDelta, int basepal, double smoothratio);
void viewInitializePrediction(void);
void viewUpdatePrediction(InputPacket *pInput);
void viewCorrectPrediction(void);

View file

@ -248,10 +248,10 @@ int CheckLink(DBloodActor *actor)
return 0;
}
int CheckLink(int *x, int *y, int *z, int *nSector)
int CheckLink(int *x, int *y, int *z, sectortype** pSector)
{
auto upper = getUpperLink(*nSector);
auto lower = getLowerLink(*nSector);
auto upper = (*pSector)->upperLink;
auto lower = (*pSector)->lowerLink;
if (upper)
{
spritetype *pUpper = &upper->s();
@ -259,21 +259,21 @@ int CheckLink(int *x, int *y, int *z, int *nSector)
if (pUpper->type == kMarkerUpLink)
z1 = pUpper->z;
else
z1 = getflorzofslope(*nSector, *x, *y);
z1 = getflorzofslopeptr(*pSector, *x, *y);
if (z1 <= *z)
{
lower = upper->GetOwner();
assert(lower);
spritetype *pLower = &lower->s();
assert(validSectorIndex(pLower->sectnum));
*nSector = pLower->sectnum;
*pSector = pLower->sector();
*x += pLower->x-pUpper->x;
*y += pLower->y-pUpper->y;
int z2;
if (pUpper->type == kMarkerLowLink)
z2 = pLower->z;
else
z2 = getceilzofslope(*nSector, *x, *y);
z2 = getceilzofslopeptr(*pSector, *x, *y);
*z += z2-z1;
return pUpper->type;
}
@ -285,21 +285,21 @@ int CheckLink(int *x, int *y, int *z, int *nSector)
if (pLower->type == kMarkerLowLink)
z1 = pLower->z;
else
z1 = getceilzofslope(*nSector, *x, *y);
z1 = getceilzofslopeptr(*pSector, *x, *y);
if (z1 >= *z)
{
upper = lower->GetOwner();
assert(upper);
spritetype *pUpper = &upper->s();
assert(validSectorIndex(pUpper->sectnum));
*nSector = pUpper->sectnum;
assert(pUpper);
*pSector = pUpper->sector();
*x += pUpper->x-pLower->x;
*y += pUpper->y-pLower->y;
int z2;
if (pLower->type == kMarkerUpLink)
z2 = pUpper->z;
else
z2 = getflorzofslope(*nSector, *x, *y);
z2 = getflorzofslopeptr(*pSector, *x, *y);
*z += z2-z1;
return pLower->type;
}