- floating point MultiClip API.

This commit is contained in:
Christoph Oelckers 2022-09-03 22:20:12 +02:00
parent d80b39d184
commit caa41e312d
3 changed files with 10 additions and 12 deletions

View file

@ -37,9 +37,8 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
BEGIN_SW_NS BEGIN_SW_NS
Collision MultiClipMove(PLAYER* pp, int z, int floor_dist) Collision MultiClipMove(PLAYER* pp, double zz, double floordist)
{ {
double zz = z * inttoworld;
int i; int i;
DVector3 opos[MAX_CLIPBOX], pos[MAX_CLIPBOX]; DVector3 opos[MAX_CLIPBOX], pos[MAX_CLIPBOX];
SECTOR_OBJECT* sop = pp->sop; SECTOR_OBJECT* sop = pp->sop;
@ -62,7 +61,7 @@ Collision MultiClipMove(PLAYER* pp, int z, int floor_dist)
int xvect = vect.X * 16 * worldtoint; // note: this means clipmove input is Q18.14! int xvect = vect.X * 16 * worldtoint; // note: this means clipmove input is Q18.14!
int yvect = vect.Y * 16 * worldtoint; int yvect = vect.Y * 16 * worldtoint;
clipmove(spos, &pp->cursector, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER, coll, 1); clipmove(spos, &pp->cursector, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), int(floordist * zworldtoint), CLIPMASK_PLAYER, coll, 1);
if (coll.type != kHitNone) if (coll.type != kHitNone)
{ {
@ -90,10 +89,10 @@ Collision MultiClipMove(PLAYER* pp, int z, int floor_dist)
{ {
// save off the start position // save off the start position
opos[i] = pos[i] = spos; opos[i] = pos[i] = spos;
pos[i].Z = z; pos[i].Z = zz;
// move the box // move the box
clipmove(pos[i], &pp->cursector, pp->vect.X, pp->vect.Y, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER, coll); clipmove(pos[i], &pp->cursector, pp->vect.X, pp->vect.Y, (int)sop->clipbox_dist[i], Z(4), int(floordist * zworldtoint), CLIPMASK_PLAYER, coll);
// save the dist moved // save the dist moved
dist = (pos[i].XY() - opos[i].XY()).Length(); dist = (pos[i].XY() - opos[i].XY()).Length();
@ -113,9 +112,8 @@ Collision MultiClipMove(PLAYER* pp, int z, int floor_dist)
return min_ret; return min_ret;
} }
short MultiClipTurn(PLAYER* pp, DAngle new_ang, int z, int floor_dist) int MultiClipTurn(PLAYER* pp, DAngle new_ang, double zz, double floordist)
{ {
double zz = z * inttoworld;
int i; int i;
SECTOR_OBJECT* sop = pp->sop; SECTOR_OBJECT* sop = pp->sop;
int ret; int ret;
@ -132,7 +130,7 @@ short MultiClipTurn(PLAYER* pp, DAngle new_ang, int z, int floor_dist)
int xvect = vect.X * 16 * worldtoint; // note: this means clipmove input is Q18.14! int xvect = vect.X * 16 * worldtoint; // note: this means clipmove input is Q18.14!
int yvect = vect.Y * 16 * worldtoint; int yvect = vect.Y * 16 * worldtoint;
clipmove(spos, &cursect, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER, coll); clipmove(spos, &cursect, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), int(floordist * zworldtoint), CLIPMASK_PLAYER, coll);
ASSERT(cursect); ASSERT(cursect);

View file

@ -27,8 +27,8 @@ BEGIN_SW_NS
#define RECT_CLIP 1 #define RECT_CLIP 1
Collision MultiClipMove(PLAYER* pp, int z, int floor_dist); Collision MultiClipMove(PLAYER* pp, double z, double floor_dist);
short MultiClipTurn(PLAYER* pp, DAngle new_ang, int z, int floor_dist); int MultiClipTurn(PLAYER* pp, DAngle new_ang, double zz, double floordist);
int RectClipMove(PLAYER* pp, DVector2* qpos); int RectClipMove(PLAYER* pp, DVector2* qpos);
int testpointinquad(const DVector2& pt, const DVector2* quad); int testpointinquad(const DVector2& pt, const DVector2* quad);
//short RectClipTurn(PLAYER* pp, short new_ang, int z, int floor_dist, int *qx, int *qy); //short RectClipTurn(PLAYER* pp, short new_ang, int z, int floor_dist, int *qx, int *qy);

View file

@ -1469,7 +1469,7 @@ void DoPlayerTurnVehicle(PLAYER* pp, float avel, int z, int floor_dist)
if (avel != 0) if (avel != 0)
{ {
auto sum = pp->angle.ang + DAngle::fromDeg(avel); auto sum = pp->angle.ang + DAngle::fromDeg(avel);
if (MultiClipTurn(pp, sum, z, floor_dist)) if (MultiClipTurn(pp, sum, z * zinttoworld, floor_dist * zinttoworld))
{ {
pp->angle.ang = sum; pp->angle.ang = sum;
pp->actor->set_int_ang(pp->angle.ang.Buildang()); pp->actor->set_int_ang(pp->angle.ang.Buildang());
@ -2608,7 +2608,7 @@ void DoPlayerMoveVehicle(PLAYER* pp)
} }
else else
{ {
actor->user.coll = MultiClipMove(pp, z, floor_dist); actor->user.coll = MultiClipMove(pp, z * zinttoworld, floor_dist * zinttoworld);
} }
plActor->spr.cstat = save_cstat; plActor->spr.cstat = save_cstat;