QGIS API Documentation 4.3.0-Master (16eddb2670e)
Loading...
Searching...
No Matches
qgschunkedentity.h
Go to the documentation of this file.
1/***************************************************************************
2 qgschunkedentity.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_H
17#define QGSCHUNKEDENTITY_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
30#include "qgs3dmapsceneentity.h"
31#include "qgsraycasthit.h"
32
33#include <QFuture>
34#include <QMatrix4x4>
35#include <QTime>
36
37#define SIP_NO_FILE
38
39class QgsAABB;
40class QgsChunkNode;
41class QgsChunkList;
42class QgsChunkLoader;
43class QgsChunkBoundsEntity;
44class QgsRay3D;
46struct QgsChunkLoaderResult;
47
48
53struct QgsChunkQueueJob
54{
55 enum class Type
56 {
57 Load,
58 Update,
59 CreateChildren,
60 };
61
62 QgsChunkNode *node;
63 Type type;
64 QFuture<void> future;
65};
66
67
73class QgsChunkedEntity : public Qgs3DMapSceneEntity
74{
75 Q_OBJECT
76 public:
78 QgsChunkedEntity( Qgs3DMapSettings *mapSettings, float tau, QgsChunkLoader *loader, bool ownsLoader, int primitivesBudget = std::numeric_limits<int>::max(), Qt3DCore::QNode *parent = nullptr );
79 ~QgsChunkedEntity() override;
80
82 void handleSceneUpdate( const SceneContext &sceneContext ) override;
83
85 int pendingJobsCount() const override;
86
88 bool needsUpdate() const override { return mNeedsUpdate; }
89
90 QgsRange<float> getNearFarPlaneRange( const QMatrix4x4 &viewMatrix ) const override;
91
93 void setShowBoundingBoxes( bool enabled );
94
96 void updateNodes( const QList<QgsChunkNode *> &nodes );
97
99 QList<QgsChunkNode *> activeNodes() const { return mActiveNodes; }
101 QgsChunkNode *rootNode() const { return mRootNode.get(); }
102
112 virtual QList<QgsRayCastHit> rayIntersection( const QgsRay3D &ray, const QgsRayCastContext &context ) const;
113
114 protected:
116 void cancelActiveJob( QgsChunkQueueJob &job );
117 void cancelActiveJobs();
119 void setNeedsUpdate( bool needsUpdate ) { mNeedsUpdate = needsUpdate; }
120
121 private:
122 void update( QgsChunkNode *node, const SceneContext &sceneContext );
123
125 void pruneLoaderQueue( const SceneContext &sceneContext );
126
128 void requestResidency( QgsChunkNode *node );
129
130 void startJobs();
131 void startJob( QgsChunkNode *node );
132
133 int unloadNodes();
134
135 void eraseJobFromList( QgsChunkQueueJob &job );
136
137 void onActiveLoadJobFinished( QgsChunkQueueJob &job, QgsChunkLoaderResult &result );
138
139 protected:
141 std::unique_ptr<QgsChunkNode> mRootNode;
143 bool mNeedsUpdate = false;
144
152 float mTau;
154 QgsChunkLoader *mChunkLoader = nullptr;
156 bool mOwnsLoader = true;
158 std::unique_ptr<QgsChunkList> mChunkLoaderQueue;
160 std::unique_ptr<QgsChunkList> mReplacementQueue;
162 QList<QgsChunkNode *> mActiveNodes;
164 int mFrustumCulled = 0;
165
166 // TODO: max. length for loading queue
167
168 QTime mCurrentTime;
169
171 QgsChunkBoundsEntity *mBboxesEntity = nullptr;
172
177 std::vector<std::unique_ptr<QgsChunkQueueJob>> mActiveJobs;
178
179 bool mIsValid = true;
180
181 int mPrimitivesBudget = std::numeric_limits<int>::max();
182};
183
185
186#endif // QGSCHUNKEDENTITY_H
Axis-aligned bounding box - in world coords.
Definition qgsaabb.h:33
A representation of a ray in 3D.
Definition qgsray3d.h:31
Responsible for defining parameters of the ray casting operations in 3D map canvases.