mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-24 04:41:53 +00:00
Merge branch 'master' of https://github.com/rheit/zdoom
This commit is contained in:
commit
1b55c17379
22 changed files with 629 additions and 2194 deletions
|
@ -956,7 +956,6 @@ add_executable( zdoom WIN32
|
|||
r_drawt.cpp
|
||||
r_main.cpp
|
||||
r_plane.cpp
|
||||
r_polymost.cpp
|
||||
r_segs.cpp
|
||||
r_sky.cpp
|
||||
r_things.cpp
|
||||
|
|
|
@ -108,10 +108,6 @@
|
|||
#include "r_renderer.h"
|
||||
#include "p_local.h"
|
||||
|
||||
#ifdef USE_POLYMOST
|
||||
#include "r_polymost.h"
|
||||
#endif
|
||||
|
||||
EXTERN_CVAR(Bool, hud_althud)
|
||||
void DrawHUD();
|
||||
|
||||
|
@ -186,9 +182,6 @@ CUSTOM_CVAR (Int, fraglimit, 0, CVAR_SERVERINFO)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef USE_POLYMOST
|
||||
CVAR(Bool, testpolymost, false, 0)
|
||||
#endif
|
||||
CVAR (Float, timelimit, 0.f, CVAR_SERVERINFO);
|
||||
CVAR (Int, wipetype, 1, CVAR_ARCHIVE);
|
||||
CVAR (Int, snd_drawoutput, 0, 0);
|
||||
|
@ -282,10 +275,6 @@ void D_ProcessEvents (void)
|
|||
continue; // console ate the event
|
||||
if (M_Responder (ev))
|
||||
continue; // menu ate the event
|
||||
#ifdef USE_POLYMOST
|
||||
if (testpolymost)
|
||||
Polymost_Responder (ev);
|
||||
#endif
|
||||
G_Responder (ev);
|
||||
}
|
||||
}
|
||||
|
@ -307,9 +296,6 @@ void D_PostEvent (const event_t *ev)
|
|||
}
|
||||
events[eventhead] = *ev;
|
||||
if (ev->type == EV_Mouse && !paused && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling
|
||||
#ifdef USE_POLYMOST
|
||||
&& !testpolymost
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (Button_Mlook.bDown || freelook)
|
||||
|
@ -743,15 +729,7 @@ void D_Display ()
|
|||
|
||||
hw2d = false;
|
||||
|
||||
#ifdef USE_POLYMOST
|
||||
if (testpolymost)
|
||||
{
|
||||
drawpolymosttest();
|
||||
C_DrawConsole(hw2d);
|
||||
M_Drawer();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
{
|
||||
unsigned int nowtime = I_FPSTime();
|
||||
TexMan.UpdateAnimations(nowtime);
|
||||
|
|
|
@ -70,6 +70,7 @@ CVAR (Bool, hud_showmonsters, true,CVAR_ARCHIVE); // Show monster stats on HUD
|
|||
CVAR (Bool, hud_showitems, false,CVAR_ARCHIVE); // Show item stats on HUD
|
||||
CVAR (Bool, hud_showstats, false, CVAR_ARCHIVE); // for stamina and accuracy.
|
||||
CVAR (Bool, hud_showscore, false, CVAR_ARCHIVE); // for user maintained score
|
||||
CVAR (Bool, hud_showweapons, true, CVAR_ARCHIVE); // Show weapons collected
|
||||
CVAR (Int , hud_showtime, 0, CVAR_ARCHIVE); // Show time on HUD
|
||||
CVAR (Int , hud_timecolor, CR_GOLD,CVAR_ARCHIVE); // Color of in-game time on HUD
|
||||
|
||||
|
@ -972,7 +973,7 @@ void DrawHUD()
|
|||
CPlayer->mo->FindInventory<AHexenArmor>(), 5, hudheight-20);
|
||||
i=DrawKeys(CPlayer, hudwidth-4, hudheight-10);
|
||||
i=DrawAmmo(CPlayer, hudwidth-5, i);
|
||||
DrawWeapons(CPlayer, hudwidth-5, i);
|
||||
if (hud_showweapons) DrawWeapons(CPlayer, hudwidth - 5, i);
|
||||
DrawInventory(CPlayer, 144, hudheight-28);
|
||||
if (CPlayer->camera && CPlayer->camera->player)
|
||||
{
|
||||
|
|
|
@ -54,19 +54,8 @@ int FBoundingBox::BoxOnLineSide (const line_t *ld) const
|
|||
int p1;
|
||||
int p2;
|
||||
|
||||
switch (ld->slopetype)
|
||||
{
|
||||
case ST_HORIZONTAL:
|
||||
p1 = m_Box[BOXTOP] > ld->v1->y;
|
||||
p2 = m_Box[BOXBOTTOM] > ld->v1->y;
|
||||
if (ld->dx < 0)
|
||||
{
|
||||
p1 ^= 1;
|
||||
p2 ^= 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case ST_VERTICAL:
|
||||
if (ld->dx == 0)
|
||||
{ // ST_VERTICAL
|
||||
p1 = m_Box[BOXRIGHT] < ld->v1->x;
|
||||
p2 = m_Box[BOXLEFT] < ld->v1->x;
|
||||
if (ld->dy < 0)
|
||||
|
@ -74,18 +63,26 @@ int FBoundingBox::BoxOnLineSide (const line_t *ld) const
|
|||
p1 ^= 1;
|
||||
p2 ^= 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case ST_POSITIVE:
|
||||
}
|
||||
else if (ld->dy == 0)
|
||||
{ // ST_HORIZONTAL:
|
||||
p1 = m_Box[BOXTOP] > ld->v1->y;
|
||||
p2 = m_Box[BOXBOTTOM] > ld->v1->y;
|
||||
if (ld->dx < 0)
|
||||
{
|
||||
p1 ^= 1;
|
||||
p2 ^= 1;
|
||||
}
|
||||
}
|
||||
else if ((ld->dy ^ ld->dx) >= 0)
|
||||
{ // ST_POSITIVE:
|
||||
p1 = P_PointOnLineSide (m_Box[BOXLEFT], m_Box[BOXTOP], ld);
|
||||
p2 = P_PointOnLineSide (m_Box[BOXRIGHT], m_Box[BOXBOTTOM], ld);
|
||||
break;
|
||||
|
||||
case ST_NEGATIVE:
|
||||
default: // Just to assure GCC that p1 and p2 really do get initialized
|
||||
}
|
||||
else
|
||||
{ // ST_NEGATIVE:
|
||||
p1 = P_PointOnLineSide (m_Box[BOXRIGHT], m_Box[BOXTOP], ld);
|
||||
p2 = P_PointOnLineSide (m_Box[BOXLEFT], m_Box[BOXBOTTOM], ld);
|
||||
break;
|
||||
}
|
||||
|
||||
return (p1 == p2) ? p1 : -1;
|
||||
|
|
|
@ -1677,7 +1677,7 @@ void FBehavior::SerializeVarSet (FArchive &arc, SDWORD *vars, int max)
|
|||
|
||||
static int ParseLocalArrayChunk(void *chunk, ACSLocalArrays *arrays, int offset)
|
||||
{
|
||||
unsigned count = (LittleShort(((unsigned *)chunk)[1]) - 2) / 4;
|
||||
unsigned count = (LittleShort(static_cast<unsigned short>(((unsigned *)chunk)[1]) - 2)) / 4;
|
||||
int *sizes = (int *)((BYTE *)chunk + 10);
|
||||
arrays->Count = count;
|
||||
if (count > 0)
|
||||
|
|
|
@ -728,15 +728,14 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (sprites[i].cstat & (16|32|32768)) continue;
|
||||
if (sprites[i].cstat & 32768) continue;
|
||||
if (sprites[i].xrepeat == 0 || sprites[i].yrepeat == 0) continue;
|
||||
|
||||
mapthings[count].type = 9988;
|
||||
mapthings[count].args[0] = sprites[i].picnum & 255;
|
||||
mapthings[count].args[1] = sprites[i].picnum >> 8;
|
||||
mapthings[count].args[0] = sprites[i].picnum;
|
||||
mapthings[count].args[2] = sprites[i].xrepeat;
|
||||
mapthings[count].args[3] = sprites[i].yrepeat;
|
||||
mapthings[count].args[4] = (sprites[i].cstat & 14) | ((sprites[i].cstat >> 9) & 1);
|
||||
mapthings[count].args[4] = sprites[i].cstat;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
@ -874,22 +873,22 @@ void ACustomSprite::BeginPlay ()
|
|||
char name[9];
|
||||
Super::BeginPlay ();
|
||||
|
||||
mysnprintf (name, countof(name), "BTIL%04d", (args[0] + args[1]*256) & 0xffff);
|
||||
mysnprintf (name, countof(name), "BTIL%04d", args[0] & 0xffff);
|
||||
picnum = TexMan.GetTexture (name, FTexture::TEX_Build);
|
||||
|
||||
scaleX = args[2] * (FRACUNIT/64);
|
||||
scaleY = args[3] * (FRACUNIT/64);
|
||||
|
||||
if (args[4] & 2)
|
||||
int cstat = args[4];
|
||||
if (cstat & 2)
|
||||
{
|
||||
RenderStyle = STYLE_Translucent;
|
||||
if (args[4] & 1)
|
||||
alpha = TRANSLUC66;
|
||||
else
|
||||
alpha = TRANSLUC33;
|
||||
alpha = (cstat & 512) ? TRANSLUC66 : TRANSLUC33;
|
||||
}
|
||||
if (args[4] & 4)
|
||||
if (cstat & 4)
|
||||
renderflags |= RF_XFLIP;
|
||||
if (args[4] & 8)
|
||||
if (cstat & 8)
|
||||
renderflags |= RF_YFLIP;
|
||||
// set face/wall/floor flags
|
||||
renderflags |= ((cstat >> 4) & 3) << 12;
|
||||
}
|
||||
|
|
|
@ -2244,24 +2244,8 @@ void FSlide::HitSlideLine (line_t* ld)
|
|||
slidemo->z <= slidemo->floorz &&
|
||||
P_GetFriction (slidemo, NULL) > ORIG_FRICTION;
|
||||
|
||||
if (ld->slopetype == ST_HORIZONTAL)
|
||||
{
|
||||
if (icyfloor && (abs(tmymove) > abs(tmxmove)))
|
||||
{
|
||||
tmxmove /= 2; // absorb half the velocity
|
||||
tmymove = -tmymove/2;
|
||||
if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING))
|
||||
{
|
||||
S_Sound (slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff!
|
||||
}
|
||||
}
|
||||
else
|
||||
tmymove = 0; // no more movement in the Y direction
|
||||
return;
|
||||
}
|
||||
|
||||
if (ld->slopetype == ST_VERTICAL)
|
||||
{
|
||||
if (ld->dx == 0)
|
||||
{ // ST_VERTICAL
|
||||
if (icyfloor && (abs(tmxmove) > abs(tmymove)))
|
||||
{
|
||||
tmxmove = -tmxmove/2; // absorb half the velocity
|
||||
|
@ -2276,6 +2260,22 @@ void FSlide::HitSlideLine (line_t* ld)
|
|||
return;
|
||||
}
|
||||
|
||||
if (ld->dy == 0)
|
||||
{ // ST_HORIZONTAL
|
||||
if (icyfloor && (abs(tmymove) > abs(tmxmove)))
|
||||
{
|
||||
tmxmove /= 2; // absorb half the velocity
|
||||
tmymove = -tmymove/2;
|
||||
if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING))
|
||||
{
|
||||
S_Sound (slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff!
|
||||
}
|
||||
}
|
||||
else
|
||||
tmymove = 0; // no more movement in the Y direction
|
||||
return;
|
||||
}
|
||||
|
||||
// The wall is angled. Bounce if the angle of approach is // phares
|
||||
// less than 45 degrees. // phares
|
||||
|
||||
|
|
|
@ -1888,13 +1888,6 @@ void P_AdjustLine (line_t *ld)
|
|||
ld->dx = v2->x - v1->x;
|
||||
ld->dy = v2->y - v1->y;
|
||||
|
||||
if (ld->dx == 0)
|
||||
ld->slopetype = ST_VERTICAL;
|
||||
else if (ld->dy == 0)
|
||||
ld->slopetype = ST_HORIZONTAL;
|
||||
else
|
||||
ld->slopetype = ((ld->dy ^ ld->dx) >= 0) ? ST_POSITIVE : ST_NEGATIVE;
|
||||
|
||||
if (v1->x < v2->x)
|
||||
{
|
||||
ld->bbox[BOXLEFT] = v1->x;
|
||||
|
|
|
@ -950,18 +950,6 @@ void FPolyObj::UpdateBBox ()
|
|||
// Update the line's slopetype
|
||||
line->dx = line->v2->x - line->v1->x;
|
||||
line->dy = line->v2->y - line->v1->y;
|
||||
if (!line->dx)
|
||||
{
|
||||
line->slopetype = ST_VERTICAL;
|
||||
}
|
||||
else if (!line->dy)
|
||||
{
|
||||
line->slopetype = ST_HORIZONTAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
line->slopetype = ((line->dy ^ line->dx) >= 0) ? ST_POSITIVE : ST_NEGATIVE;
|
||||
}
|
||||
}
|
||||
CalcCenter();
|
||||
}
|
||||
|
|
238
src/r_bsp.cpp
238
src/r_bsp.cpp
|
@ -51,13 +51,12 @@
|
|||
#include "doomstat.h"
|
||||
#include "r_state.h"
|
||||
#include "r_bsp.h"
|
||||
#include "r_segs.h"
|
||||
#include "v_palette.h"
|
||||
#include "r_sky.h"
|
||||
#include "po_man.h"
|
||||
#include "r_data/colormaps.h"
|
||||
|
||||
int WallMost (short *mostbuf, const secplane_t &plane);
|
||||
|
||||
seg_t* curline;
|
||||
side_t* sidedef;
|
||||
line_t* linedef;
|
||||
|
@ -92,18 +91,8 @@ drawseg_t* ds_p;
|
|||
size_t FirstInterestingDrawseg;
|
||||
TArray<size_t> InterestingDrawsegs;
|
||||
|
||||
fixed_t WallTX1, WallTX2; // x coords at left, right of wall in view space
|
||||
fixed_t WallTY1, WallTY2; // y coords at left, right of wall in view space
|
||||
|
||||
fixed_t WallCX1, WallCX2; // x coords at left, right of wall in camera space
|
||||
fixed_t WallCY1, WallCY2; // y coords at left, right of wall in camera space
|
||||
|
||||
int WallSX1, WallSX2; // x coords at left, right of wall in screen space
|
||||
fixed_t WallSZ1, WallSZ2; // depth at left, right of wall in screen space
|
||||
|
||||
float WallDepthOrg, WallDepthScale;
|
||||
float WallUoverZorg, WallUoverZstep;
|
||||
float WallInvZorg, WallInvZstep;
|
||||
FWallCoords WallC;
|
||||
FWallTmapVals WallT;
|
||||
|
||||
static BYTE FakeSide;
|
||||
|
||||
|
@ -419,7 +408,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
|
|||
rw_frontcz2 <= s->floorplane.ZatPoint (curline->v2->x, curline->v2->y))
|
||||
{
|
||||
// Check that the window is actually visible
|
||||
for (int z = WallSX1; z < WallSX2; ++z)
|
||||
for (int z = WallC.SX1; z < WallC.SX2; ++z)
|
||||
{
|
||||
if (floorclip[z] > ceilingclip[z])
|
||||
{
|
||||
|
@ -549,66 +538,15 @@ void R_AddLine (seg_t *line)
|
|||
if (DMulScale32 (ty1, tx1-tx2, tx1, ty2-ty1) >= 0)
|
||||
return;
|
||||
|
||||
WallTX1 = DMulScale20 (tx1, viewsin, -ty1, viewcos);
|
||||
WallTX2 = DMulScale20 (tx2, viewsin, -ty2, viewcos);
|
||||
|
||||
WallTY1 = DMulScale20 (tx1, viewtancos, ty1, viewtansin);
|
||||
WallTY2 = DMulScale20 (tx2, viewtancos, ty2, viewtansin);
|
||||
|
||||
if (MirrorFlags & RF_XFLIP)
|
||||
{
|
||||
int t = 256-WallTX1;
|
||||
WallTX1 = 256-WallTX2;
|
||||
WallTX2 = t;
|
||||
swapvalues (WallTY1, WallTY2);
|
||||
}
|
||||
|
||||
if (WallTX1 >= -WallTY1)
|
||||
{
|
||||
if (WallTX1 > WallTY1) return; // left edge is off the right side
|
||||
if (WallTY1 == 0) return;
|
||||
WallSX1 = (centerxfrac + Scale (WallTX1, centerxfrac, WallTY1)) >> FRACBITS;
|
||||
if (WallTX1 >= 0) WallSX1 = MIN (viewwidth, WallSX1+1); // fix for signed divide
|
||||
WallSZ1 = WallTY1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WallTX2 < -WallTY2) return; // wall is off the left side
|
||||
fixed_t den = WallTX1 - WallTX2 - WallTY2 + WallTY1;
|
||||
if (den == 0) return;
|
||||
WallSX1 = 0;
|
||||
WallSZ1 = WallTY1 + Scale (WallTY2 - WallTY1, WallTX1 + WallTY1, den);
|
||||
}
|
||||
|
||||
if (WallSZ1 < 32)
|
||||
if (WallC.Init(tx1, ty1, tx2, ty2, 32))
|
||||
return;
|
||||
|
||||
if (WallTX2 <= WallTY2)
|
||||
{
|
||||
if (WallTX2 < -WallTY2) return; // right edge is off the left side
|
||||
if (WallTY2 == 0) return;
|
||||
WallSX2 = (centerxfrac + Scale (WallTX2, centerxfrac, WallTY2)) >> FRACBITS;
|
||||
if (WallTX2 >= 0) WallSX2 = MIN (viewwidth, WallSX2+1); // fix for signed divide
|
||||
WallSZ2 = WallTY2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WallTX1 > WallTY1) return; // wall is off the right side
|
||||
fixed_t den = WallTY2 - WallTY1 - WallTX2 + WallTX1;
|
||||
if (den == 0) return;
|
||||
WallSX2 = viewwidth;
|
||||
WallSZ2 = WallTY1 + Scale (WallTY2 - WallTY1, WallTX1 - WallTY1, den);
|
||||
}
|
||||
|
||||
if (WallSZ2 < 32 || WallSX2 <= WallSX1)
|
||||
return;
|
||||
|
||||
if (WallSX1 > WindowRight || WallSX2 < WindowLeft)
|
||||
if (WallC.SX1 > WindowRight || WallC.SX2 < WindowLeft)
|
||||
return;
|
||||
|
||||
if (line->linedef == NULL)
|
||||
{
|
||||
if (R_CheckClipWallSegment (WallSX1, WallSX2))
|
||||
if (R_CheckClipWallSegment (WallC.SX1, WallC.SX2))
|
||||
{
|
||||
InSubsector->flags |= SSECF_DRAWN;
|
||||
}
|
||||
|
@ -622,20 +560,7 @@ void R_AddLine (seg_t *line)
|
|||
|
||||
if ((v1 == line->v1 && v2 == line->v2) || (v2 == line->v1 && v1 == line->v2))
|
||||
{ // The seg is the entire wall.
|
||||
if (MirrorFlags & RF_XFLIP)
|
||||
{
|
||||
WallUoverZorg = (float)WallTX2 * WallTMapScale;
|
||||
WallUoverZstep = (float)(-WallTY2) * 32.f;
|
||||
WallInvZorg = (float)(WallTX2 - WallTX1) * WallTMapScale;
|
||||
WallInvZstep = (float)(WallTY1 - WallTY2) * 32.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
WallUoverZorg = (float)WallTX1 * WallTMapScale;
|
||||
WallUoverZstep = (float)(-WallTY1) * 32.f;
|
||||
WallInvZorg = (float)(WallTX1 - WallTX2) * WallTMapScale;
|
||||
WallInvZstep = (float)(WallTY2 - WallTY1) * 32.f;
|
||||
}
|
||||
WallT.InitFromWallCoords(&WallC);
|
||||
}
|
||||
else
|
||||
{ // The seg is only part of the wall.
|
||||
|
@ -643,29 +568,8 @@ void R_AddLine (seg_t *line)
|
|||
{
|
||||
swapvalues (v1, v2);
|
||||
}
|
||||
tx1 = v1->x - viewx;
|
||||
tx2 = v2->x - viewx;
|
||||
ty1 = v1->y - viewy;
|
||||
ty2 = v2->y - viewy;
|
||||
|
||||
fixed_t fullx1 = DMulScale20 (tx1, viewsin, -ty1, viewcos);
|
||||
fixed_t fullx2 = DMulScale20 (tx2, viewsin, -ty2, viewcos);
|
||||
fixed_t fully1 = DMulScale20 (tx1, viewtancos, ty1, viewtansin);
|
||||
fixed_t fully2 = DMulScale20 (tx2, viewtancos, ty2, viewtansin);
|
||||
|
||||
if (MirrorFlags & RF_XFLIP)
|
||||
{
|
||||
fullx1 = -fullx1;
|
||||
fullx2 = -fullx2;
|
||||
}
|
||||
|
||||
WallUoverZorg = (float)fullx1 * WallTMapScale;
|
||||
WallUoverZstep = (float)(-fully1) * 32.f;
|
||||
WallInvZorg = (float)(fullx1 - fullx2) * WallTMapScale;
|
||||
WallInvZstep = (float)(fully2 - fully1) * 32.f;
|
||||
WallT.InitFromLine(v1->x - viewx, v1->y - viewy, v2->x - viewx, v2->y - viewy);
|
||||
}
|
||||
WallDepthScale = WallInvZstep * WallTMapScale2;
|
||||
WallDepthOrg = -WallUoverZstep * WallTMapScale2;
|
||||
|
||||
if (!(fake3D & FAKE3D_FAKEBACK))
|
||||
{
|
||||
|
@ -703,12 +607,12 @@ void R_AddLine (seg_t *line)
|
|||
if (rw_frontcz1 > rw_backcz1 || rw_frontcz2 > rw_backcz2)
|
||||
{
|
||||
rw_havehigh = true;
|
||||
WallMost (wallupper, backsector->ceilingplane);
|
||||
WallMost (wallupper, backsector->ceilingplane, &WallC);
|
||||
}
|
||||
if (rw_frontfz1 < rw_backfz1 || rw_frontfz2 < rw_backfz2)
|
||||
{
|
||||
rw_havelow = true;
|
||||
WallMost (walllower, backsector->floorplane);
|
||||
WallMost (walllower, backsector->floorplane, &WallC);
|
||||
}
|
||||
|
||||
// Closed door.
|
||||
|
@ -791,7 +695,7 @@ void R_AddLine (seg_t *line)
|
|||
// mark their subsectors as visible for automap texturing.
|
||||
if (hasglnodes && !(InSubsector->flags & SSECF_DRAWN))
|
||||
{
|
||||
if (R_CheckClipWallSegment(WallSX1, WallSX2))
|
||||
if (R_CheckClipWallSegment(WallC.SX1, WallC.SX2))
|
||||
{
|
||||
InSubsector->flags |= SSECF_DRAWN;
|
||||
}
|
||||
|
@ -805,13 +709,13 @@ void R_AddLine (seg_t *line)
|
|||
if (line->linedef->special == Line_Horizon)
|
||||
{
|
||||
// Be aware: Line_Horizon does not work properly with sloped planes
|
||||
clearbufshort (walltop+WallSX1, WallSX2 - WallSX1, centery);
|
||||
clearbufshort (wallbottom+WallSX1, WallSX2 - WallSX1, centery);
|
||||
clearbufshort (walltop+WallC.SX1, WallC.SX2 - WallC.SX1, centery);
|
||||
clearbufshort (wallbottom+WallC.SX1, WallC.SX2 - WallC.SX1, centery);
|
||||
}
|
||||
else
|
||||
{
|
||||
rw_ceilstat = WallMost (walltop, frontsector->ceilingplane);
|
||||
rw_floorstat = WallMost (wallbottom, frontsector->floorplane);
|
||||
rw_ceilstat = WallMost (walltop, frontsector->ceilingplane, &WallC);
|
||||
rw_floorstat = WallMost (wallbottom, frontsector->floorplane, &WallC);
|
||||
|
||||
// [RH] treat off-screen walls as solid
|
||||
#if 0 // Maybe later...
|
||||
|
@ -831,12 +735,120 @@ void R_AddLine (seg_t *line)
|
|||
#endif
|
||||
}
|
||||
|
||||
if (R_ClipWallSegment (WallSX1, WallSX2, solid))
|
||||
if (R_ClipWallSegment (WallC.SX1, WallC.SX2, solid))
|
||||
{
|
||||
InSubsector->flags |= SSECF_DRAWN;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// FWallCoords :: Init
|
||||
//
|
||||
// Transform and clip coordinates. Returns true if it was clipped away
|
||||
//
|
||||
bool FWallCoords::Init(int x1, int y1, int x2, int y2, int too_close)
|
||||
{
|
||||
TX1 = DMulScale20(x1, viewsin, -y1, viewcos);
|
||||
TX2 = DMulScale20(x2, viewsin, -y2, viewcos);
|
||||
|
||||
TY1 = DMulScale20(x1, viewtancos, y1, viewtansin);
|
||||
TY2 = DMulScale20(x2, viewtancos, y2, viewtansin);
|
||||
|
||||
if (MirrorFlags & RF_XFLIP)
|
||||
{
|
||||
int t = 256 - TX1;
|
||||
TX1 = 256 - TX2;
|
||||
TX2 = t;
|
||||
swapvalues(TY1, TY2);
|
||||
}
|
||||
|
||||
if (TX1 >= -TY1)
|
||||
{
|
||||
if (TX1 > TY1) return true; // left edge is off the right side
|
||||
if (TY1 == 0) return true;
|
||||
SX1 = (centerxfrac + Scale(TX1, centerxfrac, TY1)) >> FRACBITS;
|
||||
if (TX1 >= 0) SX1 = MIN(viewwidth, SX1+1); // fix for signed divide
|
||||
SZ1 = TY1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TX2 < -TY2) return true; // wall is off the left side
|
||||
fixed_t den = TX1 - TX2 - TY2 + TY1;
|
||||
if (den == 0) return true;
|
||||
SX1 = 0;
|
||||
SZ1 = TY1 + Scale(TY2 - TY1, TX1 + TY1, den);
|
||||
}
|
||||
|
||||
if (SZ1 < too_close)
|
||||
return true;
|
||||
|
||||
if (TX2 <= TY2)
|
||||
{
|
||||
if (TX2 < -TY2) return true; // right edge is off the left side
|
||||
if (TY2 == 0) return true;
|
||||
SX2 = (centerxfrac + Scale(TX2, centerxfrac, TY2)) >> FRACBITS;
|
||||
if (TX2 >= 0) SX2 = MIN(viewwidth, SX2+1); // fix for signed divide
|
||||
SZ2 = TY2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TX1 > TY1) return true; // wall is off the right side
|
||||
fixed_t den = TY2 - TY1 - TX2 + TX1;
|
||||
if (den == 0) return true;
|
||||
SX2 = viewwidth;
|
||||
SZ2 = TY1 + Scale(TY2 - TY1, TX1 - TY1, den);
|
||||
}
|
||||
|
||||
if (SZ2 < too_close || SX2 <= SX1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void FWallTmapVals::InitFromWallCoords(const FWallCoords *wallc)
|
||||
{
|
||||
if (MirrorFlags & RF_XFLIP)
|
||||
{
|
||||
UoverZorg = (float)wallc->TX2 * WallTMapScale;
|
||||
UoverZstep = (float)(-wallc->TY2) * 32.f;
|
||||
InvZorg = (float)(wallc->TX2 - wallc->TX1) * WallTMapScale;
|
||||
InvZstep = (float)(wallc->TY1 - wallc->TY2) * 32.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
UoverZorg = (float)wallc->TX1 * WallTMapScale;
|
||||
UoverZstep = (float)(-wallc->TY1) * 32.f;
|
||||
InvZorg = (float)(wallc->TX1 - wallc->TX2) * WallTMapScale;
|
||||
InvZstep = (float)(wallc->TY2 - wallc->TY1) * 32.f;
|
||||
}
|
||||
InitDepth();
|
||||
}
|
||||
|
||||
void FWallTmapVals::InitFromLine(int tx1, int ty1, int tx2, int ty2)
|
||||
{ // Coordinates should have already had viewx,viewy subtracted
|
||||
fixed_t fullx1 = DMulScale20 (tx1, viewsin, -ty1, viewcos);
|
||||
fixed_t fullx2 = DMulScale20 (tx2, viewsin, -ty2, viewcos);
|
||||
fixed_t fully1 = DMulScale20 (tx1, viewtancos, ty1, viewtansin);
|
||||
fixed_t fully2 = DMulScale20 (tx2, viewtancos, ty2, viewtansin);
|
||||
|
||||
if (MirrorFlags & RF_XFLIP)
|
||||
{
|
||||
fullx1 = -fullx1;
|
||||
fullx2 = -fullx2;
|
||||
}
|
||||
|
||||
UoverZorg = (float)fullx1 * WallTMapScale;
|
||||
UoverZstep = (float)(-fully1) * 32.f;
|
||||
InvZorg = (float)(fullx1 - fullx2) * WallTMapScale;
|
||||
InvZstep = (float)(fully2 - fully1) * 32.f;
|
||||
InitDepth();
|
||||
}
|
||||
|
||||
void FWallTmapVals::InitDepth()
|
||||
{
|
||||
DepthScale = InvZstep * WallTMapScale2;
|
||||
DepthOrg = -UoverZstep * WallTMapScale2;
|
||||
}
|
||||
|
||||
//
|
||||
// R_CheckBBox
|
||||
|
|
36
src/r_bsp.h
36
src/r_bsp.h
|
@ -26,6 +26,39 @@
|
|||
#include "tarray.h"
|
||||
#include <stddef.h>
|
||||
|
||||
// The 3072 below is just an arbitrary value picked to avoid
|
||||
// drawing lines the player is too close to that would overflow
|
||||
// the texture calculations.
|
||||
#define TOO_CLOSE_Z 3072
|
||||
|
||||
struct FWallCoords
|
||||
{
|
||||
fixed_t TX1, TX2; // x coords at left, right of wall in view space
|
||||
fixed_t TY1, TY2; // y coords at left, right of wall in view space
|
||||
|
||||
fixed_t CX1, CX2; // x coords at left, right of wall in camera space
|
||||
fixed_t CY1, CY2; // y coords at left, right of wall in camera space
|
||||
|
||||
int SX1, SX2; // x coords at left, right of wall in screen space
|
||||
fixed_t SZ1, SZ2; // depth at left, right of wall in screen space
|
||||
|
||||
bool Init(int x1, int y1, int x2, int y2, int too_close);
|
||||
};
|
||||
|
||||
struct FWallTmapVals
|
||||
{
|
||||
float DepthOrg, DepthScale;
|
||||
float UoverZorg, UoverZstep;
|
||||
float InvZorg, InvZstep;
|
||||
|
||||
void InitFromWallCoords(const FWallCoords *wallc);
|
||||
void InitFromLine(int x1, int y1, int x2, int y2);
|
||||
void InitDepth();
|
||||
};
|
||||
|
||||
extern FWallCoords WallC;
|
||||
extern FWallTmapVals WallT;
|
||||
|
||||
enum
|
||||
{
|
||||
FAKED_Center,
|
||||
|
@ -33,7 +66,6 @@ enum
|
|||
FAKED_AboveCeiling
|
||||
};
|
||||
|
||||
|
||||
struct drawseg_t
|
||||
{
|
||||
seg_t* curline;
|
||||
|
@ -58,7 +90,7 @@ struct drawseg_t
|
|||
int fake; // ident fake drawseg, don't draw and clip sprites
|
||||
// backups
|
||||
ptrdiff_t bkup; // sprtopclip backup, for mid and fake textures
|
||||
float WallUoverZorg, WallUoverZstep, WallInvZorg, WallInvZstep, WallDepthScale, WallDepthOrg;
|
||||
FWallTmapVals tmapvals;
|
||||
};
|
||||
|
||||
|
||||
|
|
13
src/r_defs.h
13
src/r_defs.h
|
@ -971,18 +971,6 @@ struct side_t
|
|||
|
||||
FArchive &operator<< (FArchive &arc, side_t::part &p);
|
||||
|
||||
//
|
||||
// Move clipping aid for LineDefs.
|
||||
//
|
||||
enum slopetype_t
|
||||
{
|
||||
ST_HORIZONTAL,
|
||||
ST_VERTICAL,
|
||||
ST_POSITIVE,
|
||||
ST_NEGATIVE
|
||||
};
|
||||
|
||||
|
||||
struct line_t
|
||||
{
|
||||
vertex_t *v1, *v2; // vertices, from v1 to v2
|
||||
|
@ -997,7 +985,6 @@ struct line_t
|
|||
side_t *sidedef[2];
|
||||
//DWORD sidenum[2]; // sidenum[1] will be NO_SIDE if one sided
|
||||
fixed_t bbox[4]; // bounding box, for the extent of the LineDef.
|
||||
slopetype_t slopetype; // To aid move clipping.
|
||||
sector_t *frontsector, *backsector;
|
||||
int validcount; // if == validcount, already checked
|
||||
int locknumber; // [Dusk] lock number for special
|
||||
|
|
|
@ -72,8 +72,6 @@
|
|||
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
||||
|
||||
void R_SpanInitData ();
|
||||
void RP_RenderBSPNode (void *node);
|
||||
bool RP_SetupFrame (bool backside);
|
||||
void R_DeinitSprites();
|
||||
|
||||
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
|
||||
|
@ -94,14 +92,12 @@ extern "C" int fuzzviewheight;
|
|||
static float CurrentVisibility = 8.f;
|
||||
static fixed_t MaxVisForWall;
|
||||
static fixed_t MaxVisForFloor;
|
||||
static bool polyclipped;
|
||||
extern bool r_showviewer;
|
||||
bool r_dontmaplines;
|
||||
|
||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||
|
||||
CVAR (String, r_viewsize, "", CVAR_NOSET)
|
||||
CVAR (Int, r_polymost, 0, 0)
|
||||
CVAR (Bool, r_shadercolormaps, true, CVAR_ARCHIVE)
|
||||
|
||||
fixed_t r_BaseVisibility;
|
||||
|
@ -612,14 +608,6 @@ void R_SetupFreelook()
|
|||
}
|
||||
}
|
||||
|
||||
void R_SetupPolymost()
|
||||
{
|
||||
if (r_polymost)
|
||||
{
|
||||
polyclipped = RP_SetupFrame (false);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_EnterMirror
|
||||
|
@ -812,11 +800,8 @@ void R_RenderActorView (AActor *actor, bool dontmaplines)
|
|||
}
|
||||
// Link the polyobjects right before drawing the scene to reduce the amounts of calls to this function
|
||||
PO_LinkToSubsectors();
|
||||
if (r_polymost < 2)
|
||||
{
|
||||
R_RenderBSPNode (nodes + numnodes - 1); // The head node is the last node output.
|
||||
R_3D_ResetClip(); // reset clips (floor/ceiling)
|
||||
}
|
||||
R_RenderBSPNode (nodes + numnodes - 1); // The head node is the last node output.
|
||||
R_3D_ResetClip(); // reset clips (floor/ceiling)
|
||||
camera->renderflags = savedflags;
|
||||
WallCycles.Unclock();
|
||||
|
||||
|
@ -843,16 +828,6 @@ void R_RenderActorView (AActor *actor, bool dontmaplines)
|
|||
MaskedCycles.Unclock();
|
||||
|
||||
NetUpdate ();
|
||||
|
||||
if (r_polymost)
|
||||
{
|
||||
RP_RenderBSPNode (nodes + numnodes - 1);
|
||||
if (polyclipped)
|
||||
{
|
||||
RP_SetupFrame (true);
|
||||
RP_RenderBSPNode (nodes + numnodes - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
WallMirrors.Clear ();
|
||||
interpolator.RestoreInterpolations ();
|
||||
|
|
1599
src/r_polymost.cpp
1599
src/r_polymost.cpp
File diff suppressed because it is too large
Load diff
|
@ -1,55 +0,0 @@
|
|||
/**************************************************************************************************
|
||||
"POLYMOST" code written by Ken Silverman
|
||||
**************************************************************************************************/
|
||||
|
||||
#include "c_cvars.h"
|
||||
|
||||
typedef void (*pmostcallbacktype)(double *dpx, double *dpy, int n, void *userdata);
|
||||
|
||||
class PolyClipper
|
||||
{
|
||||
public:
|
||||
PolyClipper();
|
||||
~PolyClipper();
|
||||
|
||||
void InitMosts (double *px, double *py, int n);
|
||||
bool TestVisibleMost (float x0, float x1);
|
||||
int DoMost (float x0, float y0, float x1, float y1, pmostcallbacktype callback, void *callbackdata);
|
||||
|
||||
private:
|
||||
struct vsptype
|
||||
{
|
||||
float X, Cy[2], Fy[2];
|
||||
int Tag, CTag, FTag;
|
||||
vsptype *Next, *Prev;
|
||||
};
|
||||
|
||||
enum { GROUP_SIZE = 128 };
|
||||
|
||||
struct vspgroup
|
||||
{
|
||||
vspgroup (vsptype *sentinel);
|
||||
|
||||
vspgroup *NextGroup;
|
||||
vsptype vsp[GROUP_SIZE];
|
||||
};
|
||||
|
||||
vsptype EmptyList;
|
||||
vsptype UsedList;
|
||||
vspgroup vsps;
|
||||
vsptype Solid;
|
||||
|
||||
int GTag;
|
||||
|
||||
vsptype *vsinsaft (vsptype *vsp);
|
||||
void EmptyAll ();
|
||||
void AddGroup ();
|
||||
vsptype *GetVsp ();
|
||||
void FreeVsp (vsptype *vsp);
|
||||
|
||||
friend void drawpolymosttest();
|
||||
|
||||
};
|
||||
|
||||
extern void drawpolymosttest();
|
||||
struct event_t; void Polymost_Responder (event_t *ev);
|
409
src/r_segs.cpp
409
src/r_segs.cpp
|
@ -64,11 +64,6 @@ CVAR(Bool, r_np2, true, 0)
|
|||
#define HEIGHTBITS 12
|
||||
#define HEIGHTSHIFT (FRACBITS-HEIGHTBITS)
|
||||
|
||||
// The 3072 below is just an arbitrary value picked to avoid
|
||||
// drawing lines the player is too close to that would overflow
|
||||
// the texture calculations.
|
||||
#define TOO_CLOSE_Z 3072
|
||||
|
||||
extern fixed_t globaluclip, globaldclip;
|
||||
|
||||
|
||||
|
@ -86,13 +81,6 @@ fixed_t rw_offset_top;
|
|||
fixed_t rw_offset_mid;
|
||||
fixed_t rw_offset_bottom;
|
||||
|
||||
int OWallMost (short *mostbuf, fixed_t z);
|
||||
int WallMost (short *mostbuf, const secplane_t &plane);
|
||||
void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat);
|
||||
void PrepLWall (fixed_t *lwall, fixed_t walxrepeat);
|
||||
extern fixed_t WallSZ1, WallSZ2, WallTX1, WallTX2, WallTY1, WallTY2, WallCX1, WallCX2, WallCY1, WallCY2;
|
||||
extern int WallSX1, WallSX2;
|
||||
extern float WallUoverZorg, WallUoverZstep, WallInvZorg, WallInvZstep, WallDepthScale, WallDepthOrg;
|
||||
|
||||
int wallshade;
|
||||
|
||||
|
@ -142,7 +130,6 @@ static fixed_t rw_bottomtexturescaley;
|
|||
FTexture *rw_pic;
|
||||
|
||||
static fixed_t *maskedtexturecol;
|
||||
static FTexture *WallSpriteTile;
|
||||
|
||||
static void R_RenderDecal (side_t *wall, DBaseDecal *first, drawseg_t *clipper, int pass);
|
||||
static void WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans));
|
||||
|
@ -218,13 +205,13 @@ void ClipMidtex(int x1, int x2)
|
|||
{
|
||||
short most[MAXWIDTH];
|
||||
|
||||
WallMost(most, curline->frontsector->ceilingplane);
|
||||
WallMost(most, curline->frontsector->ceilingplane, &WallC);
|
||||
for (int i = x1; i <= x2; ++i)
|
||||
{
|
||||
if (wallupper[i] < most[i])
|
||||
wallupper[i] = most[i];
|
||||
}
|
||||
WallMost(most, curline->frontsector->floorplane);
|
||||
WallMost(most, curline->frontsector->floorplane, &WallC);
|
||||
for (int i = x1; i <= x2; ++i)
|
||||
{
|
||||
if (walllower[i] > most[i])
|
||||
|
@ -389,26 +376,26 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2)
|
|||
goto clearfog;
|
||||
}
|
||||
|
||||
WallSZ1 = ds->sz1;
|
||||
WallSZ2 = ds->sz2;
|
||||
WallSX1 = ds->sx1;
|
||||
WallSX2 = ds->sx2;
|
||||
WallC.SZ1 = ds->sz1;
|
||||
WallC.SZ2 = ds->sz2;
|
||||
WallC.SX1 = ds->sx1;
|
||||
WallC.SX2 = ds->sx2;
|
||||
|
||||
if (fake3D & FAKE3D_CLIPTOP)
|
||||
{
|
||||
OWallMost (wallupper, textop < sclipTop - viewz ? textop : sclipTop - viewz);
|
||||
OWallMost(wallupper, textop < sclipTop - viewz ? textop : sclipTop - viewz, &WallC);
|
||||
}
|
||||
else
|
||||
{
|
||||
OWallMost (wallupper, textop);
|
||||
OWallMost(wallupper, textop, &WallC);
|
||||
}
|
||||
if (fake3D & FAKE3D_CLIPBOTTOM)
|
||||
{
|
||||
OWallMost (walllower, textop - texheight > sclipBottom - viewz ? textop - texheight : sclipBottom - viewz);
|
||||
OWallMost(walllower, textop - texheight > sclipBottom - viewz ? textop - texheight : sclipBottom - viewz, &WallC);
|
||||
}
|
||||
else
|
||||
{
|
||||
OWallMost (walllower, textop - texheight);
|
||||
OWallMost(walllower, textop - texheight, &WallC);
|
||||
}
|
||||
|
||||
for (i = x1; i <= x2; i++)
|
||||
|
@ -480,10 +467,10 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2)
|
|||
}
|
||||
else
|
||||
{ // Texture does wrap vertically.
|
||||
WallSZ1 = ds->sz1;
|
||||
WallSZ2 = ds->sz2;
|
||||
WallSX1 = ds->sx1;
|
||||
WallSX2 = ds->sx2;
|
||||
WallC.SZ1 = ds->sz1;
|
||||
WallC.SZ2 = ds->sz2;
|
||||
WallC.SX1 = ds->sx1;
|
||||
WallC.SX2 = ds->sx2;
|
||||
|
||||
if (CurrentSkybox)
|
||||
{ // Midtex clipping doesn't work properly with skyboxes, since you're normally below the floor
|
||||
|
@ -498,7 +485,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2)
|
|||
|
||||
if (fake3D & FAKE3D_CLIPTOP)
|
||||
{
|
||||
OWallMost (wallupper, sclipTop - viewz);
|
||||
OWallMost(wallupper, sclipTop - viewz, &WallC);
|
||||
for (i = x1; i <= x2; i++)
|
||||
{
|
||||
if (wallupper[i] < mceilingclip[i])
|
||||
|
@ -508,7 +495,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2)
|
|||
}
|
||||
if (fake3D & FAKE3D_CLIPBOTTOM)
|
||||
{
|
||||
OWallMost (walllower, sclipBottom - viewz);
|
||||
OWallMost(walllower, sclipBottom - viewz, &WallC);
|
||||
for (i = x1; i <= x2; i++)
|
||||
{
|
||||
if (walllower[i] > mfloorclip[i])
|
||||
|
@ -600,23 +587,18 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover)
|
|||
else if (fixedcolormap != NULL)
|
||||
dc_colormap = fixedcolormap;
|
||||
|
||||
WallSZ1 = ds->sz1;
|
||||
WallSZ2 = ds->sz2;
|
||||
WallSX1 = ds->sx1;
|
||||
WallSX2 = ds->sx2;
|
||||
WallTX1 = ds->cx;
|
||||
WallTY1 = ds->cy;
|
||||
WallTX2 = WallTX1 + ds->cdx;
|
||||
WallTY2 = WallTY1 + ds->cdy;
|
||||
WallDepthScale = ds->WallDepthScale;
|
||||
WallDepthOrg = ds->WallDepthOrg;
|
||||
WallUoverZorg = ds->WallUoverZorg;
|
||||
WallUoverZstep = ds->WallUoverZstep;
|
||||
WallInvZorg = ds->WallInvZorg;
|
||||
WallInvZstep = ds->WallInvZstep;
|
||||
WallC.SZ1 = ds->sz1;
|
||||
WallC.SZ2 = ds->sz2;
|
||||
WallC.SX1 = ds->sx1;
|
||||
WallC.SX2 = ds->sx2;
|
||||
WallC.TX1 = ds->cx;
|
||||
WallC.TY1 = ds->cy;
|
||||
WallC.TX2 = ds->cx + ds->cdx;
|
||||
WallC.TY2 = ds->cy + ds->cdy;
|
||||
WallT = ds->tmapvals;
|
||||
|
||||
OWallMost(wallupper, sclipTop - viewz);
|
||||
OWallMost(walllower, sclipBottom - viewz);
|
||||
OWallMost(wallupper, sclipTop - viewz, &WallC);
|
||||
OWallMost(walllower, sclipBottom - viewz, &WallC);
|
||||
|
||||
for (i = x1; i <= x2; i++)
|
||||
{
|
||||
|
@ -629,7 +611,7 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover)
|
|||
walllower[i] = mfloorclip[i];
|
||||
}
|
||||
|
||||
PrepLWall (lwall, curline->sidedef->TexelLength*xscale);
|
||||
PrepLWall (lwall, curline->sidedef->TexelLength*xscale, ds->sx1, ds->sx2);
|
||||
wallscan_np2_ds(ds, x1, x2, wallupper, walllower, MaskedSWall, lwall, yscale);
|
||||
R_FinishSetPatchStyle();
|
||||
}
|
||||
|
@ -1227,13 +1209,13 @@ void wallscan_striped (int x1, int x2, short *uwal, short *dwal, fixed_t *swal,
|
|||
up = uwal;
|
||||
down = most1;
|
||||
|
||||
assert(WallSX1 <= x1);
|
||||
assert(WallSX2 > x2);
|
||||
assert(WallC.SX1 <= x1);
|
||||
assert(WallC.SX2 > x2);
|
||||
|
||||
// kg3D - fake floors instead of zdoom light list
|
||||
for (unsigned int i = 0; i < frontsector->e->XFloor.lightlist.Size(); i++)
|
||||
{
|
||||
int j = WallMost (most3, frontsector->e->XFloor.lightlist[i].plane);
|
||||
int j = WallMost (most3, frontsector->e->XFloor.lightlist[i].plane, &WallC);
|
||||
if (j != 3)
|
||||
{
|
||||
for (int j = x1; j <= x2; ++j)
|
||||
|
@ -1315,7 +1297,7 @@ void wallscan_np2(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed
|
|||
dc_texturemid = FixedMul(partition - viewz, yrepeat) + texheight;
|
||||
while (partition > bot)
|
||||
{
|
||||
int j = OWallMost(most3, partition - viewz);
|
||||
int j = OWallMost(most3, partition - viewz, &WallC);
|
||||
if (j != 3)
|
||||
{
|
||||
for (int j = x1; j <= x2; ++j)
|
||||
|
@ -1339,7 +1321,7 @@ void wallscan_np2(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed
|
|||
dc_texturemid = FixedMul(partition - viewz, yrepeat) + texheight;
|
||||
while (partition < top)
|
||||
{
|
||||
int j = OWallMost(most3, partition - viewz);
|
||||
int j = OWallMost(most3, partition - viewz, &WallC);
|
||||
if (j != 12)
|
||||
{
|
||||
for (int j = x1; j <= x2; ++j)
|
||||
|
@ -1839,7 +1821,7 @@ void R_RenderSegLoop ()
|
|||
yscale = FixedMul(rw_pic->yScale, rw_midtexturescaley);
|
||||
if (xscale != lwallscale)
|
||||
{
|
||||
PrepLWall (lwall, curline->sidedef->TexelLength*xscale);
|
||||
PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.SX1, WallC.SX2);
|
||||
lwallscale = xscale;
|
||||
}
|
||||
if (midtexture->bWorldPanning)
|
||||
|
@ -1882,7 +1864,7 @@ void R_RenderSegLoop ()
|
|||
yscale = FixedMul(rw_pic->yScale, rw_toptexturescaley);
|
||||
if (xscale != lwallscale)
|
||||
{
|
||||
PrepLWall (lwall, curline->sidedef->TexelLength*xscale);
|
||||
PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.SX1, WallC.SX2);
|
||||
lwallscale = xscale;
|
||||
}
|
||||
if (toptexture->bWorldPanning)
|
||||
|
@ -1928,7 +1910,7 @@ void R_RenderSegLoop ()
|
|||
yscale = FixedMul(rw_pic->yScale, rw_bottomtexturescaley);
|
||||
if (xscale != lwallscale)
|
||||
{
|
||||
PrepLWall (lwall, curline->sidedef->TexelLength*xscale);
|
||||
PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.SX1, WallC.SX2);
|
||||
lwallscale = xscale;
|
||||
}
|
||||
if (bottomtexture->bWorldPanning)
|
||||
|
@ -2048,7 +2030,7 @@ void R_NewWall (bool needlights)
|
|||
{
|
||||
if (rw_havehigh)
|
||||
{ // front ceiling is above back ceiling
|
||||
memcpy (&walltop[WallSX1], &wallupper[WallSX1], (WallSX2 - WallSX1)*sizeof(walltop[0]));
|
||||
memcpy (&walltop[WallC.SX1], &wallupper[WallC.SX1], (WallC.SX2 - WallC.SX1)*sizeof(walltop[0]));
|
||||
rw_havehigh = false;
|
||||
}
|
||||
else if (rw_havelow && frontsector->ceilingplane != backsector->ceilingplane)
|
||||
|
@ -2058,7 +2040,7 @@ void R_NewWall (bool needlights)
|
|||
// wall but nothing to draw for it.
|
||||
// Recalculate walltop so that the wall is clipped by the back sector's
|
||||
// ceiling instead of the front sector's ceiling.
|
||||
WallMost (walltop, backsector->ceilingplane);
|
||||
WallMost (walltop, backsector->ceilingplane, &WallC);
|
||||
}
|
||||
// Putting sky ceilings on the front and back of a line alters the way unpegged
|
||||
// positioning works.
|
||||
|
@ -2273,15 +2255,15 @@ void R_NewWall (bool needlights)
|
|||
bottomtexture ? FixedMul(bottomtexture->xScale, sidedef->GetTextureXScale(side_t::bottom)) :
|
||||
FRACUNIT;
|
||||
|
||||
PrepWall (swall, lwall, sidedef->TexelLength * lwallscale);
|
||||
PrepWall (swall, lwall, sidedef->TexelLength * lwallscale, WallC.SX1, WallC.SX2);
|
||||
|
||||
if (fixedcolormap == NULL && fixedlightlev < 0)
|
||||
{
|
||||
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, frontsector->lightlevel)
|
||||
+ r_actualextralight);
|
||||
GlobVis = r_WallVisibility;
|
||||
rw_lightleft = SafeDivScale12 (GlobVis, WallSZ1);
|
||||
rw_lightstep = (SafeDivScale12 (GlobVis, WallSZ2) - rw_lightleft) / (WallSX2 - WallSX1);
|
||||
rw_lightleft = SafeDivScale12 (GlobVis, WallC.SZ1);
|
||||
rw_lightstep = (SafeDivScale12 (GlobVis, WallC.SZ2) - rw_lightleft) / (WallC.SX2 - WallC.SX1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2355,24 +2337,19 @@ void R_StoreWallRange (int start, int stop)
|
|||
}
|
||||
|
||||
rw_offset = sidedef->GetTextureXOffset(side_t::mid);
|
||||
rw_light = rw_lightleft + rw_lightstep * (start - WallSX1);
|
||||
rw_light = rw_lightleft + rw_lightstep * (start - WallC.SX1);
|
||||
|
||||
ds_p->sx1 = WallSX1;
|
||||
ds_p->sx2 = WallSX2;
|
||||
ds_p->sz1 = WallSZ1;
|
||||
ds_p->sz2 = WallSZ2;
|
||||
ds_p->cx = WallTX1;
|
||||
ds_p->cy = WallTY1;
|
||||
ds_p->cdx = WallTX2 - WallTX1;
|
||||
ds_p->cdy = WallTY2 - WallTY1;
|
||||
ds_p->WallDepthScale = WallDepthScale;
|
||||
ds_p->WallDepthOrg = WallDepthOrg;
|
||||
ds_p->WallUoverZorg = WallUoverZorg;
|
||||
ds_p->WallUoverZstep = WallUoverZstep;
|
||||
ds_p->WallInvZorg = WallInvZorg;
|
||||
ds_p->WallInvZstep = WallInvZstep;
|
||||
ds_p->siz1 = (DWORD)DivScale32 (1, WallSZ1) >> 1;
|
||||
ds_p->siz2 = (DWORD)DivScale32 (1, WallSZ2) >> 1;
|
||||
ds_p->sx1 = WallC.SX1;
|
||||
ds_p->sx2 = WallC.SX2;
|
||||
ds_p->sz1 = WallC.SZ1;
|
||||
ds_p->sz2 = WallC.SZ2;
|
||||
ds_p->cx = WallC.TX1;
|
||||
ds_p->cy = WallC.TY1;
|
||||
ds_p->cdx = WallC.TX2 - WallC.TX1;
|
||||
ds_p->cdy = WallC.TY2 - WallC.TY1;
|
||||
ds_p->tmapvals = WallT;
|
||||
ds_p->siz1 = (DWORD)DivScale32 (1, WallC.SZ1) >> 1;
|
||||
ds_p->siz2 = (DWORD)DivScale32 (1, WallC.SZ2) >> 1;
|
||||
ds_p->x1 = rw_x = start;
|
||||
ds_p->x2 = stop-1;
|
||||
ds_p->curline = curline;
|
||||
|
@ -2465,7 +2442,7 @@ void R_StoreWallRange (int start, int stop)
|
|||
if ((TexMan(sidedef->GetTexture(side_t::mid), true)->UseType != FTexture::TEX_Null || ds_p->bFakeBoundary || IsFogBoundary (frontsector, backsector)) &&
|
||||
(rw_ceilstat != 12 || !sidedef->GetTexture(side_t::top).isValid()) &&
|
||||
(rw_floorstat != 3 || !sidedef->GetTexture(side_t::bottom).isValid()) &&
|
||||
(WallSZ1 >= TOO_CLOSE_Z && WallSZ2 >= TOO_CLOSE_Z))
|
||||
(WallC.SZ1 >= TOO_CLOSE_Z && WallC.SZ2 >= TOO_CLOSE_Z))
|
||||
{
|
||||
fixed_t *swal;
|
||||
fixed_t *lwal;
|
||||
|
@ -2607,65 +2584,65 @@ void R_StoreWallRange (int start, int stop)
|
|||
ds_p++;
|
||||
}
|
||||
|
||||
int OWallMost (short *mostbuf, fixed_t z)
|
||||
int OWallMost (short *mostbuf, fixed_t z, const FWallCoords *wallc)
|
||||
{
|
||||
int bad, y, ix1, ix2, iy1, iy2;
|
||||
fixed_t s1, s2, s3, s4;
|
||||
|
||||
z = -(z >> 4);
|
||||
s1 = MulScale16 (globaluclip, WallSZ1); s2 = MulScale16 (globaluclip, WallSZ2);
|
||||
s3 = MulScale16 (globaldclip, WallSZ1); s4 = MulScale16 (globaldclip, WallSZ2);
|
||||
s1 = MulScale16 (globaluclip, wallc->SZ1); s2 = MulScale16 (globaluclip, wallc->SZ2);
|
||||
s3 = MulScale16 (globaldclip, wallc->SZ1); s4 = MulScale16 (globaldclip, wallc->SZ2);
|
||||
bad = (z<s1)+((z<s2)<<1)+((z>s3)<<2)+((z>s4)<<3);
|
||||
|
||||
#if 1
|
||||
if ((bad&3) == 3)
|
||||
{
|
||||
memset (&mostbuf[WallSX1], 0, (WallSX2 - WallSX1)*sizeof(mostbuf[0]));
|
||||
memset (&mostbuf[wallc->SX1], 0, (wallc->SX2 - wallc->SX1)*sizeof(mostbuf[0]));
|
||||
return bad;
|
||||
}
|
||||
|
||||
if ((bad&12) == 12)
|
||||
{
|
||||
clearbufshort (&mostbuf[WallSX1], WallSX2 - WallSX1, viewheight);
|
||||
clearbufshort (&mostbuf[wallc->SX1], wallc->SX2 - wallc->SX1, viewheight);
|
||||
return bad;
|
||||
}
|
||||
#endif
|
||||
ix1 = WallSX1; iy1 = WallSZ1;
|
||||
ix2 = WallSX2; iy2 = WallSZ2;
|
||||
ix1 = wallc->SX1; iy1 = wallc->SZ1;
|
||||
ix2 = wallc->SX2; iy2 = wallc->SZ2;
|
||||
#if 1
|
||||
if (bad & 3)
|
||||
{
|
||||
int t = DivScale30 (z-s1, s2-s1);
|
||||
int inty = WallSZ1 + MulScale30 (WallSZ2 - WallSZ1, t);
|
||||
int xcross = WallSX1 + Scale (MulScale30 (WallSZ2, t), WallSX2 - WallSX1, inty);
|
||||
int inty = wallc->SZ1 + MulScale30 (wallc->SZ2 - wallc->SZ1, t);
|
||||
int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2 - wallc->SX1, inty);
|
||||
|
||||
if ((bad & 3) == 2)
|
||||
{
|
||||
if (WallSX1 <= xcross) { iy2 = inty; ix2 = xcross; }
|
||||
if (WallSX2 > xcross) memset (&mostbuf[xcross], 0, (WallSX2-xcross)*sizeof(mostbuf[0]));
|
||||
if (wallc->SX1 <= xcross) { iy2 = inty; ix2 = xcross; }
|
||||
if (wallc->SX2 > xcross) memset (&mostbuf[xcross], 0, (wallc->SX2-xcross)*sizeof(mostbuf[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xcross <= WallSX2) { iy1 = inty; ix1 = xcross; }
|
||||
if (xcross > WallSX1) memset (&mostbuf[WallSX1], 0, (xcross-WallSX1)*sizeof(mostbuf[0]));
|
||||
if (xcross <= wallc->SX2) { iy1 = inty; ix1 = xcross; }
|
||||
if (xcross > wallc->SX1) memset (&mostbuf[wallc->SX1], 0, (xcross-wallc->SX1)*sizeof(mostbuf[0]));
|
||||
}
|
||||
}
|
||||
|
||||
if (bad & 12)
|
||||
{
|
||||
int t = DivScale30 (z-s3, s4-s3);
|
||||
int inty = WallSZ1 + MulScale30 (WallSZ2 - WallSZ1, t);
|
||||
int xcross = WallSX1 + Scale (MulScale30 (WallSZ2, t), WallSX2 - WallSX1, inty);
|
||||
int inty = wallc->SZ1 + MulScale30 (wallc->SZ2 - wallc->SZ1, t);
|
||||
int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2 - wallc->SX1, inty);
|
||||
|
||||
if ((bad & 12) == 8)
|
||||
{
|
||||
if (WallSX1 <= xcross) { iy2 = inty; ix2 = xcross; }
|
||||
if (WallSX2 > xcross) clearbufshort (&mostbuf[xcross], WallSX2 - xcross, viewheight);
|
||||
if (wallc->SX1 <= xcross) { iy2 = inty; ix2 = xcross; }
|
||||
if (wallc->SX2 > xcross) clearbufshort (&mostbuf[xcross], wallc->SX2 - xcross, viewheight);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xcross <= WallSX2) { iy1 = inty; ix1 = xcross; }
|
||||
if (xcross > WallSX1) clearbufshort (&mostbuf[WallSX1], xcross - WallSX1, viewheight);
|
||||
if (xcross <= wallc->SX2) { iy1 = inty; ix1 = xcross; }
|
||||
if (xcross > wallc->SX1) clearbufshort (&mostbuf[wallc->SX1], xcross - wallc->SX1, viewheight);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2683,12 +2660,12 @@ int OWallMost (short *mostbuf, fixed_t z)
|
|||
double max = viewheight;
|
||||
double zz = z / 65536.0;
|
||||
#if 0
|
||||
double z1 = zz * InvZtoScale / WallSZ1;
|
||||
double z2 = zz * InvZtoScale / WallSZ2 - z1;
|
||||
z2 /= (WallSX2 - WallSX1);
|
||||
double z1 = zz * InvZtoScale / wallc->SZ1;
|
||||
double z2 = zz * InvZtoScale / wallc->SZ2 - z1;
|
||||
z2 /= (wallc->SX2 - wallc->SX1);
|
||||
z1 += centeryfrac / 65536.0;
|
||||
|
||||
for (int x = WallSX1; x < WallSX2; ++x)
|
||||
for (int x = wallc->SX1; x < wallc->SX2; ++x)
|
||||
{
|
||||
mostbuf[x] = xs_RoundToInt(clamp(z1, 0.0, max));
|
||||
z1 += z2;
|
||||
|
@ -2696,18 +2673,18 @@ int OWallMost (short *mostbuf, fixed_t z)
|
|||
#else
|
||||
double top, bot, i;
|
||||
|
||||
i = WallSX1 - centerx;
|
||||
top = WallUoverZorg + WallUoverZstep * i;
|
||||
bot = WallInvZorg + WallInvZstep * i;
|
||||
i = wallc->SX1 - centerx;
|
||||
top = WallT.UoverZorg + WallT.UoverZstep * i;
|
||||
bot = WallT.InvZorg + WallT.InvZstep * i;
|
||||
double cy = centeryfrac / 65536.0;
|
||||
|
||||
for (int x = WallSX1; x < WallSX2; x++)
|
||||
for (int x = wallc->SX1; x < wallc->SX2; x++)
|
||||
{
|
||||
double frac = top / bot;
|
||||
double scale = frac * WallDepthScale + WallDepthOrg;
|
||||
double scale = frac * WallT.DepthScale + WallT.DepthOrg;
|
||||
mostbuf[x] = xs_RoundToInt(clamp(zz / scale + cy, 0.0, max));
|
||||
top += WallUoverZstep;
|
||||
bot += WallInvZstep;
|
||||
top += WallT.UoverZstep;
|
||||
bot += WallT.InvZstep;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -2719,11 +2696,11 @@ int OWallMost (short *mostbuf, fixed_t z)
|
|||
return bad;
|
||||
}
|
||||
|
||||
int WallMost (short *mostbuf, const secplane_t &plane)
|
||||
int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc)
|
||||
{
|
||||
if ((plane.a | plane.b) == 0)
|
||||
{
|
||||
return OWallMost (mostbuf, ((plane.c < 0) ? plane.d : -plane.d) - viewz);
|
||||
return OWallMost (mostbuf, ((plane.c < 0) ? plane.d : -plane.d) - viewz, wallc);
|
||||
}
|
||||
|
||||
fixed_t x, y, den, z1, z2, oz1, oz2;
|
||||
|
@ -2734,21 +2711,21 @@ int WallMost (short *mostbuf, const secplane_t &plane)
|
|||
{
|
||||
x = curline->v2->x;
|
||||
y = curline->v2->y;
|
||||
if (WallSX1 == 0 && 0 != (den = WallTX1 - WallTX2 + WallTY1 - WallTY2))
|
||||
if (wallc->SX1 == 0 && 0 != (den = wallc->TX1 - wallc->TX2 + wallc->TY1 - wallc->TY2))
|
||||
{
|
||||
int frac = SafeDivScale30 (WallTY1 + WallTX1, den);
|
||||
int frac = SafeDivScale30 (wallc->TY1 + wallc->TX1, den);
|
||||
x -= MulScale30 (frac, x - curline->v1->x);
|
||||
y -= MulScale30 (frac, y - curline->v1->y);
|
||||
}
|
||||
z1 = viewz - plane.ZatPoint (x, y);
|
||||
|
||||
if (WallSX2 > WallSX1 + 1)
|
||||
if (wallc->SX2 > wallc->SX1 + 1)
|
||||
{
|
||||
x = curline->v1->x;
|
||||
y = curline->v1->y;
|
||||
if (WallSX2 == viewwidth && 0 != (den = WallTX1 - WallTX2 - WallTY1 + WallTY2))
|
||||
if (wallc->SX2 == viewwidth && 0 != (den = wallc->TX1 - wallc->TX2 - wallc->TY1 + wallc->TY2))
|
||||
{
|
||||
int frac = SafeDivScale30 (WallTY2 - WallTX2, den);
|
||||
int frac = SafeDivScale30 (wallc->TY2 - wallc->TX2, den);
|
||||
x += MulScale30 (frac, curline->v2->x - x);
|
||||
y += MulScale30 (frac, curline->v2->y - y);
|
||||
}
|
||||
|
@ -2763,21 +2740,21 @@ int WallMost (short *mostbuf, const secplane_t &plane)
|
|||
{
|
||||
x = curline->v1->x;
|
||||
y = curline->v1->y;
|
||||
if (WallSX1 == 0 && 0 != (den = WallTX1 - WallTX2 + WallTY1 - WallTY2))
|
||||
if (wallc->SX1 == 0 && 0 != (den = wallc->TX1 - wallc->TX2 + wallc->TY1 - wallc->TY2))
|
||||
{
|
||||
int frac = SafeDivScale30 (WallTY1 + WallTX1, den);
|
||||
int frac = SafeDivScale30 (wallc->TY1 + wallc->TX1, den);
|
||||
x += MulScale30 (frac, curline->v2->x - x);
|
||||
y += MulScale30 (frac, curline->v2->y - y);
|
||||
}
|
||||
z1 = viewz - plane.ZatPoint (x, y);
|
||||
|
||||
if (WallSX2 > WallSX1 + 1)
|
||||
if (wallc->SX2 > wallc->SX1 + 1)
|
||||
{
|
||||
x = curline->v2->x;
|
||||
y = curline->v2->y;
|
||||
if (WallSX2 == viewwidth && 0 != (den = WallTX1 - WallTX2 - WallTY1 + WallTY2))
|
||||
if (wallc->SX2 == viewwidth && 0 != (den = wallc->TX1 - wallc->TX2 - wallc->TY1 + wallc->TY2))
|
||||
{
|
||||
int frac = SafeDivScale30 (WallTY2 - WallTX2, den);
|
||||
int frac = SafeDivScale30 (wallc->TY2 - wallc->TX2, den);
|
||||
x -= MulScale30 (frac, x - curline->v1->x);
|
||||
y -= MulScale30 (frac, y - curline->v1->y);
|
||||
}
|
||||
|
@ -2789,12 +2766,12 @@ int WallMost (short *mostbuf, const secplane_t &plane)
|
|||
}
|
||||
}
|
||||
|
||||
s1 = MulScale12 (globaluclip, WallSZ1); s2 = MulScale12 (globaluclip, WallSZ2);
|
||||
s3 = MulScale12 (globaldclip, WallSZ1); s4 = MulScale12 (globaldclip, WallSZ2);
|
||||
s1 = MulScale12 (globaluclip, wallc->SZ1); s2 = MulScale12 (globaluclip, wallc->SZ2);
|
||||
s3 = MulScale12 (globaldclip, wallc->SZ1); s4 = MulScale12 (globaldclip, wallc->SZ2);
|
||||
bad = (z1<s1)+((z2<s2)<<1)+((z1>s3)<<2)+((z2>s4)<<3);
|
||||
|
||||
ix1 = WallSX1; ix2 = WallSX2;
|
||||
iy1 = WallSZ1; iy2 = WallSZ2;
|
||||
ix1 = wallc->SX1; ix2 = wallc->SX2;
|
||||
iy1 = wallc->SZ1; iy2 = wallc->SZ2;
|
||||
oz1 = z1; oz2 = z2;
|
||||
|
||||
if ((bad&3) == 3)
|
||||
|
@ -2814,9 +2791,9 @@ int WallMost (short *mostbuf, const secplane_t &plane)
|
|||
{
|
||||
//inty = intz / (globaluclip>>16)
|
||||
int t = SafeDivScale30 (oz1-s1, s2-s1+oz1-oz2);
|
||||
int inty = WallSZ1 + MulScale30 (WallSZ2-WallSZ1,t);
|
||||
int inty = wallc->SZ1 + MulScale30 (wallc->SZ2-wallc->SZ1,t);
|
||||
int intz = oz1 + MulScale30 (oz2-oz1,t);
|
||||
int xcross = WallSX1 + Scale (MulScale30 (WallSZ2, t), WallSX2-WallSX1, inty);
|
||||
int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2-wallc->SX1, inty);
|
||||
|
||||
//t = divscale30((x1<<4)-xcross*yb1[w],xcross*(yb2[w]-yb1[w])-((x2-x1)<<4));
|
||||
//inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t);
|
||||
|
@ -2824,13 +2801,13 @@ int WallMost (short *mostbuf, const secplane_t &plane)
|
|||
|
||||
if ((bad&3) == 2)
|
||||
{
|
||||
if (WallSX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; }
|
||||
memset (&mostbuf[xcross], 0, (WallSX2-xcross)*sizeof(mostbuf[0]));
|
||||
if (wallc->SX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; }
|
||||
memset (&mostbuf[xcross], 0, (wallc->SX2-xcross)*sizeof(mostbuf[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xcross <= WallSX2) { z1 = intz; iy1 = inty; ix1 = xcross; }
|
||||
memset (&mostbuf[WallSX1], 0, (xcross-WallSX1)*sizeof(mostbuf[0]));
|
||||
if (xcross <= wallc->SX2) { z1 = intz; iy1 = inty; ix1 = xcross; }
|
||||
memset (&mostbuf[wallc->SX1], 0, (xcross-wallc->SX1)*sizeof(mostbuf[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2838,9 +2815,9 @@ int WallMost (short *mostbuf, const secplane_t &plane)
|
|||
{
|
||||
//inty = intz / (globaldclip>>16)
|
||||
int t = SafeDivScale30 (oz1-s3, s4-s3+oz1-oz2);
|
||||
int inty = WallSZ1 + MulScale30 (WallSZ2-WallSZ1,t);
|
||||
int inty = wallc->SZ1 + MulScale30 (wallc->SZ2-wallc->SZ1,t);
|
||||
int intz = oz1 + MulScale30 (oz2-oz1,t);
|
||||
int xcross = WallSX1 + Scale (MulScale30 (WallSZ2, t), WallSX2-WallSX1,inty);
|
||||
int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2-wallc->SX1,inty);
|
||||
|
||||
//t = divscale30((x1<<4)-xcross*yb1[w],xcross*(yb2[w]-yb1[w])-((x2-x1)<<4));
|
||||
//inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t);
|
||||
|
@ -2848,13 +2825,13 @@ int WallMost (short *mostbuf, const secplane_t &plane)
|
|||
|
||||
if ((bad&12) == 8)
|
||||
{
|
||||
if (WallSX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; }
|
||||
if (WallSX2 > xcross) clearbufshort (&mostbuf[xcross], WallSX2-xcross, viewheight);
|
||||
if (wallc->SX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; }
|
||||
if (wallc->SX2 > xcross) clearbufshort (&mostbuf[xcross], wallc->SX2-xcross, viewheight);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xcross <= WallSX2) { z1 = intz; iy1 = inty; ix1 = xcross; }
|
||||
if (xcross > WallSX1) clearbufshort (&mostbuf[WallSX1], xcross-WallSX1, viewheight);
|
||||
if (xcross <= wallc->SX2) { z1 = intz; iy1 = inty; ix1 = xcross; }
|
||||
if (xcross > wallc->SX1) clearbufshort (&mostbuf[wallc->SX1], xcross-wallc->SX1, viewheight);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2877,16 +2854,16 @@ int WallMost (short *mostbuf, const secplane_t &plane)
|
|||
return bad;
|
||||
}
|
||||
|
||||
static void PrepWallRoundFix(fixed_t *lwall, fixed_t walxrepeat)
|
||||
static void PrepWallRoundFix(fixed_t *lwall, fixed_t walxrepeat, int x1, int x2)
|
||||
{
|
||||
// fix for rounding errors
|
||||
walxrepeat = abs(walxrepeat);
|
||||
fixed_t fix = (MirrorFlags & RF_XFLIP) ? walxrepeat-1 : 0;
|
||||
int x;
|
||||
|
||||
if (WallSX1 > 0)
|
||||
if (x1 > 0)
|
||||
{
|
||||
for (x = WallSX1; x < WallSX2; x++)
|
||||
for (x = x1; x < x2; x++)
|
||||
{
|
||||
if ((unsigned)lwall[x] >= (unsigned)walxrepeat)
|
||||
{
|
||||
|
@ -2899,7 +2876,7 @@ static void PrepWallRoundFix(fixed_t *lwall, fixed_t walxrepeat)
|
|||
}
|
||||
}
|
||||
fix = walxrepeat - 1 - fix;
|
||||
for (x = WallSX2-1; x >= WallSX1; x--)
|
||||
for (x = x2-1; x >= x1; x--)
|
||||
{
|
||||
if ((unsigned)lwall[x] >= (unsigned)walxrepeat)
|
||||
{
|
||||
|
@ -2912,16 +2889,16 @@ static void PrepWallRoundFix(fixed_t *lwall, fixed_t walxrepeat)
|
|||
}
|
||||
}
|
||||
|
||||
void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat)
|
||||
void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat, int x1, int x2)
|
||||
{ // swall = scale, lwall = texturecolumn
|
||||
double top, bot, i;
|
||||
double xrepeat = fabs((double)walxrepeat);
|
||||
|
||||
i = WallSX1 - centerx;
|
||||
top = WallUoverZorg + WallUoverZstep * i;
|
||||
bot = WallInvZorg + WallInvZstep * i;
|
||||
i = x1 - centerx;
|
||||
top = WallT.UoverZorg + WallT.UoverZstep * i;
|
||||
bot = WallT.InvZorg + WallT.InvZstep * i;
|
||||
|
||||
for (int x = WallSX1; x < WallSX2; x++)
|
||||
for (int x = x1; x < x2; x++)
|
||||
{
|
||||
double frac = top / bot;
|
||||
if (walxrepeat < 0)
|
||||
|
@ -2932,27 +2909,27 @@ void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat)
|
|||
{
|
||||
lwall[x] = xs_RoundToInt(frac * xrepeat);
|
||||
}
|
||||
swall[x] = xs_RoundToInt(frac * WallDepthScale + WallDepthOrg);
|
||||
top += WallUoverZstep;
|
||||
bot += WallInvZstep;
|
||||
swall[x] = xs_RoundToInt(frac * WallT.DepthScale + WallT.DepthOrg);
|
||||
top += WallT.UoverZstep;
|
||||
bot += WallT.InvZstep;
|
||||
}
|
||||
PrepWallRoundFix(lwall, walxrepeat);
|
||||
PrepWallRoundFix(lwall, walxrepeat, x1, x2);
|
||||
}
|
||||
|
||||
void PrepLWall (fixed_t *lwall, fixed_t walxrepeat)
|
||||
void PrepLWall (fixed_t *lwall, fixed_t walxrepeat, int x1, int x2)
|
||||
{ // lwall = texturecolumn
|
||||
double top, bot, i;
|
||||
double xrepeat = fabs((double)walxrepeat);
|
||||
double topstep;
|
||||
|
||||
i = WallSX1 - centerx;
|
||||
top = WallUoverZorg + WallUoverZstep * i;
|
||||
bot = WallInvZorg + WallInvZstep * i;
|
||||
i = x1 - centerx;
|
||||
top = WallT.UoverZorg + WallT.UoverZstep * i;
|
||||
bot = WallT.InvZorg + WallT.InvZstep * i;
|
||||
|
||||
top *= xrepeat;
|
||||
topstep = WallUoverZstep * xrepeat;
|
||||
topstep = WallT.UoverZstep * xrepeat;
|
||||
|
||||
for (int x = WallSX1; x < WallSX2; x++)
|
||||
for (int x = x1; x < x2; x++)
|
||||
{
|
||||
if (walxrepeat < 0)
|
||||
{
|
||||
|
@ -2963,9 +2940,9 @@ void PrepLWall (fixed_t *lwall, fixed_t walxrepeat)
|
|||
lwall[x] = xs_RoundToInt(top / bot);
|
||||
}
|
||||
top += topstep;
|
||||
bot += WallInvZstep;
|
||||
bot += WallT.InvZstep;
|
||||
}
|
||||
PrepWallRoundFix(lwall, walxrepeat);
|
||||
PrepWallRoundFix(lwall, walxrepeat, x1, x2);
|
||||
}
|
||||
|
||||
// pass = 0: when seg is first drawn
|
||||
|
@ -3044,14 +3021,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
|
|||
// to a wall, we use the wall's angle instead of the decal's. This is
|
||||
// pretty much the same as what R_AddLine() does.
|
||||
|
||||
fixed_t savetx1, savetx2, savety1, savety2, savesz1, savesz2;
|
||||
|
||||
savetx1 = WallTX1;
|
||||
savetx2 = WallTX2;
|
||||
savety1 = WallTY1;
|
||||
savety2 = WallTY2;
|
||||
savesz1 = WallSZ1;
|
||||
savesz2 = WallSZ2;
|
||||
FWallCoords savecoord = WallC;
|
||||
|
||||
x2 = WallSpriteTile->GetWidth();
|
||||
x1 = WallSpriteTile->LeftOffset;
|
||||
|
@ -3068,76 +3038,16 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
|
|||
ly = decaly - FixedMul (x1, finesine[ang]) - viewy;
|
||||
ly2 = decaly + FixedMul (x2, finesine[ang]) - viewy;
|
||||
|
||||
WallTX1 = DMulScale20 (lx, viewsin, -ly, viewcos);
|
||||
WallTX2 = DMulScale20 (lx2, viewsin, -ly2, viewcos);
|
||||
|
||||
WallTY1 = DMulScale20 (lx, viewtancos, ly, viewtansin);
|
||||
WallTY2 = DMulScale20 (lx2, viewtancos, ly2, viewtansin);
|
||||
|
||||
if (MirrorFlags & RF_XFLIP)
|
||||
{
|
||||
int t = 256-WallTX1;
|
||||
WallTX1 = 256-WallTX2;
|
||||
WallTX2 = t;
|
||||
swapvalues (WallTY1, WallTY2);
|
||||
}
|
||||
|
||||
if (WallTX1 >= -WallTY1)
|
||||
{
|
||||
if (WallTX1 > WallTY1) goto done; // left edge is off the right side
|
||||
if (WallTY1 == 0) goto done;
|
||||
x1 = (centerxfrac + Scale (WallTX1, centerxfrac, WallTY1)) >> FRACBITS;
|
||||
if (WallTX1 >= 0) x1 = MIN (viewwidth, x1+1); // fix for signed divide
|
||||
WallSZ1 = WallTY1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WallTX2 < -WallTY2) goto done; // wall is off the left side
|
||||
fixed_t den = WallTX1 - WallTX2 - WallTY2 + WallTY1;
|
||||
if (den == 0) goto done;
|
||||
x1 = 0;
|
||||
WallSZ1 = WallTY1 + Scale (WallTY2 - WallTY1, WallTX1 + WallTY1, den);
|
||||
}
|
||||
|
||||
if (WallSZ1 < TOO_CLOSE_Z)
|
||||
if (WallC.Init(lx, ly, lx2, ly2, TOO_CLOSE_Z))
|
||||
goto done;
|
||||
|
||||
if (WallTX2 <= WallTY2)
|
||||
{
|
||||
if (WallTX2 < -WallTY2) goto done; // right edge is off the left side
|
||||
if (WallTY2 == 0) goto done;
|
||||
x2 = (centerxfrac + Scale (WallTX2, centerxfrac, WallTY2)) >> FRACBITS;
|
||||
if (WallTX2 >= 0) x2 = MIN (viewwidth, x2+1); // fix for signed divide
|
||||
WallSZ2 = WallTY2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WallTX1 > WallTY1) goto done; // wall is off the right side
|
||||
fixed_t den = WallTY2 - WallTY1 - WallTX2 + WallTX1;
|
||||
if (den == 0) goto done;
|
||||
x2 = viewwidth;
|
||||
WallSZ2 = WallTY1 + Scale (WallTY2 - WallTY1, WallTX1 - WallTY1, den);
|
||||
}
|
||||
x1 = WallC.SX1;
|
||||
x2 = WallC.SX2;
|
||||
|
||||
if (x1 >= x2 || x1 > clipper->x2 || x2 <= clipper->x1 || WallSZ2 < TOO_CLOSE_Z)
|
||||
if (x1 > clipper->x2 || x2 <= clipper->x1)
|
||||
goto done;
|
||||
|
||||
if (MirrorFlags & RF_XFLIP)
|
||||
{
|
||||
WallUoverZorg = (float)WallTX2 * WallTMapScale;
|
||||
WallUoverZstep = (float)(-WallTY2) * 32.f;
|
||||
WallInvZorg = (float)(WallTX2 - WallTX1) * WallTMapScale;
|
||||
WallInvZstep = (float)(WallTY1 - WallTY2) * 32.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
WallUoverZorg = (float)WallTX1 * WallTMapScale;
|
||||
WallUoverZstep = (float)(-WallTY1) * 32.f;
|
||||
WallInvZorg = (float)(WallTX1 - WallTX2) * WallTMapScale;
|
||||
WallInvZstep = (float)(WallTY2 - WallTY1) * 32.f;
|
||||
}
|
||||
WallDepthScale = WallInvZstep * WallTMapScale2;
|
||||
WallDepthOrg = -WallUoverZstep * WallTMapScale2;
|
||||
WallT.InitFromWallCoords(&WallC);
|
||||
|
||||
// Get the top and bottom clipping arrays
|
||||
switch (decal->RenderFlags & RF_CLIPMASK)
|
||||
|
@ -3210,11 +3120,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
|
|||
goto done;
|
||||
}
|
||||
|
||||
swapvalues (x1, WallSX1);
|
||||
swapvalues (x2, WallSX2);
|
||||
PrepWall (swall, lwall, WallSpriteTile->GetWidth() << FRACBITS);
|
||||
swapvalues (x1, WallSX1);
|
||||
swapvalues (x2, WallSX2);
|
||||
PrepWall (swall, lwall, WallSpriteTile->GetWidth() << FRACBITS, x1, x2);
|
||||
|
||||
if (flipx)
|
||||
{
|
||||
|
@ -3239,7 +3145,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
|
|||
rereadcolormap = false;
|
||||
}
|
||||
|
||||
rw_light = rw_lightleft + (x1 - WallSX1) * rw_lightstep;
|
||||
rw_light = rw_lightleft + (x1 - WallC.SX1) * rw_lightstep;
|
||||
if (fixedlightlev >= 0)
|
||||
dc_colormap = usecolormap->Maps + fixedlightlev;
|
||||
else if (fixedcolormap != NULL)
|
||||
|
@ -3300,8 +3206,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
|
|||
{ // calculate lighting
|
||||
dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT);
|
||||
}
|
||||
|
||||
WallSpriteColumn (R_DrawMaskedColumn);
|
||||
R_WallSpriteColumn (R_DrawMaskedColumn);
|
||||
dc_x++;
|
||||
}
|
||||
|
||||
|
@ -3314,7 +3219,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
|
|||
rt_initcols();
|
||||
for (int zz = 4; zz; --zz)
|
||||
{
|
||||
WallSpriteColumn (R_DrawMaskedColumnHoriz);
|
||||
R_WallSpriteColumn (R_DrawMaskedColumnHoriz);
|
||||
dc_x++;
|
||||
}
|
||||
rt_draw4cols (dc_x - 4);
|
||||
|
@ -3326,8 +3231,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
|
|||
{ // calculate lighting
|
||||
dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT);
|
||||
}
|
||||
|
||||
WallSpriteColumn (R_DrawMaskedColumn);
|
||||
R_WallSpriteColumn (R_DrawMaskedColumn);
|
||||
dc_x++;
|
||||
}
|
||||
}
|
||||
|
@ -3346,28 +3250,5 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
|
|||
|
||||
R_FinishSetPatchStyle ();
|
||||
done:
|
||||
WallTX1 = savetx1;
|
||||
WallTX2 = savetx2;
|
||||
WallTY1 = savety1;
|
||||
WallTY2 = savety2;
|
||||
WallSZ1 = savesz1;
|
||||
WallSZ2 = savesz2;
|
||||
}
|
||||
|
||||
static void WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans))
|
||||
{
|
||||
unsigned int texturecolumn = lwall[dc_x] >> FRACBITS;
|
||||
dc_iscale = MulScale16 (swall[dc_x], rw_offset);
|
||||
spryscale = SafeDivScale32 (1, dc_iscale);
|
||||
if (sprflipvert)
|
||||
sprtopscreen = centeryfrac + FixedMul (dc_texturemid, spryscale);
|
||||
else
|
||||
sprtopscreen = centeryfrac - FixedMul (dc_texturemid, spryscale);
|
||||
|
||||
const BYTE *column;
|
||||
const FTexture::Span *spans;
|
||||
column = WallSpriteTile->GetColumn (texturecolumn, &spans);
|
||||
dc_texturefrac = 0;
|
||||
drawfunc (column, spans);
|
||||
rw_light += rw_lightstep;
|
||||
WallC = savecoord;
|
||||
}
|
||||
|
|
12
src/r_segs.h
12
src/r_segs.h
|
@ -31,10 +31,22 @@ extern short *openings;
|
|||
extern ptrdiff_t lastopening;
|
||||
extern size_t maxopenings;
|
||||
|
||||
int OWallMost (short *mostbuf, fixed_t z, const FWallCoords *wallc);
|
||||
int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc);
|
||||
void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat, int x1, int x2);
|
||||
void PrepLWall (fixed_t *lwall, fixed_t walxrepeat, int x1, int x2);
|
||||
|
||||
ptrdiff_t R_NewOpening (ptrdiff_t len);
|
||||
|
||||
void R_CheckDrawSegs ();
|
||||
|
||||
void R_RenderSegLoop ();
|
||||
|
||||
extern fixed_t swall[MAXWIDTH];
|
||||
extern fixed_t lwall[MAXWIDTH];
|
||||
extern fixed_t rw_light; // [RH] Scale lights with viewsize adjustments
|
||||
extern fixed_t rw_lightstep;
|
||||
extern fixed_t rw_lightleft;
|
||||
extern fixed_t rw_offset;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "r_bsp.h"
|
||||
#include "r_swrenderer.h"
|
||||
#include "r_3dfloors.h"
|
||||
#include "r_polymost.h"
|
||||
#include "textures/textures.h"
|
||||
#include "r_data/voxels.h"
|
||||
|
||||
|
@ -49,7 +48,6 @@ class FArchive;
|
|||
void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, int trueratio);
|
||||
void R_SetupColormap(player_t *);
|
||||
void R_SetupFreelook();
|
||||
void R_SetupPolymost();
|
||||
void R_InitRenderer();
|
||||
|
||||
extern float LastFOV;
|
||||
|
@ -245,7 +243,6 @@ void FSoftwareRenderer::SetupFrame(player_t *player)
|
|||
{
|
||||
R_SetupColormap(player);
|
||||
R_SetupFreelook();
|
||||
R_SetupPolymost();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
252
src/r_things.cpp
252
src/r_things.cpp
|
@ -114,6 +114,8 @@ FDynamicColormap *VisPSpritesBaseColormap[NUMPSPRITES];
|
|||
|
||||
static int spriteshade;
|
||||
|
||||
FTexture *WallSpriteTile;
|
||||
|
||||
// constant arrays
|
||||
// used for psprite clipping and initializing clipping
|
||||
short zeroarray[MAXWIDTH];
|
||||
|
@ -145,6 +147,8 @@ static vissprite_t **spritesorter;
|
|||
static int spritesortersize = 0;
|
||||
static int vsprcount;
|
||||
|
||||
static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t fz, FTextureID picnum, fixed_t xscale, fixed_t yscale, INTBOOL flip);
|
||||
|
||||
|
||||
void R_DeinitSprites()
|
||||
{
|
||||
|
@ -401,6 +405,151 @@ void R_DrawVisSprite (vissprite_t *vis)
|
|||
NetUpdate ();
|
||||
}
|
||||
|
||||
void R_DrawWallSprite(vissprite_t *spr)
|
||||
{
|
||||
int x1, x2;
|
||||
fixed_t yscale;
|
||||
int shade = LIGHT2SHADE(140);
|
||||
|
||||
x1 = MAX<int>(spr->x1, spr->wallc.SX1);
|
||||
x2 = MIN<int>(spr->x2, spr->wallc.SX2 + 1);
|
||||
if (x1 >= x2)
|
||||
return;
|
||||
WallT.InitFromWallCoords(&spr->wallc);
|
||||
PrepWall(swall, lwall, spr->pic->GetWidth() << FRACBITS, x1, x2);
|
||||
dc_texturemid = spr->gzt - viewz;
|
||||
yscale = FRACUNIT;
|
||||
if (spr->renderflags & RF_XFLIP)
|
||||
{
|
||||
int right = (spr->pic->GetWidth() << FRACBITS) - 1;
|
||||
|
||||
for (int i = x1; i < x2; i++)
|
||||
{
|
||||
lwall[i] = right - lwall[i];
|
||||
}
|
||||
}
|
||||
// Prepare lighting
|
||||
bool calclighting = false;
|
||||
FDynamicColormap *usecolormap = basecolormap;
|
||||
bool rereadcolormap = true;
|
||||
|
||||
// Decals that are added to the scene must fade to black.
|
||||
if (spr->Style.RenderStyle == LegacyRenderStyles[STYLE_Add] && usecolormap->Fade != 0)
|
||||
{
|
||||
usecolormap = GetSpecialLights(usecolormap->Color, 0, usecolormap->Desaturate);
|
||||
rereadcolormap = false;
|
||||
}
|
||||
|
||||
rw_light = rw_lightleft + (x1 - spr->wallc.SX1) * rw_lightstep;
|
||||
if (fixedlightlev >= 0)
|
||||
dc_colormap = usecolormap->Maps + fixedlightlev;
|
||||
else if (fixedcolormap != NULL)
|
||||
dc_colormap = fixedcolormap;
|
||||
else if (!foggy && (spr->renderflags & RF_FULLBRIGHT))
|
||||
dc_colormap = usecolormap->Maps;
|
||||
else
|
||||
calclighting = true;
|
||||
|
||||
// Draw it
|
||||
WallSpriteTile = spr->pic;
|
||||
if (spr->renderflags & RF_YFLIP)
|
||||
{
|
||||
sprflipvert = true;
|
||||
yscale = -yscale;
|
||||
dc_texturemid = dc_texturemid - (spr->pic->GetHeight() << FRACBITS);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprflipvert = false;
|
||||
}
|
||||
|
||||
// rw_offset is used as the texture's vertical scale
|
||||
rw_offset = SafeDivScale30(1, yscale);
|
||||
|
||||
dc_x = x1;
|
||||
ESPSResult mode;
|
||||
|
||||
mode = R_SetPatchStyle (spr->Style.RenderStyle, spr->Style.alpha, spr->Translation, spr->FillColor);
|
||||
|
||||
// R_SetPatchStyle can modify basecolormap.
|
||||
if (rereadcolormap)
|
||||
{
|
||||
usecolormap = basecolormap;
|
||||
}
|
||||
|
||||
if (mode == DontDraw)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
int stop4;
|
||||
|
||||
if (mode == DoDraw0)
|
||||
{ // 1 column at a time
|
||||
stop4 = dc_x;
|
||||
}
|
||||
else // DoDraw1
|
||||
{ // up to 4 columns at a time
|
||||
stop4 = x2 & ~3;
|
||||
}
|
||||
|
||||
while ((dc_x < stop4) && (dc_x & 3))
|
||||
{
|
||||
if (calclighting)
|
||||
{ // calculate lighting
|
||||
dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT);
|
||||
}
|
||||
R_WallSpriteColumn(R_DrawMaskedColumn);
|
||||
dc_x++;
|
||||
}
|
||||
|
||||
while (dc_x < stop4)
|
||||
{
|
||||
if (calclighting)
|
||||
{ // calculate lighting
|
||||
dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT);
|
||||
}
|
||||
rt_initcols();
|
||||
for (int zz = 4; zz; --zz)
|
||||
{
|
||||
R_WallSpriteColumn(R_DrawMaskedColumnHoriz);
|
||||
dc_x++;
|
||||
}
|
||||
rt_draw4cols(dc_x - 4);
|
||||
}
|
||||
|
||||
while (dc_x < x2)
|
||||
{
|
||||
if (calclighting)
|
||||
{ // calculate lighting
|
||||
dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT);
|
||||
}
|
||||
R_WallSpriteColumn(R_DrawMaskedColumn);
|
||||
dc_x++;
|
||||
}
|
||||
}
|
||||
R_FinishSetPatchStyle();
|
||||
}
|
||||
|
||||
void R_WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans))
|
||||
{
|
||||
unsigned int texturecolumn = lwall[dc_x] >> FRACBITS;
|
||||
dc_iscale = MulScale16 (swall[dc_x], rw_offset);
|
||||
spryscale = SafeDivScale32 (1, dc_iscale);
|
||||
if (sprflipvert)
|
||||
sprtopscreen = centeryfrac + FixedMul (dc_texturemid, spryscale);
|
||||
else
|
||||
sprtopscreen = centeryfrac - FixedMul (dc_texturemid, spryscale);
|
||||
|
||||
const BYTE *column;
|
||||
const FTexture::Span *spans;
|
||||
column = WallSpriteTile->GetColumn (texturecolumn, &spans);
|
||||
dc_texturefrac = 0;
|
||||
drawfunc (column, spans);
|
||||
rw_light += rw_lightstep;
|
||||
}
|
||||
|
||||
void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop, short *clipbot)
|
||||
{
|
||||
ESPSResult mode;
|
||||
|
@ -521,12 +670,6 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
|||
fy = thing->PrevY + FixedMul (r_TicFrac, thing->y - thing->PrevY);
|
||||
fz = thing->PrevZ + FixedMul (r_TicFrac, thing->z - thing->PrevZ) + thing->GetBobOffset(r_TicFrac);
|
||||
|
||||
// transform the origin point
|
||||
tr_x = fx - viewx;
|
||||
tr_y = fy - viewy;
|
||||
|
||||
tz = DMulScale20 (tr_x, viewtancos, tr_y, viewtansin);
|
||||
|
||||
tex = NULL;
|
||||
voxel = NULL;
|
||||
|
||||
|
@ -618,6 +761,18 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
|||
return;
|
||||
}
|
||||
|
||||
if ((thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE)
|
||||
{
|
||||
R_ProjectWallSprite(thing, fx, fy, fz, picnum, spritescaleX, spritescaleY, flip);
|
||||
return;
|
||||
}
|
||||
|
||||
// transform the origin point
|
||||
tr_x = fx - viewx;
|
||||
tr_y = fy - viewy;
|
||||
|
||||
tz = DMulScale20 (tr_x, viewtancos, tr_y, viewtansin);
|
||||
|
||||
// thing is behind view plane?
|
||||
if (voxel == NULL && tz < MINZ)
|
||||
return;
|
||||
|
@ -782,7 +937,6 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
|||
vis->heightsec = heightsec;
|
||||
vis->sector = thing->Sector;
|
||||
|
||||
vis->cx = tx2;
|
||||
vis->depth = tz;
|
||||
vis->gx = fx;
|
||||
vis->gy = fy;
|
||||
|
@ -807,12 +961,14 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
|||
{
|
||||
vis->voxel = voxel->Voxel;
|
||||
vis->bIsVoxel = true;
|
||||
vis->bWallSprite = false;
|
||||
DrewAVoxel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
vis->pic = tex;
|
||||
vis->bIsVoxel = false;
|
||||
vis->bWallSprite = false;
|
||||
}
|
||||
|
||||
// The software renderer cannot invert the source without inverting the overlay
|
||||
|
@ -874,6 +1030,78 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
|||
}
|
||||
}
|
||||
|
||||
static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t fz, FTextureID picnum, fixed_t xscale, fixed_t yscale, INTBOOL flip)
|
||||
{
|
||||
FWallCoords wallc;
|
||||
int x1, x2;
|
||||
fixed_t lx1, lx2, ly1, ly2;
|
||||
fixed_t gzb, gzt, tz;
|
||||
FTexture *pic = TexMan(picnum, true);
|
||||
angle_t ang = (thing->angle + ANGLE_90) >> ANGLETOFINESHIFT;
|
||||
vissprite_t *vis;
|
||||
|
||||
// Determine left and right edges of sprite. The sprite's angle is its normal,
|
||||
// so the edges are 90 degrees each side of it.
|
||||
x2 = pic->GetScaledWidth();
|
||||
x1 = pic->GetScaledLeftOffset();
|
||||
|
||||
x1 *= xscale;
|
||||
x2 *= xscale;
|
||||
|
||||
lx1 = fx - FixedMul(x1, finecosine[ang]) - viewx;
|
||||
ly1 = fy - FixedMul(x1, finesine[ang]) - viewy;
|
||||
lx2 = lx1 + FixedMul(x2, finecosine[ang]);
|
||||
ly2 = ly1 + FixedMul(x2, finesine[ang]);
|
||||
|
||||
// Is it off-screen?
|
||||
if (wallc.Init(lx1, ly1, lx2, ly2, TOO_CLOSE_Z))
|
||||
return;
|
||||
|
||||
if (wallc.SX1 > WindowRight || wallc.SX2 <= WindowLeft)
|
||||
return;
|
||||
|
||||
// Sprite sorting should probably treat these as walls, not sprites,
|
||||
// but right now, I just want to get them drawing.
|
||||
tz = DMulScale20(fx - viewx, viewtancos, fy - viewy, viewtansin);
|
||||
|
||||
int scaled_to = pic->GetScaledTopOffset();
|
||||
int scaled_bo = scaled_to - pic->GetScaledHeight();
|
||||
gzt = fz + yscale * scaled_to;
|
||||
gzb = fz + yscale * scaled_bo;
|
||||
|
||||
vis = R_NewVisSprite();
|
||||
vis->x1 = wallc.SX1 < WindowLeft ? WindowLeft : wallc.SX1;
|
||||
vis->x2 = wallc.SX2 >= WindowRight ? WindowRight-1 : wallc.SX2-1;
|
||||
vis->idepth = (unsigned)DivScale32(1, tz) >> 1;
|
||||
vis->depth = tz;
|
||||
vis->sector = thing->Sector;
|
||||
vis->heightsec = NULL;
|
||||
vis->gx = fx;
|
||||
vis->gy = fy;
|
||||
vis->gz = fz;
|
||||
vis->gzb = gzb;
|
||||
vis->gzt = gzt;
|
||||
vis->deltax = fx - viewx;
|
||||
vis->deltay = fy - viewy;
|
||||
vis->renderflags = thing->renderflags;
|
||||
if(thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D
|
||||
vis->Style.RenderStyle = thing->RenderStyle;
|
||||
vis->FillColor = thing->fillcolor;
|
||||
vis->Translation = thing->Translation;
|
||||
vis->FakeFlatStat = 0;
|
||||
vis->Style.alpha = thing->alpha;
|
||||
vis->fakefloor = NULL;
|
||||
vis->fakeceiling = NULL;
|
||||
vis->ColormapNum = 0;
|
||||
vis->bInMirror = MirrorFlags & RF_XFLIP;
|
||||
vis->pic = pic;
|
||||
vis->bIsVoxel = false;
|
||||
vis->bWallSprite = true;
|
||||
vis->ColormapNum = GETPALOOKUP(
|
||||
(fixed_t)DivScale12 (r_SpriteVisibility, MAX(tz, MINZ)), spriteshade);
|
||||
vis->Style.colormap = basecolormap->Maps + (vis->ColormapNum << COLORMAPSHIFT);
|
||||
vis->wallc = wallc;
|
||||
}
|
||||
|
||||
//
|
||||
// R_AddSprites
|
||||
|
@ -1904,7 +2132,14 @@ void R_DrawSprite (vissprite_t *spr)
|
|||
{
|
||||
mfloorclip = clipbot;
|
||||
mceilingclip = cliptop;
|
||||
R_DrawVisSprite (spr);
|
||||
if (!spr->bWallSprite)
|
||||
{
|
||||
R_DrawVisSprite(spr);
|
||||
}
|
||||
else
|
||||
{
|
||||
R_DrawWallSprite(spr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2161,7 +2396,6 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade,
|
|||
vis->yscale = xscale;
|
||||
vis->depth = tz;
|
||||
vis->idepth = (DWORD)DivScale32 (1, tz) >> 1;
|
||||
vis->cx = tx;
|
||||
vis->gx = particle->x;
|
||||
vis->gy = particle->y;
|
||||
vis->gz = particle->z; // kg3D
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#ifndef __R_THINGS__
|
||||
#define __R_THINGS__
|
||||
|
||||
#include "r_bsp.h"
|
||||
|
||||
// A vissprite_t is a thing
|
||||
// that will be drawn during a refresh.
|
||||
|
@ -31,7 +32,6 @@
|
|||
struct vissprite_t
|
||||
{
|
||||
short x1, x2;
|
||||
fixed_t cx; // for line side calculation
|
||||
fixed_t gx, gy, gz; // origin in world coordinates
|
||||
angle_t angle;
|
||||
fixed_t gzb, gzt; // global bottom / top for silhouette clipping
|
||||
|
@ -43,18 +43,26 @@ struct vissprite_t
|
|||
fixed_t floorclip;
|
||||
union
|
||||
{
|
||||
// Used by regular sprites
|
||||
FTexture *pic;
|
||||
struct FVoxel *voxel;
|
||||
};
|
||||
union
|
||||
{
|
||||
// Used by face sprites
|
||||
struct
|
||||
{
|
||||
FTexture *pic;
|
||||
fixed_t texturemid;
|
||||
fixed_t startfrac; // horizontal position of x1
|
||||
fixed_t xiscale; // negative if flipped
|
||||
};
|
||||
// Used by wall sprites
|
||||
struct
|
||||
{
|
||||
FWallCoords wallc;
|
||||
};
|
||||
// Used by voxels
|
||||
struct
|
||||
{
|
||||
struct FVoxel *voxel;
|
||||
fixed_t vx, vy, vz; // view origin
|
||||
angle_t vang; // view angle
|
||||
};
|
||||
|
@ -64,6 +72,7 @@ struct vissprite_t
|
|||
F3DFloor *fakefloor;
|
||||
F3DFloor *fakeceiling;
|
||||
BYTE bIsVoxel:1; // [RH] Use voxel instead of pic
|
||||
BYTE bWallSprite:1; // [RH] This is a wall sprite
|
||||
BYTE bSplitSprite:1; // [RH] Sprite was split by a drawseg
|
||||
BYTE bInMirror:1; // [RH] Sprite is "inside" a mirror
|
||||
BYTE FakeFlatStat; // [RH] which side of fake/floor ceiling sprite is on
|
||||
|
@ -99,9 +108,11 @@ extern fixed_t pspritexscale;
|
|||
extern fixed_t pspriteyscale;
|
||||
extern fixed_t pspritexiscale;
|
||||
|
||||
extern FTexture *WallSpriteTile;
|
||||
|
||||
|
||||
void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *spans);
|
||||
|
||||
void R_WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans));
|
||||
|
||||
void R_CacheSprite (spritedef_t *sprite);
|
||||
void R_SortVisSprites (int (STACK_ARGS *compare)(const void *, const void *), size_t first);
|
||||
|
|
|
@ -816,6 +816,7 @@ OptionMenu "AltHUDOptions"
|
|||
Option "Show item count", "hud_showitems", "OnOff"
|
||||
Option "Show stamina and accuracy", "hud_showstats", "OnOff"
|
||||
Option "Show berserk", "hud_berserk_health", "OnOff"
|
||||
Option "Show weapons", "hud_showweapons", "OnOff"
|
||||
Option "Show time", "hud_showtime", "AltHUDTime"
|
||||
Option "Time color", "hud_timecolor", "TextColors"
|
||||
Slider "Red ammo display below %", "hud_ammo_red", 0, 100, 1, 0
|
||||
|
|
|
@ -2309,10 +2309,6 @@
|
|||
RelativePath=".\src\r_plane.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\r_polymost.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\r_segs.cpp"
|
||||
>
|
||||
|
@ -2353,10 +2349,6 @@
|
|||
RelativePath=".\src\r_plane.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\r_polymost.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\r_segs.h"
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue