diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 571cf493bd..3a4b1e9c62 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2795,7 +2795,27 @@ QImage Application::renderAvatarBillboard() { return image; } +// FIXME, preprocessor guard this check to occur only in DEBUG builds +static QThread * activeRenderingThread = nullptr; + +ViewFrustum* Application::getViewFrustum() { + if (QThread::currentThread() == activeRenderingThread) { + // FIXME, should this be an assert? + qWarning() << "Calling Application::getViewFrustum() from the active rendering thread, did you mean Application::getDisplayViewFrustum()?"; + } + return &_viewFrustum; +} + +ViewFrustum* Application::getDisplayViewFrustum() { + if (QThread::currentThread() != activeRenderingThread) { + // FIXME, should this be an assert? + qWarning() << "Calling Application::getDisplayViewFrustum() from outside the active rendering thread or outside rendering, did you mean Application::getViewFrustum()?"; + } + return &_displayViewFrustum; +} + void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs::RenderSide renderSide) { + activeRenderingThread = QThread::currentThread(); PROFILE_RANGE(__FUNCTION__); PerformanceTimer perfTimer("display"); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()"); @@ -3020,6 +3040,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs glClear(GL_DEPTH_BUFFER_BIT); _overlays.renderWorld(true); } + activeRenderingThread = nullptr; } void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation) { diff --git a/interface/src/Application.h b/interface/src/Application.h index b013692393..ae68374fed 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -174,8 +174,12 @@ public: bool isThrottleRendering() const { return _glWidget->isThrottleRendering(); } Camera* getCamera() { return &_myCamera; } - ViewFrustum* getViewFrustum() { return &_viewFrustum; } - ViewFrustum* getDisplayViewFrustum() { return &_displayViewFrustum; } + // Represents the current view frustum of the avatar. + ViewFrustum* getViewFrustum(); + // Represents the view frustum of the current rendering pass, + // which might be different from the viewFrustum, i.e. shadowmap + // passes, mirror window passes, etc + ViewFrustum* getDisplayViewFrustum(); ViewFrustum* getShadowViewFrustum() { return &_shadowViewFrustum; } const OctreePacketProcessor& getOctreePacketProcessor() const { return _octreeProcessor; } EntityTreeRenderer* getEntities() { return &_entities; } diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 75d77b780a..d2f0f815df 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -338,7 +338,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool // simple frustum check float boundingRadius = getBillboardSize(); ViewFrustum* frustum = (renderMode == Avatar::SHADOW_RENDER_MODE) ? - Application::getInstance()->getShadowViewFrustum() : Application::getInstance()->getViewFrustum(); + Application::getInstance()->getShadowViewFrustum() : Application::getInstance()->getDisplayViewFrustum(); if (frustum->sphereInFrustum(getPosition(), boundingRadius) == ViewFrustum::OUTSIDE) { return; } diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index c7b350f100..158deb00ff 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -122,7 +122,7 @@ void Overlays::renderWorld(bool drawFront, RenderArgs::RenderMode renderMode, Re float myAvatarScale = 1.0f; auto lodManager = DependencyManager::get(); - RenderArgs args = { NULL, Application::getInstance()->getViewFrustum(), + RenderArgs args = { NULL, Application::getInstance()->getDisplayViewFrustum(), lodManager->getOctreeSizeScale(), lodManager->getBoundaryLevelAdjust(), renderMode, renderSide,