summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Render/Q3DSTranslation.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2019-02-20 14:19:47 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2019-02-21 09:02:27 +0000
commite0fab988306bd1848d3b76e0877ce04837e8c45e (patch)
tree9bff4c2a608784bd5decbe3a31e829ef97ec8c9e /src/Authoring/Studio/Render/Q3DSTranslation.cpp
parenta10d1cf421c1a6151bc9575ab2aedc2eb530606b (diff)
Implement scene light disabling in edit views
When scene lights are disabled, there is a point light at camera position when in edit views. Task-number: QT3DS-3066 Change-Id: Ic2b8312bf81c34894f7e32da1d6f920f6657cf72 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Jere Tuliniemi <jere.tuliniemi@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Render/Q3DSTranslation.cpp')
-rw-r--r--src/Authoring/Studio/Render/Q3DSTranslation.cpp67
1 files changed, 61 insertions, 6 deletions
diff --git a/src/Authoring/Studio/Render/Q3DSTranslation.cpp b/src/Authoring/Studio/Render/Q3DSTranslation.cpp
index 457c2919..e0f3ac44 100644
--- a/src/Authoring/Studio/Render/Q3DSTranslation.cpp
+++ b/src/Authoring/Studio/Render/Q3DSTranslation.cpp
@@ -42,6 +42,7 @@
#include "IDocumentReader.h"
#include "StudioProjectSettings.h"
#include "SlideSystem.h"
+#include "StudioPreferences.h"
#include <QtCore/qmath.h>
#include <Qt3DRender/qcamera.h>
@@ -1167,9 +1168,20 @@ void Q3DSTranslation::prepareRender(const QRect &rect, const QSize &size, qreal
m_presentationInit = true;
}
if (m_editCameraEnabled) {
- const auto values = m_editCameras.values();
- for (auto camera : values)
+ const auto cameras = m_editCameras.values();
+ for (auto camera : cameras)
m_editCameraInfo.applyToCamera(*camera, QSizeF(m_size));
+ const bool editLightEnabled = CStudioPreferences::editModeLightingEnabled();
+ if (m_editLightEnabled != editLightEnabled) {
+ m_editLightEnabled = editLightEnabled;
+ enableSceneLights(!m_editLightEnabled);
+ const auto lights = m_editLights.values();
+ for (auto light : lights) {
+ Q3DSPropertyChangeList list;
+ list.append(light->setEyeballEnabled(m_editLightEnabled));
+ light->notifyPropertyChanges(list);
+ }
+ }
}
if (rect != m_rect || size != m_size || pixelRatio != m_pixelRatio) {
// We are always rendering into a fbo with 1x pixel ratio. The scene widget will
@@ -1178,15 +1190,17 @@ void Q3DSTranslation::prepareRender(const QRect &rect, const QSize &size, qreal
m_rect = rect;
m_size = size;
m_pixelRatio = pixelRatio;
- m_manipulationWidget.setDefaultScale(QVector3D(m_pixelRatio, m_pixelRatio, m_pixelRatio));
+ m_manipulationWidget.setDefaultScale(
+ QVector3D(float(m_pixelRatio), float(m_pixelRatio), float(m_pixelRatio)));
}
}
void Q3DSTranslation::enableEditCamera(const SEditCameraPersistentInformation &info)
{
m_editCameraInfo = info;
- // loop through layers and create edit camera for each
+ // loop through layers and create edit camera and light for each
Q3DSGraphObject *object = m_scene->firstChild();
+ m_editLightEnabled = CStudioPreferences::editModeLightingEnabled();
while (object) {
if (object->type() != Q3DSGraphObject::Layer) {
object = object->nextSibling();
@@ -1217,21 +1231,56 @@ void Q3DSTranslation::enableEditCamera(const SEditCameraPersistentInformation &i
list.append(editCamera->setName(info.m_name));
editCamera->notifyPropertyChanges(list);
+ if (layer != m_backgroundLayer && layer != m_foregroundLayer
+ && layer != m_foregroundPickingLayer) {
+ QByteArray editLightId = QByteArrayLiteral("StudioEditLight_");
+ editLightId.append(layer->id());
+ Q3DSLightNode *editLight = nullptr;
+ if (!m_editLights.contains(editLightId)) {
+ editLight = m_presentation->newObject<Q3DSLightNode>(editLightId);
+ editCamera->appendChildNode(editLight);
+ m_presentation->masterSlide()->addObject(editLight);
+ m_editLights.insert(editLightId, editLight);
+ } else {
+ editLight = m_editLights[editLightId];
+ if (editCamera != editLight->parent()) {
+ editLight->parent()->removeChildNode(editLight);
+ editCamera->appendChildNode(editLight);
+ }
+ }
+ list.clear();
+ list.append(editLight->setEyeballEnabled(m_editLightEnabled));
+ list.append(editLight->setCastShadow(false));
+ list.append(editLight->setName(editLightId));
+ list.append(editLight->setLightType(Q3DSLightNode::Point));
+ editLight->notifyPropertyChanges(list);
+ }
+
object = object->nextSibling();
}
enableSceneCameras(false);
+ enableSceneLights(!m_editLightEnabled);
m_editCameraEnabled = true;
updateForegroundLayerProperties();
}
void Q3DSTranslation::disableEditCamera()
{
- const auto values = m_editCameras.values();
- for (auto camera : values) {
+ const auto lights = m_editLights.values();
+ for (auto light : lights) {
+ Q3DSPropertyChangeList list;
+ list.append(light->setEyeballEnabled(false));
+ light->notifyPropertyChanges(list);
+ }
+
+ const auto cameras = m_editCameras.values();
+ for (auto camera : cameras) {
Q3DSPropertyChangeList list;
list.append(camera->setEyeballEnabled(false));
camera->notifyPropertyChanges(list);
}
+
+ enableSceneLights(true);
enableSceneCameras(true);
m_editCameraEnabled = false;
m_oldCameraType = EditCameraTypes::SceneCamera;
@@ -1249,6 +1298,12 @@ void Q3DSTranslation::enableSceneCameras(bool enable)
translator->setEditCameraEnabled(!enable);
}
+void Q3DSTranslation::enableSceneLights(bool enable)
+{
+ for (auto translator : qAsConst(m_lightTranslators))
+ translator->setEditLightEnabled(!enable);
+}
+
void Q3DSTranslation::wheelZoom(qreal factor)
{
// Too large and too small zooms cause artifacts, so use large but sensible bounds