mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-16 04:30:38 +00:00
SW: Use a bit more Q16.16 in places.
This commit is contained in:
parent
156a225ff4
commit
40ca656f38
3 changed files with 37 additions and 18 deletions
|
@ -3019,7 +3019,7 @@ void getinput(int const playerNum)
|
|||
#define MAXANGVEL 1024
|
||||
#define MAXHORIZVEL 256
|
||||
#define HORIZ_SPEED (16)
|
||||
#define TURN_SHIFT 2
|
||||
#define TURN_SHIFT 4
|
||||
#define SET_LOC_KEY(bits, sync_num, key_test) SET(bits, ((!!(key_test)) << (sync_num)))
|
||||
|
||||
static int32_t turnheldtime;
|
||||
|
@ -3295,17 +3295,17 @@ void getinput(int const playerNum)
|
|||
{
|
||||
if (FLAG_KEY_PRESSED(pp, SK_TURN_180))
|
||||
{
|
||||
short delta_ang;
|
||||
fix16_t delta_q16ang;
|
||||
|
||||
FLAG_KEY_RELEASE(pp, SK_TURN_180);
|
||||
|
||||
pp->turn180_target = NORM_ANGLE(fix16_to_int(pp->q16ang) + 1024);
|
||||
pp->turn180_target = fix16_sadd(pp->q16ang, fix16_from_int(1024)) & 0x7FFFFFF;
|
||||
|
||||
// make the first turn in the clockwise direction
|
||||
// the rest will follow
|
||||
delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(pp->q16ang));
|
||||
delta_q16ang = GetDeltaAngleQ16(pp->turn180_target, pp->q16ang);
|
||||
|
||||
pp->q16ang = fix16_sadd(pp->q16ang, fix16_from_float(scaleAdjustmentToInterval(labs(delta_ang) >> TURN_SHIFT))) & 0x7FFFFFF;
|
||||
pp->q16ang = fix16_sadd(pp->q16ang, fix16_max(fix16_one,fix16_from_float(scaleAdjustmentToInterval(fix16_to_int(fix16_sdiv(fix16_abs(delta_q16ang), fix16_from_int(TURN_SHIFT))))))) & 0x7FFFFFF;
|
||||
|
||||
SET(pp->Flags, PF_TURN_180);
|
||||
}
|
||||
|
@ -3318,10 +3318,10 @@ void getinput(int const playerNum)
|
|||
|
||||
if (TEST(pp->Flags, PF_TURN_180))
|
||||
{
|
||||
short delta_ang;
|
||||
fix16_t delta_q16ang;
|
||||
|
||||
delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(pp->q16ang));
|
||||
pp->q16ang = fix16_sadd(pp->q16ang, fix16_from_float(scaleAdjustmentToInterval(delta_ang >> TURN_SHIFT))) & 0x7FFFFFF;
|
||||
delta_q16ang = GetDeltaAngleQ16(pp->turn180_target, pp->q16ang);
|
||||
pp->q16ang = fix16_sadd(pp->q16ang, fix16_from_float(scaleAdjustmentToInterval(fix16_to_int(fix16_sdiv(fix16_abs(delta_q16ang), fix16_from_int(TURN_SHIFT)))))) & 0x7FFFFFF;
|
||||
|
||||
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
|
||||
if (!Prediction)
|
||||
|
@ -3331,11 +3331,11 @@ void getinput(int const playerNum)
|
|||
}
|
||||
|
||||
// get new delta to see how close we are
|
||||
delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(pp->q16ang));
|
||||
delta_q16ang = GetDeltaAngleQ16(pp->turn180_target, pp->q16ang);
|
||||
|
||||
if (labs(delta_ang) < (3<<TURN_SHIFT))
|
||||
if (fix16_abs(delta_q16ang) < fix16_from_int(3 * TURN_SHIFT))
|
||||
{
|
||||
pp->q16ang = fix16_from_int(pp->turn180_target);
|
||||
pp->q16ang = pp->turn180_target;
|
||||
RESET(pp->Flags, PF_TURN_180);
|
||||
}
|
||||
else
|
||||
|
@ -3344,7 +3344,7 @@ void getinput(int const playerNum)
|
|||
|
||||
if (input.q16avel != 0)
|
||||
{
|
||||
pp->q16ang = fix16_sadd(pp->q16ang, input.q16avel) & 0x7FFFFFF;
|
||||
pp->q16ang = fix16_sadd(pp->q16ang, input.q16avel) & 0x7FFFFFF;
|
||||
|
||||
// update players sprite angle
|
||||
// NOTE: It's also updated in UpdatePlayerSprite, but needs to be
|
||||
|
|
|
@ -1138,7 +1138,7 @@ struct PLAYERstruct
|
|||
short camera_check_time_delay;
|
||||
|
||||
short cursectnum,lastcursectnum;
|
||||
short turn180_target; // 180 degree turn
|
||||
fix16_t turn180_target; // 180 degree turn
|
||||
|
||||
// variables that do not fit into sprite structure
|
||||
int hvel,tilt,tilt_dest;
|
||||
|
@ -2122,6 +2122,7 @@ void SetBorder(PLAYERp pp, int);
|
|||
void SetFragBar(PLAYERp pp);
|
||||
int Distance(int x1, int y1, int x2, int y2);
|
||||
short GetDeltaAngle(short, short);
|
||||
fix16_t GetDeltaAngleQ16(fix16_t, fix16_t);
|
||||
|
||||
int SetActorRotation(short SpriteNum,int,int);
|
||||
int NewStateGroup(short SpriteNum, STATEp SpriteGroup[]);
|
||||
|
|
|
@ -1152,6 +1152,26 @@ GetDeltaAngle(short ang1, short ang2)
|
|||
|
||||
}
|
||||
|
||||
fix16_t
|
||||
GetDeltaAngleQ16(fix16_t ang1, fix16_t ang2)
|
||||
{
|
||||
// Look at the smaller angle if > 1024 (180 degrees)
|
||||
if (fix16_abs(fix16_sub(ang1, ang2)) > fix16_from_int(1024))
|
||||
{
|
||||
if (ang1 <= fix16_from_int(1024))
|
||||
ang1 = fix16_add(ang1, fix16_from_int(2048));
|
||||
|
||||
if (ang2 <= fix16_from_int(1024))
|
||||
ang2 = fix16_add(ang2, fix16_from_int(2048));
|
||||
}
|
||||
|
||||
//if (ang1 - ang2 == -fix16_from_int(1024))
|
||||
// return(fix16_from_int(1024));
|
||||
|
||||
return fix16_sub(ang1, ang2);
|
||||
|
||||
}
|
||||
|
||||
TARGET_SORT TargetSort[MAX_TARGET_SORT];
|
||||
unsigned TargetSortCount;
|
||||
|
||||
|
@ -6303,15 +6323,13 @@ void DoPlayerDeathFollowKiller(PLAYERp pp)
|
|||
if (pp->Killer > -1)
|
||||
{
|
||||
SPRITEp kp = &sprite[pp->Killer];
|
||||
short ang2,delta_ang;
|
||||
fix16_t delta_q16ang;
|
||||
|
||||
if (FAFcansee(kp->x, kp->y, SPRITEp_TOS(kp), kp->sectnum,
|
||||
pp->posx, pp->posy, pp->posz, pp->cursectnum))
|
||||
{
|
||||
ang2 = getangle(kp->x - pp->posx, kp->y - pp->posy);
|
||||
|
||||
delta_ang = GetDeltaAngle(ang2, fix16_to_int(pp->q16ang));
|
||||
pp->q16ang = fix16_sadd(pp->q16ang, fix16_from_int((delta_ang >> 4))) & 0x7FFFFFF;
|
||||
delta_q16ang = GetDeltaAngleQ16(fix16_from_int(getangle(kp->x - pp->posx, kp->y - pp->posy)), pp->q16ang);
|
||||
pp->q16ang = fix16_sadd(pp->q16ang, fix16_sdiv(delta_q16ang, fix16_from_int(16))) & 0x7FFFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue