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
qquick3dparticlesceneshape_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 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 QQUICK3DPARTICLESCENESHAPE_H
7#define QQUICK3DPARTICLESCENESHAPE_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
22#include <QVector3D>
23
24#include <QList>
25
26#include <vector>
27
28QT_BEGIN_NAMESPACE
29
30class QQuick3DModel;
31class QQuick3DNode;
32class QQmlComponent;
33class QQuick3DGeometry;
34
35class Q_QUICK3DPARTICLES_EXPORT QQuick3DParticleSceneShape : public QQuick3DParticleAbstractShape
36{
37 Q_OBJECT
38 Q_PROPERTY(QQuick3DNode *scene READ scene WRITE setScene NOTIFY sceneChanged)
39 Q_PROPERTY(QVector3D sceneCenter READ sceneCenter WRITE setSceneCenter NOTIFY sceneCenterChanged)
40 Q_PROPERTY(QVector3D sceneExtents READ sceneExtents WRITE setSceneExtents NOTIFY sceneExtentsChanged)
41 Q_PROPERTY(float shapeResolution READ shapeResolution WRITE setShapeResolution NOTIFY shapeResolutionChanged)
42 Q_PROPERTY(QList<QQuick3DNode *> excludedNodes READ excludedNodes WRITE setExcludedNodes NOTIFY excludedNodesChanged)
43 Q_PROPERTY(QQuick3DGeometry *geometry READ geometry NOTIFY geometryChanged)
44 QML_NAMED_ELEMENT(ParticleSceneShape3D)
45 QML_ADDED_IN_VERSION(6, 11)
46
47public:
48 explicit QQuick3DParticleSceneShape(QObject *parent = nullptr);
49 ~QQuick3DParticleSceneShape() override;
50
51 QQuick3DNode *scene() const;
52 QVector3D sceneCenter() const;
53 QVector3D sceneExtents() const;
54 float shapeResolution() const;
55 QQuick3DGeometry *geometry() const;
56 QList<QQuick3DNode *> excludedNodes() const;
57
58public Q_SLOTS:
59 void setScene(QQuick3DNode *scene);
60 void setSceneCenter(const QVector3D &extents);
61 void setSceneExtents(const QVector3D &extents);
62 void setShapeResolution(float resolution);
63 void setExcludedNodes(const QList<QQuick3DNode *> &nodes);
64
65 // Returns point inside this shape
66 QVector3D getPosition(int particleIndex) override;
67 QVector3D getSurfaceNormal(int particleIndex) override;
68
69Q_SIGNALS:
70 void sceneChanged();
71 void sceneCenterChanged();
72 void sceneExtentsChanged();
73 void shapeResolutionChanged();
74 void geometryChanged();
75 void excludedNodesChanged();
76
77private:
78 QVector3D randomPositionModel(int particleIndex);
79 void createShapeData();
80 void clearModelVertexPositions();
81 void calculateModelVertexPositions();
82 QList<QVector3D> excludeTriangles(const QList<QVector3D> &list);
83 void updateGeometry();
84 bool isVisibleRecursive(QQuick3DNode *node);
85 bool isExcluded(QQuick3DModel *model);
86 void markDirty(bool dirty = true, bool excludeDirty = false);
87
88 QList<QQuick3DNode *> m_excludeList;
89 QQuick3DGeometry *m_geometry = nullptr;
90 QQuick3DNode *m_root = nullptr;
91 QQuick3DNode *m_scene = nullptr;
92 struct ShapeData {
93 QQuick3DModel *model;
94 QVector<QVector3D> vertexPositions;
95 float modelTriangleAreasSum = 0;
96 QVector<float> modelTriangleAreas;
97 QVector3D modelTriangleCenter;
98 bool dirty = true;
99 bool hasVertices = false;
100 bool visible = false;
101 bool excluded = false;
102 bool excludedDirty = true;
103 QMetaObject::Connection sceneTransformConnection;
104 QMetaObject::Connection visibilityConnection;
105 void clear()
106 {
107 vertexPositions.clear();
108 modelTriangleAreasSum = 0;
109 modelTriangleAreas.clear();
110 modelTriangleCenter = {};
111 }
112 };
113 struct SceneNapkinMesh;
114 std::vector<ShapeData> m_data;
115 ShapeData m_sceneData;
116 SceneNapkinMesh *m_sceneMesh = nullptr;
117 QVector3D m_cachedNormal;
118 QVector3D m_sceneCenter;
119 QVector3D m_sceneExtents;
120 float m_shapeResolution = 10.0f;
121 int m_cachedIndex = -1;
122};
123
124QT_END_NAMESPACE
125
126#endif // QQUICK3DPARTICLESCENESHAPE_H
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:28
void init(float x, float z, float w, float d, int ccx, int ccz, float y)
void initCells(Cell *cells, float x, float z, float w, float d, int ccx, int ccz, float y)
void update(const QVector3D &v1, const QVector3D &v2, const QVector3D &v3, bool append=true)
QList< QVector3D > positions(float miny, float icp100)