History

add more options to render scripting interface

SamGondelman committed 7 years ago

Commit 2e666831 parent 8b7a30f4 files · +144 −54Browse files

Showing the changes to interface/src/scripting/RenderScriptingInterface.cpp (1 of 4 files). Show all

Unified · Split

interface/src/scripting/RenderScriptingInterface.cpp+86−8
@@ -7,6 +7,9 @@ · 6 unmodified lines
77 //
88 #include "RenderScriptingInterface.h"
99
10+#include "LightingModel.h"
11+#include "AntialiasingEffect.h"
12+
1013 const QString DEFERRED = "deferred";
1114 const QString FORWARD = "forward";
1215
@@ -17,6 +20,9 @@ RenderScriptingInterface* RenderScriptingInterface::getInstance() { · 4 unmodified lines
1720
1821 RenderScriptingInterface::RenderScriptingInterface() {
1922 setRenderMethod((render::Args::RenderMethod)_renderMethodSetting.get() == render::Args::RenderMethod::DEFERRED ? DEFERRED : FORWARD);
23+ setShadowsEnabled(_shadowsEnabledSetting.get());
24+ setAmbientOcclusionEnabled(_ambientOcclusionEnabledSetting.get());
25+ setAntialiasingEnabled(_antialiasingEnabledSetting.get());
2026 }
2127
2228 QString RenderScriptingInterface::getRenderMethod() {
@@ -24,6 +30,11 @@ QString RenderScriptingInterface::getRenderMethod() { · 1 unmodified line
2430 }
2531
2632 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+
2738 if (QThread::currentThread() != thread()) {
2839 QMetaObject::invokeMethod(this, "setRenderMethod", Q_ARG(const QString&, renderMethod));
2940 return;
@@ -31,14 +42,81 @@ void RenderScriptingInterface::setRenderMethod(const QString& renderMethod) { · 1 unmodified line
3142
3243 auto config = dynamic_cast<task::SwitchConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch"));
3344 if (config) {
34− if (renderMethod == DEFERRED) {
35− _renderMethodSetting.set(render::Args::RenderMethod::DEFERRED);
36− config->setBranch(render::Args::RenderMethod::DEFERRED);
37− emit config->dirtyEnabled();
38− } else if (renderMethod == FORWARD) {
39− _renderMethodSetting.set(render::Args::RenderMethod::FORWARD);
40− config->setBranch(render::Args::RenderMethod::FORWARD);
41− emit config->dirtyEnabled();
45+ _renderMethodSetting.set(newMethod);
46+ config->setBranch(newMethod);
47+ emit config->dirtyEnabled();
48+ }
49+}
50+
51+bool RenderScriptingInterface::getShadowsEnabled() {
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);
42120 }
43121 }
44122 }