Skip to content

Commit

Permalink
Add bounding box to line_t.
Browse files Browse the repository at this point in the history
  • Loading branch information
doomhack committed Dec 15, 2019
1 parent c702237 commit f561d86
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 44 deletions.
7 changes: 1 addition & 6 deletions include/r_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ typedef struct line_s
fixed_t dx, dy; // Precalculated v2 - v1 for side checking.

unsigned short sidenum[2]; // Visual appearance: SideDefs.
fixed_t bbox[4]; //Line bounding box.

unsigned short flags; // Animation related.
short const_special;
Expand All @@ -200,12 +201,6 @@ typedef struct line_s

} line_t;

#define LN_BBOX_LEFT(l) (l->v1.x < l->v2.x ? l->v1.x : l->v2.x)
#define LN_BBOX_RIGHT(l) (l->v1.x < l->v2.x ? l->v2.x : l->v1.x)

#define LN_BBOX_TOP(l) (l->v1.y < l->v2.y ? l->v2.y : l->v1.y)
#define LN_BBOX_BOTTOM(l) (l->v1.y < l->v2.y ? l->v1.y : l->v2.y)

#define LN_FRONTSECTOR(l) (_g->sides[(l)->sidenum[0]].sector)
#define LN_BACKSECTOR(l) ((l)->sidenum[1] != NO_INDEX ? _g->sides[(l)->sidenum[1]].sector : NULL)

Expand Down
8 changes: 4 additions & 4 deletions source/p_enemy.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,10 @@ static void P_DoNewChaseDir(mobj_t *actor, fixed_t deltax, fixed_t deltay)
static boolean PIT_AvoidDropoff(const line_t *line)
{
if (LN_BACKSECTOR(line) && // Ignore one-sided linedefs
_g->tmbbox[BOXRIGHT] > LN_BBOX_LEFT(line) &&
_g->tmbbox[BOXLEFT] < LN_BBOX_RIGHT(line) &&
_g->tmbbox[BOXTOP] > LN_BBOX_BOTTOM(line) && // Linedef must be contacted
_g->tmbbox[BOXBOTTOM] < LN_BBOX_TOP(line) &&
_g->tmbbox[BOXRIGHT] > line->bbox[BOXLEFT] &&
_g->tmbbox[BOXLEFT] < line->bbox[BOXRIGHT] &&
_g->tmbbox[BOXTOP] > line->bbox[BOXBOTTOM] && // Linedef must be contacted
_g->tmbbox[BOXBOTTOM] < line->bbox[BOXTOP] &&
P_BoxOnLineSide(_g->tmbbox, line) == -1)
{
fixed_t front = LN_FRONTSECTOR(line)->floorheight;
Expand Down
32 changes: 16 additions & 16 deletions source/p_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ boolean PIT_CrossLine (const line_t* ld)
{
if (!(ld->flags & ML_TWOSIDED) ||
(ld->flags & (ML_BLOCKING|ML_BLOCKMONSTERS)))
if (!(_g->tmbbox[BOXLEFT] > LN_BBOX_RIGHT(ld) ||
_g->tmbbox[BOXRIGHT] < LN_BBOX_LEFT(ld) ||
_g->tmbbox[BOXTOP] < LN_BBOX_BOTTOM(ld) ||
_g->tmbbox[BOXBOTTOM] > LN_BBOX_TOP(ld)))
if (!(_g->tmbbox[BOXLEFT] > ld->bbox[BOXRIGHT] ||
_g->tmbbox[BOXRIGHT] < ld->bbox[BOXLEFT] ||
_g->tmbbox[BOXTOP] < ld->bbox[BOXBOTTOM] ||
_g->tmbbox[BOXBOTTOM] > ld->bbox[BOXTOP]))
if (P_PointOnLineSide(_g->pe_x,_g->pe_y,ld) != P_PointOnLineSide(_g->ls_x,_g->ls_y,ld))
return(false); // line blocks trajectory // ^
return(true); // line doesn't block trajectory // |
Expand All @@ -212,10 +212,10 @@ static int untouched(const line_t *ld)
{
fixed_t x, y, tmbbox[4];
return
(tmbbox[BOXRIGHT] = (x=_g->tmthing->x)+_g->tmthing->radius) <= LN_BBOX_LEFT(ld) ||
(tmbbox[BOXLEFT] = x-_g->tmthing->radius) >= LN_BBOX_RIGHT(ld) ||
(tmbbox[BOXTOP] = (y=_g->tmthing->y)+_g->tmthing->radius) <= LN_BBOX_BOTTOM(ld) ||
(tmbbox[BOXBOTTOM] = y-_g->tmthing->radius) >= LN_BBOX_TOP(ld) ||
(tmbbox[BOXRIGHT] = (x=_g->tmthing->x)+_g->tmthing->radius) <= ld->bbox[BOXLEFT] ||
(tmbbox[BOXLEFT] = x-_g->tmthing->radius) >= ld->bbox[BOXRIGHT] ||
(tmbbox[BOXTOP] = (y=_g->tmthing->y)+_g->tmthing->radius) <= ld->bbox[BOXBOTTOM] ||
(tmbbox[BOXBOTTOM] = y-_g->tmthing->radius) >= ld->bbox[BOXTOP] ||
P_BoxOnLineSide(tmbbox, ld) != -1;
}

Expand All @@ -227,10 +227,10 @@ static int untouched(const line_t *ld)
static // killough 3/26/98: make static
boolean PIT_CheckLine (const line_t* ld)
{
if (_g->tmbbox[BOXRIGHT] <= LN_BBOX_LEFT(ld)
|| _g->tmbbox[BOXLEFT] >= LN_BBOX_RIGHT(ld)
|| _g->tmbbox[BOXTOP] <= LN_BBOX_BOTTOM(ld)
|| _g->tmbbox[BOXBOTTOM] >= LN_BBOX_TOP(ld) )
if (_g->tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT]
|| _g->tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT]
|| _g->tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM]
|| _g->tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP] )
return true; // didn't hit it

