mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 01:11:44 +00:00
Add clipupdatesector(), a special version of updatesector() that only searches and returns results that are already in clipsectorlist[]
git-svn-id: https://svn.eduke32.com/eduke32@7546 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
556d2ccd83
commit
7abfcd28be
3 changed files with 47 additions and 14 deletions
|
@ -1473,6 +1473,15 @@ extern const int32_t engine_v8;
|
|||
int32_t Mulscale(int32_t a, int32_t b, int32_t sh);
|
||||
#endif
|
||||
|
||||
static inline bool inside_p(int32_t const x, int32_t const y, int const sectnum) { return (sectnum >= 0 && inside(x, y, sectnum) == 1); }
|
||||
|
||||
#define SET_AND_RETURN(Lval, Rval) \
|
||||
do \
|
||||
{ \
|
||||
(Lval) = (Rval); \
|
||||
return; \
|
||||
} while (0)
|
||||
|
||||
static inline int32_t clipmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist,
|
||||
int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2,3,4)));
|
||||
|
||||
|
|
|
@ -921,6 +921,41 @@ int sectoradjacent(int sect1, int sect2)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void clipupdatesector(int32_t const x, int32_t const y, int16_t *const sectnum)
|
||||
{
|
||||
if (inside_p(x, y, *sectnum))
|
||||
return;
|
||||
|
||||
static int16_t sectlist[MAXCLIPSECTORS];
|
||||
static uint8_t sectbitmap[MAXCLIPSECTORS >> 3];
|
||||
int32_t nsecs;
|
||||
|
||||
bfirst_search_init(sectlist, sectbitmap, &nsecs, numsectors, *sectnum);
|
||||
|
||||
for (int sectcnt = 0; sectcnt < nsecs; sectcnt++)
|
||||
{
|
||||
if (inside_p(x, y, sectlist[sectcnt]))
|
||||
SET_AND_RETURN(*sectnum, sectlist[sectcnt]);
|
||||
|
||||
auto const sec = §or[sectlist[sectcnt]];
|
||||
int const startwall = sec->wallptr;
|
||||
int const endwall = sec->wallptr + sec->wallnum;
|
||||
|
||||
for (int j = startwall; j < endwall; j++)
|
||||
if (wall[j].nextsector >= 0)
|
||||
{
|
||||
for (int k = 0; k < clipsectnum; k++)
|
||||
if (clipsectorlist[k] == wall[j].nextsector)
|
||||
{
|
||||
bfirst_search_try(sectlist, sectbitmap, &nsecs, wall[j].nextsector);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*sectnum = -1;
|
||||
}
|
||||
|
||||
//
|
||||
// clipmove
|
||||
//
|
||||
|
@ -1283,7 +1318,7 @@ int32_t clipmove(vec3_t *pos, int16_t *sectnum, int32_t xvect, int32_t yvect,
|
|||
|
||||
if ((tempint1^tempint2) < 0)
|
||||
{
|
||||
updatesector(pos->x, pos->y, sectnum);
|
||||
clipupdatesector(pos->x, pos->y, sectnum);
|
||||
return clipReturn;
|
||||
}
|
||||
}
|
||||
|
@ -1298,7 +1333,7 @@ int32_t clipmove(vec3_t *pos, int16_t *sectnum, int32_t xvect, int32_t yvect,
|
|||
}
|
||||
|
||||
int const osectnum = *sectnum;
|
||||
updatesector(vec.x, vec.y, sectnum);
|
||||
clipupdatesector(vec.x, vec.y, sectnum);
|
||||
|
||||
if (*sectnum == osectnum || editstatus || (*sectnum != -1 && !check_floor_curb(osectnum, *sectnum, flordist, pos->z, vec.x, vec.y)))
|
||||
{
|
||||
|
@ -1433,7 +1468,7 @@ int32_t pushmove(vec3_t *vect, int16_t *sectnum,
|
|||
} while (clipinsidebox((vec2_t *)vect, i, walldist-4) != 0);
|
||||
bad = -1;
|
||||
k--; if (k <= 0) return bad;
|
||||
updatesector(vect->x, vect->y, sectnum);
|
||||
clipupdatesector(vect->x, vect->y, sectnum);
|
||||
if (*sectnum < 0) return -1;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -10964,10 +10964,6 @@ void bfirst_search_try(int16_t * const list, uint8_t * const bitmap, int32_t * c
|
|||
/* Different "is inside" predicates.
|
||||
* NOTE: The redundant bound checks are expected to be optimized away in the
|
||||
* inlined code. */
|
||||
static inline bool inside_p(int32_t const x, int32_t const y, int const sectnum)
|
||||
{
|
||||
return (sectnum>=0 && inside(x, y, sectnum) == 1);
|
||||
}
|
||||
|
||||
static inline bool inside_exclude_p(int32_t const x, int32_t const y, int const sectnum, const uint8_t *excludesectbitmap)
|
||||
{
|
||||
|
@ -10982,13 +10978,6 @@ static inline bool inside_z_p(int32_t const x, int32_t const y, int32_t const z,
|
|||
return (z >= cz && z <= fz && inside_p(x, y, sectnum));
|
||||
}
|
||||
|
||||
#define SET_AND_RETURN(Lval, Rval) \
|
||||
do \
|
||||
{ \
|
||||
(Lval) = (Rval); \
|
||||
return; \
|
||||
} while (0)
|
||||
|
||||
//
|
||||
// updatesector[z]
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue