From b3764f4ee298a0ac91eb91a52730fd88b02cd62b Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Tue, 16 Dec 2014 22:54:49 +0200 Subject: [PATCH] Fixed trivial bug with two-sided portals not clipping stuff correctly --- src/r_bsp.cpp | 6 ++---- src/r_main.cpp | 2 +- src/r_things.cpp | 10 +++++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 4174ab629..5605272e7 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -589,7 +589,7 @@ void R_AddLine (seg_t *line) rw_havehigh = rw_havelow = false; // Single sided line? - if (backsector == NULL) + if (backsector == NULL || (line->linedef->portal && line->sidedef == line->linedef->sidedef[0])) { solid = true; } @@ -654,9 +654,7 @@ void R_AddLine (seg_t *line) // Window. solid = false; } - else if (line->linedef->portal // [ZZ] portals are always drawn, even if there's exactly same sector on both sides - - || backsector->lightlevel != frontsector->lightlevel + else if (backsector->lightlevel != frontsector->lightlevel || backsector->GetTexture(sector_t::floor) != frontsector->GetTexture(sector_t::floor) || backsector->GetTexture(sector_t::ceiling) != frontsector->GetTexture(sector_t::ceiling) || curline->sidedef->GetTexture(side_t::mid).isValid() diff --git a/src/r_main.cpp b/src/r_main.cpp index 676b59ac3..ef942734e 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -639,7 +639,7 @@ void R_HighlightPortal (PortalDrawseg* pds) if (x == pds->x1 || x == pds->x2) { - RenderTarget->DrawLine(x, Ytop, x, Ybottom, color, 0); + RenderTarget->DrawLine(x, Ytop, x, Ybottom+1, color, 0); continue; } diff --git a/src/r_things.cpp b/src/r_things.cpp index 03539eeb6..2aa97f7f0 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2157,7 +2157,8 @@ void R_DrawSprite (vissprite_t *spr) ds->curline->v1->x - spr->gx, ds->curline->v2->y - ds->curline->v1->y) <= 0)) { // seg is behind sprite, so draw the mid texture if it has one - if (ds->maskedtexturecol != -1 || ds->bFogBoundary) + if (ds->CurrentPortalUniq == CurrentPortalUniq && // [ZZ] instead, portal uniq check is made here + (ds->maskedtexturecol != -1 || ds->bFogBoundary)) R_RenderMaskedSegRange (ds, r1, r2); continue; } @@ -2522,9 +2523,6 @@ static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) for (unsigned int p = InterestingDrawsegs.Size(); p-- > FirstInterestingDrawseg; ) { drawseg_t *ds = &drawsegs[InterestingDrawsegs[p]]; - // [ZZ] only draw stuff that's inside the same portal as the particle, other portals will care for themselves - if (ds->CurrentPortalUniq != vis->CurrentPortalUniq) - continue; // kg3D - no fake segs if (ds->fake) continue; if (ds->x1 >= x2 || ds->x2 < x1) @@ -2533,7 +2531,9 @@ static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) } if (Scale (ds->siz2 - ds->siz1, (x2 + x1)/2 - ds->sx1, ds->sx2 - ds->sx1) + ds->siz1 < vis->idepth) { - R_RenderMaskedSegRange (ds, MAX (ds->x1, x1), MIN (ds->x2, x2-1)); + // [ZZ] only draw stuff that's inside the same portal as the particle, other portals will care for themselves + if (ds->CurrentPortalUniq == vis->CurrentPortalUniq) + R_RenderMaskedSegRange (ds, MAX (ds->x1, x1), MIN (ds->x2, x2-1)); } } }