mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-18 17:51:06 +00:00
- Blood: Floatify position drawing code and clean up now-unused wrappers.
* Still work to be done on bob/sway/zView variables.
This commit is contained in:
parent
dd23b60810
commit
9eec69d810
10 changed files with 69 additions and 87 deletions
|
@ -221,8 +221,6 @@ void S_PauseSound(bool notmusic, bool notsfx);
|
|||
void S_ResumeSound(bool notsfx);
|
||||
void S_SetSoundPaused(int state);
|
||||
|
||||
const int MaxSmoothRatio = FRACUNIT;
|
||||
|
||||
FString G_GetDemoPath();
|
||||
|
||||
enum
|
||||
|
|
|
@ -259,16 +259,6 @@ void loaddefinitionsfile(const char* fn, bool cumulative = false, bool maingrp =
|
|||
|
||||
bool calcChaseCamPos(DVector3& ppos, DCoreActor* pspr, sectortype** psectnum, DAngle ang, fixedhoriz horiz, double const interpfrac);
|
||||
|
||||
inline bool calcChaseCamPos(int* px, int* py, int* pz, DCoreActor* pspr, sectortype** psectnum, DAngle ang, fixedhoriz horiz, double const smoothratio)
|
||||
{
|
||||
auto pos = DVector3((*px) * inttoworld, (*py) * inttoworld, (*pz) * zinttoworld);
|
||||
auto res = calcChaseCamPos(pos, pspr, psectnum, ang, horiz, smoothratio * (1. / MaxSmoothRatio));
|
||||
(*px) = pos.X * worldtoint;
|
||||
(*py) = pos.Y * worldtoint;
|
||||
(*pz) = pos.Z * zworldtoint;
|
||||
return res;
|
||||
}
|
||||
|
||||
void PlanesAtPoint(const sectortype* sec, float dax, float day, float* ceilz, float* florz);
|
||||
|
||||
int getslopeval(sectortype* sect, int x, int y, int z, int planez);
|
||||
|
|
|
@ -8,15 +8,6 @@ struct IntRect;
|
|||
void render_drawrooms(DCoreActor* playersprite, const DVector3& position, int sectnum, DAngle angle, fixedhoriz horizon, DAngle rollang, double interpfrac, float fov = -1);
|
||||
void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortype* sect, DAngle angle, fixedhoriz horizon, DAngle rollang, FGameTexture* camtex, IntRect& rect, double interpfrac);
|
||||
|
||||
inline void render_drawrooms(DCoreActor* playersprite, const vec3_t& position, int sectnum, DAngle angle, fixedhoriz horizon, DAngle rollang, double smoothratio, float fov = -1)
|
||||
{
|
||||
render_drawrooms(playersprite, DVector3(position.X * inttoworld, position.Y * inttoworld, position.Z * zinttoworld), sectnum, angle, horizon, rollang, smoothratio * (1. / MaxSmoothRatio), fov);
|
||||
}
|
||||
inline void render_camtex(DCoreActor* playersprite, const vec3_t& position, sectortype* sect, DAngle angle, fixedhoriz horizon, DAngle rollang, FGameTexture* camtex, IntRect& rect, double smoothratio)
|
||||
{
|
||||
render_camtex(playersprite, DVector3(position.X* inttoworld, position.Y * inttoworld, position.Z* zinttoworld), sect, angle, horizon, rollang, camtex, rect, smoothratio * (1. / MaxSmoothRatio));
|
||||
}
|
||||
|
||||
struct PortalDesc
|
||||
{
|
||||
int type;
|
||||
|
|
|
@ -364,20 +364,21 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
|
|||
pNSprite->set_int_z(getflorzofslopeptr(pTSprite->sectp, pNSprite->int_pos().X, pNSprite->int_pos().Y));
|
||||
if ((pNSprite->sectp->floorpicnum >= 4080) && (pNSprite->sectp->floorpicnum <= 4095) && !VanillaMode()) // if floor has ror, find actual floor
|
||||
{
|
||||
int cX = pNSprite->int_pos().X, cY = pNSprite->int_pos().Y, cZ = pNSprite->int_pos().Z, cZrel = pNSprite->int_pos().Z;
|
||||
DVector3 cPos = pNSprite->pos;
|
||||
double cZrel = cPos.Z;
|
||||
auto cSect = pNSprite->sectp;
|
||||
for (int i = 0; i < 16; i++) // scan through max stacked sectors
|
||||
{
|
||||
if (!CheckLink(&cX, &cY, &cZ, &cSect)) // if no more floors underneath, abort
|
||||
if (!CheckLink(cPos, &cSect)) // if no more floors underneath, abort
|
||||
break;
|
||||
const int newFloorZ = getflorzofslopeptr(cSect, cX, cZ);
|
||||
cZrel += newFloorZ - cZ; // get height difference for next sector's ceiling/floor, and add to relative height for shadow
|
||||
const double newFloorZ = getflorzofslopeptrf(cSect, cPos.X, cPos.Z);
|
||||
cZrel += newFloorZ - cPos.Z; // get height difference for next sector's ceiling/floor, and add to relative height for shadow
|
||||
if ((cSect->floorpicnum < 4080) || (cSect->floorpicnum > 4095)) // if current sector is not open air, use as floor for shadow casting, otherwise continue to next sector
|
||||
break;
|
||||
cZ = newFloorZ;
|
||||
cPos.Z = newFloorZ;
|
||||
}
|
||||
pNSprite->sectp = cSect;
|
||||
pNSprite->set_int_z(cZrel);
|
||||
pNSprite->pos.Z = cZrel;
|
||||
}
|
||||
pNSprite->shade = 127;
|
||||
pNSprite->cstat |= CSTAT_SPRITE_TRANSLUCENT;
|
||||
|
|
|
@ -572,6 +572,11 @@ inline int QRandom2(int a1)
|
|||
return MulScale(qrand(), a1, 14) - a1;
|
||||
}
|
||||
|
||||
inline double QRandom2F(double a1)
|
||||
{
|
||||
return MulScaleF(qrand(), a1, 14) - a1;
|
||||
}
|
||||
|
||||
inline int scale(int a1, int a2, int a3, int a4, int a5)
|
||||
{
|
||||
return a4 + (a5 - a4) * (a1 - a2) / (a3 - a2);
|
||||
|
|
|
@ -66,7 +66,7 @@ extern ZONE gStartZone[8];
|
|||
|
||||
void warpInit(TArray<DBloodActor*>& actors);
|
||||
int CheckLink(DBloodActor* pSprite);
|
||||
int CheckLink(int* x, int* y, int* z, sectortype** pSector);
|
||||
int CheckLink(DVector3& cPos, sectortype** pSector);
|
||||
|
||||
void RotateVector(int* dx, int* dy, int nAngle);
|
||||
|
||||
|
|
|
@ -405,7 +405,7 @@ void viewUpdateDelirium(PLAYER* pPlayer)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void viewUpdateShake(PLAYER* pPlayer, int& cX, int& cY, int& cZ, DAngle& cA, fixedhoriz& cH, double& pshakeX, double& pshakeY)
|
||||
void viewUpdateShake(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, fixedhoriz& cH, double& pshakeX, double& pshakeY)
|
||||
{
|
||||
auto doEffect = [&](const int& effectType)
|
||||
{
|
||||
|
@ -414,9 +414,9 @@ void viewUpdateShake(PLAYER* pPlayer, int& cX, int& cY, int& cZ, DAngle& cA, fix
|
|||
int nValue = ClipHigh(effectType * 8, 2000);
|
||||
cH += buildhoriz(QRandom2(nValue >> 8));
|
||||
cA += DAngle::fromBuild(QRandom2(nValue >> 8));
|
||||
cX += QRandom2(nValue >> 4);
|
||||
cY += QRandom2(nValue >> 4);
|
||||
cZ += QRandom2(nValue);
|
||||
cPos.X += QRandom2F(nValue * inttoworld) * inttoworld;
|
||||
cPos.Y += QRandom2F(nValue * inttoworld) * inttoworld;
|
||||
cPos.Z += QRandom2F(nValue) * zinttoworld;
|
||||
pshakeX += QRandom2(nValue);
|
||||
pshakeY += QRandom2(nValue);
|
||||
}
|
||||
|
@ -456,9 +456,9 @@ static void DrawMap(PLAYER* pPlayer, const double interpfrac)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void SetupView(PLAYER* pPlayer, int& cX, int& cY, int& cZ, DAngle& cA, fixedhoriz& cH, sectortype*& pSector, double& zDelta, double& shakeX, double& shakeY, DAngle& rotscrnang, const double interpfrac)
|
||||
static void SetupView(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, fixedhoriz& cH, sectortype*& pSector, double& zDelta, double& shakeX, double& shakeY, DAngle& rotscrnang, const double interpfrac)
|
||||
{
|
||||
int bobWidth, bobHeight;
|
||||
double bobWidth, bobHeight;
|
||||
|
||||
pSector = pPlayer->actor->sector();
|
||||
#if 0
|
||||
|
@ -490,12 +490,11 @@ static void SetupView(PLAYER* pPlayer, int& cX, int& cY, int& cZ, DAngle& cA, fi
|
|||
else
|
||||
#endif
|
||||
{
|
||||
cX = interpolatedvalue(pPlayer->actor->opos.X, pPlayer->actor->spr.pos.X, interpfrac) * worldtoint;
|
||||
cY = interpolatedvalue(pPlayer->actor->opos.Y, pPlayer->actor->spr.pos.Y, interpfrac) * worldtoint;
|
||||
cZ = interpolatedvalue(pPlayer->ozView, pPlayer->zView, interpfrac);
|
||||
cPos.XY() = pPlayer->actor->interpolatedpos(interpfrac).XY();
|
||||
cPos.Z = interpolatedvalue(pPlayer->ozView, pPlayer->zView, interpfrac) * zinttoworld;
|
||||
zDelta = interpolatedvalue<double>(pPlayer->ozWeapon, pPlayer->zWeapon - pPlayer->zView - (12 << 8), interpfrac);
|
||||
bobWidth = interpolatedvalue(pPlayer->obobWidth, pPlayer->bobWidth, interpfrac);
|
||||
bobHeight = interpolatedvalue(pPlayer->obobHeight, pPlayer->bobHeight, interpfrac);
|
||||
bobWidth = interpolatedvalue<double>(pPlayer->obobWidth, pPlayer->bobWidth, interpfrac);
|
||||
bobHeight = interpolatedvalue<double>(pPlayer->obobHeight, pPlayer->bobHeight, interpfrac);
|
||||
shakeX = interpolatedvalue<double>(pPlayer->oswayWidth, pPlayer->swayWidth, interpfrac);
|
||||
shakeY = interpolatedvalue<double>(pPlayer->oswayHeight, pPlayer->swayHeight, interpfrac);
|
||||
|
||||
|
@ -513,27 +512,27 @@ static void SetupView(PLAYER* pPlayer, int& cX, int& cY, int& cZ, DAngle& cA, fi
|
|||
}
|
||||
}
|
||||
|
||||
viewUpdateShake(pPlayer, cX, cY, cZ, cA, cH, shakeX, shakeY);
|
||||
viewUpdateShake(pPlayer, cPos, cA, cH, shakeX, shakeY);
|
||||
cH += buildhoriz(MulScale(0x40000000 - Cos(pPlayer->tiltEffect << 2), 30, 30));
|
||||
if (gViewPos == 0)
|
||||
{
|
||||
if (cl_viewhbob)
|
||||
{
|
||||
cX -= MulScale(bobWidth, Sin(cA.Buildang()), 30) >> 4;
|
||||
cY += MulScale(bobWidth, Cos(cA.Buildang()), 30) >> 4;
|
||||
cPos.X -= bobWidth * cA.Sin() * (1. / 256.);
|
||||
cPos.Y += bobWidth * cA.Cos() * (1. / 256.);
|
||||
}
|
||||
if (cl_viewvbob)
|
||||
{
|
||||
cZ += bobHeight;
|
||||
cPos.Z += bobHeight * zinttoworld;
|
||||
}
|
||||
cZ += int(cH.asq16() * (1. / 6553.6));
|
||||
cPos.Z += FixedToFloat<24>(cH.asq16() * 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
calcChaseCamPos((int*)&cX, (int*)&cY, (int*)&cZ, pPlayer->actor, &pSector, cA, cH, interpfrac * MaxSmoothRatio);
|
||||
calcChaseCamPos(cPos, pPlayer->actor, &pSector, cA, cH, interpfrac);
|
||||
}
|
||||
if (pSector != nullptr)
|
||||
CheckLink((int*)&cX, (int*)&cY, (int*)&cZ, &pSector);
|
||||
CheckLink(cPos, &pSector);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -617,8 +616,13 @@ void viewDrawScreen(bool sceneonly)
|
|||
FireProcess();
|
||||
}
|
||||
|
||||
double interpfrac = !paused && (!M_Active() || gGameOptions.nGameType != 0) || !cl_interpolate || cl_capfps ? 1. : I_GetTimeFrac();
|
||||
double gInterpolate = interpfrac * MaxSmoothRatio;
|
||||
double interpfrac;
|
||||
|
||||
if (!paused && (!M_Active() || gGameOptions.nGameType != 0))
|
||||
{
|
||||
interpfrac = !cl_interpolate || cl_capfps ? 1. : I_GetTimeFrac() * 1.;
|
||||
}
|
||||
else interpfrac = 1.;
|
||||
|
||||
if (cl_interpolate)
|
||||
{
|
||||
|
@ -645,13 +649,13 @@ void viewDrawScreen(bool sceneonly)
|
|||
UpdateDacs(basepal);
|
||||
UpdateBlend(pPlayer);
|
||||
|
||||
int cX, cY, cZ;
|
||||
DVector3 cPos;
|
||||
DAngle cA, rotscrnang;
|
||||
fixedhoriz cH;
|
||||
sectortype* pSector;
|
||||
double zDelta;
|
||||
double shakeX, shakeY;
|
||||
SetupView(pPlayer, cX, cY, cZ, cA, cH, pSector, zDelta, shakeX, shakeY, rotscrnang, interpfrac);
|
||||
SetupView(pPlayer, cPos, cA, cH, pSector, zDelta, shakeX, shakeY, rotscrnang, interpfrac);
|
||||
|
||||
DAngle tilt = interpolatedvalue(gScreenTiltO, gScreenTilt, interpfrac);
|
||||
bool bDelirium = powerupCheck(pPlayer, kPwUpDeliriumShroom) > 0;
|
||||
|
@ -706,18 +710,17 @@ void viewDrawScreen(bool sceneonly)
|
|||
|
||||
if (pSector != nullptr)
|
||||
{
|
||||
int ceilingZ, floorZ;
|
||||
getzsofslopeptr(pSector, cX, cY, &ceilingZ, &floorZ);
|
||||
if ((cZ > floorZ - (1 << 8)) && (pSector->upperLink == nullptr)) // clamp to floor
|
||||
double ceilingZ, floorZ;
|
||||
getzsofslopeptr(pSector, cPos, &ceilingZ, &floorZ);
|
||||
if ((cPos.Z > floorZ - 1) && (pSector->upperLink == nullptr)) // clamp to floor
|
||||
{
|
||||
cZ = floorZ - (1 << 8);
|
||||
cPos.Z = floorZ - 1;
|
||||
}
|
||||
if ((cZ < ceilingZ + (1 << 8)) && (pSector->lowerLink == nullptr)) // clamp to ceiling
|
||||
if ((cPos.Z < ceilingZ + 1) && (pSector->lowerLink == nullptr)) // clamp to ceiling
|
||||
{
|
||||
cZ = ceilingZ + (1 << 8);
|
||||
cPos.Z = ceilingZ + 1;
|
||||
}
|
||||
}
|
||||
|
||||
cH = q16horiz(ClipRange(cH.asq16(), gi->playerHorizMin(), gi->playerHorizMax()));
|
||||
|
||||
if ((tilt.Degrees() || bDelirium) && !sceneonly)
|
||||
|
@ -736,7 +739,7 @@ void viewDrawScreen(bool sceneonly)
|
|||
fixedhoriz deliriumPitchI = interpolatedvalue(q16horiz(deliriumPitchO), q16horiz(deliriumPitch), interpfrac);
|
||||
auto bakCstat = pPlayer->actor->spr.cstat;
|
||||
pPlayer->actor->spr.cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP;
|
||||
render_drawrooms(pPlayer->actor, vec3_t( cX, cY, cZ ), sectnum(pSector), cA, cH + deliriumPitchI, rotscrnang, gInterpolate);
|
||||
render_drawrooms(pPlayer->actor, cPos, sectnum(pSector), cA, cH + deliriumPitchI, rotscrnang, interpfrac);
|
||||
pPlayer->actor->spr.cstat = bakCstat;
|
||||
bDeliriumOld = bDelirium && gDeliriumBlur;
|
||||
|
||||
|
|
|
@ -261,54 +261,52 @@ int CheckLink(DBloodActor* actor)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int CheckLink(int* x, int* y, int* z, sectortype** pSector)
|
||||
int CheckLink(DVector3& cPos, sectortype** pSector)
|
||||
{
|
||||
auto aUpper = barrier_cast<DBloodActor*>((*pSector)->upperLink);
|
||||
auto aLower = barrier_cast<DBloodActor*>((*pSector)->lowerLink);
|
||||
if (aUpper)
|
||||
{
|
||||
int z1;
|
||||
double z1;
|
||||
if (aUpper->spr.type == kMarkerUpLink)
|
||||
z1 = aUpper->int_pos().Z;
|
||||
z1 = aUpper->spr.pos.Z;
|
||||
else
|
||||
z1 = getflorzofslopeptr(*pSector, *x, *y);
|
||||
if (z1 <= *z)
|
||||
z1 = getflorzofslopeptrf(*pSector, cPos);
|
||||
if (z1 <= cPos.Z)
|
||||
{
|
||||
aLower = aUpper->GetOwner();
|
||||
assert(aLower);
|
||||
assert(aLower->insector());
|
||||
*pSector = aLower->sector();
|
||||
*x += aLower->int_pos().X - aUpper->int_pos().X;
|
||||
*y += aLower->int_pos().Y - aUpper->int_pos().Y;
|
||||
int z2;
|
||||
cPos.XY() += aLower->spr.pos.XY() - aUpper->spr.pos.XY();
|
||||
double z2;
|
||||
if (aUpper->spr.type == kMarkerLowLink)
|
||||
z2 = aLower->int_pos().Z;
|
||||
z2 = aLower->spr.pos.Z;
|
||||
else
|
||||
z2 = getceilzofslopeptr(*pSector, *x, *y);
|
||||
*z += z2 - z1;
|
||||
z2 = getceilzofslopeptrf(*pSector, cPos);
|
||||
cPos.Z += z2 - z1;
|
||||
return aUpper->spr.type;
|
||||
}
|
||||
}
|
||||
if (aLower)
|
||||
{
|
||||
int z1;
|
||||
double z1;
|
||||
if (aLower->spr.type == kMarkerLowLink)
|
||||
z1 = aLower->int_pos().Z;
|
||||
z1 = aLower->spr.pos.Z;
|
||||
else
|
||||
z1 = getceilzofslopeptr(*pSector, *x, *y);
|
||||
if (z1 >= *z)
|
||||
z1 = getceilzofslopeptrf(*pSector, cPos);
|
||||
if (z1 >= cPos.Z)
|
||||
{
|
||||
aUpper = aLower->GetOwner();
|
||||
assert(aUpper);
|
||||
*pSector = aUpper->sector();
|
||||
*x += aUpper->int_pos().X - aLower->int_pos().X;
|
||||
*y += aUpper->int_pos().Y - aLower->int_pos().Y;
|
||||
int z2;
|
||||
cPos.XY() += aUpper->spr.pos.XY() - aLower->spr.pos.XY();
|
||||
double z2;
|
||||
if (aLower->spr.type == kMarkerUpLink)
|
||||
z2 = aUpper->int_pos().Z;
|
||||
z2 = aUpper->spr.pos.Z;
|
||||
else
|
||||
z2 = getflorzofslopeptr(*pSector, *x, *y);
|
||||
*z += z2 - z1;
|
||||
z2 = getflorzofslopeptrf(*pSector, cPos);
|
||||
cPos.Z += z2 - z1;
|
||||
return aLower->spr.type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ void GameInterface::UpdateCameras(double smoothratio)
|
|||
display_mirror = 1; // should really be 'display external view'.
|
||||
auto cstat = camera->spr.cstat;
|
||||
camera->spr.cstat = CSTAT_SPRITE_INVISIBLE;
|
||||
render_camtex(camera, camera->int_pos(), camera->sector(), camera->interpolatedangle(smoothratio * (1. / MaxSmoothRatio)), buildhoriz(camera->spr.shade), nullAngle, tex, rect, smoothratio);
|
||||
render_camtex(camera, camera->spr.pos, camera->sector(), camera->interpolatedangle(smoothratio), buildhoriz(camera->spr.shade), nullAngle, tex, rect, smoothratio);
|
||||
camera->spr.cstat = cstat;
|
||||
display_mirror = 0;
|
||||
});
|
||||
|
@ -383,7 +383,7 @@ void displayrooms(int snum, double interpfrac, bool sceneonly)
|
|||
|
||||
bool GameInterface::GenerateSavePic()
|
||||
{
|
||||
displayrooms(myconnectindex, MaxSmoothRatio, true);
|
||||
displayrooms(myconnectindex, 1., true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -400,18 +400,14 @@ void JS_InitMirrors(void)
|
|||
/////////////////////////////////////////////////////
|
||||
// Draw a 3d screen to a specific tile
|
||||
/////////////////////////////////////////////////////
|
||||
void drawroomstotile(const DVector3& pos,
|
||||
DAngle ang, fixedhoriz horiz, sectortype* dacursect, short tilenume, double smoothratio)
|
||||
void drawroomstotile(const DVector3& pos, DAngle ang, fixedhoriz horiz, sectortype* dacursect, short tilenume, double smoothratio)
|
||||
{
|
||||
int daposx = pos.X * worldtoint;
|
||||
int daposy = pos.Y * worldtoint;
|
||||
int daposz = pos.Z * zworldtoint;
|
||||
auto canvas = tileGetCanvas(tilenume);
|
||||
if (!canvas) return;
|
||||
|
||||
screen->RenderTextureView(canvas, [=](IntRect& rect)
|
||||
{
|
||||
render_camtex(nullptr, vec3_t( daposx, daposy, daposz ), dacursect, ang, horiz, nullAngle, tileGetTexture(tilenume), rect, smoothratio);
|
||||
render_camtex(nullptr, pos, dacursect, ang, horiz, nullAngle, tileGetTexture(tilenume), rect, smoothratio);
|
||||
});
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue