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#include "qssgrenderableobjects_p.h"
6
7#include <QtQuick3DRuntimeRender/private/qssgrenderer_p.h>
8#include <QtQuick3DRuntimeRender/private/qssgrhicustommaterialsystem_p.h>
9#include <QtQuick3DRuntimeRender/private/qssgrenderlight_p.h>
10#include <QtQuick3DRuntimeRender/private/qssgrenderdefaultmaterialshadergenerator_p.h>
11
12QT_BEGIN_NAMESPACE
13struct QSSGRenderableImage;
14struct QSSGSubsetRenderable;
15
16QSSGSubsetRenderable::QSSGSubsetRenderable(Type type,
17 QSSGRenderableObjectFlags inFlags,
18 const QVector3D &inWorldCenterPt,
19 QSSGRenderer *rendr,
20 const QSSGRenderSubset &inSubset,
21 const QSSGModelContext &inModelContext,
22 float inOpacity,
23 quint32 inSubsetLevelOfDetail,
24 const QSSGRenderGraphObject &mat,
25 QSSGRenderableImage *inFirstImage,
26 QSSGShaderDefaultMaterialKey inShaderKey,
27 const QSSGShaderLightListView &inLights)
28 : QSSGRenderableObject(type,
29 inFlags,
30 inWorldCenterPt,
31 inModelContext.model.globalTransform,
32 inSubset.bounds,
33 inModelContext.model.m_depthBiasSq,
34 inModelContext.model.instancingLodMin,
35 inModelContext.model.instancingLodMax)
36 , subsetLevelOfDetail(inSubsetLevelOfDetail)
37 , renderer(rendr)
38 , modelContext(inModelContext)
39 , subset(inSubset)
40 , opacity(inOpacity)
41 , material(mat)
42 , firstImage(inFirstImage)
43 , shaderDescription(inShaderKey)
44 , lights(inLights)
45{
46 if (mat.type == QSSGRenderGraphObject::Type::CustomMaterial)
47 depthWriteMode = static_cast<const QSSGRenderCustomMaterial *>(&mat)->m_depthDrawMode;
48 else
49 depthWriteMode = static_cast<const QSSGRenderDefaultMaterial *>(&mat)->depthDrawMode;
50
51 const bool modelBlendParticle = (inModelContext.model.particleBuffer != nullptr
52 && inModelContext.model.particleBuffer->particleCount());
53 if (modelBlendParticle)
54 globalBounds = inModelContext.model.particleBuffer->bounds();
55 else
56 globalBounds.transform(inMatrix: globalTransform);
57}
58
59QSSGParticlesRenderable::QSSGParticlesRenderable(QSSGRenderableObjectFlags inFlags,
60 const QVector3D &inWorldCenterPt,
61 QSSGRenderer *rendr,
62 const QSSGRenderParticles &inParticles,
63 QSSGRenderableImage *inFirstImage,
64 QSSGRenderableImage *inColorTable,
65 const QSSGShaderLightListView &inLights,
66 float inOpacity)
67 : QSSGRenderableObject(Type::Particles,
68 inFlags,
69 inWorldCenterPt,
70 inParticles.globalTransform,
71 inParticles.m_particleBuffer.bounds(),
72 inParticles.m_depthBiasSq)
73 , renderer(rendr)
74 , particles(inParticles)
75 , firstImage(inFirstImage)
76 , colorTable(inColorTable)
77 , lights(inLights)
78 , opacity(inOpacity)
79{
80 // Bounds are in global space for _model blend_ particles
81 globalBounds = inParticles.m_particleBuffer.bounds();
82 if (inParticles.type != QSSGRenderParticles::Type::ModelBlendParticle)
83 globalBounds.transform(inMatrix: globalTransform);
84}
85
86QT_END_NAMESPACE
87

source code of qtquick3d/src/runtimerender/rendererimpl/qssgrenderableobjects.cpp