mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
Minimal wallmost changes
- Add comments - Fixed: When WallMost() finds a line entirely above the screen, it should set the most array to 0, not -1.
This commit is contained in:
parent
6f11a65893
commit
ac69ed3361
1 changed files with 18 additions and 19 deletions
|
@ -2670,53 +2670,51 @@ int OWallMost (short *mostbuf, double z, const FWallCoords *wallc)
|
||||||
s3 = globaldclip * wallc->sz1; s4 = globaldclip * wallc->sz2;
|
s3 = globaldclip * wallc->sz1; s4 = globaldclip * wallc->sz2;
|
||||||
bad = (z<s1)+((z<s2)<<1)+((z>s3)<<2)+((z>s4)<<3);
|
bad = (z<s1)+((z<s2)<<1)+((z>s3)<<2)+((z>s4)<<3);
|
||||||
|
|
||||||
#if 1
|
|
||||||
if ((bad&3) == 3)
|
if ((bad&3) == 3)
|
||||||
{
|
{ // entire line is above the screen
|
||||||
memset (&mostbuf[wallc->sx1], 0, (wallc->sx2 - wallc->sx1)*sizeof(mostbuf[0]));
|
memset (&mostbuf[wallc->sx1], 0, (wallc->sx2 - wallc->sx1)*sizeof(mostbuf[0]));
|
||||||
return bad;
|
return bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((bad&12) == 12)
|
if ((bad&12) == 12)
|
||||||
{
|
{ // entire line is below the screen
|
||||||
clearbufshort (&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight);
|
clearbufshort (&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight);
|
||||||
return bad;
|
return bad;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
ix1 = wallc->sx1; iy1 = wallc->sz1;
|
ix1 = wallc->sx1; iy1 = wallc->sz1;
|
||||||
ix2 = wallc->sx2; iy2 = wallc->sz2;
|
ix2 = wallc->sx2; iy2 = wallc->sz2;
|
||||||
#if 1
|
#if 1
|
||||||
if (bad & 3)
|
if (bad & 3)
|
||||||
{
|
{ // the line intersects the top of the screen
|
||||||
double t = (z-s1) / (s2-s1);
|
double t = (z-s1) / (s2-s1);
|
||||||
double inty = wallc->sz1 + t * (wallc->sz2 - wallc->sz1);
|
double inty = wallc->sz1 + t * (wallc->sz2 - wallc->sz1);
|
||||||
int xcross = xs_RoundToInt(wallc->sx1 + (t * wallc->sz2 * (wallc->sx2 - wallc->sx1)) / inty);
|
int xcross = xs_RoundToInt(wallc->sx1 + (t * wallc->sz2 * (wallc->sx2 - wallc->sx1)) / inty);
|
||||||
|
|
||||||
if ((bad & 3) == 2)
|
if ((bad & 3) == 2)
|
||||||
{
|
{ // the right side is above the screen
|
||||||
if (wallc->sx1 <= xcross) { iy2 = inty; ix2 = xcross; }
|
if (wallc->sx1 <= xcross) { iy2 = inty; ix2 = xcross; }
|
||||||
if (wallc->sx2 > xcross) memset (&mostbuf[xcross], 0, (wallc->sx2-xcross)*sizeof(mostbuf[0]));
|
if (wallc->sx2 > xcross) memset (&mostbuf[xcross], 0, (wallc->sx2-xcross)*sizeof(mostbuf[0]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{ // the left side is above the screen
|
||||||
if (xcross <= wallc->sx2) { iy1 = inty; ix1 = xcross; }
|
if (xcross <= wallc->sx2) { iy1 = inty; ix1 = xcross; }
|
||||||
if (xcross > wallc->sx1) memset (&mostbuf[wallc->sx1], 0, (xcross-wallc->sx1)*sizeof(mostbuf[0]));
|
if (xcross > wallc->sx1) memset (&mostbuf[wallc->sx1], 0, (xcross-wallc->sx1)*sizeof(mostbuf[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bad & 12)
|
if (bad & 12)
|
||||||
{
|
{ // the line intersects the bottom of the screen
|
||||||
double t = (z-s3) / (s4-s3);
|
double t = (z-s3) / (s4-s3);
|
||||||
double inty = wallc->sz1 + t * (wallc->sz2 - wallc->sz1);
|
double inty = wallc->sz1 + t * (wallc->sz2 - wallc->sz1);
|
||||||
int xcross = xs_RoundToInt(wallc->sx1 + (t * wallc->sz2 * (wallc->sx2 - wallc->sx1)) / inty);
|
int xcross = xs_RoundToInt(wallc->sx1 + (t * wallc->sz2 * (wallc->sx2 - wallc->sx1)) / inty);
|
||||||
|
|
||||||
if ((bad & 12) == 8)
|
if ((bad & 12) == 8)
|
||||||
{
|
{ // the right side is below the screen
|
||||||
if (wallc->sx1 <= xcross) { iy2 = inty; ix2 = xcross; }
|
if (wallc->sx1 <= xcross) { iy2 = inty; ix2 = xcross; }
|
||||||
if (wallc->sx2 > xcross) clearbufshort (&mostbuf[xcross], wallc->sx2 - xcross, viewheight);
|
if (wallc->sx2 > xcross) clearbufshort (&mostbuf[xcross], wallc->sx2 - xcross, viewheight);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{ // the left side is below the screen
|
||||||
if (xcross <= wallc->sx2) { iy1 = inty; ix1 = xcross; }
|
if (xcross <= wallc->sx2) { iy1 = inty; ix1 = xcross; }
|
||||||
if (xcross > wallc->sx1) clearbufshort (&mostbuf[wallc->sx1], xcross - wallc->sx1, viewheight);
|
if (xcross > wallc->sx1) clearbufshort (&mostbuf[wallc->sx1], xcross - wallc->sx1, viewheight);
|
||||||
}
|
}
|
||||||
|
@ -2779,6 +2777,7 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc)
|
||||||
int bad, ix1, ix2;
|
int bad, ix1, ix2;
|
||||||
double iy1, iy2;
|
double iy1, iy2;
|
||||||
|
|
||||||
|
// Get Z coordinates at both ends of the line
|
||||||
if (MirrorFlags & RF_XFLIP)
|
if (MirrorFlags & RF_XFLIP)
|
||||||
{
|
{
|
||||||
x = curline->v2->fX();
|
x = curline->v2->fX();
|
||||||
|
@ -2847,20 +2846,20 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc)
|
||||||
oz1 = z1; oz2 = z2;
|
oz1 = z1; oz2 = z2;
|
||||||
|
|
||||||
if ((bad&3) == 3)
|
if ((bad&3) == 3)
|
||||||
{
|
{ // The entire line is above the screen
|
||||||
memset (&mostbuf[ix1], -1, (ix2-ix1)*sizeof(mostbuf[0]));
|
memset (&mostbuf[ix1], 0, (ix2-ix1)*sizeof(mostbuf[0]));
|
||||||
return bad;
|
return bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((bad&12) == 12)
|
if ((bad&12) == 12)
|
||||||
{
|
{ // The entire line is below the screen
|
||||||
clearbufshort (&mostbuf[ix1], ix2-ix1, viewheight);
|
clearbufshort (&mostbuf[ix1], ix2-ix1, viewheight);
|
||||||
return bad;
|
return bad;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bad&3)
|
if (bad&3)
|
||||||
{
|
{ // The line intersects the top of the screen
|
||||||
//inty = intz / (globaluclip>>16)
|
//inty = intz / (globaluclip>>16)
|
||||||
double t = (oz1-s1) / (s2-s1+oz1-oz2);
|
double t = (oz1-s1) / (s2-s1+oz1-oz2);
|
||||||
double inty = wallc->sz1 + t * (wallc->sz2-wallc->sz1);
|
double inty = wallc->sz1 + t * (wallc->sz2-wallc->sz1);
|
||||||
|
@ -2872,19 +2871,19 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc)
|
||||||
//intz = z1 + mulscale30(z2-z1,t);
|
//intz = z1 + mulscale30(z2-z1,t);
|
||||||
|
|
||||||
if ((bad&3) == 2)
|
if ((bad&3) == 2)
|
||||||
{
|
{ // The right side of the line is above the screen
|
||||||
if (wallc->sx1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; }
|
if (wallc->sx1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; }
|
||||||
memset (&mostbuf[xcross], 0, (wallc->sx2-xcross)*sizeof(mostbuf[0]));
|
memset (&mostbuf[xcross], 0, (wallc->sx2-xcross)*sizeof(mostbuf[0]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{ // The left side of the line is above the screen
|
||||||
if (xcross <= wallc->sx2) { z1 = intz; iy1 = inty; ix1 = xcross; }
|
if (xcross <= wallc->sx2) { z1 = intz; iy1 = inty; ix1 = xcross; }
|
||||||
memset (&mostbuf[wallc->sx1], 0, (xcross-wallc->sx1)*sizeof(mostbuf[0]));
|
memset (&mostbuf[wallc->sx1], 0, (xcross-wallc->sx1)*sizeof(mostbuf[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bad&12)
|
if (bad&12)
|
||||||
{
|
{ // The line intersects the bottom of the screen
|
||||||
//inty = intz / (globaldclip>>16)
|
//inty = intz / (globaldclip>>16)
|
||||||
double t = (oz1-s3) / (s4-s3+oz1-oz2);
|
double t = (oz1-s3) / (s4-s3+oz1-oz2);
|
||||||
double inty = wallc->sz1 + t * (wallc->sz2-wallc->sz1);
|
double inty = wallc->sz1 + t * (wallc->sz2-wallc->sz1);
|
||||||
|
@ -2896,12 +2895,12 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc)
|
||||||
//intz = z1 + mulscale30(z2-z1,t);
|
//intz = z1 + mulscale30(z2-z1,t);
|
||||||
|
|
||||||
if ((bad&12) == 8)
|
if ((bad&12) == 8)
|
||||||
{
|
{ // The right side of the line is below the screen
|
||||||
if (wallc->sx1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; }
|
if (wallc->sx1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; }
|
||||||
if (wallc->sx2 > xcross) clearbufshort (&mostbuf[xcross], wallc->sx2-xcross, viewheight);
|
if (wallc->sx2 > xcross) clearbufshort (&mostbuf[xcross], wallc->sx2-xcross, viewheight);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{ // The left side of the line is below the screen
|
||||||
if (xcross <= wallc->sx2) { z1 = intz; iy1 = inty; ix1 = xcross; }
|
if (xcross <= wallc->sx2) { z1 = intz; iy1 = inty; ix1 = xcross; }
|
||||||
if (xcross > wallc->sx1) clearbufshort (&mostbuf[wallc->sx1], xcross-wallc->sx1, viewheight);
|
if (xcross > wallc->sx1) clearbufshort (&mostbuf[wallc->sx1], xcross-wallc->sx1, viewheight);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue