- floatify all 3 player position variables.

This commit is contained in:
Christoph Oelckers 2022-08-20 13:38:48 +02:00
parent c5414bd29c
commit 280cd8970e
5 changed files with 31 additions and 48 deletions

View file

@ -779,11 +779,9 @@ void analyzesprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, int
else // Otherwise just interpolate the player sprite else // Otherwise just interpolate the player sprite
{ {
pp = tActor->user.PlayerP; pp = tActor->user.PlayerP;
int sr = 65536 - int(smoothratio); double sr = 1. - smoothratio * (1. / 65536.);
tsp->add_int_x(-MulScale(pp->int_ppos().X - pp->__int_popos.X, sr, 16)); tsp->pos -= (pp->pos - pp->opos) * sr;
tsp->add_int_y(-MulScale(pp->int_ppos().Y - pp->__int_popos.Y, sr, 16)); tsp->angle = interpolatedangle(pp->angle.oang, pp->angle.ang, sr, 0);
tsp->add_int_z(-MulScale(pp->int_ppos().Z - pp->__int_popos.Z, sr, 16));
tsp->add_int_ang(-MulScale(pp->angle.ang.Buildang() - pp->angle.oang.Buildang(), sr, 16));
} }
} }
@ -1383,9 +1381,9 @@ void drawscreen(PLAYER* pp, double smoothratio, bool sceneonly)
else else
camerapp = pp; camerapp = pp;
tx = interpolatedvalue(camerapp->__int_popos.X, camerapp->int_ppos().X, sr); tx = int(interpolatedvalue(camerapp->opos.X, camerapp->pos.X, sr) * worldtoint);
ty = interpolatedvalue(camerapp->__int_popos.Y, camerapp->int_ppos().Y, sr); ty = int(interpolatedvalue(camerapp->opos.Y, camerapp->pos.Y, sr) * worldtoint);
tz = interpolatedvalue(camerapp->__int_popos.Z, camerapp->int_ppos().Z, sr); tz = int(interpolatedvalue(camerapp->opos.Z, camerapp->pos.Z, sr) * zworldtoint);
// Interpolate the player's angle while on a sector object, just like VoidSW. // Interpolate the player's angle while on a sector object, just like VoidSW.
// This isn't needed for the turret as it was fixable, but moving sector objects are problematic. // This isn't needed for the turret as it was fixable, but moving sector objects are problematic.

View file

@ -405,7 +405,7 @@ void InitLevel(MapRecord *maprec)
SpawnSpriteDef sprites; SpawnSpriteDef sprites;
vec3_t ppos; vec3_t ppos;
loadMap(maprec->fileName, SW_SHAREWARE ? 1 : 0, &ppos, &ang, &cursect, sprites); loadMap(maprec->fileName, SW_SHAREWARE ? 1 : 0, &ppos, &ang, &cursect, sprites);
Player[0].__int_ppos = ppos; Player[0].set_int_ppos(ppos);
spawnactors(sprites); spawnactors(sprites);
Player[0].cursector = &sector[cursect]; Player[0].cursector = &sector[cursect];

View file

