- SW: Replace use of clipmove_old() inline wrapper with clipmove() and remove inline wrappers.

This commit is contained in:
Mitch Richters 2021-10-30 21:59:47 +11:00 committed by Christoph Oelckers
parent 0ac63fd663
commit adcdbdc931
4 changed files with 50 additions and 67 deletions

View file

@ -627,23 +627,6 @@ static inline int64_t compat_maybe_truncate_to_int32(int64_t val)
return enginecompatibility_mode != ENGINECOMPATIBILITY_NONE ? (int32_t)val : val; return enginecompatibility_mode != ENGINECOMPATIBILITY_NONE ? (int32_t)val : val;
} }
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)));
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)
{
vec3_t vector = { *x, *y, *z };
int32_t result = clipmove(&vector, sectnum, xvect, yvect, walldist, ceildist, flordist, cliptype);
*x = vector.x;
*y = vector.y;
*z = vector.z;
return result;
}
static inline int32_t pushmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t walldist, static inline int32_t pushmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t walldist,
int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2,3,4))); int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2,3,4)));

View file

@ -41,7 +41,7 @@ BEGIN_SW_NS
int MultiClipMove(PLAYERp pp, int z, int floor_dist) int MultiClipMove(PLAYERp pp, int z, int floor_dist)
{ {
int i; int i;
int ox[MAX_CLIPBOX],oy[MAX_CLIPBOX]; vec3_t opos[MAX_CLIPBOX], pos[MAX_CLIPBOX];
SECTOR_OBJECTp sop = pp->sop; SECTOR_OBJECTp sop = pp->sop;
short ang; short ang;
short min_ndx = 0; short min_ndx = 0;
@ -51,10 +51,8 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist)
int ret_start; int ret_start;
int ret; int ret;
int min_ret=0; int min_ret=0;
int x[MAX_CLIPBOX],y[MAX_CLIPBOX];
int xvect,yvect; int xvect,yvect;
int xs,ys;
for (i = 0; i < sop->clipbox_num; i++) for (i = 0; i < sop->clipbox_num; i++)
{ {
@ -62,13 +60,12 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist)
// allowing you to move through wall // allowing you to move through wall
ang = NORM_ANGLE(pp->angle.ang.asbuild() + sop->clipbox_ang[i]); ang = NORM_ANGLE(pp->angle.ang.asbuild() + sop->clipbox_ang[i]);
xs = pp->posx; vec3_t spos = { pp->posx, pp->posy, z };
ys = pp->posy;
xvect = sop->clipbox_vdist[i] * bcos(ang); xvect = sop->clipbox_vdist[i] * bcos(ang);
yvect = sop->clipbox_vdist[i] * bsin(ang); yvect = sop->clipbox_vdist[i] * bsin(ang);
clipmoveboxtracenum = 1; clipmoveboxtracenum = 1;
ret_start = clipmove_old(&xs, &ys, &z, &pp->cursectnum, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER); ret_start = clipmove(&spos, &pp->cursectnum, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER);
clipmoveboxtracenum = 3; clipmoveboxtracenum = 3;
if (ret_start) if (ret_start)
@ -77,15 +74,15 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist)
min_dist = 0; min_dist = 0;
min_ndx = i; min_ndx = i;
// ox is where it should be // ox is where it should be
ox[i] = x[i] = pp->posx + MulScale(sop->clipbox_vdist[i], bcos(ang), 14); opos[i].x = pos[i].x = pp->posx + MulScale(sop->clipbox_vdist[i], bcos(ang), 14);
oy[i] = y[i] = pp->posy + MulScale(sop->clipbox_vdist[i], bsin(ang), 14); opos[i].y = pos[i].y = pp->posy + MulScale(sop->clipbox_vdist[i], bsin(ang), 14);
// xs is where it hit // spos.x is where it hit
x[i] = xs; pos[i].x = spos.x;
y[i] = ys; pos[i].y = spos.y;
// see the dist moved // see the dist moved
dist = ksqrt(SQ(x[i] - ox[i]) + SQ(y[i] - oy[i])); dist = ksqrt(SQ(pos[i].x - opos[i].x) + SQ(pos[i].y - opos[i].y));
// save it off // save it off
if (dist < min_dist) if (dist < min_dist)
@ -98,14 +95,14 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist)
else else
{ {
// save off the start position // save off the start position
ox[i] = x[i] = xs; opos[i] = pos[i] = spos;
oy[i] = y[i] = ys; pos[i].z = z;
// move the box // move the box
ret = clipmove_old(&x[i], &y[i], &z, &pp->cursectnum, pp->xvect, pp->yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER); ret = clipmove(&pos[i], &pp->cursectnum, pp->xvect, pp->yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER);
// save the dist moved // save the dist moved
dist = ksqrt(SQ(x[i] - ox[i]) + SQ(y[i] - oy[i])); dist = ksqrt(SQ(pos[i].x - opos[i].x) + SQ(pos[i].y - opos[i].y));
if (ret) if (ret)
{ {
@ -121,8 +118,8 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist)
} }
// put posx and y off from offset // put posx and y off from offset
pp->posx += x[min_ndx] - ox[min_ndx]; pp->posx += pos[min_ndx].x - opos[min_ndx].x;
pp->posy += y[min_ndx] - oy[min_ndx]; pp->posy += pos[min_ndx].y - opos[min_ndx].y;
return min_ret; return min_ret;
} }
@ -141,14 +138,13 @@ short MultiClipTurn(PLAYERp pp, short new_ang, int z, int floor_dist)
{ {
ang = NORM_ANGLE(new_ang + sop->clipbox_ang[i]); ang = NORM_ANGLE(new_ang + sop->clipbox_ang[i]);
x = pp->posx; vec3_t pos = { pp->posx, pp->posy, z };
y = pp->posy;
xvect = sop->clipbox_vdist[i] * bcos(ang); xvect = sop->clipbox_vdist[i] * bcos(ang);
yvect = sop->clipbox_vdist[i] * bsin(ang); yvect = sop->clipbox_vdist[i] * bsin(ang);
// move the box // move the box
ret = clipmove_old(&x, &y, &z, &cursectnum, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER); ret = clipmove(&pos, &cursectnum, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER);
ASSERT(cursectnum >= 0); ASSERT(cursectnum >= 0);

View file

@ -2424,7 +2424,9 @@ DoPlayerMoveBoat(PLAYERp pp)
pp->cursectnum = pp->sop->op_main_sector; // for speed pp->cursectnum = pp->sop->op_main_sector; // for speed
floor_dist = labs(z - pp->sop->floor_loz); floor_dist = labs(z - pp->sop->floor_loz);
clipmove_old(&pp->posx, &pp->posy, &z, &pp->cursectnum, pp->xvect, pp->yvect, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER); vec3_t clippos = { pp->posx, pp->posy, z };
clipmove_old(&clippos, &pp->cursectnum, pp->xvect, pp->yvect, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER);
pp->pos.vec2 = clippos.vec2;
OperateSectorObject(pp->sop, pp->angle.ang.asbuild(), pp->posx, pp->posy); OperateSectorObject(pp->sop, pp->angle.ang.asbuild(), pp->posx, pp->posy);
pp->cursectnum = save_sectnum; // for speed pp->cursectnum = save_sectnum; // for speed
@ -2894,9 +2896,15 @@ DoPlayerMoveVehicle(PLAYERp pp)
save_cstat = pp->SpriteP->cstat; save_cstat = pp->SpriteP->cstat;
RESET(pp->SpriteP->cstat, CSTAT_SPRITE_BLOCK); RESET(pp->SpriteP->cstat, CSTAT_SPRITE_BLOCK);
if (pp->sop->clipdist) if (pp->sop->clipdist)
u->ret = clipmove_old(&pp->posx, &pp->posy, &z, &pp->cursectnum, pp->xvect, pp->yvect, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER); {
vec3_t clippos = { pp->posx, pp->posy, z };
u->ret = clipmove(&clippos, &pp->cursectnum, pp->xvect, pp->yvect, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER);
pp->pos.vec2 = clippos.vec2;
}
else else
{
u->ret = MultiClipMove(pp, z, floor_dist); u->ret = MultiClipMove(pp, z, floor_dist);
}
pp->SpriteP->cstat = save_cstat; pp->SpriteP->cstat = save_cstat;
//SetupDriveCrush(pp, x, y); //SetupDriveCrush(pp, x, y);

View file

@ -6828,7 +6828,6 @@ SpriteControl(void)
int int
move_sprite(int spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics) move_sprite(int spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics)
{ {
int daz;
int retval=0, zh; int retval=0, zh;
short dasectnum, tempshort; short dasectnum, tempshort;
SPRITEp spr; SPRITEp spr;
@ -6839,14 +6838,12 @@ move_sprite(int spritenum, int xchange, int ychange, int zchange, int ceildist,
ASSERT(u); ASSERT(u);
vec3_t clippos = spr->pos;
// Can't modify sprite sectors // Can't modify sprite sectors
// directly becuase of linked lists // directly becuase of linked lists
dasectnum = lastsectnum = spr->sectnum; dasectnum = lastsectnum = spr->sectnum;
// Must do this if not using the new
// centered centering (of course)
daz = spr->z;
if (TEST(spr->cstat, CSTAT_SPRITE_YCENTER)) if (TEST(spr->cstat, CSTAT_SPRITE_YCENTER))
{ {
zh = 0; zh = 0;
@ -6855,16 +6852,17 @@ move_sprite(int spritenum, int xchange, int ychange, int zchange, int ceildist,
{ {
// move the center point up for moving // move the center point up for moving
zh = u->zclip; zh = u->zclip;
daz -= zh; clippos.z -= zh;
} }
// ASSERT(inside(spr->x,spr->y,dasectnum)); // ASSERT(inside(spr->x,spr->y,dasectnum));
clipmoveboxtracenum = 1; clipmoveboxtracenum = 1;
retval = clipmove_old(&spr->x, &spr->y, &daz, &dasectnum, retval = clipmove(&clippos, &dasectnum,
((xchange * numtics) << 11), ((ychange * numtics) << 11), ((xchange * numtics) << 11), ((ychange * numtics) << 11),
(((int) spr->clipdist) << 2), ceildist, flordist, cliptype); (((int) spr->clipdist) << 2), ceildist, flordist, cliptype);
spr->pos.vec2 = clippos.vec2;
clipmoveboxtracenum = 3; clipmoveboxtracenum = 3;
//if (TEST(retval, HIT_MASK) == HIT_WALL) //if (TEST(retval, HIT_MASK) == HIT_WALL)
@ -6905,16 +6903,16 @@ move_sprite(int spritenum, int xchange, int ychange, int zchange, int ceildist,
// Takes info from global variables // Takes info from global variables
DoActorGlobZ(spritenum); DoActorGlobZ(spritenum);
daz = spr->z + ((zchange * numtics) >> 3); clippos.z = spr->z + ((zchange * numtics) >> 3);
// test for hitting ceiling or floor // test for hitting ceiling or floor
if ((daz - zh <= globhiz) || (daz - zh > globloz)) if ((clippos.z - zh <= globhiz) || (clippos.z - zh > globloz))
{ {
if (retval == 0) if (retval == 0)
{ {
if (TEST(u->Flags, SPR_CLIMBING)) if (TEST(u->Flags, SPR_CLIMBING))
{ {
spr->z = daz; spr->z = clippos.z;
return 0; return 0;
} }
@ -6923,7 +6921,7 @@ move_sprite(int spritenum, int xchange, int ychange, int zchange, int ceildist,
} }
else else
{ {
spr->z = daz; spr->z = clippos.z;
} }
// extra processing for Stacks and warping // extra processing for Stacks and warping
@ -7076,7 +7074,6 @@ MissileZrange(short SpriteNum)
int int
move_missile(int spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics) move_missile(int spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics)
{ {
int daz;
int retval, zh; int retval, zh;
short dasectnum, tempshort; short dasectnum, tempshort;
SPRITEp sp; SPRITEp sp;
@ -7087,13 +7084,11 @@ move_missile(int spritenum, int xchange, int ychange, int zchange, int ceildist,
ASSERT(u); ASSERT(u);
// Can't modify sprite sectors vec3_t clippos = sp->pos;
// directly becuase of linked lists
dasectnum = lastsectnum = sp->sectnum;
// Can't modify sprite sectors // Can't modify sprite sectors
// directly becuase of linked lists // directly becuase of linked lists
daz = sp->z; dasectnum = lastsectnum = sp->sectnum;
if (TEST(sp->cstat, CSTAT_SPRITE_YCENTER)) if (TEST(sp->cstat, CSTAT_SPRITE_YCENTER))
{ {
@ -7102,15 +7097,16 @@ move_missile(int spritenum, int xchange, int ychange, int zchange, int ceildist,
else else
{ {
zh = u->zclip; zh = u->zclip;
daz -= zh; clippos.z -= zh;
} }
// ASSERT(inside(sp->x,sp->y,dasectnum)); // ASSERT(inside(sp->x,sp->y,dasectnum));
clipmoveboxtracenum = 1; clipmoveboxtracenum = 1;
retval = clipmove_old(&sp->x, &sp->y, &daz, &dasectnum, retval = clipmove(&clippos, &dasectnum,
((xchange * numtics) << 11), ((ychange * numtics) << 11), ((xchange * numtics) << 11), ((ychange * numtics) << 11),
(((int) sp->clipdist) << 2), ceildist, flordist, cliptype); (((int) sp->clipdist) << 2), ceildist, flordist, cliptype);
sp->pos.vec2 = clippos.vec2;
clipmoveboxtracenum = 3; clipmoveboxtracenum = 3;
if (dasectnum < 0) if (dasectnum < 0)
@ -7143,20 +7139,20 @@ move_missile(int spritenum, int xchange, int ychange, int zchange, int ceildist,
// missiles don't need the water to be down // missiles don't need the water to be down
MissileWaterAdjust(spritenum); MissileWaterAdjust(spritenum);
daz = sp->z + ((zchange * numtics) >> 3); clippos.z = sp->z + ((zchange * numtics) >> 3);
// NOTE: this does not tell you when you hit a floor sprite // NOTE: this does not tell you when you hit a floor sprite
// this case is currently treated like it hit a sector // this case is currently treated like it hit a sector
// test for hitting ceiling or floor // test for hitting ceiling or floor
if (daz - zh <= u->hiz + ceildist) if (clippos.z - zh <= u->hiz + ceildist)
{ {
// normal code // normal code
sp->z = u->hiz + zh + ceildist; sp->z = u->hiz + zh + ceildist;
if (retval == 0) if (retval == 0)
retval = dasectnum|HIT_SECTOR; retval = dasectnum|HIT_SECTOR;
} }
else if (daz - zh > u->loz - flordist) else if (clippos.z - zh > u->loz - flordist)
{ {
sp->z = u->loz + zh - flordist; sp->z = u->loz + zh - flordist;
if (retval == 0) if (retval == 0)
@ -7164,7 +7160,7 @@ move_missile(int spritenum, int xchange, int ychange, int zchange, int ceildist,
} }
else else
{ {
sp->z = daz; sp->z = clippos.z;
} }
if (FAF_ConnectArea(sp->sectnum)) if (FAF_ConnectArea(sp->sectnum))
@ -7231,6 +7227,7 @@ move_ground_missile(short spritenum, int xchange, int ychange, int ceildist, int
// directly becuase of linked lists // directly becuase of linked lists
dasectnum = lastsectnum = sp->sectnum; dasectnum = lastsectnum = sp->sectnum;
vec3_t opos = sp->pos;
daz = sp->z; daz = sp->z;
// climbing a wall // climbing a wall
@ -7253,8 +7250,6 @@ move_ground_missile(short spritenum, int xchange, int ychange, int ceildist, int
u->z_tgt = 0; u->z_tgt = 0;
} }
ox = sp->x;
oy = sp->y;
sp->x += xchange/2; sp->x += xchange/2;
sp->y += ychange/2; sp->y += ychange/2;
@ -7264,12 +7259,13 @@ move_ground_missile(short spritenum, int xchange, int ychange, int ceildist, int
{ {
// back up and try again // back up and try again
dasectnum = lastsectnum = sp->sectnum; dasectnum = lastsectnum = sp->sectnum;
sp->x = ox; opos = sp->pos;
sp->y = oy; opos.z = daz;
clipmoveboxtracenum = 1; clipmoveboxtracenum = 1;
retval = clipmove_old(&sp->x, &sp->y, &daz, &dasectnum, retval = clipmove(&opos, &dasectnum,
((xchange * numtics) << 11), ((ychange * numtics) << 11), ((xchange * numtics) << 11), ((ychange * numtics) << 11),
(((int) sp->clipdist) << 2), ceildist, flordist, cliptype); (((int) sp->clipdist) << 2), ceildist, flordist, cliptype);
sp->pos.vec2 = opos.vec2;
clipmoveboxtracenum = 3; clipmoveboxtracenum = 3;
} }