Showing the changes to interface/src/scripting/RenderScriptingInterface.cpp (1 of 4 files). Show all
Unified · Split
| @@ -7,6 +7,9 @@ · 6 unmodified lines | |||
| 7 | // | 7 | // |
| 8 | #include "RenderScriptingInterface.h" | 8 | #include "RenderScriptingInterface.h" |
| 9 | 9 | ||
| 10 | #include "LightingModel.h" | ||
| 11 | #include "AntialiasingEffect.h" | ||
| 12 | |||
| 10 | const QString DEFERRED = "deferred"; | 13 | const QString DEFERRED = "deferred"; |
| 11 | const QString FORWARD = "forward"; | 14 | const QString FORWARD = "forward"; |
| 12 | 15 | ||
| @@ -17,6 +20,9 @@ RenderScriptingInterface* RenderScriptingInterface::getInstance() { · 4 unmodified lines | |||
| 17 | 20 | ||
| 18 | RenderScriptingInterface::RenderScriptingInterface() { | 21 | RenderScriptingInterface::RenderScriptingInterface() { |
| 19 | setRenderMethod((render::Args::RenderMethod)_renderMethodSetting.get() == render::Args::RenderMethod::DEFERRED ? DEFERRED : FORWARD); | 22 | setRenderMethod((render::Args::RenderMethod)_renderMethodSetting.get() == render::Args::RenderMethod::DEFERRED ? DEFERRED : FORWARD); |
| 23 | setShadowsEnabled(_shadowsEnabledSetting.get()); | ||
| 24 | setAmbientOcclusionEnabled(_ambientOcclusionEnabledSetting.get()); | ||
| 25 | setAntialiasingEnabled(_antialiasingEnabledSetting.get()); | ||
| 20 | } | 26 | } |
| 21 | 27 | ||
| 22 | QString RenderScriptingInterface::getRenderMethod() { | 28 | QString RenderScriptingInterface::getRenderMethod() { |
| @@ -24,6 +30,11 @@ QString RenderScriptingInterface::getRenderMethod() { · 1 unmodified line | |||
| 24 | } | 30 | } |
| 25 | 31 | ||
| 26 | void RenderScriptingInterface::setRenderMethod(const QString& renderMethod) { | 32 | void RenderScriptingInterface::setRenderMethod(const QString& renderMethod) { |
| 33 | render::Args::RenderMethod newMethod = renderMethod == FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED; | ||
| 34 | if (_renderMethodSetting.get() == newMethod) { | ||
| 35 | return; | ||
| 36 | } | ||
| 37 | |||
| 27 | if (QThread::currentThread() != thread()) { | 38 | if (QThread::currentThread() != thread()) { |
| 28 | QMetaObject::invokeMethod(this, "setRenderMethod", Q_ARG(const QString&, renderMethod)); | 39 | QMetaObject::invokeMethod(this, "setRenderMethod", Q_ARG(const QString&, renderMethod)); |
| 29 | return; | 40 | return; |
| @@ -31,14 +42,81 @@ void RenderScriptingInterface::setRenderMethod(const QString& renderMethod) { · 1 unmodified line | |||
| 31 | 42 | ||
| 32 | auto config = dynamic_cast<task::SwitchConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch")); | 43 | auto config = dynamic_cast<task::SwitchConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch")); |
| 33 | if (config) { | 44 | if (config) { |
| 34 | if (renderMethod == DEFERRED) { | 45 | _renderMethodSetting.set(newMethod); |
| 35 | _renderMethodSetting.set(render::Args::RenderMethod::DEFERRED); | 46 | config->setBranch(newMethod); |
| 36 | config->setBranch(render::Args::RenderMethod::DEFERRED); | 47 | emit config->dirtyEnabled(); |
| 37 | emit config->dirtyEnabled(); | 48 | } |
| 38 | } else if (renderMethod == FORWARD) { | 49 | } |
| 39 | _renderMethodSetting.set(render::Args::RenderMethod::FORWARD); | 50 | |
| 40 | config->setBranch(render::Args::RenderMethod::FORWARD); | 51 | bool RenderScriptingInterface::getShadowsEnabled() { |
| 41 | emit config->dirtyEnabled(); | 52 | return _shadowsEnabledSetting.get(); |
| 53 | } | ||
| 54 | |||
| 55 | void RenderScriptingInterface::setShadowsEnabled(bool enabled) { | ||
| 56 | if (_shadowsEnabledSetting.get() == enabled) { | ||
| 57 | return; | ||
| 58 | } | ||
| 59 | |||
| 60 | if (QThread::currentThread() != thread()) { | ||
| 61 | QMetaObject::invokeMethod(this, "setShadowsEnabled", Q_ARG(bool, enabled)); | ||
| 62 | return; | ||
| 63 | } | ||
| 64 | |||
| 65 | auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel"); | ||
| 66 | if (lightingModelConfig) { | ||
| 67 | Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled); | ||
| 68 | _shadowsEnabledSetting.set(enabled); | ||
| 69 | lightingModelConfig->setShadow(enabled); | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | bool RenderScriptingInterface::getAmbientOcclusionEnabled() { | ||
| 74 | return _ambientOcclusionEnabledSetting.get(); | ||
| 75 | } | ||
| 76 | |||
| 77 | void RenderScriptingInterface::setAmbientOcclusionEnabled(bool enabled) { | ||
| 78 | if (_ambientOcclusionEnabledSetting.get() == enabled) { | ||
| 79 | return; | ||
| 80 | } | ||
| 81 | |||
| 82 | if (QThread::currentThread() != thread()) { | ||
| 83 | QMetaObject::invokeMethod(this, "setAmbientOcclusionEnabled", Q_ARG(bool, enabled)); | ||
| 84 | return; | ||
| 85 | } | ||
| 86 | |||
| 87 | auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel"); | ||
| 88 | if (lightingModelConfig) { | ||
| 89 | Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled); | ||
| 90 | _ambientOcclusionEnabledSetting.set(enabled); | ||
| 91 | lightingModelConfig->setAmbientOcclusion(enabled); | ||
| 92 | } | ||
| 93 | } | ||
| 94 | |||
| 95 | bool RenderScriptingInterface::getAntialiasingEnabled() { | ||
| 96 | return _antialiasingEnabledSetting.get(); | ||
| 97 | } | ||
| 98 | |||
| 99 | void RenderScriptingInterface::setAntialiasingEnabled(bool enabled) { | ||
| 100 | if (_antialiasingEnabledSetting.get() == enabled) { | ||
| 101 | return; | ||
| 102 | } | ||
| 103 | |||
| 104 | if (QThread::currentThread() != thread()) { | ||
| 105 | QMetaObject::invokeMethod(this, "setAntialiasingEnabled", Q_ARG(bool, enabled)); | ||
| 106 | return; | ||
| 107 | } | ||
| 108 | |||
| 109 | auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderMainView.JitterCam"); | ||
| 110 | auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("RenderMainView.Antialiasing"); | ||
| 111 | if (mainViewJitterCamConfig && mainViewAntialiasingConfig) { | ||
| 112 | Menu::getInstance()->setIsOptionChecked(MenuOption::AntiAliasing, enabled); | ||
| 113 | _antialiasingEnabledSetting.set(enabled); | ||
| 114 | if (enabled) { | ||
| 115 | mainViewJitterCamConfig->play(); | ||
| 116 | mainViewAntialiasingConfig->setDebugFXAA(false); | ||
| 117 | } else { | ||
| 118 | mainViewJitterCamConfig->none(); | ||
| 119 | mainViewAntialiasingConfig->setDebugFXAA(true); | ||
| 42 | } | 120 | } |
| 43 | } | 121 | } |
| 44 | } | 122 | } |