Skip to content

Commit

Permalink
libdeng1: Added macro DBL2FIX
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Apr 9, 2013
1 parent f71957c commit 329eba4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
12 changes: 6 additions & 6 deletions doomsday/client/src/map/p_maputil.cpp
Expand Up @@ -546,8 +546,8 @@ int PIT_AddLineDefIntercepts(LineDef *line, void * /*parameters*/)
if(s1 == s2) return false;

// 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] )) };
fixed_t linePointX[2] = { DBL2FIX(line->v1Origin()[VX]), DBL2FIX(line->v1Origin()[VY]) };
fixed_t lineDirectionX[2] = { DBL2FIX(line->direction()[VX]), DBL2FIX(line->direction()[VY]) };

float distance = V2x_Intersection(linePointX, lineDirectionX,
traceLos.origin, traceLos.direction);
Expand Down Expand Up @@ -592,10 +592,10 @@ int PIT_AddMobjIntercepts(mobj_t *mo, void * /*parameters*/)

// Calculate interception point.
divline_t dl;
dl.origin[VX] = FLT2FIX(float( from[VX] ));
dl.origin[VY] = FLT2FIX(float( from[VY] ));
dl.direction[VX] = FLT2FIX(float( to[VX] - from[VX] ));
dl.direction[VY] = FLT2FIX(float( to[VY] - from[VY] ));
dl.origin[VX] = DBL2FIX(from[VX]);
dl.origin[VY] = DBL2FIX(from[VY]);
dl.direction[VX] = DBL2FIX(to[VX] - from[VX]);
dl.direction[VY] = DBL2FIX(to[VY] - from[VY]);
coord_t distance = FIX2FLT(Divline_Intersection(&dl, &traceLos));

// On the correct side of the trace origin?
Expand Down
16 changes: 8 additions & 8 deletions doomsday/client/src/map/p_sight.cpp
Expand Up @@ -67,10 +67,10 @@ class LineSightTest
V3d_Copy(_to, to);

// Configure the ray:
_ray.origin[VX] = FLT2FIX(float( _from[VX] ));
_ray.origin[VY] = FLT2FIX(float( _from[VY] ));
_ray.direction[VX] = FLT2FIX(float( _to[VX] - _from[VX] ));
_ray.direction[VY] = FLT2FIX(float( _to[VY] - _from[VY] ));
_ray.origin[VX] = DBL2FIX(_from[VX]);
_ray.origin[VY] = DBL2FIX(_from[VY]);
_ray.direction[VX] = DBL2FIX(_to[VX] - _from[VX]);
_ray.direction[VY] = DBL2FIX(_to[VY] - _from[VY]);

if(_from[VX] > _to[VX])
{
Expand Down Expand Up @@ -153,11 +153,11 @@ class LineSightTest
Divline_PointOnSide(&_ray, line.v2Origin()))
return true;

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] )) };
fixed_t linePointX[2] = { DBL2FIX(line.v1Origin()[VX]), DBL2FIX(line.v1Origin()[VY]) };
fixed_t lineDirectionX[2] = { DBL2FIX(line.direction()[VX]), DBL2FIX(line.direction()[VY]) };

fixed_t fromPointX[2] = { FLT2FIX(float( _from[VX] )), FLT2FIX(float( _from[VY] )) };
fixed_t toPointX[2] = { FLT2FIX(float( _to[VX] )), FLT2FIX(float( _to[VY] )) };
fixed_t fromPointX[2] = { DBL2FIX(_from[VX]), DBL2FIX(_from[VY]) };
fixed_t toPointX[2] = { DBL2FIX(_to[VX]), DBL2FIX(_to[VY]) };

if(V2x_PointOnLineSide(fromPointX, linePointX, lineDirectionX) ==
V2x_PointOnLineSide(toPointX, linePointX, lineDirectionX))
Expand Down
1 change: 1 addition & 0 deletions doomsday/libdeng1/include/de/fixedpoint.h
Expand Up @@ -37,6 +37,7 @@
#define FIX2FLT(x) ( (x) / (float) FRACUNIT )
#define Q_FIX2FLT(x) ( (float) ((x) >> FRACBITS) )
#define FLT2FIX(x) ( (fixed_t) ((x) * FRACUNIT) )
#define DBL2FIX(x) ( (fixed_t) FLT2FIX((float)(x)) )

#ifdef __cplusplus
extern "C" {
Expand Down

0 comments on commit 329eba4

Please sign in to comment.