| 366 | { |
| 367 | |
| 368 | void SoundScene::SimulateSpeedOfSound(IWave* sound) |
| 369 | { |
| 370 | float distance = sound->GetPosition().Distance(GScene->GetCamera()->Position()); |
| 371 | // sound will not start playing between frames |
| 372 | // it is therefore more accurate to subtract half of expected frame duration |
| 373 | // from wait time. This way we are effectively rounding to nearest frame instead |
| 374 | // of rounding to next one |
| 375 | float halfFrame = GEngine->GetAvgFrameDuration(4) * (0.001f * 0.5f); |
| 376 | float skip = -distance * InvSpeedOfSound + halfFrame; |
| 377 | // avoid skipping sound start, only delay is allowed |
| 378 | if (skip < 0) |
| 379 | { |
| 380 | sound->Skip(skip); |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | // FindSound lives in OptionsUI.cpp (mission -> campaign -> global config |
| 385 | // resolution incl. mission-dir prefix and the per-language voice suffix); |
no test coverage detected