- eliminated fixed point GetSoundPos variants

This commit is contained in:
Christoph Oelckers 2022-09-16 19:27:22 +02:00
parent ab23f6b114
commit fd4f04b5fd
2 changed files with 5 additions and 23 deletions

View file

@ -4,24 +4,6 @@
#include "vectors.h"
#include "build.h"
inline FVector3 GetSoundPos(const vec3_t *pos)
{
// converts a Build coordinate to a sound system coordinate
const float xmul = 1 / 16.f;
const float ymul = -1 / 16.f;
const float zmul = -1 / 256.f;
return { pos->X* xmul, pos->Z* zmul, pos->Y* ymul };
}
inline FVector3 GetSoundPos(const vec3_t& pos)
{
// converts a Build coordinate to a sound system coordinate
const float xmul = 1 / 16.f;
const float ymul = -1 / 16.f;
const float zmul = -1 / 256.f;
return { pos.X * xmul, pos.Z * zmul, pos.Y * ymul };
}
inline FVector3 GetSoundPos(const DVector3& pos)
{
return { float(pos.X), float(-pos.Z), float(-pos.Y) };
@ -58,4 +40,4 @@ public:
virtual bool SourceIsActor(FSoundChan* chan) { return chan->SourceType == SOURCE_Actor; }
virtual int SoundSourceIndex(FSoundChan* chan) { return 0; }
virtual void SetSource(FSoundChan* chan, int index) {}
};
};

View file

@ -76,7 +76,7 @@ void BloodSoundEngine::CalcPosVel(int type, const void* source, const float pt[3
PLAYER* pPlayer = &gPlayer[myconnectindex];
FVector3 camera;
if (pPlayer && pPlayer->actor) camera = GetSoundPos(pPlayer->actor->int_pos());
if (pPlayer && pPlayer->actor) camera = GetSoundPos(pPlayer->actor->spr.pos);
else camera = { 0, 0, 0 }; // don't crash if there is no player.
if (vel) vel->Zero();
@ -94,7 +94,7 @@ void BloodSoundEngine::CalcPosVel(int type, const void* source, const float pt[3
// Engine expects velocity in units per second, not units per tic.
if (vel) *vel = FVector3(actor->vel.X * 30, actor->vel.Z * -30, actor->vel.Y * -30);
*pos = GetSoundPos(actor->int_pos());
*pos = GetSoundPos(actor->spr.pos);
}
else if (type == SOURCE_Ambient)
{
@ -122,7 +122,7 @@ void GameInterface::UpdateSounds()
{
listener.angle = -pPlayer->actor->spr.int_ang() * float(BAngRadian); // Build uses a period of 2048.
listener.velocity.Zero();
listener.position = GetSoundPos(pPlayer->actor->int_pos());
listener.position = GetSoundPos(pPlayer->actor->spr.pos);
listener.valid = true;
}
else
@ -198,7 +198,7 @@ void sfxPlay3DSoundCP(DBloodActor* pActor, int soundId, int playchannel, int pla
auto sid = soundEngine->FindSoundByResID(soundId);
if (sid == 0) return;
auto svec = GetSoundPos(pActor->int_pos());
auto svec = GetSoundPos(pActor->spr.pos);
float attenuation;
sid = getSfx(sid, attenuation, pitch, volume);