From ec84437212bb830953ec6c1f71878fa2704bd4ca Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 25 Apr 2012 03:21:55 +0000 Subject: [PATCH] - Extended wallscan_np2 to work with masked walls. SVN r3592 (trunk) --- src/r_segs.cpp | 85 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 27 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 4696b4413..7d2857978 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -146,6 +146,9 @@ 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)); +void wallscan_np2(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat, fixed_t top, fixed_t bot, bool mask); +static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat); +static void call_wallscan(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat, bool mask); //============================================================================= // @@ -471,14 +474,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) rw_offset = 0; rw_pic = tex; - if (colfunc == basecolfunc) - { - maskwallscan(x1, x2, mceilingclip, mfloorclip, MaskedSWall, maskedtexturecol, ds->yrepeat); - } - else - { - transmaskwallscan(x1, x2, mceilingclip, mfloorclip, MaskedSWall, maskedtexturecol, ds->yrepeat); - } + wallscan_np2_ds(ds, x1, x2, mceilingclip, mfloorclip, MaskedSWall, maskedtexturecol, ds->yrepeat); } clearfog: @@ -586,12 +582,7 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) } PrepLWall (lwall, curline->sidedef->TexelLength*xscale); - - if(colfunc == basecolfunc) - maskwallscan(x1, x2, wallupper, walllower, MaskedSWall , lwall, yscale); - else { - transmaskwallscan(x1, x2, wallupper, walllower, MaskedSWall, lwall, yscale); - } + wallscan_np2_ds(ds, x1, x2, wallupper, walllower, MaskedSWall, lwall, yscale); R_FinishSetPatchStyle(); } @@ -1217,15 +1208,29 @@ void wallscan_striped (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, wallshade = startshade; } -static void call_wallscan(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat) +static void call_wallscan(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat, bool mask) { - if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size())) + if (mask) { - wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); + if (colfunc == basecolfunc) + { + maskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); + } + else + { + transmaskwallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); + } } else { - wallscan_striped(x1, x2, uwal, dwal, swal, lwal, yrepeat); + if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size())) + { + wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); + } + else + { + wallscan_striped(x1, x2, uwal, dwal, swal, lwal, yrepeat); + } } } @@ -1240,7 +1245,7 @@ static void call_wallscan(int x1, int x2, short *uwal, short *dwal, fixed_t *swa // //============================================================================= -void wallscan_np2(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat, fixed_t top, fixed_t bot) +void wallscan_np2(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat, fixed_t top, fixed_t bot, bool mask) { short *up = uwal; @@ -1264,7 +1269,7 @@ void wallscan_np2(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed { down[j] = clamp (most3[j], up[j], dwal[j]); } - call_wallscan(x1, x2, up, down, swal, lwal, yrepeat); + call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); up = down; down = (down == most1) ? most2 : most1; } @@ -1272,7 +1277,33 @@ void wallscan_np2(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed dc_texturemid -= texheight; } } - call_wallscan(x1, x2, up, dwal, swal, lwal, yrepeat); + call_wallscan(x1, x2, up, dwal, swal, lwal, yrepeat, mask); +} + +static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat) +{ + if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) + { + fixed_t frontcz1 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v1->x, ds->curline->v1->y); + fixed_t frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1->x, ds->curline->v1->y); + fixed_t frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2->x, ds->curline->v2->y); + fixed_t frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2->x, ds->curline->v2->y); + fixed_t top = MAX(frontcz1, frontcz2); + fixed_t bot = MIN(frontfz1, frontfz2); + if (fake3D & FAKE3D_CLIPTOP) + { + top = MIN(top, sclipTop); + } + if (fake3D & FAKE3D_CLIPBOTTOM) + { + bot = MAX(bot, sclipBottom); + } + wallscan_np2(x1, x2, uwal, dwal, swal, lwal, yrepeat, top, bot, true); + } + else + { + call_wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat, true); + } } inline fixed_t mvline1 (fixed_t vince, BYTE *colormap, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest) @@ -1743,11 +1774,11 @@ void R_RenderSegLoop () } if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) { - wallscan_np2(x1, x2-1, walltop, wallbottom, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_frontfz1, rw_frontfz2)); + wallscan_np2(x1, x2-1, walltop, wallbottom, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_frontfz1, rw_frontfz2), false); } else { - call_wallscan(x1, x2-1, walltop, wallbottom, swall, lwall, yscale); + call_wallscan(x1, x2-1, walltop, wallbottom, swall, lwall, yscale, false); } } clearbufshort (ceilingclip+x1, x2-x1, viewheight); @@ -1782,11 +1813,11 @@ void R_RenderSegLoop () } if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) { - wallscan_np2(x1, x2-1, walltop, wallupper, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_backcz1, rw_backcz2)); + wallscan_np2(x1, x2-1, walltop, wallupper, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_backcz1, rw_backcz2), false); } else { - call_wallscan(x1, x2-1, walltop, wallupper, swall, lwall, yscale); + call_wallscan(x1, x2-1, walltop, wallupper, swall, lwall, yscale, false); } } memcpy (ceilingclip+x1, wallupper+x1, (x2-x1)*sizeof(short)); @@ -1824,11 +1855,11 @@ void R_RenderSegLoop () } if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) { - wallscan_np2(x1, x2-1, walllower, wallbottom, swall, lwall, yscale, MAX(rw_backfz1, rw_backfz2), MIN(rw_frontfz1, rw_frontfz2)); + wallscan_np2(x1, x2-1, walllower, wallbottom, swall, lwall, yscale, MAX(rw_backfz1, rw_backfz2), MIN(rw_frontfz1, rw_frontfz2), false); } else { - call_wallscan(x1, x2-1, walllower, wallbottom, swall, lwall, yscale); + call_wallscan(x1, x2-1, walllower, wallbottom, swall, lwall, yscale, false); } } memcpy (floorclip+x1, walllower+x1, (x2-x1)*sizeof(short));