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 */ /* Calculate attenuation */
float att = _attenuationCurve(dist); float att = _attenuationCurve(dist);
att = (m_maxVol - m_minVol) * att + m_minVol; att = (m_maxVol - m_minVol) * att + m_minVol;
//if (!std::isnan(att)) { att = m_attCache.getVolume(att, false);
att = m_attCache.getVolume(att, false);
//} else {
//att = 0.f;
//}
if (att > FLT_EPSILON) { if (att > FLT_EPSILON) {
/* Apply pan law */ /* Apply pan law */
const std::array<float, 8> thisCoefs = m_vox->_panLaw(frontPan, backPan, span); 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) { void Listener::setVectors(const float* pos, const float* dir, const float* heading, const float* up) {
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
m_pos[i] = pos[i]; if (!std::isnan(pos[i])) {
m_dir[i] = dir[i]; m_pos[i] = pos[i];
m_heading[i] = heading[i]; } else {
m_up[i] = up[i]; 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); m_heading = Normalize(m_heading);