if (P_BoxOnLineSide(_g->tmbbox, ld) != -1)
Expand Down Expand Up @@ -1708,10 +1708,10 @@ void P_DelSeclist(msecnode_t* node)

boolean PIT_GetSectors(const line_t* ld)
{
if (_g->tmbbox[BOXRIGHT] <= LN_BBOX_LEFT(ld) ||
_g->tmbbox[BOXLEFT] >= LN_BBOX_RIGHT(ld) ||
_g->tmbbox[BOXTOP] <= LN_BBOX_BOTTOM(ld) ||
_g->tmbbox[BOXBOTTOM] >= LN_BBOX_TOP(ld))
if (_g->tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] ||
_g->tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] ||
_g->tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] ||
_g->tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP])
return true;

if (P_BoxOnLineSide(_g->tmbbox, ld) != -1)
Expand Down
19 changes: 7 additions & 12 deletions source/p_mobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,21 @@ boolean P_SetMobjState(mobj_t* mobj, statenum_t state)

// Modified handling.
// Call action functions when the state is set

if(_g->player.cheats & CF_ENEMY_ROCKETS)
if(st->action)
{
if (st->action)
if(!(_g->player.cheats & CF_ENEMY_ROCKETS))
{
st->action(mobj);
}
else
{
if(mobj->info->missilestate && (state >= mobj->info->missilestate) && (state < mobj->info->painstate))
{
A_CyberAttack(mobj);
}
else
st->action(mobj);
}
}
else
{
if (st->action)
st->action(mobj);
}

state = st->nextstate;

} while (!mobj->tics);

return true;
Expand Down
8 changes: 4 additions & 4 deletions source/p_sight.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ static boolean P_CrossSubsector(int num)
//you and open doors to come after you. It was awesome!
//I guess they could just see you even when out of sight.

if (LN_BBOX_LEFT(line) > _g->los.bbox[BOXRIGHT ] ||
LN_BBOX_RIGHT(line) < _g->los.bbox[BOXLEFT ] ||
LN_BBOX_BOTTOM(line) > _g->los.bbox[BOXTOP ] ||
LN_BBOX_TOP(line) < _g->los.bbox[BOXBOTTOM])
if (line->bbox[BOXLEFT] > _g->los.bbox[BOXRIGHT ] ||
line->bbox[BOXRIGHT] < _g->los.bbox[BOXLEFT ] ||
line->bbox[BOXBOTTOM] > _g->los.bbox[BOXTOP ] ||
line->bbox[BOXTOP] < _g->los.bbox[BOXBOTTOM])
continue;

// cph - do what we can before forced to check intersection
Expand Down
5 changes: 3 additions & 2 deletions source/r_hotpath.iwram.c
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,7 @@ static void R_RenderSegLoop (void)
dcvars.colormap = R_LoadColorMap(rw_lightlevel);



for ( ; rw_x < rw_stopx ; rw_x++)
{
// mark floor / ceiling areas
Expand Down Expand Up @@ -1926,14 +1927,14 @@ static void R_StoreWallRange(const int start, const int stop)

linedata_t* linedata = &_g->linedata[curline->linenum];

// mark the segment as visible for auto map
linedata->r_flags |= ML_MAPPED;

sidedef = &_g->sides[curline->sidenum];
linedef = &_g->lines[curline->linenum];


// mark the segment as visible for auto map
linedata->r_flags |= ML_MAPPED;
//linedata->r_flags |= ML_MAPPED;
//linedef->flags |= ML_MAPPED;

// calculate rw_distance for scale calculation
Expand Down

0 comments on commit f561d86

Please sign in to comment.