Showing the changes to interface/src/scripting/RenderScriptingInterface.cpp (1 of 16 files). Show all
Unified · Split
| @@ -21,34 +21,43 @@ RenderScriptingInterface::RenderScriptingInterface() { · 20 unmodified lines | ||
| 21 | 21 | std::call_once(registry_flag, [] { |
| 22 | 22 | qmlRegisterType<RenderScriptingInterface>("RenderEnums", 1, 0, "RenderEnums"); |
| 23 | 23 | }); |
| 24 | +} | |
| 24 | 25 | |
| 25 | − setRenderMethod((RenderMethod)_renderMethodSettingLock.resultWithReadLock<int>([&] { | |
| 26 | − return _renderMethodSetting.get(); | |
| 27 | − })); | |
| 28 | − setShadowsEnabled(_shadowsEnabledSetting.get()); | |
| 29 | − setAmbientOcclusionEnabled(_ambientOcclusionEnabledSetting.get()); | |
| 30 | − setAntialiasingEnabled(_antialiasingEnabledSetting.get()); | |
| 26 | +void RenderScriptingInterface::loadSettings() { | |
| 27 | + _renderSettingLock.withReadLock([&] { | |
| 28 | + _renderMethod.store(_renderMethodSetting.get()); | |
| 29 | + _shadowsEnabled.store(_shadowsEnabledSetting.get()); | |
| 30 | + _ambientOcclusionEnabled.store(_ambientOcclusionEnabledSetting.get()); | |
| 31 | + _antialiasingEnabled.store(_antialiasingEnabledSetting.get()); | |
| 32 | + }); | |
| 33 | + forceRenderMethod((RenderMethod)_renderMethod.load()); | |
| 34 | + forceShadowsEnabled(_shadowsEnabled.load()); | |
| 35 | + forceAmbientOcclusionEnabled(_ambientOcclusionEnabled.load()); | |
| 36 | + forceAntialiasingEnabled(_antialiasingEnabled.load()); | |
| 31 | 37 | } |
| 32 | 38 | |
| 33 | 39 | RenderScriptingInterface::RenderMethod RenderScriptingInterface::getRenderMethod() { |
| 34 | − return (RenderMethod) _renderMethod; | |
| 40 | + return (RenderMethod) _renderMethod.load(); | |
| 35 | 41 | } |
| 36 | 42 | |
| 37 | 43 | void RenderScriptingInterface::setRenderMethod(RenderMethod renderMethod) { |
| 38 | 44 | if (_renderMethod != (int) renderMethod) { |
| 39 | − _renderMethodSettingLock.withWriteLock([&] { | |
| 40 | − _renderMethod = (int)renderMethod; | |
| 41 | − _renderMethodSetting.set((int)renderMethod); | |
| 42 | − | |
| 43 | − auto config = dynamic_cast<task::SwitchConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch")); | |
| 44 | − if (config) { | |
| 45 | − _renderMethodSetting.set((int)renderMethod); | |
| 46 | − config->setBranch((int)renderMethod); | |
| 47 | − } | |
| 48 | − }); | |
| 45 | + forceRenderMethod(renderMethod); | |
| 49 | 46 | emit settingsChanged(); |
| 50 | 47 | } |
| 51 | 48 | } |
| 49 | +void RenderScriptingInterface::forceRenderMethod(RenderMethod renderMethod) { | |
| 50 | + _renderSettingLock.withWriteLock([&] { | |
| 51 | + _renderMethod = (int)renderMethod; | |
| 52 | + _renderMethodSetting.set((int)renderMethod); | |
| 53 | + | |
| 54 | + auto config = dynamic_cast<task::SwitchConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch")); | |
| 55 | + if (config) { | |
| 56 | + _renderMethodSetting.set((int)renderMethod); | |
| 57 | + config->setBranch((int)renderMethod); | |
| 58 | + } | |
| 59 | + }); | |
| 60 | +} | |
| 52 | 61 | |
| 53 | 62 | QStringList RenderScriptingInterface::getRenderMethodNames() const { |
| 54 | 63 | static const QStringList refrenderMethodNames = { "DEFERRED", "FORWARD" }; |
| @@ -56,78 +65,83 @@ QStringList RenderScriptingInterface::getRenderMethodNames() const { · 1 unmodified line | ||
| 56 | 65 | } |
| 57 | 66 | |
| 58 | 67 | bool RenderScriptingInterface::getShadowsEnabled() { |
| 59 | − return _shadowsEnabledSetting.get(); | |
| 68 | + return _shadowsEnabled.load(); | |
| 60 | 69 | } |
| 61 | 70 | |
| 62 | 71 | void RenderScriptingInterface::setShadowsEnabled(bool enabled) { |
| 63 | − if (_shadowsEnabledSetting.get() == enabled) { | |
| 64 | − return; | |
| 65 | − } | |
| 66 | − | |
| 67 | − if (QThread::currentThread() != thread()) { | |
| 68 | − QMetaObject::invokeMethod(this, "setShadowsEnabled", Q_ARG(bool, enabled)); | |
| 69 | − return; | |
| 72 | + if (_shadowsEnabled != enabled) { | |
| 73 | + forceShadowsEnabled(enabled); | |
| 74 | + emit settingsChanged(); | |
| 70 | 75 | } |
| 76 | +} | |
| 71 | 77 | |
| 72 | − auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel"); | |
| 73 | − if (lightingModelConfig) { | |
| 74 | − Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled); | |
| 78 | +void RenderScriptingInterface::forceShadowsEnabled(bool enabled) { | |
| 79 | + _renderSettingLock.withWriteLock([&] { | |
| 80 | + _shadowsEnabled.store(enabled); | |
| 75 | 81 | _shadowsEnabledSetting.set(enabled); |
| 76 | − lightingModelConfig->setShadow(enabled); | |
| 77 | − emit settingsChanged(); | |
| 78 | − } | |
| 82 | + | |
| 83 | + auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel"); | |
| 84 | + if (lightingModelConfig) { | |
| 85 | + Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled); | |
| 86 | + lightingModelConfig->setShadow(enabled); | |
| 87 | + } | |
| 88 | + }); | |
| 79 | 89 | } |
| 80 | 90 | |
| 81 | 91 | bool RenderScriptingInterface::getAmbientOcclusionEnabled() { |
| 82 | − return _ambientOcclusionEnabledSetting.get(); | |
| 92 | + return _ambientOcclusionEnabled.load(); | |
| 83 | 93 | } |
| 84 | 94 | |
| 85 | 95 | void RenderScriptingInterface::setAmbientOcclusionEnabled(bool enabled) { |
| 86 | − if (_ambientOcclusionEnabledSetting.get() == enabled) { | |
| 87 | − return; | |
| 88 | − } | |
| 89 | − | |
| 90 | − if (QThread::currentThread() != thread()) { | |
| 91 | − QMetaObject::invokeMethod(this, "setAmbientOcclusionEnabled", Q_ARG(bool, enabled)); | |
| 92 | − return; | |
| 96 | + if (_ambientOcclusionEnabled.load() != enabled) { | |
| 97 | + forceAmbientOcclusionEnabled(enabled); | |
| 98 | + emit settingsChanged(); | |
| 93 | 99 | } |
| 100 | +} | |
| 94 | 101 | |
| 95 | − auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel"); | |
| 96 | − if (lightingModelConfig) { | |
| 97 | − Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled); | |
| 102 | +void RenderScriptingInterface::forceAmbientOcclusionEnabled(bool enabled) { | |
| 103 | + _renderSettingLock.withWriteLock([&] { | |
| 104 | + _ambientOcclusionEnabled.store(enabled); | |
| 98 | 105 | _ambientOcclusionEnabledSetting.set(enabled); |
| 99 | − lightingModelConfig->setAmbientOcclusion(enabled); | |
| 100 | − emit settingsChanged(); | |
| 101 | − } | |
| 106 | + | |
| 107 | + auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel"); | |
| 108 | + if (lightingModelConfig) { | |
| 109 | + Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled); | |
| 110 | + lightingModelConfig->setAmbientOcclusion(enabled); | |
| 111 | + } | |
| 112 | + }); | |
| 102 | 113 | } |
| 103 | 114 | |
| 104 | 115 | bool RenderScriptingInterface::getAntialiasingEnabled() { |
| 105 | − return _antialiasingEnabledSetting.get(); | |
| 116 | + return _antialiasingEnabled.load(); | |
| 106 | 117 | } |
| 107 | 118 | |
| 108 | 119 | void RenderScriptingInterface::setAntialiasingEnabled(bool enabled) { |
| 109 | − if (_antialiasingEnabledSetting.get() == enabled) { | |
| 110 | − return; | |
| 111 | − } | |
| 112 | − | |
| 113 | − if (QThread::currentThread() != thread()) { | |
| 114 | − QMetaObject::invokeMethod(this, "setAntialiasingEnabled", Q_ARG(bool, enabled)); | |
| 115 | − return; | |
| 120 | + if (_antialiasingEnabled.load() != enabled) { | |
| 121 | + forceAntialiasingEnabled(enabled); | |
| 122 | + emit settingsChanged(); | |
| 116 | 123 | } |
| 124 | +} | |
| 117 | 125 | |
| 118 | − auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderMainView.JitterCam"); | |
| 119 | − auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("RenderMainView.Antialiasing"); | |
| 120 | − if (mainViewJitterCamConfig && mainViewAntialiasingConfig) { | |
| 121 | − Menu::getInstance()->setIsOptionChecked(MenuOption::AntiAliasing, enabled); | |
| 126 | +void RenderScriptingInterface::forceAntialiasingEnabled(bool enabled) { | |
| 127 | + _renderSettingLock.withWriteLock([&] { | |
| 128 | + _antialiasingEnabled.store(enabled); | |
| 122 | 129 | _antialiasingEnabledSetting.set(enabled); |
| 123 | − if (enabled) { | |
| 124 | − mainViewJitterCamConfig->play(); | |
| 125 | − mainViewAntialiasingConfig->setDebugFXAA(false); | |
| 126 | − } else { | |
| 127 | − mainViewJitterCamConfig->none(); | |
| 128 | − mainViewAntialiasingConfig->setDebugFXAA(true); | |
| 129 | − } | |
| 130 | 130 | |
| 131 | − emit settingsChanged(); | |
| 132 | − } | |
| 131 | + auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderMainView.JitterCam"); | |
| 132 | + auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("RenderMainView.Antialiasing"); | |
| 133 | + if (mainViewJitterCamConfig && mainViewAntialiasingConfig) { | |
| 134 | + Menu::getInstance()->setIsOptionChecked(MenuOption::AntiAliasing, enabled); | |
| 135 | + if (enabled) { | |
| 136 | + mainViewJitterCamConfig->play(); | |
| 137 | + mainViewAntialiasingConfig->setDebugFXAA(false); | |
| 138 | + } | |
| 139 | + else { | |
| 140 | + mainViewJitterCamConfig->none(); | |
| 141 | + mainViewAntialiasingConfig->setDebugFXAA(true); | |
| 142 | + } | |
| 143 | + } | |
| 144 | + }); | |
| 133 | 145 | } |
| 146 | + | |
| 147 | + | |