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
qquick3dparticlemodelshape_p.h
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#ifndef QQUICK3DPARTICLEMODELSHAPE_H
7#define QQUICK3DPARTICLEMODELSHAPE_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
21#include <QVector3D>
22
24
25class QQuick3DModel;
26class QQmlComponent;
27
28class Q_QUICK3DPARTICLES_EXPORT QQuick3DParticleModelShape : public QQuick3DParticleAbstractShape
29{
30 Q_OBJECT
31 Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged)
32 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
33 QML_NAMED_ELEMENT(ParticleModelShape3D)
34 QML_ADDED_IN_VERSION(6, 2)
35
36public:
37 QQuick3DParticleModelShape(QObject *parent = nullptr);
38 ~QQuick3DParticleModelShape() override;
39
40 bool fill() const;
41 QQmlComponent *delegate() const;
42
43public Q_SLOTS:
44 void setFill(bool fill);
45 void setDelegate(QQmlComponent *delegate);
46
47 // Returns point inside this shape
48 QVector3D getPosition(int particleIndex) override;
49 QVector3D getSurfaceNormal(int particleIndex) override;
50
51Q_SIGNALS:
52 void fillChanged();
53 void delegateChanged();
54
55private:
56 QVector3D randomPositionModel(int particleIndex);
57 void createModel();
58 void clearModelVertexPositions();
59 void calculateModelVertexPositions();
60
61 QQmlComponent *m_delegate = nullptr;
62 QQuick3DModel *m_model = nullptr;
63 QVector<QVector3D> m_vertexPositions;
64 float m_modelTriangleAreasSum = 0;
65 QVector<float> m_modelTriangleAreas;
66 QVector3D m_modelTriangleCenter;
67 QVector3D m_cachedNormal;
68 int m_cachedIndex = -1;
69 bool m_fill = true;
70};
71
72QT_END_NAMESPACE
73
74#endif // QQUICK3DPARTICLEMODELSHAPE_H
Combined button and popup list for selecting options.