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