- SW: Promote all vehicle angle code to proper Q16.16.

* Input still rough with `cl_syncinput 0` for vehicles.
This commit is contained in:
Mitchell Richters 2020-09-07 22:36:11 +10:00
parent e1a5e37126
commit df0331a4c3
3 changed files with 40 additions and 67 deletions

View file

@ -863,7 +863,7 @@ struct PLAYERstruct
int slide_xvect, slide_yvect; int slide_xvect, slide_yvect;
short slide_ang; short slide_ang;
int slide_dec; int slide_dec;
int drive_angvel; int drive_q16avel;
@ -1710,13 +1710,14 @@ struct SECTOR_OBJECTstruct
morph_z_max, morph_z_max,
bob_amt, // bob amount max in z coord bob_amt, // bob amount max in z coord
// variables set by mappers for drivables // variables set by mappers for drivables
drive_angspeed,
drive_angslide, drive_angslide,
drive_speed, drive_speed,
drive_slide, drive_slide,
crush_z, crush_z,
flags; flags;
fixed_t drive_angspeed;
short sector[MAX_SO_SECTOR], // hold the sector numbers of the sector object short sector[MAX_SO_SECTOR], // hold the sector numbers of the sector object
sp_num[MAX_SO_SPRITE], // hold the sprite numbers of the object sp_num[MAX_SO_SPRITE], // hold the sprite numbers of the object
xorig[MAX_SO_POINTS], // save the original x & y location of each wall so it can be xorig[MAX_SO_POINTS], // save the original x & y location of each wall so it can be

View file

