Harden Listener against NaN as well

This commit is contained in:
Phillip Stephens 2020-09-27 22:07:01 -07:00
parent 69bc5dd69f
commit fa3188e569
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
2 changed files with 21 additions and 9 deletions

View File

@ -67,11 +67,7 @@ void Emitter::_update() {
/* Calculate attenuation */
float att = _attenuationCurve(dist);
att = (m_maxVol - m_minVol) * att + m_minVol;
//if (!std::isnan(att)) {
att = m_attCache.getVolume(att, false);
//} else {
//att = 0.f;
//}
att = m_attCache.getVolume(att, false);
if (att > FLT_EPSILON) {
/* Apply pan law */
const std::array<float, 8> thisCoefs = m_vox->_panLaw(frontPan, backPan, span);

View File

@ -12,10 +12,26 @@ static constexpr Vector3f Cross(const Vector3f& a, const Vector3f& b) {
void Listener::setVectors(const float* pos, const float* dir, const float* heading, const float* up) {
for (int i = 0; i < 3; ++i) {
m_pos[i] = pos[i];
m_dir[i] = dir[i];
m_heading[i] = heading[i];
m_up[i] = up[i];
if (!std::isnan(pos[i])) {
m_pos[i] = pos[i];
} else {
m_pos[i] = 0.f;
}
if (!std::isnan(dir[i])) {
m_dir[i] = dir[i];
} else {
m_dir[i] = 0.f;
}
if (!std::isnan(heading[i])) {
m_heading[i] = heading[i];
} else {
m_heading[i] = 0.f;
}
if (std::isnan(up[i])) {
m_up[i] = up[i];
} else {
m_heading[i] = 0.f;
}
}
m_heading = Normalize(m_heading);