- floatified quake and weapon code

This commit is contained in:
Christoph Oelckers 2016-03-23 20:45:48 +01:00
parent 2dbd79cc8d
commit 6557f3b8c8
13 changed files with 140 additions and 179 deletions

View file

@ -269,7 +269,7 @@ void InitBotStuff()
AWeapon *w = (AWeapon*)GetDefaultByType(cls); AWeapon *w = (AWeapon*)GetDefaultByType(cls);
if (w != NULL) if (w != NULL)
{ {
w->MoveCombatDist = botinits[i].movecombatdist; w->MoveCombatDist = botinits[i].movecombatdist/65536.;
w->WeaponFlags |= botinits[i].weaponflags; w->WeaponFlags |= botinits[i].weaponflags;
w->ProjectileType = PClass::FindActor(botinits[i].projectile); w->ProjectileType = PClass::FindActor(botinits[i].projectile);
} }

View file

@ -171,7 +171,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
angle = player->mo->__f_AngleTo(enemy); angle = player->mo->__f_AngleTo(enemy);
if (player->ReadyWeapon == NULL || if (player->ReadyWeapon == NULL ||
player->mo->AproxDistance(enemy) > player->mo->Distance2D(enemy) >
player->ReadyWeapon->MoveCombatDist) player->ReadyWeapon->MoveCombatDist)
{ {
// If a monster, use lower speed (just for cooler apperance while strafing down doomed monster) // If a monster, use lower speed (just for cooler apperance while strafing down doomed monster)

View file

@ -46,7 +46,7 @@ private:
struct WeaponInfo struct WeaponInfo
{ {
PClassWeapon *Type; PClassWeapon *Type;
fixed_t Position; int Position;
}; };
void SetInitialPositions(); void SetInitialPositions();
void Sort(); void Sort();
@ -274,7 +274,7 @@ public:
virtual void ReplaceClassRef(PClass *oldclass, PClass *newclass); virtual void ReplaceClassRef(PClass *oldclass, PClass *newclass);
int SlotNumber; int SlotNumber;
fixed_t SlotPriority; int SlotPriority;
}; };
class AWeapon : public AInventory class AWeapon : public AInventory
@ -288,18 +288,18 @@ public:
int MinAmmo1, MinAmmo2; // Minimum ammo needed to switch to this weapon int MinAmmo1, MinAmmo2; // Minimum ammo needed to switch to this weapon
int AmmoUse1, AmmoUse2; // How much ammo to use with each shot int AmmoUse1, AmmoUse2; // How much ammo to use with each shot
int Kickback; int Kickback;
fixed_t YAdjust; // For viewing the weapon fullscreen float YAdjust; // For viewing the weapon fullscreen (visual only so no need to be a double)
FSoundIDNoInit UpSound, ReadySound; // Sounds when coming up and idle FSoundIDNoInit UpSound, ReadySound; // Sounds when coming up and idle
PClassWeapon *SisterWeaponType; // Another weapon to pick up with this one PClassWeapon *SisterWeaponType; // Another weapon to pick up with this one
PClassActor *ProjectileType; // Projectile used by primary attack PClassActor *ProjectileType; // Projectile used by primary attack
PClassActor *AltProjectileType; // Projectile used by alternate attack PClassActor *AltProjectileType; // Projectile used by alternate attack
int SelectionOrder; // Lower-numbered weapons get picked first int SelectionOrder; // Lower-numbered weapons get picked first
int MinSelAmmo1, MinSelAmmo2; // Ignore in BestWeapon() if inadequate ammo int MinSelAmmo1, MinSelAmmo2; // Ignore in BestWeapon() if inadequate ammo
fixed_t MoveCombatDist; // Used by bots, but do they *really* need it? double MoveCombatDist; // Used by bots, but do they *really* need it?
int ReloadCounter; // For A_CheckForReload int ReloadCounter; // For A_CheckForReload
int BobStyle; // [XA] Bobbing style. Defines type of bobbing (e.g. Normal, Alpha) int BobStyle; // [XA] Bobbing style. Defines type of bobbing (e.g. Normal, Alpha) (visual only so no need to be a double)
fixed_t BobSpeed; // [XA] Bobbing speed. Defines how quickly a weapon bobs. float BobSpeed; // [XA] Bobbing speed. Defines how quickly a weapon bobs.
fixed_t BobRangeX, BobRangeY; // [XA] Bobbing range. Defines how far a weapon bobs in either direction. float BobRangeX, BobRangeY; // [XA] Bobbing range. Defines how far a weapon bobs in either direction.
// In-inventory instance variables // In-inventory instance variables
TObjPtr<AAmmo> Ammo1, Ammo2; TObjPtr<AAmmo> Ammo1, Ammo2;
@ -395,7 +395,7 @@ public:
bool TryPickup(AActor *&toucher); bool TryPickup(AActor *&toucher);
void Serialize(FArchive &arc); void Serialize(FArchive &arc);
fixed_t DropAmmoFactor; double DropAmmoFactor;
}; };