@ -85,9 +85,6 @@ SWBOOL NightVision = FALSE;
extern SWBOOL FinishAnim; extern SWBOOL FinishAnim;
//#define PLAYER_TURN_SCALE (8)
#define PLAYER_TURN_SCALE (12)
// the smaller the number the slower the going // the smaller the number the slower the going
#define PLAYER_RUN_FRICTION (50000L) #define PLAYER_RUN_FRICTION (50000L)
//#define PLAYER_RUN_FRICTION 0xcb00 //#define PLAYER_RUN_FRICTION 0xcb00
@ -1313,7 +1310,7 @@ DoPlayerResetMovement(PLAYERp pp)
pp->yvect = pp->oxvect = 0; pp->yvect = pp->oxvect = 0;
pp->slide_xvect = 0; pp->slide_xvect = 0;
pp->slide_yvect = 0; pp->slide_yvect = 0;
pp->drive_angvel = 0; pp->drive_q16avel = 0;
RESET(pp->Flags, PF_PLAYER_MOVED); RESET(pp->Flags, PF_PLAYER_MOVED);
} }
@ -1633,30 +1630,24 @@ DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust)
void void
DoPlayerTurnBoat(PLAYERp pp) DoPlayerTurnBoat(PLAYERp pp)
{ {
int angvel; fixed_t q16avel;
int angslide;
SECTOR_OBJECTp sop = pp->sop; SECTOR_OBJECTp sop = pp->sop;
if (sop->drive_angspeed) if (sop->drive_angspeed)
{ {
int drive_oangvel = pp->drive_angvel; fixed_t drive_oq16avel = pp->drive_q16avel;
pp->drive_angvel = mulscale16(FixedToInt(pp->input.q16avel), sop->drive_angspeed); pp->drive_q16avel = (mulscale16(pp->input.q16avel, sop->drive_angspeed) + (drive_oq16avel * (sop->drive_angslide - 1))) / sop->drive_angslide;
angslide = sop->drive_angslide; q16avel = pp->drive_q16avel;
pp->drive_angvel = (pp->drive_angvel + (drive_oangvel*(angslide-1)))/angslide;
angvel = pp->drive_angvel;
} }
else else
{ {
angvel = FixedToInt(pp->input.q16avel) * PLAYER_TURN_SCALE; q16avel = xs_CRoundToInt(q16avel * 1.4);
angvel += angvel - DIV4(angvel);
angvel = DIV32(angvel * synctics);
} }
if (angvel != 0) if (q16avel != 0)
{ {
pp->q16ang = IntToFixed(NORM_ANGLE(FixedToInt(pp->q16ang) + angvel)); pp->q16ang = (pp->q16ang * q16avel) & 0x7FFFFFF;
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang); sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
} }
} }
@ -1664,31 +1655,26 @@ DoPlayerTurnBoat(PLAYERp pp)
void void
DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist) DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist)
{ {
int angvel; fixed_t q16avel;
SECTOR_OBJECTp sop = pp->sop; SECTOR_OBJECTp sop = pp->sop;
if (sop->drive_angspeed) if (sop->drive_angspeed)
{ {
int angslide; fixed_t drive_oq16avel = pp->drive_q16avel;
pp->drive_q16avel = (mulscale16(pp->input.q16avel, sop->drive_angspeed) + (drive_oq16avel * (sop->drive_angslide - 1))) / sop->drive_angslide;
int drive_oangvel = pp->drive_angvel; q16avel = pp->drive_q16avel;
pp->drive_angvel = mulscale16(FixedToInt(pp->input.q16avel), sop->drive_angspeed);
angslide = sop->drive_angslide;
pp->drive_angvel = (pp->drive_angvel + (drive_oangvel*(angslide-1)))/angslide;
angvel = pp->drive_angvel;
} }
else else
{ {
angvel = DIV8(FixedToInt(pp->input.q16avel) * synctics); q16avel = DIV8(pp->input.q16avel * synctics);
} }
if (angvel != 0) if (q16avel != 0)
{ {
if (MultiClipTurn(pp, NORM_ANGLE(FixedToInt(pp->q16ang) + angvel), z, floor_dist)) if (MultiClipTurn(pp, NORM_ANGLE(FixedToInt(pp->q16ang + q16avel)), z, floor_dist))
{ {
pp->q16ang = IntToFixed(NORM_ANGLE(FixedToInt(pp->q16ang) + angvel)); pp->q16ang = (pp->q16ang + q16avel) & 0x7FFFFFF;
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang); sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
} }
} }
@ -1697,31 +1683,26 @@ DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist)
void void
DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy) DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy)
{ {
int angvel; fixed_t q16avel;
SECTOR_OBJECTp sop = pp->sop; SECTOR_OBJECTp sop = pp->sop;
if (sop->drive_angspeed) if (sop->drive_angspeed)
{ {
int angslide; fixed_t drive_oq16avel = pp->drive_q16avel;
pp->drive_q16avel = (mulscale16(pp->input.q16avel, sop->drive_angspeed) + (drive_oq16avel * (sop->drive_angslide - 1))) / sop->drive_angslide;
int drive_oangvel = pp->drive_angvel; q16avel = pp->drive_q16avel;
pp->drive_angvel = mulscale16(FixedToInt(pp->input.q16avel), sop->drive_angspeed);
angslide = sop->drive_angslide;
pp->drive_angvel = (pp->drive_angvel + (drive_oangvel*(angslide-1)))/angslide;
angvel = pp->drive_angvel;
} }
else else
{ {
angvel = DIV8(FixedToInt(pp->input.q16avel) * synctics); q16avel = DIV8(pp->input.q16avel * synctics);
} }
if (angvel != 0) if (q16avel != 0)
{ {
if (RectClipTurn(pp, NORM_ANGLE(FixedToInt(pp->q16ang) + angvel), x, y, ox, oy)) if (RectClipTurn(pp, NORM_ANGLE(FixedToInt(pp->q16ang + q16avel)), x, y, ox, oy))
{ {
pp->q16ang = IntToFixed(NORM_ANGLE(FixedToInt(pp->q16ang) + angvel)); pp->q16ang = (pp->q16ang + q16avel) & 0x7FFFFFF;
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang); sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
} }
} }
@ -1730,9 +1711,7 @@ DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy)
void void
DoPlayerTurnTurret(PLAYERp pp) DoPlayerTurnTurret(PLAYERp pp)
{ {
int angvel; fixed_t q16avel, new_ang, diff;
short new_ang;
short diff;
SECTOR_OBJECTp sop = pp->sop; SECTOR_OBJECTp sop = pp->sop;
if (!Prediction) if (!Prediction)
@ -1745,40 +1724,34 @@ DoPlayerTurnTurret(PLAYERp pp)
if (sop->drive_angspeed) if (sop->drive_angspeed)
{ {
int angslide; fixed_t drive_oq16avel = pp->drive_q16avel;
pp->drive_q16avel = (mulscale16(pp->input.q16avel, sop->drive_angspeed) + (drive_oq16avel * (sop->drive_angslide - 1))) / sop->drive_angslide;
int drive_oangvel = pp->drive_angvel; q16avel = pp->drive_q16avel;
pp->drive_angvel = mulscale16(FixedToInt(pp->input.q16avel), sop->drive_angspeed);
angslide = sop->drive_angslide;
pp->drive_angvel = (pp->drive_angvel + (drive_oangvel*(angslide-1)))/angslide;
angvel = pp->drive_angvel;
} }
else else
{ {
angvel = DIV4(FixedToInt(pp->input.q16avel) * synctics); q16avel = DIV4(pp->input.q16avel * synctics);
} }
if (angvel != 0) if (q16avel != 0)
{ {
new_ang = NORM_ANGLE(FixedToInt(pp->q16ang) + angvel); new_ang = (pp->q16ang + q16avel) & 0x7FFFFFF;
if (sop->limit_ang_center >= 0) if (sop->limit_ang_center >= 0)
{ {
diff = GetDeltaAngle(new_ang, sop->limit_ang_center); diff = GetDeltaQ16Angle(new_ang, IntToFixed(sop->limit_ang_center));
if (labs(diff) >= sop->limit_ang_delta) if (labs(diff) >= IntToFixed(sop->limit_ang_delta))
{ {
if (diff < 0) if (diff < 0)
new_ang = sop->limit_ang_center - sop->limit_ang_delta; new_ang = IntToFixed(sop->limit_ang_center - sop->limit_ang_delta);
else else
new_ang = sop->limit_ang_center + sop->limit_ang_delta; new_ang = IntToFixed(sop->limit_ang_center + sop->limit_ang_delta);
} }
} }
pp->q16ang = IntToFixed(new_ang); pp->q16ang = new_ang;
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang); sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
} }
} }

View file

@ -1273,8 +1273,7 @@ SetupSectorObject(short sectnum, short tag)
case SO_DRIVABLE_ATTRIB: case SO_DRIVABLE_ATTRIB:
sop->drive_angspeed = SP_TAG2(sp); sop->drive_angspeed = SP_TAG2(sp) << 21;
sop->drive_angspeed <<= 5;
sop->drive_angslide = SP_TAG3(sp); sop->drive_angslide = SP_TAG3(sp);
if (sop->drive_angslide <= 0 || sop->drive_angslide == 32) if (sop->drive_angslide <= 0 || sop->drive_angslide == 32)
sop->drive_angslide = 1; sop->drive_angslide = 1;