@ -578,45 +578,31 @@ struct PLAYER
{ {
// variable that fit in the sprite or user structure // variable that fit in the sprite or user structure
// hackery to make the transition easier DVector3 pos, opos, oldpos;
union
{
vec3_t __int_ppos;
vec3_t pos;
};
union
{
vec3_t __int_popos;
vec3_t opos;
};
union
{
vec3_t __int_poldpos;
vec3_t oldpos;
};
const vec3_t int_ppos() const const vec3_t int_ppos() const
{ {
return __int_ppos; return { int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint) };
} }
void set_int_ppos(vec3_t z) void set_int_ppos(vec3_t z)
{ {
__int_ppos = z; pos = { z.X * inttoworld, z.Y * inttoworld, z.Z * zinttoworld };
} }
void set_int_ppos_XY(vec2_t z) void set_int_ppos_XY(vec2_t z)
{ {
__int_ppos.XY() = z; pos.XY() = {z.X * inttoworld, z.Y * inttoworld };
} }
void set_int_ppos_Z(int z) void set_int_ppos_Z(int z)
{ {
__int_ppos.Z = z; pos.Z = z * zinttoworld;
} }
void add_int_ppos_Z(int z) void add_int_ppos_Z(int z)
{ {
__int_ppos.Z += z; pos.Z += z * zinttoworld;
} }
void add_int_ppos_XY(vec2_t z) void add_int_ppos_XY(vec2_t z)
{ {
__int_ppos.XY() += z; pos.XY() += { z.X * inttoworld, z.Y * inttoworld };
} }
DSWActor* actor; // this may not be a TObjPtr! DSWActor* actor; // this may not be a TObjPtr!

View file

@ -1271,8 +1271,7 @@ void DoPlayerTeleportPause(PLAYER* pp)
void DoPlayerTeleportToSprite(PLAYER* pp, vec3_t* pos, int ang) void DoPlayerTeleportToSprite(PLAYER* pp, vec3_t* pos, int ang)
{ {
pp->angle.ang = pp->angle.oang = DAngle::fromBuild(ang); pp->angle.ang = pp->angle.oang = DAngle::fromBuild(ang);
pp->__int_ppos.X = pos->X; pp->set_int_ppos_XY(pos->XY());
pp->__int_ppos.Y = pos->Y;
pp->oldpos.XY() = pp->opos.XY() = pp->pos.XY(); pp->oldpos.XY() = pp->opos.XY() = pp->pos.XY();
@ -1354,7 +1353,7 @@ void DoPlayerWarpTeleporter(PLAYER* pp)
TAG 5 to 8 = random match locations TAG 5 to 8 = random match locations
#endif #endif
if ((act_warp = Warp(&pp->__int_ppos.X, &pp->__int_ppos.Y, &pp->__int_ppos.Z, &pp->cursector)) == nullptr) if ((act_warp = Warp(pp->pos, &pp->cursector)) == nullptr)
{ {
return; return;
} }
@ -1607,7 +1606,7 @@ void DoPlayerBob(PLAYER* pp)
dist = 0; dist = 0;
dist = Distance(pp->int_ppos().X, pp->int_ppos().Y, pp->__int_poldpos.X, pp->__int_poldpos.Y); dist = DistanceI(pp->pos, pp->oldpos);
if (dist > 512) if (dist > 512)
dist = 0; dist = 0;
@ -1899,7 +1898,7 @@ void DoPlayerSlide(PLAYER* pp)
if (labs(pp->slide_vect.X) < 12800 && labs(pp->slide_vect.Y) < 12800) if (labs(pp->slide_vect.X) < 12800 && labs(pp->slide_vect.Y) < 12800)
pp->slide_vect.X = pp->slide_vect.Y = 0; pp->slide_vect.X = pp->slide_vect.Y = 0;
push_ret = pushmove(&pp->__int_ppos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER); push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER);
if (push_ret < 0) if (push_ret < 0)
{ {
if (!(pp->Flags & PF_DEAD)) if (!(pp->Flags & PF_DEAD))
@ -1913,10 +1912,10 @@ void DoPlayerSlide(PLAYER* pp)
return; return;
} }
Collision coll; Collision coll;
clipmove(pp->__int_ppos, &pp->cursector, pp->slide_vect.X, pp->slide_vect.Y, ((int)actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER, coll); clipmove(pp->pos, &pp->cursector, pp->slide_vect.X, pp->slide_vect.Y, ((int)actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER, coll);
PlayerCheckValidMove(pp); PlayerCheckValidMove(pp);
push_ret = pushmove(&pp->__int_ppos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER); push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER);
if (push_ret < 0) if (push_ret < 0)
{ {
if (!(pp->Flags & PF_DEAD)) if (!(pp->Flags & PF_DEAD))
@ -2048,7 +2047,7 @@ void DoPlayerMove(PLAYER* pp)
} }
else else
{ {
push_ret = pushmove(&pp->__int_ppos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist - Z(16), CLIPMASK_PLAYER); push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist - Z(16), CLIPMASK_PLAYER);
if (push_ret < 0) if (push_ret < 0)
{ {
@ -2071,12 +2070,12 @@ void DoPlayerMove(PLAYER* pp)
actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK); actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK);
Collision coll; Collision coll;
updatesector(pp->int_ppos().X, pp->int_ppos().Y, &pp->cursector); updatesector(pp->int_ppos().X, pp->int_ppos().Y, &pp->cursector);
clipmove(pp->__int_ppos, &pp->cursector, pp->vect.X, pp->vect.Y, ((int)actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER, coll); clipmove(pp->pos, &pp->cursector, pp->vect.X, pp->vect.Y, ((int)actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER, coll);
actor->spr.cstat = save_cstat; actor->spr.cstat = save_cstat;
PlayerCheckValidMove(pp); PlayerCheckValidMove(pp);
push_ret = pushmove(&pp->__int_ppos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist - Z(16), CLIPMASK_PLAYER); push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist - Z(16), CLIPMASK_PLAYER);
if (push_ret < 0) if (push_ret < 0)
{ {
@ -2098,7 +2097,7 @@ void DoPlayerMove(PLAYER* pp)
} }
// check for warp - probably can remove from CeilingHit // check for warp - probably can remove from CeilingHit
if (WarpPlane(&pp->__int_ppos.X, &pp->__int_ppos.Y, &pp->__int_ppos.Z, &pp->cursector)) if (WarpPlane(pp->pos, &pp->cursector))
{ {
PlayerWarpUpdatePos(pp); PlayerWarpUpdatePos(pp);
} }
@ -3307,7 +3306,7 @@ void DoPlayerClimb(PLAYER* pp)
LadderUpdate = true; LadderUpdate = true;
} }
if (WarpPlane(&pp->__int_ppos.X, &pp->__int_ppos.Y, &pp->__int_ppos.Z, &pp->cursector)) if (WarpPlane(pp->pos, &pp->cursector))
{ {
PlayerWarpUpdatePos(pp); PlayerWarpUpdatePos(pp);
LadderUpdate = true; LadderUpdate = true;
@ -4529,7 +4528,7 @@ void DoPlayerCurrent(PLAYER* pp)
xvect = sectu->speed * synctics * bcos(sectu->ang) >> 4; xvect = sectu->speed * synctics * bcos(sectu->ang) >> 4;
yvect = sectu->speed * synctics * bsin(sectu->ang) >> 4; yvect = sectu->speed * synctics * bsin(sectu->ang) >> 4;
push_ret = pushmove(&pp->__int_ppos, &pp->cursector, ((int)pp->actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER); push_ret = pushmove(pp->pos, &pp->cursector, ((int)pp->actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER);
if (push_ret < 0) if (push_ret < 0)
{ {
if (!(pp->Flags & PF_DEAD)) if (!(pp->Flags & PF_DEAD))
@ -4545,10 +4544,10 @@ void DoPlayerCurrent(PLAYER* pp)
return; return;
} }
Collision coll; Collision coll;
clipmove(pp->__int_ppos, &pp->cursector, xvect, yvect, ((int)pp->actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER, coll); clipmove(pp->pos, &pp->cursector, xvect, yvect, ((int)pp->actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER, coll);
PlayerCheckValidMove(pp); PlayerCheckValidMove(pp);
pushmove(&pp->__int_ppos, &pp->cursector, ((int)pp->actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER); pushmove(pp->pos, &pp->cursector, ((int)pp->actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER);
if (push_ret < 0) if (push_ret < 0)
{ {
if (!(pp->Flags & PF_DEAD)) if (!(pp->Flags & PF_DEAD))
@ -6827,7 +6826,7 @@ void PlayerSpawnPosition(PLAYER* pp)
ASSERT(spawn_sprite != nullptr); ASSERT(spawn_sprite != nullptr);
pp->__int_ppos = spawn_sprite->int_pos(); pp->pos = spawn_sprite->spr.pos;
pp->opos = pp->pos; pp->opos = pp->pos;
pp->angle.ang = pp->angle.oang = spawn_sprite->spr.angle; pp->angle.ang = pp->angle.oang = spawn_sprite->spr.angle;
pp->setcursector(spawn_sprite->sector()); pp->setcursector(spawn_sprite->sector());

View file

@ -1557,7 +1557,7 @@ void MovePlayer(PLAYER* pp, SECTOR_OBJECT* sop, int nx, int ny)
// increment Players delta angle // increment Players delta angle
pp->RevolveDeltaAng = (pp->RevolveDeltaAng + GlobSpeedSO).Normalized360(); pp->RevolveDeltaAng = (pp->RevolveDeltaAng + GlobSpeedSO).Normalized360();
rotatepoint(sop->int_pmid().vec2, *(vec2_t *)&pp->Revolve.X, pp->RevolveDeltaAng.Buildang(), &pp->__int_ppos.vec2); pp->pos.XY() = rotatepoint(sop->pmid.XY(), {pp->Revolve.X * inttoworld, pp->Revolve.Y * inttoworld}, pp->RevolveDeltaAng);
// THIS WAS CAUSING PROLEMS!!!! // THIS WAS CAUSING PROLEMS!!!!
// Sectors are still being manipulated so you can end up in a void (-1) sector // Sectors are still being manipulated so you can end up in a void (-1) sector