From f561d860e7806e248cbc706376f33e0234fc4c81 Mon Sep 17 00:00:00 2001 From: Zak Larue-Buckley Date: Sun, 15 Dec 2019 17:03:22 +0000 Subject: [PATCH] Add bounding box to line_t. --- include/r_defs.h | 7 +------ source/p_enemy.c | 8 ++++---- source/p_map.c | 32 ++++++++++++++++---------------- source/p_mobj.c | 19 +++++++------------ source/p_sight.c | 8 ++++---- source/r_hotpath.iwram.c | 5 +++-- 6 files changed, 35 insertions(+), 44 deletions(-) diff --git a/include/r_defs.h b/include/r_defs.h index ac0f619..3b3bb97 100644 --- a/include/r_defs.h +++ b/include/r_defs.h @@ -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; @@ -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) diff --git a/source/p_enemy.c b/source/p_enemy.c index 0a14ac0..4bd04e2 100644 --- a/source/p_enemy.c +++ b/source/p_enemy.c @@ -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; diff --git a/source/p_map.c b/source/p_map.c index b969b13..fd80f40 100644 --- a/source/p_map.c +++ b/source/p_map.c @@ -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 // | @@ -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; } @@ -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) @@ -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) diff --git a/source/p_mobj.c b/source/p_mobj.c index 65fa5e5..e0c9594 100644 --- a/source/p_mobj.c +++ b/source/p_mobj.c @@ -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; diff --git a/source/p_sight.c b/source/p_sight.c index 77ed000..7f566bd 100644 --- a/source/p_sight.c +++ b/source/p_sight.c @@ -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 diff --git a/source/r_hotpath.iwram.c b/source/r_hotpath.iwram.c index d6cdeb8..1b7e6e8 100644 --- a/source/r_hotpath.iwram.c +++ b/source/r_hotpath.iwram.c @@ -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 @@ -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