diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index e6beaef342..5c31a05fde 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -175,13 +175,11 @@ void mainRenderFunc() { } #endif - if (SgctEngine->isMaster()) { - OsEng.render(viewMatrix, projectionMatrix); - } - else { - glm::mat4 sceneMatrix = SgctEngine->getModelMatrix(); - OsEng.render(viewMatrix * sceneMatrix, projectionMatrix); - } + OsEng.render( + SgctEngine->getModelMatrix(), + viewMatrix, + projectionMatrix + ); LTRACE("main::mainRenderFunc(end)"); } diff --git a/include/openspace/engine/configurationmanager.h b/include/openspace/engine/configurationmanager.h index f67b55bc6e..906704219b 100644 --- a/include/openspace/engine/configurationmanager.h +++ b/include/openspace/engine/configurationmanager.h @@ -104,6 +104,8 @@ public: /// The key that stores whether the master node should perform rendering just function /// as a pure manager static const std::string KeyDisableMasterRendering; + /// The key that stores whether the master node should apply the scene transformation + static const std::string KeyDisableSceneOnMaster; /// The key that sets the request URL that is used to request additional data to be /// downloaded static const std::string KeyDownloadRequestURL; diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index b13bc94b6e..dfc04f409b 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -88,7 +88,8 @@ public: void deinitialize(); void preSynchronization(); void postSynchronizationPreDraw(); - void render(const glm::mat4& viewMatrix, const glm::mat4& projectionMatrix); + void render(const glm::mat4& sceneMatrix, const glm::mat4& viewMatrix, + const glm::mat4& projectionMatrix); void postDraw(); void keyboardCallback(Key key, KeyModifier mod, KeyAction action); void charCallback(unsigned int codepoint, KeyModifier mod); diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index ca93e45031..bbd88093b8 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -98,7 +98,8 @@ public: void updateFade(); void updateRenderer(); void updateScreenSpaceRenderables(); - void render(const glm::mat4& viewMatrix, const glm::mat4& projectionMatrix); + void render(const glm::mat4& sceneMatrix, const glm::mat4& viewMatrix, + const glm::mat4& projectionMatrix); void renderScreenLog(); void renderShutdownInformation(float timer, float fullTime); @@ -211,6 +212,7 @@ private: properties::BoolProperty _applyWarping; properties::BoolProperty _showFrameNumber; properties::BoolProperty _disableMasterRendering; + properties::BoolProperty _disableSceneOnMaster; float _globalBlackOutFactor; float _fadeDuration; diff --git a/openspace.cfg b/openspace.cfg index 70735f840f..971434804f 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -88,6 +88,7 @@ return { -- OnScreenTextScaling = "framebuffer", -- PerSceneCache = true, -- DisableRenderingOnMaster = true, + KeyDisableSceneOnMaster = true, DownloadRequestURL = "http://data.openspaceproject.com/request.cgi", RenderingMethod = "Framebuffer" --RenderingMethod = "ABuffer" -- alternative: "Framebuffer" diff --git a/src/engine/configurationmanager.cpp b/src/engine/configurationmanager.cpp index dc532650d7..2c4d466603 100644 --- a/src/engine/configurationmanager.cpp +++ b/src/engine/configurationmanager.cpp @@ -73,6 +73,7 @@ const string ConfigurationManager::KeyCapabilitiesVerbosity = const string ConfigurationManager::KeyShutdownCountdown = "ShutdownCountdown"; const string ConfigurationManager::KeyDisableMasterRendering = "DisableRenderingOnMaster"; +const string ConfigurationManager::KeyDisableSceneOnMaster = "DisableSceneOnMaster"; const string ConfigurationManager::KeyDownloadRequestURL = "DownloadRequestURL"; const string ConfigurationManager::KeyPerSceneCache = "PerSceneCache"; const string ConfigurationManager::KeyRenderingMethod = "RenderingMethod"; diff --git a/src/engine/configurationmanager_doc.inl b/src/engine/configurationmanager_doc.inl index c00eb44b83..193299bd08 100644 --- a/src/engine/configurationmanager_doc.inl +++ b/src/engine/configurationmanager_doc.inl @@ -338,6 +338,16 @@ documentation::Documentation ConfigurationManager::Documentation() { "the master computer does not have the resources to render a scene.", Optional::Yes }, + { + ConfigurationManager::KeyDisableSceneOnMaster, + new BoolVerifier, + "Toggles whether a potential scene transformation matrix, for example as " + "specified in an SGCT configuration file, should apply to the master node. " + "With some configurations, applying such a transformation complicates the " + "interaction and it is thus desired to disable the transformation. The " + "default is false.", + Optional::Yes + }, { ConfigurationManager::KeyHttpProxy, new TableVerifier({ diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 43a410ff1f..c6d7147bba 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -1028,11 +1028,12 @@ void OpenSpaceEngine::postSynchronizationPreDraw() { LTRACE("OpenSpaceEngine::postSynchronizationPreDraw(end)"); } -void OpenSpaceEngine::render(const glm::mat4& viewMatrix, +void OpenSpaceEngine::render(const glm::mat4& sceneMatrix, + const glm::mat4& viewMatrix, const glm::mat4& projectionMatrix) { LTRACE("OpenSpaceEngine::render(begin)"); - _renderEngine->render(viewMatrix, projectionMatrix); + _renderEngine->render(sceneMatrix, viewMatrix, projectionMatrix); for (const auto& func : _moduleCallbacks.render) { func(); diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index d1cd2e6456..c8fda8c90e 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -108,6 +108,7 @@ RenderEngine::RenderEngine() , _takeScreenshot("takeScreenshot", "Take Screenshot") , _showFrameNumber("showFrameNumber", "Show Frame Number", false) , _disableMasterRendering("disableMasterRendering", "Disable Master Rendering", false) + , _disableSceneOnMaster("disableSceneOnMaster", "Disable Scene on Master", false) , _shouldTakeScreenshot(false) , _renderer(nullptr) , _rendererImplementation(RendererImplementation::Invalid) @@ -165,6 +166,7 @@ RenderEngine::RenderEngine() addProperty(_showFrameNumber); addProperty(_disableMasterRendering); + addProperty(_disableSceneOnMaster); } void RenderEngine::setRendererFromString(const std::string& renderingMethod) { @@ -211,6 +213,12 @@ void RenderEngine::initialize() { ); } + if (confManager.hasKey(ConfigurationManager::KeyDisableSceneOnMaster)) { + _disableSceneOnMaster = confManager.value( + ConfigurationManager::KeyDisableSceneOnMaster + ); + } + _raycasterManager = std::make_unique(); _nAaSamples = OsEng.windowWrapper().currentNumberOfAaSamples(); @@ -385,12 +393,20 @@ void RenderEngine::updateFade() { -void RenderEngine::render(const glm::mat4& viewMatrix, const glm::mat4& projectionMatrix) { +void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMatrix, + const glm::mat4& projectionMatrix) +{ LTRACE("RenderEngine::render(begin)"); - _camera->sgctInternal.setViewMatrix(viewMatrix); + WindowWrapper& wrapper = OsEng.windowWrapper(); + + if (_disableSceneOnMaster && wrapper.isMaster()) { + _camera->sgctInternal.setViewMatrix(viewMatrix); + } + else { + _camera->sgctInternal.setViewMatrix(viewMatrix * sceneMatrix); + } _camera->sgctInternal.setProjectionMatrix(projectionMatrix); - WindowWrapper& wrapper = OsEng.windowWrapper(); if (!(wrapper.isMaster() && _disableMasterRendering) && !wrapper.isGuiWindow()) { _renderer->render(_globalBlackOutFactor, _performanceManager != nullptr);