Minor pushmove() cleanup

git-svn-id: https://svn.eduke32.com/eduke32@7825 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-07-24 01:37:47 +00:00 committed by Christoph Oelckers
parent ed457895f1
commit dc0130625a
2 changed files with 31 additions and 38 deletions

View file

@ -83,8 +83,8 @@ int32_t clipmove(vec3_t *const pos, int16_t *const sectnum, int32_t xvect, int32
int32_t const flordist, uint32_t const cliptype) ATTRIBUTE((nonnull(1, 2))); int32_t const flordist, uint32_t const cliptype) ATTRIBUTE((nonnull(1, 2)));
int32_t clipmovex(vec3_t *const pos, int16_t *const sectnum, int32_t xvect, int32_t yvect, int32_t const walldist, int32_t const ceildist, int32_t clipmovex(vec3_t *const pos, int16_t *const sectnum, int32_t xvect, int32_t yvect, int32_t const walldist, int32_t const ceildist,
int32_t const flordist, uint32_t const cliptype, uint8_t const noslidep) ATTRIBUTE((nonnull(1, 2))); int32_t const flordist, uint32_t const cliptype, uint8_t const noslidep) ATTRIBUTE((nonnull(1, 2)));
int32_t pushmove(vec3_t *const vect, int16_t *const sectnum, int32_t const walldist, int32_t const ceildist, int32_t const flordist, int pushmove(vec3_t *const vect, int16_t *const sectnum, int32_t const walldist, int32_t const ceildist, int32_t const flordist,
uint32_t const cliptype) ATTRIBUTE((nonnull(1, 2))); uint32_t const cliptype, bool clear = true) ATTRIBUTE((nonnull(1, 2)));
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -1379,11 +1379,10 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int
// //
// pushmove // pushmove
// //
int32_t pushmove(vec3_t * const vect, int16_t * const sectnum, int pushmove(vec3_t *const vect, int16_t *const sectnum,
int32_t const walldist, int32_t const ceildist, int32_t const flordist, uint32_t const cliptype) int32_t const walldist, int32_t const ceildist, int32_t const flordist, uint32_t const cliptype, bool clear /*= true*/)
{ {
int32_t i, j, k, t, dx, dy, dax, day, daz; int bad;
int32_t dir, bad, bad2;
const int32_t dawalclipmask = (cliptype&65535); const int32_t dawalclipmask = (cliptype&65535);
// const int32_t dasprclipmask = (cliptype>>16); // const int32_t dasprclipmask = (cliptype>>16);
@ -1391,25 +1390,27 @@ int32_t pushmove(vec3_t * const vect, int16_t * const sectnum,
if (*sectnum < 0) if (*sectnum < 0)
return -1; return -1;
k = 32; int32_t k = 32;
dir = 1;
int dir = 1;
do do
{ {
int32_t clipsectcnt; int32_t clipsectcnt = 0;
bad = 0; bad = 0;
clipsectorlist[0] = *sectnum; if (clear)
clipsectcnt = 0; {
clipsectnum = 1; clipsectorlist[0] = *sectnum;
clipsectnum = 1;
Bmemset(clipsectormap, 0, (numsectors+7)>>3); Bmemset(clipsectormap, 0, (numsectors + 7) >> 3);
bitmap_set(clipsectormap, *sectnum); bitmap_set(clipsectormap, *sectnum);
}
do do
{ {
uwallptr_t wal; uwallptr_t wal;
usectorptr_t sec;
int32_t startwall, endwall; int32_t startwall, endwall;
#if 0 #if 0
// Push FACE sprites // Push FACE sprites
@ -1444,27 +1445,28 @@ int32_t pushmove(vec3_t * const vect, int16_t * const sectnum,
} }
} }
#endif #endif
sec = (usectorptr_t)&sector[clipsectorlist[clipsectcnt]]; auto sec = (usectorptr_t)&sector[clipsectorlist[clipsectcnt]];
if (dir > 0) if (dir > 0)
startwall = sec->wallptr, endwall = startwall + sec->wallnum; startwall = sec->wallptr, endwall = startwall + sec->wallnum;
else else
endwall = sec->wallptr, startwall = endwall + sec->wallnum; endwall = sec->wallptr, startwall = endwall + sec->wallnum;
int i;
for (i=startwall, wal=(uwallptr_t)&wall[startwall]; i!=endwall; i+=dir, wal+=dir) for (i=startwall, wal=(uwallptr_t)&wall[startwall]; i!=endwall; i+=dir, wal+=dir)
if (clipinsidebox((vec2_t *)vect, i, walldist-4) == 1) if (clipinsidebox((vec2_t *)vect, i, walldist-4) == 1)
{ {
j = 0; int j = 0;
if (wal->nextsector < 0) j = 1; if (wal->nextsector < 0 || wal->cstat&dawalclipmask) j = 1;
if (wal->cstat&dawalclipmask) j = 1; else
if (j == 0)
{ {
auto const sec2 = (usectorptr_t)&sector[wal->nextsector];
int32_t daz2; int32_t daz2;
//Find closest point on wall (dax, day) to (vect->x, vect->y) //Find closest point on wall (dax, day) to (vect->x, vect->y)
dax = wall[wal->point2].x-wal->x; int32_t dax = wall[wal->point2].x-wal->x;
day = wall[wal->point2].y-wal->y; int32_t day = wall[wal->point2].y-wal->y;
daz = dax*((vect->x)-wal->x) + day*((vect->y)-wal->y); int32_t daz = dax*((vect->x)-wal->x) + day*((vect->y)-wal->y);
int32_t t;
if (daz <= 0) if (daz <= 0)
t = 0; t = 0;
else else
@ -1477,24 +1479,15 @@ int32_t pushmove(vec3_t * const vect, int16_t * const sectnum,
vec2_t closest = { dax, day }; vec2_t closest = { dax, day };
getsectordist(closest, clipsectorlist[clipsectcnt], &closest); j = cliptestsector(clipsectorlist[clipsectcnt], wal->nextsector, flordist, ceildist, closest, vect->z);
daz = getflorzofslope(clipsectorlist[clipsectcnt], closest.x, closest.y);
daz2 = getflorzofslope(wal->nextsector, closest.x, closest.y);
if ((daz2 < daz-(1<<8)) && ((sec2->floorstat&1) == 0))
if (vect->z >= daz2-(flordist-1)) j = 1;
daz = getceilzofslope(clipsectorlist[clipsectcnt], closest.x, closest.y);
daz2 = getceilzofslope(wal->nextsector, closest.x, closest.y);
if ((daz2 > daz+(1<<8)) && ((sec2->ceilingstat&1) == 0))
if (vect->z <= daz2+(ceildist-1)) j = 1;
} }
if (j != 0) if (j != 0)
{ {
j = getangle(wall[wal->point2].x-wal->x, wall[wal->point2].y-wal->y); j = getangle(wall[wal->point2].x-wal->x, wall[wal->point2].y-wal->y);
dx = (sintable[(j+1024)&2047]>>11); int32_t dx = (sintable[(j+1024)&2047]>>11);
dy = (sintable[(j+512)&2047]>>11); int32_t dy = (sintable[(j+512)&2047]>>11);
bad2 = 16; int bad2 = 16;
do do
{ {
vect->x = (vect->x) + dx; vect->y = (vect->y) + dy; vect->x = (vect->x) + dx; vect->y = (vect->y) + dy;