Remove the ProjectedWallTexcoords arrays
This commit is contained in:
parent
370c185415
commit
5c21a6c973
8 changed files with 76 additions and 156 deletions
|
|
@ -223,65 +223,53 @@ namespace swrenderer
|
|||
|
||||
void ProjectedWallTexcoords::Project(RenderViewport *viewport, double walxrepeat, int x1, int x2, const FWallTmapVals &WallT, bool flipx)
|
||||
{
|
||||
float uOverZ = WallT.UoverZorg + WallT.UoverZstep * (float)(x1 + 0.5 - viewport->CenterX);
|
||||
float invZ = WallT.InvZorg + WallT.InvZstep * (float)(x1 + 0.5 - viewport->CenterX);
|
||||
this->walxrepeat = walxrepeat;
|
||||
this->x1 = x1;
|
||||
this->x2 = x2;
|
||||
this->WallT = WallT;
|
||||
CenterX = viewport->CenterX;
|
||||
WallTMapScale2 = viewport->WallTMapScale2;
|
||||
valid = true;
|
||||
}
|
||||
|
||||
float ProjectedWallTexcoords::VStep(int x) const
|
||||
{
|
||||
float uOverZ = WallT.UoverZorg + WallT.UoverZstep * (float)(x1 + 0.5 - CenterX);
|
||||
float invZ = WallT.InvZorg + WallT.InvZstep * (float)(x1 + 0.5 - CenterX);
|
||||
float uGradient = WallT.UoverZstep;
|
||||
float zGradient = WallT.InvZstep;
|
||||
float xrepeat = (float)fabs(walxrepeat);
|
||||
float depthScale = (float)(WallT.InvZstep * viewport->WallTMapScale2);
|
||||
float depthOrg = (float)(-WallT.UoverZstep * viewport->WallTMapScale2);
|
||||
float depthScale = (float)(WallT.InvZstep * WallTMapScale2);
|
||||
float depthOrg = (float)(-WallT.UoverZstep * WallTMapScale2);
|
||||
float u = (uOverZ + uGradient * (x - x1)) / (invZ + zGradient * (x - x1));
|
||||
|
||||
return depthOrg + u * depthScale;
|
||||
}
|
||||
|
||||
fixed_t ProjectedWallTexcoords::UPos(int x) const
|
||||
{
|
||||
float uOverZ = WallT.UoverZorg + WallT.UoverZstep * (float)(x1 + 0.5 - CenterX);
|
||||
float invZ = WallT.InvZorg + WallT.InvZstep * (float)(x1 + 0.5 - CenterX);
|
||||
float uGradient = WallT.UoverZstep;
|
||||
float zGradient = WallT.InvZstep;
|
||||
float u = (uOverZ + uGradient * (x - x1)) / (invZ + zGradient * (x - x1));
|
||||
|
||||
fixed_t value;
|
||||
if (walxrepeat < 0.0)
|
||||
{
|
||||
for (int x = x1; x < x2; x++)
|
||||
{
|
||||
float u = uOverZ / invZ;
|
||||
|
||||
UPos[x] = (fixed_t)((xrepeat - u * xrepeat) * FRACUNIT);
|
||||
VStep[x] = depthOrg + u * depthScale;
|
||||
|
||||
uOverZ += uGradient;
|
||||
invZ += zGradient;
|
||||
}
|
||||
float xrepeat = -walxrepeat;
|
||||
value = (fixed_t)((xrepeat - u * xrepeat) * FRACUNIT);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int x = x1; x < x2; x++)
|
||||
{
|
||||
float u = uOverZ / invZ;
|
||||
|
||||
UPos[x] = (fixed_t)(u * xrepeat * FRACUNIT);
|
||||
VStep[x] = depthOrg + u * depthScale;
|
||||
|
||||
uOverZ += uGradient;
|
||||
invZ += zGradient;
|
||||
}
|
||||
value = (fixed_t)(u * walxrepeat * FRACUNIT);
|
||||
}
|
||||
|
||||
if (flipx)
|
||||
{
|
||||
int right = (int)walxrepeat - 1;
|
||||
for (int i = x1; i < x2; i++)
|
||||
{
|
||||
UPos[i] = right - UPos[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void DrawSegmentWallTexcoords::Set(RenderThread* thread, const ProjectedWallTexcoords& texcoords, int x1, int x2, fixed_t xoffset, double yscale)
|
||||
{
|
||||
UPos = thread->FrameMemory->AllocMemory<fixed_t>(x2 - x1) - x1;
|
||||
VStep = thread->FrameMemory->AllocMemory<float>(x2 - x1) - x1;
|
||||
|
||||
for (int i = x1; i < x2; i++)
|
||||
{
|
||||
UPos[i] = texcoords.UPos[i] + xoffset;
|
||||
VStep[i] = texcoords.VStep[i];
|
||||
value = (int)walxrepeat - 1 - value;
|
||||
}
|
||||
|
||||
this->yscale = (float)yscale;
|
||||
return value + xoffset;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue