QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgschunkedentity_p.h
Go to the documentation of this file.
1/***************************************************************************
2 qgschunkedentity_p.h
3 --------------------------------------
4 Date : July 2017
5 Copyright : (C) 2017 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSCHUNKEDENTITY_P_H
17#define QGSCHUNKEDENTITY_P_H
18
20
21//
22// W A R N I N G
23// -------------
24//
25// This file is not part of the QGIS API. It exists purely as an
26// implementation detail. This header file may change from version to
27// version without notice, or even be removed.
28//
29
31#include <numeric>
32
33#define SIP_NO_FILE
34
35class QgsAABB;
36class QgsChunkNode;
37class QgsChunkList;
38class QgsChunkQueueJob;
39class QgsChunkLoaderFactory;
40class QgsChunkBoundsEntity;
41class QgsChunkQueueJobFactory;
42
43namespace QgsRayCastingUtils
44{
45 class Ray3D;
46 struct RayCastContext;
47 struct RayHit;
48}
49
50#include <QVector3D>
51#include <QMatrix4x4>
52
53#include <QTime>
54
55#include "qgschunknode_p.h"
56
57
64class QgsChunkedEntity : public Qgs3DMapSceneEntity
65{
66 Q_OBJECT
67 public:
69 QgsChunkedEntity( float tau, QgsChunkLoaderFactory *loaderFactory, bool ownsFactory,
70 int primitivesBudget = std::numeric_limits<int>::max(),
71 Qt3DCore::QNode *parent = nullptr );
72 ~QgsChunkedEntity() override;
73
75 void handleSceneUpdate( const SceneState &state ) override;
76
78 int pendingJobsCount() const override;
79
81 bool needsUpdate() const override { return mNeedsUpdate; }
82
83 QgsRange<float> getNearFarPlaneRange( const QMatrix4x4 &viewMatrix ) const override;
84
86 void setShowBoundingBoxes( bool enabled );
87
89 void updateNodes( const QList<QgsChunkNode *> &nodes, QgsChunkQueueJobFactory *updateJobFactory );
90
92 QList<QgsChunkNode *> activeNodes() const { return mActiveNodes; }
94 QgsChunkNode *rootNode() const { return mRootNode; }
95
97 void setUsingAdditiveStrategy( bool additive ) { mAdditiveStrategy = additive; }
98
104 bool usingAditiveStrategy() const { return mAdditiveStrategy; }
105
110 void setGpuMemoryLimit( double gpuMemoryLimit ) { mGpuMemoryLimit = gpuMemoryLimit; }
111
116 double gpuMemoryLimit() const { return mGpuMemoryLimit; }
117
118 static double calculateEntityGpuMemorySize( Qt3DCore::QEntity *entity );
119
129 virtual QVector<QgsRayCastingUtils::RayHit> rayIntersection( const QgsRayCastingUtils::Ray3D &ray, const QgsRayCastingUtils::RayCastContext &context ) const;
130
131 protected:
133 void cancelActiveJob( QgsChunkQueueJob *job );
134 void cancelActiveJobs();
136 void setNeedsUpdate( bool needsUpdate ) { mNeedsUpdate = needsUpdate; }
137
138 private:
139 void update( QgsChunkNode *node, const SceneState &state );
140
142 void pruneLoaderQueue( const SceneState &state );
143
145 void requestResidency( QgsChunkNode *node );
146
147 void startJobs();
148 QgsChunkQueueJob *startJob( QgsChunkNode *node );
149
150 private slots:
151 void onActiveJobFinished();
152
153 protected:
155 QgsChunkNode *mRootNode = nullptr;
157 bool mNeedsUpdate = false;
158
166 float mTau;
168 QgsChunkLoaderFactory *mChunkLoaderFactory = nullptr;
170 bool mOwnsFactory = true;
172 QgsChunkList *mChunkLoaderQueue = nullptr;
174 QgsChunkList *mReplacementQueue = nullptr;
176 QList<QgsChunkNode *> mActiveNodes;
178 int mFrustumCulled = 0;
179
180 // TODO: max. length for loading queue
181
182 QTime mCurrentTime;
183
185 QgsChunkBoundsEntity *mBboxesEntity = nullptr;
186
188 QList<QgsChunkQueueJob *> mActiveJobs;
189
194 bool mAdditiveStrategy = false;
195
196 bool mIsValid = true;
197
198 int mPrimitivesBudget = std::numeric_limits<int>::max();
199 double mGpuMemoryLimit = 500.0; // in megabytes
200};
201
203
204#endif // QGSCHUNKEDENTITY_P_H
3
Definition: qgsaabb.h:34
A template based class for storing ranges (lower to upper values).
Definition: qgsrange.h:47