Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#include <QtQuick3DRuntimeRender/private/qssgrenderparticles_p.h>
5#include <cmath>
6
8
9static int divisibleBy(int a, int b)
10{
11 return (a % b) ? a + b - (a % b) : a;
12}
13static int ceilDivide(int a, int b)
14{
15 int x = a / b;
16 int y = (a % b) ? 1 : 0;
17 return x + y;
18}
19
20void QSSGParticleBuffer::resize(int particleCount, int particleSize)
21{
22 if (particleCount == 0) {
23 m_particlesPerSlice = 0;
24 m_particleCount = 0;
25 m_sliceStride = 0;
26 m_size = QSize();
27 m_particleBuffer.resize(0);
28 return;
29 }
30 int vec4PerParticle = ceilDivide(particleSize, 16);
31 int vec4s = particleCount * vec4PerParticle;
32 int width = divisibleBy(std::sqrt(vec4s), vec4PerParticle);
33 int height = ceilDivide(vec4s, width);
34 m_particlesPerSlice = width / vec4PerParticle;
35 m_particleCount = particleCount;
38 m_sliceStride = width * 16;
39 m_size = QSize(width, height);
40 m_particleBuffer.resize(m_sliceStride * height);
41}
42
43void QSSGParticleBuffer::resizeLine(int particleCount, int segmentCount)
44{
45 m_segments = segmentCount;
47}
48
50{
51 m_bounds = bounds;
52 m_serial++;
53}
54
56{
57 return m_particleBuffer.data();
58}
59
60const char *QSSGParticleBuffer::pointer() const
61{
62 return m_particleBuffer.constData();
63}
64
66{
67 return m_particlesPerSlice;
68}
69
71{
72 return m_sliceStride;
73}
74
76{
77 return m_particleCount;
78}
79
81{
82 return m_size;
83}
84
86{
87 return m_size.height();
88}
89
91{
92 return m_particleBuffer;
93}
94
96{
97 return m_particleBuffer.size();
98}
99
101{
102 return m_serial;
103}
104
106{
107 return m_segments;
108}
109
111{
112 return m_bounds;
113}
114
120
\inmodule QtCore
Definition qbytearray.h:57
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
Definition qbytearray.h:611
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
Definition qbytearray.h:494
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
Definition qbytearray.h:124
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
Class representing 3D range or axis aligned bounding box.
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLint GLsizei width
GLint y
static int segmentCount(const QPainterPath &path, qreal pathLength)
static int ceilDivide(int a, int b)
static QT_BEGIN_NAMESPACE int divisibleBy(int a, int b)
void resize(int particleCount, int particleSize=sizeof(QSSGParticleSimple))
void setBounds(const QSSGBounds3 &bounds)
QSSGBounds3 bounds() const
void resizeLine(int particleCount, int segmentCount)
QByteArray data() const
Definition moc.h:23