mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- SW: rewrote sound code to avoid using a position pointer-
This commit is contained in:
parent
9407fa549d
commit
825d94f5a5
1 changed files with 9 additions and 6 deletions
|
@ -520,7 +520,8 @@ void SWSoundEngine::CalcPosVel(int type, const void* source, const float pt[3],
|
||||||
{
|
{
|
||||||
PLAYER* pp = Player + screenpeek;
|
PLAYER* pp = Player + screenpeek;
|
||||||
FVector3 campos = GetSoundPos(pp->pos);
|
FVector3 campos = GetSoundPos(pp->pos);
|
||||||
vec3_t *vpos = nullptr;
|
vec3_t vpos = {};
|
||||||
|
bool pancheck = false;
|
||||||
|
|
||||||
if (vel) vel->Zero();
|
if (vel) vel->Zero();
|
||||||
|
|
||||||
|
@ -532,7 +533,8 @@ void SWSoundEngine::CalcPosVel(int type, const void* source, const float pt[3],
|
||||||
}
|
}
|
||||||
else if (type == SOURCE_Actor || type == SOURCE_Player)
|
else if (type == SOURCE_Actor || type == SOURCE_Player)
|
||||||
{
|
{
|
||||||
vpos = type == SOURCE_Actor ? &((DSWActor*)source)->spr.__int_pos : &((PLAYER*)source)->pos;
|
vpos = type == SOURCE_Actor ? ((DSWActor*)source)->spr.int_pos() : ((PLAYER*)source)->pos;
|
||||||
|
pancheck = true;
|
||||||
FVector3 npos = GetSoundPos(vpos);
|
FVector3 npos = GetSoundPos(vpos);
|
||||||
|
|
||||||
*pos = npos;
|
*pos = npos;
|
||||||
|
@ -552,13 +554,14 @@ void SWSoundEngine::CalcPosVel(int type, const void* source, const float pt[3],
|
||||||
else if (type == SOURCE_Ambient)
|
else if (type == SOURCE_Ambient)
|
||||||
{
|
{
|
||||||
auto spot = ((AmbientSound*)source)->spot;
|
auto spot = ((AmbientSound*)source)->spot;
|
||||||
vpos = &spot->spr.__int_pos;
|
vpos = spot->spr.int_pos();
|
||||||
FVector3 npos = GetSoundPos(vpos);
|
FVector3 npos = GetSoundPos(vpos);
|
||||||
|
pancheck = true;
|
||||||
|
|
||||||
// Can the ambient sound see the player? If not, tone it down some.
|
// Can the ambient sound see the player? If not, tone it down some.
|
||||||
if ((chanflags & CHANF_LOOP))
|
if ((chanflags & CHANF_LOOP))
|
||||||
{
|
{
|
||||||
if (!FAFcansee(vpos->X, vpos->Y, vpos->Z, spot->sector(), pp->pos.X, pp->pos.Y, pp->pos.Z, pp->cursector))
|
if (!FAFcansee(vpos.X, vpos.Y, vpos.Z, spot->sector(), pp->pos.X, pp->pos.Y, pp->pos.Z, pp->cursector))
|
||||||
{
|
{
|
||||||
auto distvec = npos - campos;
|
auto distvec = npos - campos;
|
||||||
npos = campos + distvec * 1.75f; // Play more quietly
|
npos = campos + distvec * 1.75f; // Play more quietly
|
||||||
|
@ -567,11 +570,11 @@ void SWSoundEngine::CalcPosVel(int type, const void* source, const float pt[3],
|
||||||
*pos = npos;
|
*pos = npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vpos && chanflags & CHANEXF_DONTPAN)
|
if (pancheck && chanflags & CHANEXF_DONTPAN)
|
||||||
{
|
{
|
||||||
// For unpanned sounds the volume must be set directly and the position taken from the listener.
|
// For unpanned sounds the volume must be set directly and the position taken from the listener.
|
||||||
*pos = campos;
|
*pos = campos;
|
||||||
auto sdist = SoundDist(vpos->X, vpos->Y, vpos->Z, voc[chanSound].voc_distance);
|
auto sdist = SoundDist(vpos.X, vpos.Y, vpos.Z, voc[chanSound].voc_distance);
|
||||||
if (chan) SetVolume(chan, (255 - sdist) * (1 / 255.f));
|
if (chan) SetVolume(chan, (255 - sdist) * (1 / 255.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue