mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Templatize bfirst_search_init() and bfirst_search_try() so they can be used with types other than int16_t
git-svn-id: https://svn.eduke32.com/eduke32@7629 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/build/src/build.cpp
This commit is contained in:
parent
74c44125f8
commit
3db7512c69
6 changed files with 31 additions and 33 deletions
|
@ -1157,9 +1157,6 @@ static FORCE_INLINE void rotatesprite_win(int32_t sx, int32_t sy, int32_t z, int
|
||||||
rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, windowxy1.x,windowxy1.y,windowxy2.x,windowxy2.y);
|
rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, windowxy1.x,windowxy1.y,windowxy2.x,windowxy2.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bfirst_search_init(int16_t * const list, uint8_t * const bitmap, int32_t * const eltnumptr, int const maxelts, int const firstelt);
|
|
||||||
void bfirst_search_try(int16_t * const list, uint8_t * const bitmap, int32_t * const eltnumptr, int const elt);
|
|
||||||
|
|
||||||
void getzrange(const vec3_t *pos, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz,
|
void getzrange(const vec3_t *pos, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz,
|
||||||
int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(1,3,4,5,6)));
|
int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(1,3,4,5,6)));
|
||||||
int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz,
|
int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz,
|
||||||
|
|
|
@ -1138,9 +1138,35 @@ CONSTEXPR size_t logbasenegative(T n)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
////////// Bitfield manipulation //////////
|
||||||
|
|
||||||
|
static FORCE_INLINE void bitmap_set(uint8_t *const ptr, int const n) { ptr[n >> 3] |= 1 << (n & 7); }
|
||||||
|
static FORCE_INLINE void bitmap_clear(uint8_t *const ptr, int const n) { ptr[n >> 3] &= ~(1 << (n & 7)); }
|
||||||
|
static FORCE_INLINE CONSTEXPR char bitmap_test(uint8_t const *const ptr, int const n) { return ptr[n >> 3] & (1 << (n & 7)); }
|
||||||
|
|
||||||
////////// Utility functions //////////
|
////////// Utility functions //////////
|
||||||
|
|
||||||
|
// breadth-first search helpers
|
||||||
|
template <typename T>
|
||||||
|
void bfirst_search_init(T *const list, uint8_t *const bitmap, T *const eltnumptr, int const maxelts, int const firstelt)
|
||||||
|
{
|
||||||
|
Bmemset(bitmap, 0, (maxelts+7)>>3);
|
||||||
|
|
||||||
|
list[0] = firstelt;
|
||||||
|
bitmap_set(bitmap, firstelt);
|
||||||
|
*eltnumptr = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void bfirst_search_try(T *const list, uint8_t *const bitmap, T *const eltnumptr, int const elt)
|
||||||
|
{
|
||||||
|
if (!bitmap_test(bitmap, elt))
|
||||||
|
{
|
||||||
|
bitmap_set(bitmap, elt);
|
||||||
|
list[(*eltnumptr)++] = elt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if RAND_MAX == 32767
|
#if RAND_MAX == 32767
|
||||||
static FORCE_INLINE uint16_t system_15bit_rand(void) { return (uint16_t)rand(); }
|
static FORCE_INLINE uint16_t system_15bit_rand(void) { return (uint16_t)rand(); }
|
||||||
#else // RAND_MAX > 32767, assumed to be of the form 2^k - 1
|
#else // RAND_MAX > 32767, assumed to be of the form 2^k - 1
|
||||||
|
@ -1168,12 +1194,6 @@ static inline void append_ext_UNSAFE(char *outbuf, const char *ext)
|
||||||
Bstrcpy(p, ext);
|
Bstrcpy(p, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////// Bitfield manipulation //////////
|
|
||||||
|
|
||||||
static FORCE_INLINE void bitmap_set(uint8_t *const ptr, int const n) { ptr[n >> 3] |= 1 << (n & 7); }
|
|
||||||
static FORCE_INLINE void bitmap_clear(uint8_t *const ptr, int const n) { ptr[n >> 3] &= ~(1 << (n & 7)); }
|
|
||||||
static FORCE_INLINE CONSTEXPR char bitmap_test(uint8_t const *const ptr, int const n) { return ptr[n >> 3] & (1 << (n & 7)); }
|
|
||||||
|
|
||||||
/* Begin dependence on compat.o object. */
|
/* Begin dependence on compat.o object. */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -933,7 +933,7 @@ static void clipupdatesector(vec2_t const &pos, int16_t * const sectnum, int con
|
||||||
|
|
||||||
static int16_t sectlist[MAXSECTORS];
|
static int16_t sectlist[MAXSECTORS];
|
||||||
static uint8_t sectbitmap[(MAXSECTORS+7)>>3];
|
static uint8_t sectbitmap[(MAXSECTORS+7)>>3];
|
||||||
int32_t nsecs;
|
int16_t nsecs;
|
||||||
|
|
||||||
bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXCLIPSECTORS, *sectnum);
|
bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXCLIPSECTORS, *sectnum);
|
||||||
|
|
||||||
|
|
|
@ -11007,25 +11007,6 @@ int32_t lastwall(int16_t point)
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
// breadth-first search helpers
|
|
||||||
void bfirst_search_init(int16_t * const list, uint8_t * const bitmap, int32_t * const eltnumptr, int const maxelts, int const firstelt)
|
|
||||||
{
|
|
||||||
Bmemset(bitmap, 0, (maxelts+7)>>3);
|
|
||||||
|
|
||||||
list[0] = firstelt;
|
|
||||||
bitmap_set(bitmap, firstelt);
|
|
||||||
*eltnumptr = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void bfirst_search_try(int16_t * const list, uint8_t * const bitmap, int32_t * const eltnumptr, int const elt)
|
|
||||||
{
|
|
||||||
if (elt >= 0 && bitmap_test(bitmap, elt)==0)
|
|
||||||
{
|
|
||||||
bitmap_set(bitmap, elt);
|
|
||||||
list[(*eltnumptr)++] = elt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////// UPDATESECTOR* FAMILY OF FUNCTIONS //////////
|
////////// UPDATESECTOR* FAMILY OF FUNCTIONS //////////
|
||||||
|
|
||||||
/* Different "is inside" predicates.
|
/* Different "is inside" predicates.
|
||||||
|
@ -11121,7 +11102,7 @@ void updatesector(int32_t const x, int32_t const y, int16_t * const sectnum)
|
||||||
|
|
||||||
static int16_t sectlist[MAXSECTORS];
|
static int16_t sectlist[MAXSECTORS];
|
||||||
static uint8_t sectbitmap[(MAXSECTORS+7)>>3];
|
static uint8_t sectbitmap[(MAXSECTORS+7)>>3];
|
||||||
int32_t nsecs;
|
int16_t nsecs;
|
||||||
|
|
||||||
bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXSECTORS, initialsectnum);
|
bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXSECTORS, initialsectnum);
|
||||||
|
|
||||||
|
@ -11220,7 +11201,7 @@ void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int16_t *
|
||||||
|
|
||||||
static int16_t sectlist[MAXSECTORS];
|
static int16_t sectlist[MAXSECTORS];
|
||||||
static uint8_t sectbitmap[(MAXSECTORS+7)>>3];
|
static uint8_t sectbitmap[(MAXSECTORS+7)>>3];
|
||||||
int32_t nsecs;
|
int16_t nsecs;
|
||||||
|
|
||||||
bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXSECTORS, correctedsectnum);
|
bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXSECTORS, correctedsectnum);
|
||||||
|
|
||||||
|
|
|
@ -6718,7 +6718,7 @@ static void Keys3d(void)
|
||||||
|
|
||||||
static int16_t sectlist[MAXSECTORS];
|
static int16_t sectlist[MAXSECTORS];
|
||||||
static uint8_t sectbitmap[(MAXSECTORS+7)>>3];
|
static uint8_t sectbitmap[(MAXSECTORS+7)>>3];
|
||||||
int32_t sectcnt, sectnum;
|
int16_t sectcnt, sectnum;
|
||||||
|
|
||||||
i = searchsector;
|
i = searchsector;
|
||||||
if (CEILINGFLOOR(i, stat)&1)
|
if (CEILINGFLOOR(i, stat)&1)
|
||||||
|
|
|
@ -1235,7 +1235,7 @@ skip_check:
|
||||||
|
|
||||||
const int32_t o_g_st=vm.g_st, arsize = gar->size;
|
const int32_t o_g_st=vm.g_st, arsize = gar->size;
|
||||||
instype *const end=insptr;
|
instype *const end=insptr;
|
||||||
int32_t sectcnt, numsects=0;
|
int16_t sectcnt, numsects=0;
|
||||||
|
|
||||||
// XXX: relies on -fno-strict-aliasing
|
// XXX: relies on -fno-strict-aliasing
|
||||||
int16_t *const sectlist = (int16_t *)gar->vals; // actually an int32_t array
|
int16_t *const sectlist = (int16_t *)gar->vals; // actually an int32_t array
|
||||||
|
|
Loading…
Reference in a new issue