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 if (!instanceTable || !anyLightHasShadows || !(inFlags.castsShadows() || inFlags.receivesShadows()))
76 return;
77
78 // Check for specified instancing shadow bounds
79 QSSGBounds3 bounds = QSSGBounds3(instanceTable->getShadowBoundsMinimum(), instanceTable->getShadowBoundsMaximum());
80 if (!bounds.isEmpty() && bounds.isFinite()) {
81 globalBoundsInstancing = bounds;
82 return;
83 }
84
85 // Calculate instancing shadow bounds
86 const auto points = globalBounds.toQSSGBoxPointsNoEmptyCheck();
87 for (int i = 0; i < instanceTable->count(); ++i) {
88 const QMatrix4x4 transform = instanceTable->getTransform(i);
89 for (const QVector3D &point : points) {
90 globalBoundsInstancing.include(transform.map(point));
91 }
92 }
93}
94
95QSSGParticlesRenderable::QSSGParticlesRenderable(QSSGRenderableObjectFlags inFlags,
96 const QVector3D &inWorldCenterPt,
97 QSSGRenderer *rendr,
98 const QMatrix4x4 &inGlobalTransform,
99 const QSSGRenderParticles &inParticles,
100 QSSGRenderableImage *inFirstImage,
101 QSSGRenderableImage *inColorTable,
102 const QSSGShaderLightListView &inLights,
103 float inOpacity,
104 QSSGShaderParticleMaterialKey inShaderKey)
105 : QSSGRenderableObject(Type::Particles,
106 inFlags,
107 inWorldCenterPt,
108 inParticles.m_particleBuffer.bounds(),
109 inParticles.m_depthBiasSq)
110 , renderer(rendr)
111 , particles(inParticles)
112 , firstImage(inFirstImage)
113 , colorTable(inColorTable)
114 , lights(inLights)
115 , globalTransform(inGlobalTransform)
116 , opacity(inOpacity)
117 , shaderDescription(inShaderKey)
118{
119 // Bounds are in global space for _model blend_ particles
120 globalBounds = inParticles.m_particleBuffer.bounds();
121 if (inParticles.type != QSSGRenderParticles::Type::ModelBlendParticle)
122 globalBounds.transform(inGlobalTransform);
123}
124
125QT_END_NAMESPACE
Combined button and popup list for selecting options.