Skip to content

Commit

Permalink
Inline some more code
Browse files Browse the repository at this point in the history
  • Loading branch information
viciious committed Jan 6, 2024
1 parent 870faa6 commit 4e7b4c7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
1 change: 0 additions & 1 deletion p_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ typedef struct
fixed_t P_AproxDistance (fixed_t dx, fixed_t dy);
int P_PointOnLineSide (fixed_t x, fixed_t y, line_t *line);
int P_PointOnDivlineSide (fixed_t x, fixed_t y, divline_t *line);
int P_DivlineSide(fixed_t x, fixed_t y, divline_t *node);
boolean P_BoxCrossLine (line_t *ld, fixed_t testbbox[4]);

fixed_t P_LineOpening (line_t *linedef);
Expand Down
20 changes: 0 additions & 20 deletions p_maputl.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ fixed_t P_AproxDistance(fixed_t dx, fixed_t dy) ATTR_DATA_CACHE_ALIGN;
int P_PointOnLineSide(fixed_t x, fixed_t y, line_t* line) ATTR_DATA_CACHE_ALIGN;
boolean P_BoxCrossLine(line_t *ld, fixed_t testbbox[4]) ATTR_DATA_CACHE_ALIGN;
int P_PointOnDivlineSide(fixed_t x, fixed_t y, divline_t* line) ATTR_DATA_CACHE_ALIGN;
int P_DivlineSide(fixed_t x, fixed_t y, divline_t *node) ATTR_DATA_CACHE_ALIGN;
fixed_t P_LineOpening(line_t* linedef) ATTR_DATA_CACHE_ALIGN;
void P_LineBBox(line_t* ld, fixed_t* bbox) ATTR_DATA_CACHE_ALIGN;
void P_UnsetThingPosition(mobj_t* thing) ATTR_DATA_CACHE_ALIGN;
Expand Down Expand Up @@ -151,25 +150,6 @@ int P_PointOnDivlineSide (fixed_t x, fixed_t y, divline_t *line)
return 1; /* back side */
}

//
// Returns side 0 (front), 1 (back), or 2 (on).
//
int P_DivlineSide(fixed_t x, fixed_t y, divline_t *node)
{
fixed_t dx;
fixed_t dy;
fixed_t left;
fixed_t right;

dx = x - node->x;
dy = y - node->y;

left = (node->dy>>FRACBITS) * (dx>>FRACBITS);
right = (dy>>FRACBITS) * (node->dx>>FRACBITS);

return (left <= right) + (left == right);
}

/*
==================
=
Expand Down
14 changes: 7 additions & 7 deletions p_shoot.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ static boolean PA_CrossSubsector(shootWork_t *sw, int bspnum) ATTR_DATA_CACHE_AL
static boolean PA_CrossBSPNode(shootWork_t *sw, int bspnum) ATTR_DATA_CACHE_ALIGN;
void P_Shoot2(lineattack_t *la) ATTR_DATA_CACHE_ALIGN;

//
// Returns side 0 (front or on), 1 (back)
//
#define PA_NodeSide(xx,yy,n) (!((((xx) - (n)->x * FRACUNIT)>>FRACBITS) * ((n)->dy) > (((yy) - (n)->y * FRACUNIT)>>FRACBITS) * ((n)->dx)))

//
// First checks the endpoints of the line to make sure that they cross the
// sight trace treated as an infinite line.
Expand Down Expand Up @@ -364,7 +369,6 @@ static boolean PA_CrossSubsector(shootWork_t *sw, int bspnum)
static boolean PA_CrossBSPNode(shootWork_t *sw, int bspnum)
{
node_t *bsp;
divline_t dl;
int side, side2;

check:
Expand All @@ -375,14 +379,10 @@ static boolean PA_CrossBSPNode(shootWork_t *sw, int bspnum)
}

bsp = &nodes[bspnum];
dl.dx = (fixed_t)bsp->dx << 16;
dl.dy = (fixed_t)bsp->dy << 16;
dl.x = (fixed_t)bsp->x << 16;
dl.y = (fixed_t)bsp->y << 16;

// decide which side the start point is on
side = P_DivlineSide(sw->shootdiv.x, sw->shootdiv.y, &dl) == 1;
side2 = P_DivlineSide(sw->shootx2, sw->shooty2, &dl) == 1;
side = PA_NodeSide(sw->shootdiv.x, sw->shootdiv.y, bsp);
side2 = PA_NodeSide(sw->shootx2, sw->shooty2, bsp);

// cross the starting side
if(!PA_CrossBSPNode(sw, bsp->children[side]))
Expand Down

0 comments on commit 4e7b4c7

Please sign in to comment.