Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qssgrenderparticles.cpp
Go to the documentation of this file.
1
// Copyright (C) 2021 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
6
#
include
<
QtQuick3DRuntimeRender
/
private
/
qssgrenderparticles_p
.
h
>
7
#
include
<
cmath
>
8
9
QT_BEGIN_NAMESPACE
10
11
static
int
divisibleBy
(
int
a,
int
b)
12
{
13
return
(a % b) ? a + b - (a % b) : a;
14
}
15
static
int
ceilDivide
(
int
a,
int
b)
16
{
17
int
x = a / b;
18
int
y = (a % b) ? 1 : 0;
19
return
x + y;
20
}
21
22
void
QSSGParticleBuffer::resize(
int
particleCount,
int
particleSize)
23
{
24
if
(particleCount == 0) {
25
m_particlesPerSlice = 0;
26
m_particleCount = 0;
27
m_sliceStride = 0;
28
m_size = QSize();
29
m_particleBuffer.resize(0);
30
return
;
31
}
32
int
vec4PerParticle = ceilDivide(particleSize, 16);
33
int
vec4s = particleCount * vec4PerParticle;
34
int
width = divisibleBy(std::sqrt(vec4s), vec4PerParticle);
35
int
height = ceilDivide(vec4s, width);
36
m_particlesPerSlice = width / vec4PerParticle;
37
m_particleCount = particleCount;
38
width = divisibleBy(width, 4);
39
height = divisibleBy(height, 4);
40
m_sliceStride = width * 16;
41
m_size = QSize(width, height);
42
m_particleBuffer.resize(m_sliceStride * height);
43
}
44
45
void
QSSGParticleBuffer::resizeLine(
int
particleCount,
int
segmentCount)
46
{
47
m_segments = segmentCount;
48
resize(particleCount * segmentCount,
sizeof
(QSSGLineParticle));
49
}
50
51
void
QSSGParticleBuffer::setBounds(
const
QSSGBounds3& bounds)
52
{
53
m_bounds = bounds;
54
m_serial++;
55
}
56
57
char
*QSSGParticleBuffer::pointer()
58
{
59
return
m_particleBuffer.data();
60
}
61
62
const
char
*QSSGParticleBuffer::pointer()
const
63
{
64
return
m_particleBuffer.constData();
65
}
66
67
int
QSSGParticleBuffer::particlesPerSlice()
const
68
{
69
return
m_particlesPerSlice;
70
}
71
72
int
QSSGParticleBuffer::sliceStride()
const
73
{
74
return
m_sliceStride;
75
}
76
77
int
QSSGParticleBuffer::particleCount()
const
78
{
79
return
m_particleCount;
80
}
81
82
QSize QSSGParticleBuffer::size()
const
83
{
84
return
m_size;
85
}
86
87
int
QSSGParticleBuffer::sliceCount()
const
88
{
89
return
m_size.height();
90
}
91
92
QByteArray QSSGParticleBuffer::data()
const
93
{
94
return
m_particleBuffer;
95
}
96
97
int
QSSGParticleBuffer::bufferSize()
const
98
{
99
return
m_particleBuffer.size();
100
}
101
102
int
QSSGParticleBuffer::serial()
const
103
{
104
return
m_serial;
105
}
106
107
int
QSSGParticleBuffer::segments()
const
108
{
109
return
m_segments;
110
}
111
112
QSSGBounds3 QSSGParticleBuffer::bounds()
const
113
{
114
return
m_bounds;
115
}
116
117
QSSGRenderParticles::QSSGRenderParticles()
118
: QSSGRenderNode(QSSGRenderGraphObject::Type::Particles)
119
{
120
121
}
122
123
QT_END_NAMESPACE
ceilDivide
static int ceilDivide(int a, int b)
Definition
qssgrenderparticles.cpp:15
divisibleBy
static QT_BEGIN_NAMESPACE int divisibleBy(int a, int b)
Definition
qssgrenderparticles.cpp:11
qtquick3d
src
runtimerender
graphobjects
qssgrenderparticles.cpp
Generated on
for Qt by
1.18.0