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 | std::call_once(registry_flag, [] { | 21 | std::call_once(registry_flag, [] { |
| 22 | qmlRegisterType<RenderScriptingInterface>("RenderEnums", 1, 0, "RenderEnums"); | 22 | qmlRegisterType<RenderScriptingInterface>("RenderEnums", 1, 0, "RenderEnums"); |
| 23 | }); | 23 | }); |
| 24 | } | ||
| 24 | 25 | ||
| 25 | setRenderMethod((RenderMethod)_renderMethodSettingLock.resultWithReadLock<int>([&] { | 26 | void RenderScriptingInterface::loadSettings() { |
| 26 | return _renderMethodSetting.get(); | 27 | _renderSettingLock.withReadLock([&] { |
| 27 | })); | 28 | _renderMethod.store(_renderMethodSetting.get()); |
| 28 | setShadowsEnabled(_shadowsEnabledSetting.get()); | 29 | _shadowsEnabled.store(_shadowsEnabledSetting.get()); |
| 29 | setAmbientOcclusionEnabled(_ambientOcclusionEnabledSetting.get()); | 30 | _ambientOcclusionEnabled.store(_ambientOcclusionEnabledSetting.get()); |
| 30 | setAntialiasingEnabled(_antialiasingEnabledSetting.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 | RenderScriptingInterface::RenderMethod RenderScriptingInterface::getRenderMethod() { | 39 | RenderScriptingInterface::RenderMethod RenderScriptingInterface::getRenderMethod() { |
| 34 | return (RenderMethod) _renderMethod; | 40 | return (RenderMethod) _renderMethod.load(); |
| 35 | } | 41 | } |
| 36 | 42 | ||
| 37 | void RenderScriptingInterface::setRenderMethod(RenderMethod renderMethod) { | 43 | void RenderScriptingInterface::setRenderMethod(RenderMethod renderMethod) { |
| 38 | if (_renderMethod != (int) renderMethod) { | 44 | if (_renderMethod != (int) renderMethod) { |
| 39 | _renderMethodSettingLock.withWriteLock([&] { | 45 | forceRenderMethod(renderMethod); |
| 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 | }); | ||
| 49 | emit settingsChanged(); | 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 | QStringList RenderScriptingInterface::getRenderMethodNames() const { | 62 | QStringList RenderScriptingInterface::getRenderMethodNames() const { |
| 54 | static const QStringList refrenderMethodNames = { "DEFERRED", "FORWARD" }; | 63 | static const QStringList refrenderMethodNames = { "DEFERRED", "FORWARD" }; |
| @@ -56,78 +65,83 @@ QStringList RenderScriptingInterface::getRenderMethodNames() const { · 1 unmodified line | |||
| 56 | } | 65 | } |
| 57 | 66 | ||
| 58 | bool RenderScriptingInterface::getShadowsEnabled() { | 67 | bool RenderScriptingInterface::getShadowsEnabled() { |
| 59 | return _shadowsEnabledSetting.get(); | 68 | return _shadowsEnabled.load(); |
| 60 | } | 69 | } |
| 61 | 70 | ||
| 62 | void RenderScriptingInterface::setShadowsEnabled(bool enabled) { | 71 | void RenderScriptingInterface::setShadowsEnabled(bool enabled) { |
| 63 | if (_shadowsEnabledSetting.get() == enabled) { | 72 | if (_shadowsEnabled != enabled) { |
| 64 | return; | 73 | forceShadowsEnabled(enabled); |
| 65 | } | 74 | emit settingsChanged(); |
| 66 | |||
| 67 | if (QThread::currentThread() != thread()) { | ||
| 68 | QMetaObject::invokeMethod(this, "setShadowsEnabled", Q_ARG(bool, enabled)); | ||
| 69 | return; | ||
| 70 | } | 75 | } |
| 76 | } | ||
| 71 | 77 | ||
| 72 | auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel"); | 78 | void RenderScriptingInterface::forceShadowsEnabled(bool enabled) { |
| 73 | if (lightingModelConfig) { | 79 | _renderSettingLock.withWriteLock([&] { |
| 74 | Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled); | 80 | _shadowsEnabled.store(enabled); |
| 75 | _shadowsEnabledSetting.set(enabled); | 81 | _shadowsEnabledSetting.set(enabled); |
| 76 | lightingModelConfig->setShadow(enabled); | 82 | |
| 77 | emit settingsChanged(); | 83 | auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel"); |
| 78 | } | 84 | if (lightingModelConfig) { |
| 85 | Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled); | ||
| 86 | lightingModelConfig->setShadow(enabled); | ||
| 87 | } | ||
| 88 | }); | ||
| 79 | } | 89 | } |
| 80 | 90 | ||
| 81 | bool RenderScriptingInterface::getAmbientOcclusionEnabled() { | 91 | bool RenderScriptingInterface::getAmbientOcclusionEnabled() { |
| 82 | return _ambientOcclusionEnabledSetting.get(); | 92 | return _ambientOcclusionEnabled.load(); |
| 83 | } | 93 | } |
| 84 | 94 | ||
| 85 | void RenderScriptingInterface::setAmbientOcclusionEnabled(bool enabled) { | 95 | void RenderScriptingInterface::setAmbientOcclusionEnabled(bool enabled) { |
| 86 | if (_ambientOcclusionEnabledSetting.get() == enabled) { | 96 | if (_ambientOcclusionEnabled.load() != enabled) { |
| 87 | return; | 97 | forceAmbientOcclusionEnabled(enabled); |
| 88 | } | 98 | emit settingsChanged(); |
| 89 | |||
| 90 | if (QThread::currentThread() != thread()) { | ||
| 91 | QMetaObject::invokeMethod(this, "setAmbientOcclusionEnabled", Q_ARG(bool, enabled)); | ||
| 92 | return; | ||
| 93 | } | 99 | } |
| 100 | } | ||
| 94 | 101 | ||
| 95 | auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel"); | 102 | void RenderScriptingInterface::forceAmbientOcclusionEnabled(bool enabled) { |
| 96 | if (lightingModelConfig) { | 103 | _renderSettingLock.withWriteLock([&] { |
| 97 | Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled); | 104 | _ambientOcclusionEnabled.store(enabled); |
| 98 | _ambientOcclusionEnabledSetting.set(enabled); | 105 | _ambientOcclusionEnabledSetting.set(enabled); |
| 99 | lightingModelConfig->setAmbientOcclusion(enabled); | 106 | |
| 100 | emit settingsChanged(); | 107 | auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel"); |
| 101 | } | 108 | if (lightingModelConfig) { |
| 109 | Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled); | ||
| 110 | lightingModelConfig->setAmbientOcclusion(enabled); | ||
| 111 | } | ||
| 112 | }); | ||
| 102 | } | 113 | } |
| 103 | 114 | ||
| 104 | bool RenderScriptingInterface::getAntialiasingEnabled() { | 115 | bool RenderScriptingInterface::getAntialiasingEnabled() { |
| 105 | return _antialiasingEnabledSetting.get(); | 116 | return _antialiasingEnabled.load(); |
| 106 | } | 117 | } |
| 107 | 118 | ||
| 108 | void RenderScriptingInterface::setAntialiasingEnabled(bool enabled) { | 119 | void RenderScriptingInterface::setAntialiasingEnabled(bool enabled) { |
| 109 | if (_antialiasingEnabledSetting.get() == enabled) { | 120 | if (_antialiasingEnabled.load() != enabled) { |
| 110 | return; | 121 | forceAntialiasingEnabled(enabled); |
| 111 | } | 122 | emit settingsChanged(); |
| 112 | |||
| 113 | if (QThread::currentThread() != thread()) { | ||
| 114 | QMetaObject::invokeMethod(this, "setAntialiasingEnabled", Q_ARG(bool, enabled)); | ||
| 115 | return; | ||
| 116 | } | 123 | } |
| 124 | } | ||
| 117 | 125 | ||
| 118 | auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderMainView.JitterCam"); | 126 | void RenderScriptingInterface::forceAntialiasingEnabled(bool enabled) { |
| 119 | auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("RenderMainView.Antialiasing"); | 127 | _renderSettingLock.withWriteLock([&] { |
| 120 | if (mainViewJitterCamConfig && mainViewAntialiasingConfig) { | 128 | _antialiasingEnabled.store(enabled); |
| 121 | Menu::getInstance()->setIsOptionChecked(MenuOption::AntiAliasing, enabled); | ||
| 122 | _antialiasingEnabledSetting.set(enabled); | 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(); | 131 | auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderMainView.JitterCam"); |
| 132 | } | 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 | |||