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
qssgrenderableobjects.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// Qt-Security score:significant reason:default
5
6
9
10#include <QtQuick3DRuntimeRender/private/qssgrenderer_p.h>
11#include <QtQuick3DRuntimeRender/private/qssgrhicustommaterialsystem_p.h>
12#include <QtQuick3DRuntimeRender/private/qssgrenderlight_p.h>
13#include <QtQuick3DRuntimeRender/private/qssgrenderdefaultmaterialshadergenerator_p.h>
14
16struct QSSGRenderableImage;
17class QSSGSubsetRenderable;
18
19QSSGModelContext::QSSGModelContext(const QSSGRenderModel &inModel,
20 const QMatrix4x4 &inGlobalTransform,
21 const QMatrix3x3 &inNormalMatrix,
22 const QSSGRenderMvpArray &inModelViewProjections)
23 : model(inModel)
24 , globalTransform(inGlobalTransform)
25 , normalMatrix(inNormalMatrix)
26 , modelViewProjections(inModelViewProjections)
27{
28
29}
30
31QSSGSubsetRenderable::QSSGSubsetRenderable(Type type,
32 QSSGRenderableObjectFlags inFlags,
33 const QVector3D &inWorldCenterPt,
34 QSSGRenderer *rendr,
35 const QSSGRenderSubset &inSubset,
36 const QSSGModelContext &inModelContext,
37 float inOpacity,
38 quint32 inSubsetLevelOfDetail,
39 const QSSGRenderGraphObject &mat,
40 QSSGRenderableImage *inFirstImage,
41 QSSGShaderDefaultMaterialKey inShaderKey,
42 const QSSGShaderLightListView &inLights,
43 bool anyLightHasShadows)
44 : QSSGRenderableObject(type,
45 inFlags,
46 inWorldCenterPt,
47 inSubset.bounds,
48 inModelContext.model.m_depthBiasSq,
49 inModelContext.model.instancingLodMin,
50 inModelContext.model.instancingLodMax)
51 , subsetLevelOfDetail(inSubsetLevelOfDetail)
52 , renderer(rendr)
53 , modelContext(inModelContext)
54 , subset(inSubset)
55 , opacity(inOpacity)
56 , material(mat)
57 , firstImage(inFirstImage)
58 , shaderDescription(inShaderKey)
59 , lights(inLights)
60{
61 if (mat.type == QSSGRenderGraphObject::Type::CustomMaterial)
62 depthWriteMode = static_cast<const QSSGRenderCustomMaterial *>(&mat)->m_depthDrawMode;
63 else
64 depthWriteMode = static_cast<const QSSGRenderDefaultMaterial *>(&mat)->depthDrawMode;
65
66 const bool modelBlendParticle = (inModelContext.model.particleBuffer != nullptr
67 && inModelContext.model.particleBuffer->particleCount());
68 if (modelBlendParticle)
69 globalBounds = inModelContext.model.particleBuffer->bounds();
70 else
71 globalBounds.transform(inModelContext.globalTransform);
72
73 // Do we need instanced bounds
74 const QSSGRenderInstanceTable *instanceTable = inModelContext.model.instanceTable;
75 isInstanced = instanceTable != nullptr;
76 if (!instanceTable || !anyLightHasShadows || !(inFlags.castsShadows() || inFlags.receivesShadows()))
77 return;
78
79 // Check for specified instancing shadow bounds
80 QSSGBounds3 bounds = QSSGBounds3(instanceTable->getShadowBoundsMinimum(), instanceTable->getShadowBoundsMaximum());
81 if (!bounds.isEmpty() && bounds.isFinite()) {
82 globalBoundsInstancing = bounds;
83 return;
84 }
85
86 // Calculate instancing shadow bounds
87 const auto points = globalBounds.toQSSGBoxPointsNoEmptyCheck();
88 for (int i = 0; i < instanceTable->count(); ++i) {
89 const QMatrix4x4 transform = instanceTable->getTransform(i);
90 for (const QVector3D &point : points) {
91 globalBoundsInstancing.include(transform.map(point));
92 }
93 }
94}
95
96QSSGParticlesRenderable::QSSGParticlesRenderable(QSSGRenderableObjectFlags inFlags,
97 const QVector3D &inWorldCenterPt,
98 QSSGRenderer *rendr,
99 const QMatrix4x4 &inGlobalTransform,
100 const QSSGRenderParticles &inParticles,
101 QSSGRenderableImage *inFirstImage,
102 QSSGRenderableImage *inColorTable,
103 const QSSGShaderLightListView &inLights,
104 float inOpacity,
105 QSSGShaderParticleMaterialKey inShaderKey)
106 : QSSGRenderableObject(Type::Particles,
107 inFlags,
108 inWorldCenterPt,
109 inParticles.m_particleBuffer.bounds(),
110 inParticles.m_depthBiasSq)
111 , renderer(rendr)
112 , particles(inParticles)
113 , firstImage(inFirstImage)
114 , colorTable(inColorTable)
115 , lights(inLights)
116 , globalTransform(inGlobalTransform)
117 , opacity(inOpacity)
118 , shaderDescription(inShaderKey)
119{
120 // Bounds are in global space for _model blend_ particles
121 globalBounds = inParticles.m_particleBuffer.bounds();
122 if (inParticles.type != QSSGRenderParticles::Type::ModelBlendParticle)
123 globalBounds.transform(inGlobalTransform);
124}
125
126QT_END_NAMESPACE
Combined button and popup list for selecting options.