mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- initialize portals with all other static line specials instead of doing it separately in P_FinishLoadingLineDefs when the map isn't fully set up yet.
- replace all float use in portal.cpp with doubles.
This commit is contained in:
parent
a85a8c1465
commit
9eaefc3685
4 changed files with 49 additions and 50 deletions
|
@ -2064,9 +2064,6 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha)
|
|||
ld->special = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// [ZZ] check initial portal link
|
||||
P_CheckPortal(ld);
|
||||
}
|
||||
// killough 4/4/98: delay using sidedefs until they are loaded
|
||||
void P_FinishLoadingLineDefs ()
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#include "a_keys.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "r_sky.h"
|
||||
#include "portal.h"
|
||||
|
||||
// State.
|
||||
#include "r_state.h"
|
||||
|
@ -1428,6 +1429,10 @@ void P_SpawnSpecials (void)
|
|||
}
|
||||
break;
|
||||
|
||||
case Line_SetPortal:
|
||||
P_SpawnLinePortal(&lines[i]);
|
||||
break;
|
||||
|
||||
// [RH] ZDoom Static_Init settings
|
||||
case Static_Init:
|
||||
switch (lines[i].args[1])
|
||||
|
|
|
@ -11,15 +11,15 @@
|
|||
CVAR(Int, sv_portal_recursions, 4, CVAR_ARCHIVE|CVAR_SERVERINFO)
|
||||
|
||||
// [ZZ] lots of floats here to avoid overflowing a lot
|
||||
bool R_IntersectLines(fixed_t o1x, fixed_t o1y, fixed_t p1x, fixed_t p1y,
|
||||
bool P_IntersectLines(fixed_t o1x, fixed_t o1y, fixed_t p1x, fixed_t p1y,
|
||||
fixed_t o2x, fixed_t o2y, fixed_t p2x, fixed_t p2y,
|
||||
fixed_t& rx, fixed_t& ry)
|
||||
{
|
||||
float xx = FIXED2FLOAT(o2x) - FIXED2FLOAT(o1x);
|
||||
float xy = FIXED2FLOAT(o2y) - FIXED2FLOAT(o1y);
|
||||
double xx = FIXED2DBL(o2x) - FIXED2DBL(o1x);
|
||||
double xy = FIXED2DBL(o2y) - FIXED2DBL(o1y);
|
||||
|
||||
float d1x = FIXED2FLOAT(p1x) - FIXED2FLOAT(o1x);
|
||||
float d1y = FIXED2FLOAT(p1y) - FIXED2FLOAT(o1y);
|
||||
double d1x = FIXED2DBL(p1x) - FIXED2DBL(o1x);
|
||||
double d1y = FIXED2DBL(p1y) - FIXED2DBL(o1y);
|
||||
|
||||
if (d1x > d1y)
|
||||
{
|
||||
|
@ -32,14 +32,14 @@ bool R_IntersectLines(fixed_t o1x, fixed_t o1y, fixed_t p1x, fixed_t p1y,
|
|||
d1y = 32767.0;
|
||||
}
|
||||
|
||||
float d2x = FIXED2FLOAT(p2x) - FIXED2FLOAT(o2x);
|
||||
float d2y = FIXED2FLOAT(p2y) - FIXED2FLOAT(o2y);
|
||||
double d2x = FIXED2DBL(p2x) - FIXED2DBL(o2x);
|
||||
double d2y = FIXED2DBL(p2y) - FIXED2DBL(o2y);
|
||||
|
||||
float cross = d1x*d2y - d1y*d2x;
|
||||
double cross = d1x*d2y - d1y*d2x;
|
||||
if (fabs(cross) < 1e-8)
|
||||
return false;
|
||||
|
||||
float t1 = (xx * d2y - xy * d2x)/cross;
|
||||
double t1 = (xx * d2y - xy * d2x)/cross;
|
||||
rx = o1x + FLOAT2FIXED(d1x * t1);
|
||||
ry = o1y + FLOAT2FIXED(d1y * t1);
|
||||
return true;
|
||||
|
@ -53,8 +53,8 @@ inline int P_PointOnLineSideExplicit (fixed_t x, fixed_t y, fixed_t x1, fixed_t
|
|||
bool P_ClipLineToPortal(line_t* line, line_t* portal, fixed_t viewx, fixed_t viewy, bool partial, bool samebehind)
|
||||
{
|
||||
// check if this line is between portal and the viewer. clip away if it is.
|
||||
bool behind1 = !!P_PointOnLineSide(line->v1->x, line->v1->y, portal);
|
||||
bool behind2 = !!P_PointOnLineSide(line->v2->x, line->v2->y, portal);
|
||||
bool behind1 = !!P_PointOnLineSidePrecise(line->v1->x, line->v1->y, portal);
|
||||
bool behind2 = !!P_PointOnLineSidePrecise(line->v2->x, line->v2->y, portal);
|
||||
|
||||
// [ZZ] update 16.12.2014: if a vertex equals to one of portal's vertices, it's treated as being behind the portal.
|
||||
// this is required in order to clip away diagonal lines around the portal (example: 1-sided triangle shape with a mirror on it's side)
|
||||
|
@ -69,8 +69,8 @@ bool P_ClipLineToPortal(line_t* line, line_t* portal, fixed_t viewx, fixed_t vie
|
|||
{
|
||||
// line is behind the portal plane. now check if it's in front of two view plane borders (i.e. if it will get in the way of rendering)
|
||||
fixed_t dummyx, dummyy;
|
||||
bool infront1 = R_IntersectLines(line->v1->x, line->v1->y, line->v2->x, line->v2->y, viewx, viewy, portal->v1->x, portal->v1->y, dummyx, dummyy);
|
||||
bool infront2 = R_IntersectLines(line->v1->x, line->v1->y, line->v2->x, line->v2->y, viewx, viewy, portal->v2->x, portal->v2->y, dummyx, dummyy);
|
||||
bool infront1 = P_IntersectLines(line->v1->x, line->v1->y, line->v2->x, line->v2->y, viewx, viewy, portal->v1->x, portal->v1->y, dummyx, dummyy);
|
||||
bool infront2 = P_IntersectLines(line->v1->x, line->v1->y, line->v2->x, line->v2->y, viewx, viewy, portal->v2->x, portal->v2->y, dummyx, dummyy);
|
||||
if (infront1 && infront2)
|
||||
return true;
|
||||
}
|
||||
|
@ -78,9 +78,7 @@ bool P_ClipLineToPortal(line_t* line, line_t* portal, fixed_t viewx, fixed_t vie
|
|||
return false;
|
||||
}
|
||||
|
||||
bool P_CheckPortal(line_t* line)
|
||||
{
|
||||
if (line->special == Line_SetPortal)
|
||||
void P_SpawnLinePortal(line_t* line)
|
||||
{
|
||||
// portal destination is special argument #0
|
||||
line_t* dst = NULL;
|
||||
|
@ -114,8 +112,6 @@ bool P_CheckPortal(line_t* line)
|
|||
line->_portal_dst = NULL;
|
||||
}
|
||||
}
|
||||
return (line->_portal);
|
||||
}
|
||||
|
||||
void P_TranslatePortalXY(line_t* src, line_t* dst, fixed_t& x, fixed_t& y)
|
||||
{
|
||||
|
@ -222,9 +218,9 @@ fixed_t P_PointLineDistance(line_t* line, fixed_t x, fixed_t y)
|
|||
|
||||
void P_NormalizeVXVY(fixed_t& vx, fixed_t& vy)
|
||||
{
|
||||
float _vx = FIXED2FLOAT(vx);
|
||||
float _vy = FIXED2FLOAT(vy);
|
||||
float len = sqrt(_vx*_vx+_vy*_vy);
|
||||
double _vx = FIXED2DBL(vx);
|
||||
double _vy = FIXED2DBL(vy);
|
||||
double len = sqrt(_vx*_vx+_vy*_vy);
|
||||
vx = FLOAT2FIXED(_vx/len);
|
||||
vy = FLOAT2FIXED(_vy/len);
|
||||
}
|
||||
|
@ -339,7 +335,7 @@ bool PortalTracer::TraceStep()
|
|||
}
|
||||
}
|
||||
|
||||
//Printf("returning %d; vx = %.2f; vy = %.2f\n", (oDepth != depth), FIXED2FLOAT(this->vx), FIXED2FLOAT(this->vy));
|
||||
//Printf("returning %d; vx = %.2f; vy = %.2f\n", (oDepth != depth), FIXED2DBL(this->vx), FIXED2DBL(this->vy));
|
||||
|
||||
return (oDepth != depth); // if a portal has been found, return false
|
||||
}
|
||||
|
|
|
@ -8,10 +8,11 @@
|
|||
#include "p_local.h"
|
||||
#include "m_bbox.h"
|
||||
|
||||
void P_SpawnLinePortal(line_t* line);
|
||||
|
||||
|
||||
/* code ported from prototype */
|
||||
bool P_ClipLineToPortal(line_t* line, line_t* portal, fixed_t viewx, fixed_t viewy, bool partial = true, bool samebehind = true);
|
||||
bool P_CheckPortal(line_t* line);
|
||||
void P_TranslatePortalXY(line_t* src, line_t* dst, fixed_t& x, fixed_t& y);
|
||||
void P_TranslatePortalVXVY(line_t* src, line_t* dst, fixed_t& vx, fixed_t& vy);
|
||||
void P_TranslatePortalAngle(line_t* src, line_t* dst, angle_t& angle);
|
||||
|
|
Loading…
Reference in a new issue