View file

@ -43,18 +43,14 @@ DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int in
m_QuakeSFX = quakesound; m_QuakeSFX = quakesound;
m_Spot = center; m_Spot = center;
// Radii are specified in tile units (64 pixels) // Radii are specified in tile units (64 pixels)
m_DamageRadius = damrad << FRACBITS; m_DamageRadius = damrad;
m_TremorRadius = tremrad << FRACBITS; m_TremorRadius = tremrad;
m_IntensityX = intensityX << FRACBITS; m_Intensity = DVector3(intensityX, intensityY, intensityZ);
m_IntensityY = intensityY << FRACBITS;
m_IntensityZ = intensityZ << FRACBITS;
m_CountdownStart = duration; m_CountdownStart = duration;
m_Countdown = duration; m_Countdown = duration;
m_Flags = flags; m_Flags = flags;
m_WaveSpeedX = (float)waveSpeedX; m_WaveSpeed = DVector3(waveSpeedX, waveSpeedY, waveSpeedZ);
m_WaveSpeedY = (float)waveSpeedY; m_Falloff = falloff;
m_WaveSpeedZ = (float)waveSpeedZ;
m_Falloff = falloff << FRACBITS;
m_Highpoint = highpoint; m_Highpoint = highpoint;
m_MiniCount = highpoint; m_MiniCount = highpoint;
} }
@ -68,46 +64,11 @@ DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int in
void DEarthquake::Serialize (FArchive &arc) void DEarthquake::Serialize (FArchive &arc)
{ {
Super::Serialize (arc); Super::Serialize (arc);
arc << m_Spot << m_IntensityX << m_Countdown arc << m_Spot << m_Intensity << m_Countdown
<< m_TremorRadius << m_DamageRadius << m_TremorRadius << m_DamageRadius
<< m_QuakeSFX; << m_QuakeSFX << m_Flags << m_CountdownStart
if (SaveVersion < 4519) << m_WaveSpeed
{ << m_Falloff << m_Highpoint << m_MiniCount;
m_IntensityY = m_IntensityX;
m_IntensityZ = 0;
m_Flags = 0;
}
else
{
arc << m_IntensityY << m_IntensityZ << m_Flags;
}
if (SaveVersion < 4520)
{
m_CountdownStart = 0;
}
else
{
arc << m_CountdownStart;
}
if (SaveVersion < 4521)
{
m_WaveSpeedX = m_WaveSpeedY = m_WaveSpeedZ = 0;
m_IntensityX <<= FRACBITS;
m_IntensityY <<= FRACBITS;
m_IntensityZ <<= FRACBITS;
}
else
{
arc << m_WaveSpeedX << m_WaveSpeedY << m_WaveSpeedZ;
}
if (SaveVersion < 4534)
{
m_Falloff = m_Highpoint = m_MiniCount = 0;
}
else
{
arc << m_Falloff << m_Highpoint << m_MiniCount;
}
} }
//========================================================================== //==========================================================================
@ -141,9 +102,9 @@ void DEarthquake::Tick ()
if (playeringame[i] && !(players[i].cheats & CF_NOCLIP)) if (playeringame[i] && !(players[i].cheats & CF_NOCLIP))
{ {
AActor *victim = players[i].mo; AActor *victim = players[i].mo;
fixed_t dist; double dist;
dist = m_Spot->AproxDistance (victim, true); dist = m_Spot->Distance2D(victim, true);
// Check if in damage radius // Check if in damage radius
if (dist < m_DamageRadius && victim->Z() <= victim->floorz) if (dist < m_DamageRadius && victim->Z() <= victim->floorz)
{ {
@ -153,8 +114,8 @@ void DEarthquake::Tick ()
} }
// Thrust player around // Thrust player around
DAngle an = victim->Angles.Yaw + pr_quake(); DAngle an = victim->Angles.Yaw + pr_quake();
victim->Vel.X += FIXED2DBL(m_IntensityX) * an.Cos() * 0.5; victim->Vel.X += m_Intensity.X * an.Cos() * 0.5;
victim->Vel.Y += FIXED2DBL(m_IntensityY) * an.Sin() * 0.5; victim->Vel.Y += m_Intensity.Y * an.Sin() * 0.5;
} }
} }
} }
@ -182,10 +143,10 @@ void DEarthquake::Tick ()
// //
//========================================================================== //==========================================================================
fixed_t DEarthquake::GetModWave(double waveMultiplier) const double DEarthquake::GetModWave(double waveMultiplier) const
{ {
double time = m_Countdown - FIXED2DBL(r_TicFrac); double time = m_Countdown - FIXED2DBL(r_TicFrac);
return FLOAT2FIXED(g_sin(waveMultiplier * time * (M_PI * 2 / TICRATE))); return g_sin(waveMultiplier * time * (M_PI * 2 / TICRATE));
} }
//========================================================================== //==========================================================================
@ -196,7 +157,7 @@ fixed_t DEarthquake::GetModWave(double waveMultiplier) const
// //
//========================================================================== //==========================================================================
fixed_t DEarthquake::GetModIntensity(fixed_t intensity) const double DEarthquake::GetModIntensity(double intensity) const
{ {
assert(m_CountdownStart >= m_Countdown); assert(m_CountdownStart >= m_Countdown);
@ -255,7 +216,7 @@ fixed_t DEarthquake::GetModIntensity(fixed_t intensity) const
scalar = (scalar > divider) ? divider : scalar; scalar = (scalar > divider) ? divider : scalar;
} }
assert(divider > 0); assert(divider > 0);
intensity = Scale(intensity, scalar, divider); intensity = intensity * scalar / divider;
} }
return intensity; return intensity;
} }
@ -265,27 +226,25 @@ fixed_t DEarthquake::GetModIntensity(fixed_t intensity) const
// DEarthquake :: GetFalloff // DEarthquake :: GetFalloff
// //
// Given the distance of the player from the quake, find the multiplier. // Given the distance of the player from the quake, find the multiplier.
// Process everything as doubles, and output again as fixed_t (mainly
// because fixed_t was misbehaving here...)
// //
//========================================================================== //==========================================================================
fixed_t DEarthquake::GetFalloff(fixed_t dist) const double DEarthquake::GetFalloff(double dist) const
{ {
if ((dist < m_Falloff) || (m_Falloff >= m_TremorRadius) || (m_Falloff <= 0) || (m_TremorRadius - m_Falloff <= 0)) if ((dist < m_Falloff) || (m_Falloff >= m_TremorRadius) || (m_Falloff <= 0) || (m_TremorRadius - m_Falloff <= 0))
{ //Player inside the minimum falloff range, or safety check kicked in. { //Player inside the minimum falloff range, or safety check kicked in.
return FRACUNIT; return 1.;
} }
else if ((dist > m_Falloff) && (dist < m_TremorRadius)) else if ((dist > m_Falloff) && (dist < m_TremorRadius))
{ //Player inside the radius, and outside the min distance for falloff. { //Player inside the radius, and outside the min distance for falloff.
fixed_t tremorsize = m_TremorRadius - m_Falloff; double tremorsize = m_TremorRadius - m_Falloff;
fixed_t tremordist = dist - m_Falloff; double tremordist = dist - m_Falloff;
assert(tremorsize > 0); assert(tremorsize > 0);
return (FRACUNIT - FixedMul(FRACUNIT,tremordist) / tremorsize); return (1. - tremordist) / tremorsize;
} }
else else
{ //Shouldn't happen. { //Shouldn't happen.
return FRACUNIT; return 1.;
} }
} }
@ -315,14 +274,14 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger
{ {
if (quake->m_Spot != NULL) if (quake->m_Spot != NULL)
{ {
fixed_t dist = quake->m_Spot->AproxDistance (victim, true); double dist = quake->m_Spot->Distance2D (victim, true);
if (dist < quake->m_TremorRadius) if (dist < quake->m_TremorRadius)
{ {
fixed_t falloff = quake->GetFalloff(dist); double falloff = quake->GetFalloff(dist);
++count; ++count;
fixed_t x = quake->GetModIntensity(quake->m_IntensityX); double x = quake->GetModIntensity(quake->m_Intensity.X);
fixed_t y = quake->GetModIntensity(quake->m_IntensityY); double y = quake->GetModIntensity(quake->m_Intensity.Y);
fixed_t z = quake->GetModIntensity(quake->m_IntensityZ); double z = quake->GetModIntensity(quake->m_Intensity.Z);
if (!(quake->m_Flags & QF_WAVE)) if (!(quake->m_Flags & QF_WAVE))
@ -330,23 +289,23 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger
jiggers.Falloff = MAX(falloff, jiggers.Falloff); jiggers.Falloff = MAX(falloff, jiggers.Falloff);
if (quake->m_Flags & QF_RELATIVE) if (quake->m_Flags & QF_RELATIVE)
{ {
jiggers.RelIntensityX = MAX(x, jiggers.RelIntensityX); jiggers.RelIntensity.X = MAX(x, jiggers.RelIntensity.X);
jiggers.RelIntensityY = MAX(y, jiggers.RelIntensityY); jiggers.RelIntensity.Y = MAX(y, jiggers.RelIntensity.Y);
jiggers.RelIntensityZ = MAX(z, jiggers.RelIntensityZ); jiggers.RelIntensity.Z = MAX(z, jiggers.RelIntensity.Z);
} }
else else
{ {
jiggers.IntensityX = MAX(x, jiggers.IntensityX); jiggers.Intensity.X = MAX(x, jiggers.Intensity.X);
jiggers.IntensityY = MAX(y, jiggers.IntensityY); jiggers.Intensity.Y = MAX(y, jiggers.Intensity.Y);
jiggers.IntensityZ = MAX(z, jiggers.IntensityZ); jiggers.Intensity.Z = MAX(z, jiggers.Intensity.Z);
} }
} }
else else
{ {
jiggers.WFalloff = MAX(falloff, jiggers.WFalloff); jiggers.WFalloff = MAX(falloff, jiggers.WFalloff);
fixed_t mx = FixedMul(x, quake->GetModWave(quake->m_WaveSpeedX)); double mx = x * quake->GetModWave(quake->m_WaveSpeed.X);
fixed_t my = FixedMul(y, quake->GetModWave(quake->m_WaveSpeedY)); double my = y * quake->GetModWave(quake->m_WaveSpeed.Y);
fixed_t mz = FixedMul(z, quake->GetModWave(quake->m_WaveSpeedZ)); double mz = z * quake->GetModWave(quake->m_WaveSpeed.Z);
// [RH] This only gives effect to the last sine quake. I would // [RH] This only gives effect to the last sine quake. I would
// prefer if some way was found to make multiples coexist // prefer if some way was found to make multiples coexist
@ -355,15 +314,15 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger
// relative phases. // relative phases.
if (quake->m_Flags & QF_RELATIVE) if (quake->m_Flags & QF_RELATIVE)
{ {
jiggers.RelOffsetX = mx; jiggers.RelOffset.X = mx;
jiggers.RelOffsetY = my; jiggers.RelOffset.Y = my;
jiggers.RelOffsetZ = mz; jiggers.RelOffset.Z = mz;
} }
else else
{ {
jiggers.OffsetX = mx; jiggers.Offset.X = mx;
jiggers.OffsetY = my; jiggers.Offset.Y = my;
jiggers.OffsetZ = mz; jiggers.Offset.Z = mz;
} }
} }
} }

View file

@ -154,11 +154,12 @@ enum
struct FQuakeJiggers struct FQuakeJiggers
{ {
int IntensityX, IntensityY, IntensityZ; DVector3 Intensity;
int RelIntensityX, RelIntensityY, RelIntensityZ; DVector3 RelIntensity;
int OffsetX, OffsetY, OffsetZ; DVector3 Offset;
int RelOffsetX, RelOffsetY, RelOffsetZ; DVector3 RelOffset;
int Falloff, WFalloff; double Falloff;
double WFalloff;
}; };
class DEarthquake : public DThinker class DEarthquake : public DThinker
@ -173,19 +174,19 @@ public:
void Serialize (FArchive &arc); void Serialize (FArchive &arc);
void Tick (); void Tick ();
TObjPtr<AActor> m_Spot; TObjPtr<AActor> m_Spot;
fixed_t m_TremorRadius, m_DamageRadius; double m_TremorRadius, m_DamageRadius;
int m_Countdown; int m_Countdown;
int m_CountdownStart; int m_CountdownStart;
FSoundID m_QuakeSFX; FSoundID m_QuakeSFX;
int m_Flags; int m_Flags;
fixed_t m_IntensityX, m_IntensityY, m_IntensityZ; DVector3 m_Intensity;
float m_WaveSpeedX, m_WaveSpeedY, m_WaveSpeedZ; DVector3 m_WaveSpeed;
fixed_t m_Falloff; double m_Falloff;
int m_Highpoint, m_MiniCount; int m_Highpoint, m_MiniCount;
fixed_t GetModIntensity(int intensity) const; double GetModIntensity(double intensity) const;
fixed_t GetModWave(double waveMultiplier) const; double GetModWave(double waveMultiplier) const;
fixed_t GetFalloff(fixed_t dist) const; double GetFalloff(double dist) const;
static int StaticGetQuakeIntensities(AActor *viewer, FQuakeJiggers &jiggers); static int StaticGetQuakeIntensities(AActor *viewer, FQuakeJiggers &jiggers);

View file

@ -41,7 +41,7 @@ IMPLEMENT_CLASS(PClassWeapon)
PClassWeapon::PClassWeapon() PClassWeapon::PClassWeapon()
{ {
SlotNumber = -1; SlotNumber = -1;
SlotPriority = FIXED_MAX; SlotPriority = INT_MAX;
} }
void PClassWeapon::DeriveData(PClass *newclass) void PClassWeapon::DeriveData(PClass *newclass)
@ -762,8 +762,8 @@ bool AWeaponGiver::TryPickup(AActor *&toucher)
// If DropAmmoFactor is non-negative, modify the given ammo amounts. // If DropAmmoFactor is non-negative, modify the given ammo amounts.
if (DropAmmoFactor > 0) if (DropAmmoFactor > 0)
{ {
weap->AmmoGive1 = FixedMul(weap->AmmoGive1, DropAmmoFactor); weap->AmmoGive1 = int(weap->AmmoGive1 * DropAmmoFactor);
weap->AmmoGive2 = FixedMul(weap->AmmoGive2, DropAmmoFactor); weap->AmmoGive2 = int(weap->AmmoGive2 * DropAmmoFactor);
} }
weap->BecomeItem(); weap->BecomeItem();
} }
@ -984,7 +984,7 @@ void FWeaponSlot::Sort()
for (i = 1; i < (int)Weapons.Size(); ++i) for (i = 1; i < (int)Weapons.Size(); ++i)
{ {
fixed_t pos = Weapons[i].Position; int pos = Weapons[i].Position;
PClassWeapon *type = Weapons[i].Type; PClassWeapon *type = Weapons[i].Type;
for (j = i - 1; j >= 0 && Weapons[j].Position > pos; --j) for (j = i - 1; j >= 0 && Weapons[j].Position > pos; --j)
{ {

View file

@ -3130,7 +3130,7 @@ void ModifyDropAmount(AInventory *inv, int dropamount)
} }
else if (inv->IsKindOf (RUNTIME_CLASS(AWeaponGiver))) else if (inv->IsKindOf (RUNTIME_CLASS(AWeaponGiver)))
{ {
static_cast<AWeaponGiver *>(inv)->DropAmmoFactor = dropammofactor; static_cast<AWeaponGiver *>(inv)->DropAmmoFactor = FIXED2DBL(dropammofactor);
inv->ItemFlags |= flagmask; inv->ItemFlags |= flagmask;
} }
else if (inv->IsKindOf (RUNTIME_CLASS(AWeapon))) else if (inv->IsKindOf (RUNTIME_CLASS(AWeapon)))

View file

@ -367,12 +367,12 @@ void P_DropWeapon (player_t *player)
// //
//============================================================================ //============================================================================
void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y) void P_BobWeapon (player_t *player, pspdef_t *psp, float *x, float *y)
{ {
static fixed_t curbob; static float curbob;
AWeapon *weapon; AWeapon *weapon;
fixed_t bobtarget; float bobtarget;
weapon = player->ReadyWeapon; weapon = player->ReadyWeapon;
@ -384,26 +384,26 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y)
// [XA] Get the current weapon's bob properties. // [XA] Get the current weapon's bob properties.
int bobstyle = weapon->BobStyle; int bobstyle = weapon->BobStyle;
int bobspeed = (weapon->BobSpeed * 128) >> 16; float BobSpeed = (weapon->BobSpeed * 128);
fixed_t rangex = weapon->BobRangeX; float Rangex = weapon->BobRangeX;
fixed_t rangey = weapon->BobRangeY; float Rangey = weapon->BobRangeY;
// Bob the weapon based on movement speed. // Bob the weapon based on movement speed.
int angle = (bobspeed*35/TICRATE*level.time)&FINEMASK; FAngle angle = (BobSpeed * 35 / TICRATE*level.time) * (360.f / 8192.f);
// [RH] Smooth transitions between bobbing and not-bobbing frames. // [RH] Smooth transitions between bobbing and not-bobbing frames.
// This also fixes the bug where you can "stick" a weapon off-center by // This also fixes the bug where you can "stick" a weapon off-center by
// shooting it when it's at the peak of its swing. // shooting it when it's at the peak of its swing.
bobtarget = (player->WeaponState & WF_WEAPONBOBBING) ? FLOAT2FIXED(player->bob) : 0; bobtarget = float((player->WeaponState & WF_WEAPONBOBBING) ? player->bob : 0.);
if (curbob != bobtarget) if (curbob != bobtarget)
{ {
if (abs (bobtarget - curbob) <= 1*FRACUNIT) if (fabsf (bobtarget - curbob) <= 1)
{ {
curbob = bobtarget; curbob = bobtarget;
} }
else else
{ {
fixed_t zoom = MAX<fixed_t> (1*FRACUNIT, abs (curbob - bobtarget) / 40); float zoom = MAX (1.f, fabsf (curbob - bobtarget) / 40);
if (curbob > bobtarget) if (curbob > bobtarget)
{ {
curbob -= zoom; curbob -= zoom;
@ -417,38 +417,38 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y)
if (curbob != 0) if (curbob != 0)
{ {
fixed_t bobx = fixed_t(player->bob * rangex); float bobx = float(player->bob * Rangex);
fixed_t boby = fixed_t(player->bob * rangey); float boby = float(player->bob * Rangey);
switch (bobstyle) switch (level.levelnum)//bobstyle)
{ {
case AWeapon::BobNormal: case AWeapon::BobNormal:
*x = FixedMul(bobx, finecosine[angle]); *x = bobx * angle.Cos();
*y = FixedMul(boby, finesine[angle & (FINEANGLES/2-1)]); *y = boby * fabsf(angle.Sin());
break; break;
case AWeapon::BobInverse: case AWeapon::BobInverse:
*x = FixedMul(bobx, finecosine[angle]); *x = bobx*angle.Cos();
*y = boby - FixedMul(boby, finesine[angle & (FINEANGLES/2-1)]); *y = boby * (1.f - fabsf(angle.Sin()));
break; break;
case AWeapon::BobAlpha: case AWeapon::BobAlpha:
*x = FixedMul(bobx, finesine[angle]); *x = bobx * angle.Sin();
*y = FixedMul(boby, finesine[angle & (FINEANGLES/2-1)]); *y = boby * fabsf(angle.Sin());
break; break;
case AWeapon::BobInverseAlpha: case AWeapon::BobInverseAlpha:
*x = FixedMul(bobx, finesine[angle]); *x = bobx * angle.Sin();
*y = boby - FixedMul(boby, finesine[angle & (FINEANGLES/2-1)]); *y = boby * (1.f - fabsf(angle.Sin()));
break; break;
case AWeapon::BobSmooth: case AWeapon::BobSmooth:
*x = FixedMul(bobx, finecosine[angle]); *x = bobx*angle.Cos();
*y = (boby - FixedMul(boby, finecosine[angle*2 & (FINEANGLES-1)])) / 2; *y = 0.5f * (boby * (1.f - fabsf((angle * 2).Cos())));
break; break;
case AWeapon::BobInverseSmooth: case AWeapon::BobInverseSmooth:
*x = FixedMul(bobx, finecosine[angle]); *x = bobx*angle.Cos();
*y = (FixedMul(boby, finecosine[angle*2 & (FINEANGLES-1)]) + boby) / 2; *y = 0.5f * (boby * (1.f + fabsf((angle * 2).Cos())));
} }
} }
else else

View file

@ -87,7 +87,7 @@ void P_CalcSwing (player_t *player);
void P_BringUpWeapon (player_t *player); void P_BringUpWeapon (player_t *player);
void P_FireWeapon (player_t *player); void P_FireWeapon (player_t *player);
void P_DropWeapon (player_t *player); void P_DropWeapon (player_t *player);
void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y); void P_BobWeapon (player_t *player, pspdef_t *psp, float *x, float *y);
DAngle P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget = NULL, int aimflags = 0); DAngle P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget = NULL, int aimflags = 0);
void P_GunShot (AActor *mo, bool accurate, PClassActor *pufftype, DAngle pitch); void P_GunShot (AActor *mo, bool accurate, PClassActor *pufftype, DAngle pitch);

View file

@ -1350,12 +1350,12 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_
{ {
if (RenderTarget != screen || viewheight == RenderTarget->GetHeight()) if (RenderTarget != screen || viewheight == RenderTarget->GetHeight())
{ {
vis->texturemid -= weapon->YAdjust; vis->texturemid -= FLOAT2FIXED(weapon->YAdjust);
} }
else else
{ {
vis->texturemid -= FixedMul (StatusBar->GetDisplacement (), vis->texturemid -= FixedMul (StatusBar->GetDisplacement (),
weapon->YAdjust); FLOAT2FIXED(weapon->YAdjust));
} }
} }
} }
@ -1575,7 +1575,7 @@ void R_DrawPlayerSprites ()
if (camera->player != NULL) if (camera->player != NULL)
{ {
fixed_t centerhack = centeryfrac; fixed_t centerhack = centeryfrac;
fixed_t ofsx, ofsy; float ofsx, ofsy;
centery = viewheight >> 1; centery = viewheight >> 1;
centeryfrac = centery << FRACBITS; centeryfrac = centery << FRACBITS;
@ -1590,7 +1590,7 @@ void R_DrawPlayerSprites ()
// [RH] Don't draw the targeter's crosshair if the player already has a crosshair set. // [RH] Don't draw the targeter's crosshair if the player already has a crosshair set.
if (psp->state && (i != ps_targetcenter || CrosshairImage == NULL)) if (psp->state && (i != ps_targetcenter || CrosshairImage == NULL))
{ {
R_DrawPSprite (psp, i, camera, FLOAT2FIXED(psp->sx) + ofsx, FLOAT2FIXED(psp->sy) + ofsy); R_DrawPSprite (psp, i, camera, FLOAT2FIXED(psp->sx + ofsx), FLOAT2FIXED(psp->sy + ofsy));
} }
// [RH] Don't bob the targeter. // [RH] Don't bob the targeter.
if (i == ps_flash) if (i == ps_flash)

View file

@ -897,19 +897,18 @@ void R_AddInterpolationPoint(const fixedvec3a &vec)
// //
//========================================================================== //==========================================================================
static fixed_t QuakePower(fixed_t factor, fixed_t intensity, fixed_t offset, fixed_t falloff, fixed_t wfalloff) static double QuakePower(double factor, double intensity, double offset, double falloff, double wfalloff)
{ {
fixed_t randumb; double randumb;
if (intensity == 0) if (intensity == 0)
{ {
randumb = 0; randumb = 0;
} }
else else
{ {
randumb = pr_torchflicker(intensity * 2) - intensity; randumb = pr_torchflicker.GenRand_Real2() * (intensity * 2) - intensity;
} }
fixed_t rn2 = (FixedMul(wfalloff,offset) + FixedMul(falloff, randumb)); return factor * (wfalloff * offset + falloff * randumb);
return FixedMul(factor, rn2);
} }
//========================================================================== //==========================================================================
@ -1046,42 +1045,44 @@ void R_SetupFrame (AActor *actor)
if (!paused) if (!paused)
{ {
FQuakeJiggers jiggers = { 0, }; FQuakeJiggers jiggers;
memset(&jiggers, 0, sizeof(jiggers));
if (DEarthquake::StaticGetQuakeIntensities(camera, jiggers) > 0) if (DEarthquake::StaticGetQuakeIntensities(camera, jiggers) > 0)
{ {
fixed_t quakefactor = FLOAT2FIXED(r_quakeintensity); double quakefactor = r_quakeintensity;
DAngle an;
if ((jiggers.RelIntensityX | jiggers.RelOffsetX) != 0) if (jiggers.RelIntensity.X != 0 || jiggers.RelOffset.X != 0)
{ {
int ang = (camera->_f_angle()) >> ANGLETOFINESHIFT; an = camera->Angles.Yaw;
fixed_t power = QuakePower(quakefactor, jiggers.RelIntensityX, jiggers.RelOffsetX, jiggers.Falloff, jiggers.WFalloff); double power = QuakePower(quakefactor, jiggers.RelIntensity.X, jiggers.RelOffset.X, jiggers.Falloff, jiggers.WFalloff);
viewx += FixedMul(finecosine[ang], power); viewx += FLOAT2FIXED(an.Cos() * power);
viewy += FixedMul(finesine[ang], power); viewy += FLOAT2FIXED(an.Sin() * power);
} }
if ((jiggers.RelIntensityY | jiggers.RelOffsetY) != 0) if (jiggers.RelIntensity.Y != 0 || jiggers.RelOffset.Y != 0)
{ {
int ang = (camera->_f_angle() + ANG90) >> ANGLETOFINESHIFT; an = camera->Angles.Yaw + 90;
fixed_t power = QuakePower(quakefactor, jiggers.RelIntensityY, jiggers.RelOffsetY, jiggers.Falloff, jiggers.WFalloff); double power = QuakePower(quakefactor, jiggers.RelIntensity.Y, jiggers.RelOffset.Y, jiggers.Falloff, jiggers.WFalloff);
viewx += FixedMul(finecosine[ang], power); viewx += FLOAT2FIXED(an.Cos() * power);
viewy += FixedMul(finesine[ang], power); viewy += FLOAT2FIXED(an.Sin() * power);
} }
// FIXME: Relative Z is not relative // FIXME: Relative Z is not relative
if ((jiggers.RelIntensityZ | jiggers.RelOffsetZ) != 0) if (jiggers.RelIntensity.Z != 0 || jiggers.RelOffset.Z != 0)
{ {
viewz += QuakePower(quakefactor, jiggers.RelIntensityZ, jiggers.RelOffsetZ, jiggers.Falloff, jiggers.WFalloff); viewz += FLOAT2FIXED(QuakePower(quakefactor, jiggers.RelIntensity.Z, jiggers.RelOffset.Z, jiggers.Falloff, jiggers.WFalloff));
} }
if ((jiggers.IntensityX | jiggers.OffsetX) != 0) if (jiggers.Intensity.X != 0 || jiggers.Offset.X != 0)
{ {
viewx += QuakePower(quakefactor, jiggers.IntensityX, jiggers.OffsetX, jiggers.Falloff, jiggers.WFalloff); viewx += FLOAT2FIXED(QuakePower(quakefactor, jiggers.Intensity.X, jiggers.Offset.X, jiggers.Falloff, jiggers.WFalloff));
} }
if ((jiggers.IntensityY | jiggers.OffsetY) != 0) if (jiggers.Intensity.Y != 0 || jiggers.Offset.Y != 0)
{ {
viewy += QuakePower(quakefactor, jiggers.IntensityY, jiggers.OffsetY, jiggers.Falloff, jiggers.WFalloff); viewy += FLOAT2FIXED(QuakePower(quakefactor, jiggers.Intensity.Y, jiggers.Offset.Y, jiggers.Falloff, jiggers.WFalloff));
} }
if ((jiggers.IntensityZ | jiggers.OffsetZ) != 0) if (jiggers.Intensity.Z != 0 || jiggers.Offset.Z != 0)
{ {
viewz += QuakePower(quakefactor, jiggers.IntensityZ, jiggers.OffsetZ, jiggers.Falloff, jiggers.WFalloff); viewz += FLOAT2FIXED(QuakePower(quakefactor, jiggers.Intensity.Z, jiggers.Offset.Z, jiggers.Falloff, jiggers.WFalloff));
} }
} }
} }

View file

@ -2028,7 +2028,7 @@ DEFINE_CLASS_PROPERTY(upsound, S, Weapon)
//========================================================================== //==========================================================================
DEFINE_CLASS_PROPERTY(yadjust, F, Weapon) DEFINE_CLASS_PROPERTY(yadjust, F, Weapon)
{ {
PROP_FIXED_PARM(i, 0); PROP_FLOAT_PARM(i, 0);
defaults->YAdjust = i; defaults->YAdjust = i;
} }
@ -2056,7 +2056,7 @@ DEFINE_CLASS_PROPERTY(bobstyle, S, Weapon)
//========================================================================== //==========================================================================
DEFINE_CLASS_PROPERTY(bobspeed, F, Weapon) DEFINE_CLASS_PROPERTY(bobspeed, F, Weapon)
{ {
PROP_FIXED_PARM(i, 0); PROP_FLOAT_PARM(i, 0);
defaults->BobSpeed = i; defaults->BobSpeed = i;
} }
@ -2065,7 +2065,7 @@ DEFINE_CLASS_PROPERTY(bobspeed, F, Weapon)
//========================================================================== //==========================================================================
DEFINE_CLASS_PROPERTY(bobrangex, F, Weapon) DEFINE_CLASS_PROPERTY(bobrangex, F, Weapon)
{ {
PROP_FIXED_PARM(i, 0); PROP_FLOAT_PARM(i, 0);
defaults->BobRangeX = i; defaults->BobRangeX = i;
} }
@ -2074,7 +2074,7 @@ DEFINE_CLASS_PROPERTY(bobrangex, F, Weapon)
//========================================================================== //==========================================================================
DEFINE_CLASS_PROPERTY(bobrangey, F, Weapon) DEFINE_CLASS_PROPERTY(bobrangey, F, Weapon)
{ {
PROP_FIXED_PARM(i, 0); PROP_FLOAT_PARM(i, 0);
defaults->BobRangeY = i; defaults->BobRangeY = i;
} }

View file

@ -1041,14 +1041,14 @@ struct TAngle
return FLOAT2ANGLE(Degrees) >> 16; return FLOAT2ANGLE(Degrees) >> 16;
} }
double Cos() const vec_t Cos() const
{ {
return g_cosdeg(Degrees); return vec_t(g_cosdeg(Degrees));
} }
double Sin() const vec_t Sin() const
{ {
return g_sindeg(Degrees); return vec_t(g_sindeg(Degrees));
} }
double Tan() const double Tan() const
@ -1354,7 +1354,7 @@ typedef TVector2<float> FVector2;
typedef TVector3<float> FVector3; typedef TVector3<float> FVector3;
typedef TRotator<float> FRotator; typedef TRotator<float> FRotator;
typedef TMatrix3x3<float> FMatrix3x3; typedef TMatrix3x3<float> FMatrix3x3;
//typedef TAngle<float> FAngle; typedef TAngle<float> FAngle;
typedef TVector2<double> DVector2; typedef TVector2<double> DVector2;
typedef TVector3<double> DVector3; typedef TVector3<double> DVector3;