Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qssgrenderlayer.cpp
Go to the documentation of this file.
1// Copyright (C) 2008-2012 NVIDIA Corporation.
2// Copyright (C) 2019 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4
5
6#include <QtQuick3DRuntimeRender/private/qssgrenderlayer_p.h>
7#include <QtQuick3DRuntimeRender/private/qssgrendereffect_p.h>
8#include "../rendererimpl/qssglayerrenderdata_p.h"
10
11#include <QtGui/qquaternion.h>
12
14
15void QSSGRenderLayer::markDirty(DirtyFlag dirtyFlag)
16{
17 m_layerDirtyFlags |= FlagT(dirtyFlag);
18 QSSGRenderNode::markDirty(QSSGRenderNode::DirtyFlag::SubNodeDirty);
19}
20
21void QSSGRenderLayer::clearDirty(DirtyFlag dirtyFlag)
22{
23 m_layerDirtyFlags &= ~FlagT(dirtyFlag);
24 QSSGRenderNode::clearDirty(QSSGRenderNode::DirtyFlag::SubNodeDirty);
25}
26
27QSSGRenderLayer::QSSGRenderLayer()
28 : QSSGRenderNode(QSSGRenderNode::Type::Layer)
29 , firstEffect(nullptr)
30 , antialiasingMode(QSSGRenderLayer::AAMode::NoAA)
31 , antialiasingQuality(QSSGRenderLayer::AAQuality::High)
32 , background(QSSGRenderLayer::Background::Transparent)
33 , temporalAAStrength(0.3f)
34 , ssaaMultiplier(1.5f)
35 , specularAAEnabled(false)
36 , oitMethod(OITMethod::None)
37 , oitMethodDirty(false)
38 , tonemapMode(TonemapMode::Linear)
39{
40 flags = { FlagT(LocalState::Active) | FlagT(GlobalState::Active) }; // The layer node is alway active and not dirty.
41}
42
43QSSGRenderLayer::~QSSGRenderLayer()
44{
45 rootNode = nullptr;
46 rootNodeRef = nullptr;
47
48 delete importSceneNode;
49 importSceneNode = nullptr;
50
51 delete renderData;
52 renderData = nullptr;
53}
54
55void QSSGRenderLayer::setProbeOrientation(const QVector3D &angles)
56{
57 if (angles != lightProbeSettings.probeOrientationAngles) {
58 lightProbeSettings.probeOrientationAngles = angles;
59 lightProbeSettings.probeOrientation = QQuaternion::fromEulerAngles(lightProbeSettings.probeOrientationAngles).toRotationMatrix();
60 }
61}
62
63void QSSGRenderLayer::addEffect(QSSGRenderEffect &inEffect)
64{
65 // Effects need to be rendered in reverse order as described in the file.
66 inEffect.m_nextEffect = firstEffect;
67 firstEffect = &inEffect;
68}
69
70bool QSSGRenderLayer::hasEffect(QSSGRenderEffect *inEffect) const
71{
72 for (auto currentEffect = firstEffect; currentEffect != nullptr; currentEffect = currentEffect->m_nextEffect) {
73 if (currentEffect == inEffect)
74 return true;
75 }
76 return false;
77}
78
79void QSSGRenderLayer::setImportScene(QSSGRenderNode &rootNode)
80{
81 // We create a dummy node to represent the imported scene tree, as we
82 // do absolutely not want to change the node links in that tree!
83 if (importSceneNode == nullptr) {
84 importSceneNode = new QSSGRenderNode(QSSGRenderGraphObject::Type::ImportScene);
85 // Now we can add the dummy node to the layers child list
86 children.push_back(*importSceneNode);
87 } else {
88 importSceneNode->children.clear(); // Clear the list (or the list will modify the rootNode)
89 }
90
91 // The imported scene root node is now a child of the dummy node
92 auto &importChildren = importSceneNode->children;
93 Q_ASSERT(importChildren.isEmpty());
94 // We don't want the list to modify our node, so we set the tail and head manually.
95 importChildren.m_head = importChildren.m_tail = &rootNode;
96}
97
98void QSSGRenderLayer::removeImportScene(QSSGRenderNode &rootNode)
99{
100 if (importSceneNode && !importSceneNode->children.isEmpty()) {
101 if (&importSceneNode->children.back() == &rootNode)
102 importSceneNode->children.clear();
103 }
104}
105
106QT_END_NAMESPACE