- changed mirror handling so that it works without attaching a portal to the mirror line and removed line_t::portal_mirror member.

- did some cleanup on the portal interface on linedefs: All checks should go through isLinePortal (gameplay related) and isVisualPortal (renderer related) which then can decide on the actual data what to return.
- removed portal_passive because it won't survive the upcoming refactoring.
- removed all direct access to portal members of line_t.
- always use the precise (and fast) version of P_PointOnLineSide inside the renderer.
This commit is contained in:
Christoph Oelckers 2016-02-05 16:14:45 +01:00
parent 00895c245e
commit a85a8c1465
5 changed files with 34 additions and 40 deletions

View file

@ -80,14 +80,7 @@ bool P_ClipLineToPortal(line_t* line, line_t* portal, fixed_t viewx, fixed_t vie
bool P_CheckPortal(line_t* line)
{
if (line->special == Line_Mirror)
{
line->portal = true;
line->portal_mirror = true;
line->portal_passive = true;
line->portal_dst = line;
}
else if (line->special == Line_SetPortal)
if (line->special == Line_SetPortal)
{
// portal destination is special argument #0
line_t* dst = NULL;
@ -110,28 +103,18 @@ bool P_CheckPortal(line_t* line)
if (dst)
{
line->portal = true;
line->portal_mirror = false;
line->portal_passive = true;// !!(line->args[2] & PORTAL_VISUAL; (line->special == Line_SetVisualPortal);
line->portal_dst = dst;
line->_portal = true;
//line->portal_passive = true;// !!(line->args[2] & PORTAL_VISUAL; (line->special == Line_SetVisualPortal);
line->_portal_dst = dst;
}
else
{
line->portal = false;
line->portal_mirror = false;
line->portal_passive = false;
line->portal_dst = NULL;
line->_portal = false;
//line->portal_passive = false;
line->_portal_dst = NULL;
}
}
else
{
line->portal = false;
line->portal_mirror = false;
line->portal_passive = false;
line->portal_dst = NULL;
}
return (line->portal);
return (line->_portal);
}
void P_TranslatePortalXY(line_t* src, line_t* dst, fixed_t& x, fixed_t& y)
@ -297,12 +280,12 @@ bool PortalTracer::TraceStep()
{
li = in->d.line;
if (li->portal && !li->portal_passive)
if (li->isLinePortal())
{
if (P_PointOnLineSide(startx-dirx, starty-diry, li))
continue; // we're at the back side of this line
line_t* out = li->portal_dst;
line_t* out = li->getPortalDestination();
this->in = li;
this->out = out;

View file

@ -590,7 +590,7 @@ void R_AddLine (seg_t *line)
rw_havehigh = rw_havelow = false;
// Single sided line?
if (backsector == NULL || (line->linedef->portal && line->sidedef == line->linedef->sidedef[0]))
if (backsector == NULL || (line->linedef->isVisualPortal() && line->sidedef == line->linedef->sidedef[0]))
{
solid = true;
}

View file

@ -988,14 +988,25 @@ struct line_t
sector_t *frontsector, *backsector;
int validcount; // if == validcount, already checked
int locknumber; // [Dusk] lock number for special
line_t *portal_dst;
bool portal;
bool portal_mirror;
bool portal_passive;
line_t *_portal_dst;
bool _portal;
// returns true if the portal is crossable by actors
bool isLinePortal() const
{
return portal;
return false; // right now there are no crossable portals
}
// returns true if the portal needs to be handled by the renderer
bool isVisualPortal() const
{
return _portal;
}
line_t *getPortalDestination() const
{
return _portal_dst;
}
};

View file

@ -2004,8 +2004,7 @@ void R_NewWall (bool needlights)
midtexture = toptexture = bottomtexture = 0;
if (sidedef == linedef->sidedef[0] &&
linedef->portal &&
(!linedef->portal_mirror || r_drawmirrors)) // [ZZ] compatibility with r_drawmirrors cvar that existed way before portals
(linedef->isVisualPortal() || (linedef->special == Line_Mirror && r_drawmirrors))) // [ZZ] compatibility with r_drawmirrors cvar that existed way before portals
{
markfloor = markceiling = true; // act like an one-sided wall here (todo: check how does this work with transparency)
rw_markportal = true;
@ -2632,7 +2631,7 @@ void R_StoreWallRange (int start, int stop)
{
PortalDrawseg pds;
pds.src = curline->linedef;
pds.dst = curline->linedef->portal_dst;
pds.dst = curline->linedef->special == Line_Mirror? curline->linedef : curline->linedef->getPortalDestination();
pds.x1 = ds_p->x1;
pds.x2 = ds_p->x2;
pds.len = pds.x2 - pds.x1;
@ -2653,7 +2652,7 @@ void R_StoreWallRange (int start, int stop)
pds.floorclip[i] = RenderTarget->GetHeight()-1;
}
pds.mirror = curline->linedef->portal_mirror;
pds.mirror = curline->linedef->special == Line_Mirror;
WallPortals.Push(pds);
}

View file

@ -31,6 +31,7 @@
#include <stdlib.h>
#include <algorithm>
#include "p_lnspec.h"
#include "templates.h"
#include "doomdef.h"
#include "m_swap.h"
@ -339,11 +340,11 @@ static inline bool R_ClipSpriteColumnWithPortals (fixed_t x, fixed_t y, vissprit
if (!seg->curline) continue;
line_t* line = seg->curline->linedef;
// divline? wtf, anyway, divlines aren't supposed to be drawn. But I definitely saw NULL linedefs in drawsegs.
// ignore minisegs from GL nodes.
if (!line) continue;
// check if this line will clip sprites to itself
if (!line->portal)
if (!line->isVisualPortal() && line->special != Line_Mirror)
continue;
// don't clip sprites with portal's back side (it's transparent)
@ -739,7 +740,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
// [ZZ] Or less definitely not visible (hue)
// [ZZ] 10.01.2016: don't try to clip stuff inside a skybox against the current portal.
if (!CurrentPortalInSkybox && CurrentPortal && !!P_PointOnLineSide(thing->X(), thing->Y(), CurrentPortal->dst))
if (!CurrentPortalInSkybox && CurrentPortal && !!P_PointOnLineSidePrecise(thing->X(), thing->Y(), CurrentPortal->dst))
return;
// [RH] Interpolate the sprite's position to make it look smooth