mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-07 16:31:17 +00:00
- main view render function and dependencies.
This commit is contained in:
parent
0797e7ac90
commit
9388f839b6
6 changed files with 36 additions and 38 deletions
|
@ -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);
|
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.);
|
cY += (-2048. / 128.);
|
||||||
}
|
}
|
||||||
int nShade = sector[nSectnum].floorshade;
|
int nShade = pSector->floorshade;
|
||||||
int nPalette = 0;
|
int nPalette = 0;
|
||||||
if (gView->pSprite->sector()->hasX()) {
|
if (gView->pSprite->sector()->hasX()) {
|
||||||
sectortype* pSector = gView->pSprite->sector();
|
sectortype* pSector = gView->pSprite->sector();
|
||||||
|
|
|
@ -65,7 +65,7 @@ extern ZONE gStartZone[8];
|
||||||
|
|
||||||
void warpInit(void);
|
void warpInit(void);
|
||||||
int CheckLink(DBloodActor *pSprite);
|
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);
|
int GetOctant(int x, int y);
|
||||||
void RotateVector(int *dx, int *dy, int nAngle);
|
void RotateVector(int *dx, int *dy, int nAngle);
|
||||||
|
|
|
@ -1619,9 +1619,9 @@ void InitPath(sectortype* pSector, XSECTOR *pXSector)
|
||||||
evPostSector(pSector, 0, kCmdOn);
|
evPostSector(pSector, 0, kCmdOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinkSector(int nSector, XSECTOR *pXSector, EVENT event)
|
void LinkSector(sectortype* pSector, EVENT event)
|
||||||
{
|
{
|
||||||
sectortype *pSector = §or[nSector];
|
auto pXSector = &pSector->xs();
|
||||||
int nBusy = GetSourceBusy(event);
|
int nBusy = GetSourceBusy(event);
|
||||||
switch (pSector->type) {
|
switch (pSector->type) {
|
||||||
case kSectorZMotionSprite:
|
case kSectorZMotionSprite:
|
||||||
|
@ -1758,7 +1758,7 @@ void trMessageSector(sectortype* pSector, EVENT event)
|
||||||
switch (event.cmd)
|
switch (event.cmd)
|
||||||
{
|
{
|
||||||
case kCmdLink:
|
case kCmdLink:
|
||||||
LinkSector(sectnum(pSector), pXSector, event);
|
LinkSector(pSector, event);
|
||||||
break;
|
break;
|
||||||
#ifdef NOONE_EXTENSIONS
|
#ifdef NOONE_EXTENSIONS
|
||||||
case kCmdModernUse:
|
case kCmdModernUse:
|
||||||
|
@ -1825,10 +1825,10 @@ void trMessageSprite(DBloodActor* actor, EVENT event)
|
||||||
|
|
||||||
void ProcessMotion(void)
|
void ProcessMotion(void)
|
||||||
{
|
{
|
||||||
sectortype *pSector;
|
for(auto& sect : sectors())
|
||||||
int nSector;
|
|
||||||
for (pSector = §or[0], nSector = 0; nSector < numsectors; nSector++, pSector++)
|
|
||||||
{
|
{
|
||||||
|
sectortype* pSector = §
|
||||||
|
|
||||||
if (!pSector->hasX()) continue;
|
if (!pSector->hasX()) continue;
|
||||||
XSECTOR* pXSector = &pSector->xs();
|
XSECTOR* pXSector = &pSector->xs();
|
||||||
if (pXSector->bobSpeed != 0)
|
if (pXSector->bobSpeed != 0)
|
||||||
|
@ -1841,7 +1841,7 @@ void ProcessMotion(void)
|
||||||
pXSector->bobTheta += MulScale(pXSector->bobSpeed, pXSector->busy, 16);
|
pXSector->bobTheta += MulScale(pXSector->bobSpeed, pXSector->busy, 16);
|
||||||
int vdi = MulScale(Sin(pXSector->bobTheta), pXSector->bobZRange<<8, 30);
|
int vdi = MulScale(Sin(pXSector->bobTheta), pXSector->bobZRange<<8, 30);
|
||||||
|
|
||||||
BloodSectIterator it(nSector);
|
BloodSectIterator it(pSector);
|
||||||
while (auto actor = it.Next())
|
while (auto actor = it.Next())
|
||||||
{
|
{
|
||||||
auto pSprite = &actor->s();
|
auto pSprite = &actor->s();
|
||||||
|
@ -1857,7 +1857,7 @@ void ProcessMotion(void)
|
||||||
viewInterpolateSector(pSector);
|
viewInterpolateSector(pSector);
|
||||||
pSector->floorz = pSector->baseFloor + vdi;
|
pSector->floorz = pSector->baseFloor + vdi;
|
||||||
|
|
||||||
BloodSectIterator it(nSector);
|
BloodSectIterator it(pSector);
|
||||||
while (auto actor = it.Next())
|
while (auto actor = it.Next())
|
||||||
{
|
{
|
||||||
auto pSprite = &actor->s();
|
auto pSprite = &actor->s();
|
||||||
|
@ -1881,7 +1881,7 @@ void ProcessMotion(void)
|
||||||
viewInterpolateSector(pSector);
|
viewInterpolateSector(pSector);
|
||||||
pSector->ceilingz = pSector->baseCeil + vdi;
|
pSector->ceilingz = pSector->baseCeil + vdi;
|
||||||
|
|
||||||
BloodSectIterator it(nSector);
|
BloodSectIterator it(pSector);
|
||||||
while (auto actor = it.Next())
|
while (auto actor = it.Next())
|
||||||
{
|
{
|
||||||
auto pSprite = &actor->s();
|
auto pSprite = &actor->s();
|
||||||
|
|
|
@ -399,11 +399,11 @@ static void DrawMap(spritetype* pSprite)
|
||||||
setViewport(hud_size);
|
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;
|
int bobWidth, bobHeight;
|
||||||
|
|
||||||
nSectnum = gView->pSprite->sectnum;
|
pSector = gView->pSprite->sector();
|
||||||
#if 0
|
#if 0
|
||||||
if (numplayers > 1 && gView == gMe && gPrediction && gMe->pXSprite->health > 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
|
else
|
||||||
{
|
{
|
||||||
auto pSect = §or[nSectnum];
|
calcChaseCamPos((int*)&cX, (int*)&cY, (int*)&cZ, gView->pSprite, &pSector, cA, cH, gInterpolate);
|
||||||
calcChaseCamPos((int*)&cX, (int*)&cY, (int*)&cZ, gView->pSprite, &pSect, cA, cH, gInterpolate);
|
|
||||||
nSectnum = sectnum(pSect);
|
|
||||||
}
|
}
|
||||||
CheckLink((int*)&cX, (int*)&cY, (int*)&cZ, &nSectnum);
|
CheckLink((int*)&cX, (int*)&cY, (int*)&cZ, &pSector);
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderCrystalBall()
|
void renderCrystalBall()
|
||||||
|
@ -587,11 +585,11 @@ void viewDrawScreen(bool sceneonly)
|
||||||
int cX, cY, cZ;
|
int cX, cY, cZ;
|
||||||
binangle cA;
|
binangle cA;
|
||||||
fixedhoriz cH;
|
fixedhoriz cH;
|
||||||
int nSectnum;
|
sectortype* pSector;
|
||||||
double zDelta;
|
double zDelta;
|
||||||
double shakeX, shakeY;
|
double shakeX, shakeY;
|
||||||
binangle rotscrnang;
|
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);
|
binangle tilt = interpolatedangle(buildang(gScreenTiltO), buildang(gScreenTilt), gInterpolate);
|
||||||
bool bDelirium = powerupCheck(gView, kPwUpDeliriumShroom) > 0;
|
bool bDelirium = powerupCheck(gView, kPwUpDeliriumShroom) > 0;
|
||||||
|
@ -646,12 +644,12 @@ void viewDrawScreen(bool sceneonly)
|
||||||
cA += interpolatedangle(buildang(deliriumTurnO), buildang(deliriumTurn), gInterpolate);
|
cA += interpolatedangle(buildang(deliriumTurnO), buildang(deliriumTurn), gInterpolate);
|
||||||
|
|
||||||
int ceilingZ, floorZ;
|
int ceilingZ, floorZ;
|
||||||
getzsofslope(nSectnum, cX, cY, &ceilingZ, &floorZ);
|
getzsofslopeptr(pSector, cX, cY, &ceilingZ, &floorZ);
|
||||||
if ((cZ > floorZ - (1 << 8)) && (getLowerLink(nSectnum) == nullptr)) // clamp to floor
|
if ((cZ > floorZ - (1 << 8)) && (pSector->upperLink == nullptr)) // clamp to floor
|
||||||
{
|
{
|
||||||
cZ = floorZ - (1 << 8);
|
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);
|
cZ = ceilingZ + (1 << 8);
|
||||||
}
|
}
|
||||||
|
@ -674,13 +672,13 @@ void viewDrawScreen(bool sceneonly)
|
||||||
fixedhoriz deliriumPitchI = q16horiz(interpolatedvalue(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate));
|
fixedhoriz deliriumPitchI = q16horiz(interpolatedvalue(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate));
|
||||||
int bakCstat = gView->pSprite->cstat;
|
int bakCstat = gView->pSprite->cstat;
|
||||||
gView->pSprite->cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANSLUCENT_INVERT;
|
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;
|
gView->pSprite->cstat = bakCstat;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
renderSetRollAngle((float)rotscrnang.asbuildf());
|
renderSetRollAngle((float)rotscrnang.asbuildf());
|
||||||
render3DViewPolymost(nSectnum, cX, cY, cZ, cA, cH);
|
render3DViewPolymost(sectnum(pSector), cX, cY, cZ, cA, cH);
|
||||||
}
|
}
|
||||||
bDeliriumOld = bDelirium && gDeliriumBlur;
|
bDeliriumOld = bDelirium && gDeliriumBlur;
|
||||||
|
|
||||||
|
@ -695,7 +693,7 @@ void viewDrawScreen(bool sceneonly)
|
||||||
{
|
{
|
||||||
tmpSect = vf0 & (kMaxWalls - 1);
|
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)
|
if (gWeather.at12d8 > 0 || v8)
|
||||||
{
|
{
|
||||||
gWeather.Draw(cX, cY, cZ, cA.asq16(), cH.asq16() + deliriumPitch, gWeather.at12d8);
|
gWeather.Draw(cX, cY, cZ, cA.asq16(), cH.asq16() + deliriumPitch, gWeather.at12d8);
|
||||||
|
@ -709,7 +707,7 @@ void viewDrawScreen(bool sceneonly)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#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.
|
UpdateDacs(0, true); // keep the view palette active only for the actual 3D view and its overlays.
|
||||||
if (automapMode != am_off)
|
if (automapMode != am_off)
|
||||||
|
|
|
@ -138,7 +138,7 @@ extern int gShowFrameRate;
|
||||||
extern int gLastPal;
|
extern int gLastPal;
|
||||||
extern double gInterpolate;
|
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 viewInitializePrediction(void);
|
||||||
void viewUpdatePrediction(InputPacket *pInput);
|
void viewUpdatePrediction(InputPacket *pInput);
|
||||||
void viewCorrectPrediction(void);
|
void viewCorrectPrediction(void);
|
||||||
|
|
|
@ -248,10 +248,10 @@ int CheckLink(DBloodActor *actor)
|
||||||
return 0;
|
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 upper = (*pSector)->upperLink;
|
||||||
auto lower = getLowerLink(*nSector);
|
auto lower = (*pSector)->lowerLink;
|
||||||
if (upper)
|
if (upper)
|
||||||
{
|
{
|
||||||
spritetype *pUpper = &upper->s();
|
spritetype *pUpper = &upper->s();
|
||||||
|
@ -259,21 +259,21 @@ int CheckLink(int *x, int *y, int *z, int *nSector)
|
||||||
if (pUpper->type == kMarkerUpLink)
|
if (pUpper->type == kMarkerUpLink)
|
||||||
z1 = pUpper->z;
|
z1 = pUpper->z;
|
||||||
else
|
else
|
||||||
z1 = getflorzofslope(*nSector, *x, *y);
|
z1 = getflorzofslopeptr(*pSector, *x, *y);
|
||||||
if (z1 <= *z)
|
if (z1 <= *z)
|
||||||
{
|
{
|
||||||
lower = upper->GetOwner();
|
lower = upper->GetOwner();
|
||||||
assert(lower);
|
assert(lower);
|
||||||
spritetype *pLower = &lower->s();
|
spritetype *pLower = &lower->s();
|
||||||
assert(validSectorIndex(pLower->sectnum));
|
assert(validSectorIndex(pLower->sectnum));
|
||||||
*nSector = pLower->sectnum;
|
*pSector = pLower->sector();
|
||||||
*x += pLower->x-pUpper->x;
|
*x += pLower->x-pUpper->x;
|
||||||
*y += pLower->y-pUpper->y;
|
*y += pLower->y-pUpper->y;
|
||||||
int z2;
|
int z2;
|
||||||
if (pUpper->type == kMarkerLowLink)
|
if (pUpper->type == kMarkerLowLink)
|
||||||
z2 = pLower->z;
|
z2 = pLower->z;
|
||||||
else
|
else
|
||||||
z2 = getceilzofslope(*nSector, *x, *y);
|
z2 = getceilzofslopeptr(*pSector, *x, *y);
|
||||||
*z += z2-z1;
|
*z += z2-z1;
|
||||||
return pUpper->type;
|
return pUpper->type;
|
||||||
}
|
}
|
||||||
|
@ -285,21 +285,21 @@ int CheckLink(int *x, int *y, int *z, int *nSector)
|
||||||
if (pLower->type == kMarkerLowLink)
|
if (pLower->type == kMarkerLowLink)
|
||||||
z1 = pLower->z;
|
z1 = pLower->z;
|
||||||
else
|
else
|
||||||
z1 = getceilzofslope(*nSector, *x, *y);
|
z1 = getceilzofslopeptr(*pSector, *x, *y);
|
||||||
if (z1 >= *z)
|
if (z1 >= *z)
|
||||||
{
|
{
|
||||||
upper = lower->GetOwner();
|
upper = lower->GetOwner();
|
||||||
assert(upper);
|
assert(upper);
|
||||||
spritetype *pUpper = &upper->s();
|
spritetype *pUpper = &upper->s();
|
||||||
assert(validSectorIndex(pUpper->sectnum));
|
assert(pUpper);
|
||||||
*nSector = pUpper->sectnum;
|
*pSector = pUpper->sector();
|
||||||
*x += pUpper->x-pLower->x;
|
*x += pUpper->x-pLower->x;
|
||||||
*y += pUpper->y-pLower->y;
|
*y += pUpper->y-pLower->y;
|
||||||
int z2;
|
int z2;
|
||||||
if (pLower->type == kMarkerUpLink)
|
if (pLower->type == kMarkerUpLink)
|
||||||
z2 = pUpper->z;
|
z2 = pUpper->z;
|
||||||
else
|
else
|
||||||
z2 = getflorzofslope(*nSector, *x, *y);
|
z2 = getflorzofslopeptr(*pSector, *x, *y);
|
||||||
*z += z2-z1;
|
*z += z2-z1;
|
||||||
return pLower->type;
|
return pLower->type;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue