Fix audio-driven mouth viewed by others
Unified · Split
| @@ -73,20 +73,20 @@ void Head::reset() { · 72 unmodified lines | ||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | void Head::simulate(float deltaTime, bool isMine, bool billboard) { |
| 76 | + // Update audio trailing average for rendering facial animations | |
| 77 | + const float AUDIO_AVERAGING_SECS = 0.05f; | |
| 78 | + const float AUDIO_LONG_TERM_AVERAGING_SECS = 30.0f; | |
| 79 | + _averageLoudness = glm::mix(_averageLoudness, _audioLoudness, glm::min(deltaTime / AUDIO_AVERAGING_SECS, 1.0f)); | |
| 80 | + | |
| 81 | + if (_longTermAverageLoudness == -1.0) { | |
| 82 | + _longTermAverageLoudness = _averageLoudness; | |
| 83 | + } else { | |
| 84 | + _longTermAverageLoudness = glm::mix(_longTermAverageLoudness, _averageLoudness, glm::min(deltaTime / AUDIO_LONG_TERM_AVERAGING_SECS, 1.0f)); | |
| 85 | + } | |
| 86 | + | |
| 76 | 87 | if (isMine) { |
| 77 | 88 | MyAvatar* myAvatar = static_cast<MyAvatar*>(_owningAvatar); |
| 78 | 89 | |
| 79 | − // Update audio trailing average for rendering facial animations | |
| 80 | − const float AUDIO_AVERAGING_SECS = 0.05f; | |
| 81 | − const float AUDIO_LONG_TERM_AVERAGING_SECS = 30.0f; | |
| 82 | − _averageLoudness = glm::mix(_averageLoudness, _audioLoudness, glm::min(deltaTime / AUDIO_AVERAGING_SECS, 1.0f)); | |
| 83 | − | |
| 84 | − if (_longTermAverageLoudness == -1.0) { | |
| 85 | − _longTermAverageLoudness = _averageLoudness; | |
| 86 | − } else { | |
| 87 | − _longTermAverageLoudness = glm::mix(_longTermAverageLoudness, _averageLoudness, glm::min(deltaTime / AUDIO_LONG_TERM_AVERAGING_SECS, 1.0f)); | |
| 88 | − } | |
| 89 | − | |
| 90 | 90 | // Only use face trackers when not playing back a recording. |
| 91 | 91 | if (!myAvatar->isPlaying()) { |
| 92 | 92 | FaceTracker* faceTracker = Application::getInstance()->getActiveFaceTracker(); |