From 45c97c3ac55f3e6432b84d75539c455e4308c33c 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 4d4399810..0fc33c042 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 7314696be..7c15cefb0 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -641,7 +641,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 9cfedf068..92cd84155 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2150,7 +2150,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; } @@ -2515,9 +2516,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) @@ -2526,7 +2524,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)); } } }