| 592 | } |
| 593 | |
| 594 | void LevelHandler::OnEndFrame() |
| 595 | { |
| 596 | ZoneScopedC(0x4876AF); |
| 597 | |
| 598 | float timeMult = theApplication().GetTimeMult(); |
| 599 | auto& resolver = ContentResolver::Get(); |
| 600 | |
| 601 | _tileMap->OnEndFrame(); |
| 602 | |
| 603 | if (!IsPausable() || _pauseMenu == nullptr) { |
| 604 | ResolveCollisions(timeMult); |
| 605 | |
| 606 | if (!resolver.IsHeadless()) { |
| 607 | #if defined(NCINE_HAS_GAMEPAD_RUMBLE) |
| 608 | _rumble.OnEndFrame(timeMult); |
| 609 | #endif |
| 610 | |
| 611 | for (auto& viewport : _assignedViewports) { |
| 612 | viewport->UpdateCamera(timeMult); |
| 613 | } |
| 614 | |
| 615 | #if defined(WITH_AUDIO) |
| 616 | if (!_assignedViewports.empty()) { |
| 617 | // Update audio listener position |
| 618 | IAudioDevice& audioDevice = theServiceLocator().GetAudioDevice(); |
| 619 | if (_assignedViewports.size() == 1) { |
| 620 | audioDevice.updateListener(Vector3f(_assignedViewports[0]->_cameraPos, 0.0f), |
| 621 | Vector3f(_assignedViewports[0]->_targetActor->GetSpeed(), 0.0f)); |
| 622 | } else { |
| 623 | audioDevice.updateListener(Vector3f::Zero, Vector3f::Zero); |
| 624 | |
| 625 | // All audio players must be updated to the nearest listener |
| 626 | for (auto& current : _playingSounds) { |
| 627 | if (auto* currentForSplitscreen = runtime_cast<AudioBufferPlayerForSplitscreen>(current.get())) { |
| 628 | currentForSplitscreen->updatePosition(); |
| 629 | } |
| 630 | } |
| 631 | } |
| 632 | } |
| 633 | #endif |
| 634 | } |
| 635 | |
| 636 | _elapsedFrames += timeMult; |
| 637 | } |
| 638 | |
| 639 | if (!resolver.IsHeadless()) { |
| 640 | for (auto& viewport : _assignedViewports) { |
| 641 | viewport->OnEndFrame(); |
| 642 | } |
| 643 | |
| 644 | #if defined(DEATH_DEBUG) && defined(WITH_IMGUI) |
| 645 | if (PreferencesCache::ShowPerformanceMetrics && !_assignedViewports.empty()) { |
| 646 | ImDrawList* drawList = ImGui::GetBackgroundDrawList(); |
| 647 | const auto& mainViewport = *_assignedViewports[0]; |
| 648 | |
| 649 | std::size_t actorsCount = _actors.size(); |
| 650 | for (std::size_t i = 0; i < actorsCount; i++) { |
| 651 | auto* actor = _actors[i].get(); |
no test coverage detected