mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-26 22:01:43 +00:00
- Compute accurate Z values for every column in Prep(L)Wall instead of interpolating every four
columns because you can see "rippling" otherwise if you are looking across a wall as a polyobject splits it at different points. Considering that this is what Doom did in the first place, there was probably never a need for this Build optimization. SVN r2472 (polyobjects)
This commit is contained in:
parent
d29d73630e
commit
d4fbebcd3d
2 changed files with 46 additions and 147 deletions
|
@ -330,13 +330,13 @@ endif( NOT NO_ASM )
|
||||||
# Set up flags for GCC
|
# Set up flags for GCC
|
||||||
|
|
||||||
if( CMAKE_COMPILER_IS_GNUCXX )
|
if( CMAKE_COMPILER_IS_GNUCXX )
|
||||||
if( PROFILE )
|
if( PROFILE )
|
||||||
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -pg" )
|
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -pg" )
|
||||||
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg" )
|
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg" )
|
||||||
set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -pg" )
|
set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -pg" )
|
||||||
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -pg" )
|
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -pg" )
|
||||||
endif( PROFILE )
|
endif( PROFILE )
|
||||||
|
|
||||||
set( REL_CXX_FLAGS "-fno-rtti" )
|
set( REL_CXX_FLAGS "-fno-rtti" )
|
||||||
if( NOT PROFILE )
|
if( NOT PROFILE )
|
||||||
set( REL_CXX_FLAGS "${REL_CXX_FLAGS} -fomit-frame-pointer" )
|
set( REL_CXX_FLAGS "${REL_CXX_FLAGS} -fomit-frame-pointer" )
|
||||||
|
|
179
src/r_segs.cpp
179
src/r_segs.cpp
|
@ -2008,80 +2008,12 @@ int WallMost (short *mostbuf, const secplane_t &plane)
|
||||||
return bad;
|
return bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat)
|
static void PrepWallRoundFix(fixed_t *lwall, fixed_t walxrepeat)
|
||||||
{ // swall = scale, lwall = texturecolumn
|
{
|
||||||
int x;
|
|
||||||
float top, bot, i;
|
|
||||||
float xrepeat = (float)walxrepeat;
|
|
||||||
float ol, l, topinc, botinc;
|
|
||||||
|
|
||||||
i = (float)(WallSX1 - centerx);
|
|
||||||
top = WallUoverZorg + WallUoverZstep * i;
|
|
||||||
bot = WallInvZorg + WallInvZstep * i;
|
|
||||||
topinc = WallUoverZstep * 4.f;
|
|
||||||
botinc = WallInvZstep * 4.f;
|
|
||||||
|
|
||||||
x = WallSX1;
|
|
||||||
|
|
||||||
l = top / bot;
|
|
||||||
swall[x] = xs_RoundToInt(l * WallDepthScale + WallDepthOrg);
|
|
||||||
lwall[x] = xs_RoundToInt(l * xrepeat);
|
|
||||||
// As long as l is invalid, step one column at a time so that
|
|
||||||
// we can get as many correct texture columns as possible.
|
|
||||||
while (l > 1.0 && x+1 < WallSX2)
|
|
||||||
{
|
|
||||||
l = (top += WallUoverZstep) / (bot += WallInvZstep);
|
|
||||||
x++;
|
|
||||||
swall[x] = xs_RoundToInt(l * WallDepthScale + WallDepthOrg);
|
|
||||||
lwall[x] = xs_RoundToInt(l * xrepeat);
|
|
||||||
}
|
|
||||||
l *= xrepeat;
|
|
||||||
while (x+4 < WallSX2)
|
|
||||||
{
|
|
||||||
top += topinc; bot += botinc;
|
|
||||||
ol = l; l = top / bot;
|
|
||||||
swall[x+4] = xs_RoundToInt(l * WallDepthScale + WallDepthOrg);
|
|
||||||
lwall[x+4] = xs_RoundToInt(l *= xrepeat);
|
|
||||||
|
|
||||||
i = (ol+l) * 0.5f;
|
|
||||||
lwall[x+2] = xs_RoundToInt(i);
|
|
||||||
lwall[x+1] = xs_RoundToInt((ol+i) * 0.5f);
|
|
||||||
lwall[x+3] = xs_RoundToInt((l+i) * 0.5f);
|
|
||||||
swall[x+2] = ((swall[x]+swall[x+4])>>1);
|
|
||||||
swall[x+1] = ((swall[x]+swall[x+2])>>1);
|
|
||||||
swall[x+3] = ((swall[x+4]+swall[x+2])>>1);
|
|
||||||
x += 4;
|
|
||||||
}
|
|
||||||
if (x+2 < WallSX2)
|
|
||||||
{
|
|
||||||
top += topinc * 0.5f; bot += botinc * 0.5f;
|
|
||||||
ol = l; l = top / bot;
|
|
||||||
swall[x+2] = xs_RoundToInt(l * WallDepthScale + WallDepthOrg);
|
|
||||||
lwall[x+2] = xs_RoundToInt(l *= xrepeat);
|
|
||||||
|
|
||||||
lwall[x+1] = xs_RoundToInt((l+ol)*0.5f);
|
|
||||||
swall[x+1] = (swall[x]+swall[x+2])>>1;
|
|
||||||
x += 2;
|
|
||||||
}
|
|
||||||
if (x+1 < WallSX2)
|
|
||||||
{
|
|
||||||
l = (top + WallUoverZstep) / (bot + WallInvZstep);
|
|
||||||
swall[x+1] = xs_RoundToInt(l * WallDepthScale + WallDepthOrg);
|
|
||||||
lwall[x+1] = xs_RoundToInt(l * xrepeat);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
for (x = WallSX1; x < WallSX2; x++)
|
|
||||||
{
|
|
||||||
frac = top / bot;
|
|
||||||
lwall[x] = xs_RoundToInt(frac * xrepeat);
|
|
||||||
swall[x] = xs_RoundToInt(frac * WallDepthScale + WallDepthOrg);
|
|
||||||
top += WallUoverZstep;
|
|
||||||
bot += WallInvZstep;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// fix for rounding errors
|
// fix for rounding errors
|
||||||
fixed_t fix = (MirrorFlags & RF_XFLIP) ? walxrepeat-1 : 0;
|
fixed_t fix = (MirrorFlags & RF_XFLIP) ? walxrepeat-1 : 0;
|
||||||
|
int x;
|
||||||
|
|
||||||
if (WallSX1 > 0)
|
if (WallSX1 > 0)
|
||||||
{
|
{
|
||||||
for (x = WallSX1; x < WallSX2; x++)
|
for (x = WallSX1; x < WallSX2; x++)
|
||||||
|
@ -2110,85 +2042,52 @@ void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrepLWall (fixed_t *lwall, fixed_t walxrepeat)
|
void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat)
|
||||||
{ // lwall = texturecolumn
|
{ // swall = scale, lwall = texturecolumn
|
||||||
int x;
|
double top, bot, i;
|
||||||
float top, bot, i;
|
double xrepeat = walxrepeat;
|
||||||
float xrepeat = (float)walxrepeat;
|
double topinc, botinc;
|
||||||
float ol, l, topinc, botinc;
|
|
||||||
|
|
||||||
i = (float)(WallSX1 - centerx);
|
i = WallSX1 - centerx;
|
||||||
top = WallUoverZorg + WallUoverZstep * i;
|
top = WallUoverZorg + WallUoverZstep * i;
|
||||||
bot = WallInvZorg + WallInvZstep * i;
|
bot = WallInvZorg + WallInvZstep * i;
|
||||||
topinc = WallUoverZstep * 4.f;
|
topinc = WallUoverZstep * 4.f;
|
||||||
botinc = WallInvZstep * 4.f;
|
botinc = WallInvZstep * 4.f;
|
||||||
|
|
||||||
x = WallSX1;
|
for (int x = WallSX1; x < WallSX2; x++)
|
||||||
|
{
|
||||||
|
double frac = top / bot;
|
||||||
|
lwall[x] = xs_RoundToInt(frac * xrepeat);
|
||||||
|
swall[x] = xs_RoundToInt(frac * WallDepthScale + WallDepthOrg);
|
||||||
|
top += WallUoverZstep;
|
||||||
|
bot += WallInvZstep;
|
||||||
|
}
|
||||||
|
PrepWallRoundFix(lwall, walxrepeat);
|
||||||
|
}
|
||||||
|
|
||||||
l = top / bot;
|
void PrepLWall (fixed_t *lwall, fixed_t walxrepeat)
|
||||||
lwall[x] = xs_RoundToInt(l * xrepeat);
|
{ // lwall = texturecolumn
|
||||||
// As long as l is invalid, step one column at a time so that
|
double top, bot, i;
|
||||||
// we can get as many correct texture columns as possible.
|
double xrepeat = walxrepeat;
|
||||||
while (l > 1.0 && x+1 < WallSX2)
|
double topinc, botinc;
|
||||||
{
|
double topstep;
|
||||||
l = (top += WallUoverZstep) / (bot += WallInvZstep);
|
|
||||||
lwall[++x] = xs_RoundToInt(l * xrepeat);
|
|
||||||
}
|
|
||||||
l *= xrepeat;
|
|
||||||
while (x+4 < WallSX2)
|
|
||||||
{
|
|
||||||
top += topinc; bot += botinc;
|
|
||||||
ol = l; l = top / bot;
|
|
||||||
lwall[x+4] = xs_RoundToInt(l *= xrepeat);
|
|
||||||
|
|
||||||
i = (ol+l) * 0.5f;
|
i = WallSX1 - centerx;
|
||||||
lwall[x+2] = xs_RoundToInt(i);
|
top = WallUoverZorg + WallUoverZstep * i;
|
||||||
lwall[x+1] = xs_RoundToInt((ol+i) * 0.5f);
|
bot = WallInvZorg + WallInvZstep * i;
|
||||||
lwall[x+3] = xs_RoundToInt((l+i) * 0.5f);
|
topinc = WallUoverZstep * 4.f;
|
||||||
x += 4;
|
botinc = WallInvZstep * 4.f;
|
||||||
}
|
|
||||||
if (x+2 < WallSX2)
|
|
||||||
{
|
|
||||||
top += topinc * 0.5f; bot += botinc * 0.5f;
|
|
||||||
ol = l; l = top / bot;
|
|
||||||
lwall[x+2] = xs_RoundToInt(l *= xrepeat);
|
|
||||||
lwall[x+1] = xs_RoundToInt((l+ol)*0.5f);
|
|
||||||
x += 2;
|
|
||||||
}
|
|
||||||
if (x+1 < WallSX2)
|
|
||||||
{
|
|
||||||
l = (top + WallUoverZstep) / (bot + WallInvZstep);
|
|
||||||
lwall[x+1] = xs_RoundToInt(l * xrepeat);
|
|
||||||
}
|
|
||||||
|
|
||||||
// fix for rounding errors
|
top *= xrepeat;
|
||||||
fixed_t fix = (MirrorFlags & RF_XFLIP) ? walxrepeat-1 : 0;
|
topstep = WallUoverZstep * xrepeat;
|
||||||
if (WallSX1 > 0)
|
|
||||||
|
for (int x = WallSX1; x < WallSX2; x++)
|
||||||
{
|
{
|
||||||
for (x = WallSX1; x < WallSX2; x++)
|
lwall[x] = xs_RoundToInt(top / bot);
|
||||||
{
|
top += topstep;
|
||||||
if ((unsigned)lwall[x] >= (unsigned)walxrepeat)
|
bot += WallInvZstep;
|
||||||
{
|
|
||||||
lwall[x] = fix;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fix = walxrepeat - 1 - fix;
|
|
||||||
for (x = WallSX2-1; x >= WallSX1; x--)
|
|
||||||
{
|
|
||||||
if ((unsigned)lwall[x] >= (unsigned)walxrepeat)
|
|
||||||
{
|
|
||||||
lwall[x] = fix;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
PrepWallRoundFix(lwall, walxrepeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// pass = 0: when seg is first drawn
|
// pass = 0: when seg is first drawn
|
||||||
|
|
Loading…
Reference in a new issue