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 <QtQuick3DRuntimeRender/private/qssglayerrenderdata_p.h>
9
10QT_BEGIN_NAMESPACE
11
12QSSGRenderLayer::QSSGRenderLayer()
13 : QSSGRenderNode(QSSGRenderNode::Type::Layer)
14 , firstEffect(nullptr)
15 , antialiasingMode(QSSGRenderLayer::AAMode::NoAA)
16 , antialiasingQuality(QSSGRenderLayer::AAQuality::High)
17 , background(QSSGRenderLayer::Background::Transparent)
18 , temporalAAStrength(0.3f)
19 , ssaaMultiplier(1.5f)
20 , specularAAEnabled(false)
21 , tonemapMode(TonemapMode::Linear)
22{
23 flags = { FlagT(LocalState::Active) | FlagT(GlobalState::Active) }; // The layer node is alway active and not dirty.
24}
25
26QSSGRenderLayer::~QSSGRenderLayer()
27{
28 delete importSceneNode;
29 importSceneNode = nullptr;
30 delete renderData;
31}
32
33void QSSGRenderLayer::setProbeOrientation(const QVector3D &angles)
34{
35 if (angles != lightProbeSettings.probeOrientationAngles) {
36 lightProbeSettings.probeOrientationAngles = angles;
37 lightProbeSettings.probeOrientation = QQuaternion::fromEulerAngles(eulerAngles: lightProbeSettings.probeOrientationAngles).toRotationMatrix();
38 }
39}
40
41void QSSGRenderLayer::addEffect(QSSGRenderEffect &inEffect)
42{
43 // Effects need to be rendered in reverse order as described in the file.
44 inEffect.m_nextEffect = firstEffect;
45 firstEffect = &inEffect;
46}
47
48bool QSSGRenderLayer::hasEffect(QSSGRenderEffect *inEffect) const
49{
50 for (auto currentEffect = firstEffect; currentEffect != nullptr; currentEffect = currentEffect->m_nextEffect) {
51 if (currentEffect == inEffect)
52 return true;
53 }
54 return false;
55}
56
57void QSSGRenderLayer::setImportScene(QSSGRenderNode &rootNode)
58{
59 // We create a dummy node to represent the imported scene tree, as we
60 // do absolutely not want to change the node links in that tree!
61 if (importSceneNode == nullptr) {
62 importSceneNode = new QSSGRenderNode(QSSGRenderGraphObject::Type::ImportScene);
63 // Now we can add the dummy node to the layers child list
64 children.push_back(inObj&: *importSceneNode);
65 } else {
66 importSceneNode->children.clear(); // Clear the list (or the list will modify the rootNode)
67 }
68
69 // The imported scene root node is now a child of the dummy node
70 auto &importChildren = importSceneNode->children;
71 Q_ASSERT(importChildren.isEmpty());
72 // We don't want the list to modify our node, so we set the tail and head manually.
73 importChildren.m_head = importChildren.m_tail = &rootNode;
74}
75
76void QSSGRenderLayer::removeImportScene(QSSGRenderNode &rootNode)
77{
78 if (importSceneNode && !importSceneNode->children.isEmpty()) {
79 if (&importSceneNode->children.back() == &rootNode)
80 importSceneNode->children.clear();
81 }
82}
83
84QT_END_NAMESPACE
85

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtquick3d/src/runtimerender/graphobjects/qssgrenderlayer.cpp