Skip to content

Commit

Permalink
Refactor: Ignore divline_t when tracing intercepts/testing LOS
Browse files Browse the repository at this point in the history
In these cases divline_t is more obfuscation than practical use.
  • Loading branch information
danij-deng committed Apr 9, 2013
1 parent 90ba866 commit f71957c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
15 changes: 0 additions & 15 deletions doomsday/client/include/map/linedef.h
Expand Up @@ -672,21 +672,6 @@ class LineDef : public de::MapElement
return pointOnSide(point);
}

/**
* Configure the specified divline_t by setting the origin point to the
* line's left (i.e., first) vertex and the direction vector parallel to
* the line's direction vector.
*
* @param divline divline_t instance to be configured.
*/
inline void configureDivline(divline_t &dl) const
{
dl.origin[VX] = FLT2FIX(v1Origin()[VX]);
dl.origin[VY] = FLT2FIX(v1Origin()[VY]);
dl.direction[VX] = FLT2FIX(direction()[VX]);
dl.direction[VY] = FLT2FIX(direction()[VY]);
}

/**
* Calculate a unit vector parallel to the line.
*
Expand Down
10 changes: 5 additions & 5 deletions doomsday/client/src/map/p_maputil.cpp
Expand Up @@ -545,12 +545,12 @@ int PIT_AddLineDefIntercepts(LineDef *line, void * /*parameters*/)
}
if(s1 == s2) return false;

// Calculate interception point.
divline_t dl;
line->configureDivline(dl);
float distance = FIX2FLT(Divline_Intersection(&dl, &traceLos));

// On the correct side of the trace origin?
fixed_t linePointX[2] = { FLT2FIX(float( line->v1Origin()[VX] )), FLT2FIX(float( line->v1Origin()[VY] )) };
fixed_t lineDirectionX[2] = { FLT2FIX(float( line->direction()[VX] )), FLT2FIX(float( line->direction()[VY] )) };

float distance = V2x_Intersection(linePointX, lineDirectionX,
traceLos.origin, traceLos.direction);
if(!(distance < 0))
{
P_AddIntercept(ICPT_LINE, distance, line);
Expand Down
12 changes: 8 additions & 4 deletions doomsday/client/src/map/p_sight.cpp
Expand Up @@ -153,10 +153,14 @@ class LineSightTest
Divline_PointOnSide(&_ray, line.v2Origin()))
return true;

divline_t dl;
line.configureDivline(dl);
fixed_t linePointX[2] = { FLT2FIX(float( line.v1Origin()[VX] )), FLT2FIX(float( line.v1Origin()[VY] )) };
fixed_t lineDirectionX[2] = { FLT2FIX(float( line.direction()[VX] )), FLT2FIX(float( line.direction()[VY] )) };

if(Divline_PointOnSide(&dl, _from) == Divline_PointOnSide(&dl, _to))
fixed_t fromPointX[2] = { FLT2FIX(float( _from[VX] )), FLT2FIX(float( _from[VY] )) };
fixed_t toPointX[2] = { FLT2FIX(float( _to[VX] )), FLT2FIX(float( _to[VY] )) };

if(V2x_PointOnLineSide(fromPointX, linePointX, lineDirectionX) ==
V2x_PointOnLineSide(toPointX, linePointX, lineDirectionX))
return true;

// Is this the passable side of a one-way BSP window?
Expand Down Expand Up @@ -210,7 +214,7 @@ class LineSightTest
if(!ranges)
return true;

float frac = FIX2FLT(Divline_Intersection(&dl, &_ray));
float frac = V2x_Intersection(linePointX, lineDirectionX, _ray.origin, _ray.direction);

// Does the ray pass over the top range?
if(_flags & LS_PASSOVER) // Allowed.
Expand Down

0 comments on commit f71957c

Please sign in to comment.