QGIS API Documentation 3.41.0-Master (cea29feecf2)
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 <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} // namespace QgsRayCastingUtils
49
50#include <QVector3D>
51#include <QMatrix4x4>
52
53#include <QTime>
54
55#include "qgschunknode.h"
56
57
63class QgsChunkedEntity : public Qgs3DMapSceneEntity
64{
65 Q_OBJECT
66 public:
68 QgsChunkedEntity( Qgs3DMapSettings *mapSettings, float tau, QgsChunkLoaderFactory *loaderFactory, bool ownsFactory, int primitivesBudget = std::numeric_limits<int>::max(), Qt3DCore::QNode *parent = nullptr );
69 ~QgsChunkedEntity() override;
70
72 void handleSceneUpdate( const SceneContext &sceneContext ) override;
73
75 int pendingJobsCount() const override;
76
78 bool needsUpdate() const override { return mNeedsUpdate; }
79
80 QgsRange<float> getNearFarPlaneRange( const QMatrix4x4 &viewMatrix ) const override;
81
83 void setShowBoundingBoxes( bool enabled );
84
86 void updateNodes( const QList<QgsChunkNode *> &nodes, QgsChunkQueueJobFactory *updateJobFactory );
87
89 QList<QgsChunkNode *> activeNodes() const { return mActiveNodes; }
91 QgsChunkNode *rootNode() const { return mRootNode; }
92
102 virtual QVector<QgsRayCastingUtils::RayHit> rayIntersection( const QgsRayCastingUtils::Ray3D &ray, const QgsRayCastingUtils::RayCastContext &context ) const;
103
104 protected:
106 void cancelActiveJob( QgsChunkQueueJob *job );
107 void cancelActiveJobs();
109 void setNeedsUpdate( bool needsUpdate ) { mNeedsUpdate = needsUpdate; }
110
111 private:
112 void update( QgsChunkNode *node, const SceneContext &sceneContext );
113
115 void pruneLoaderQueue( const SceneContext &sceneContext );
116
118 void requestResidency( QgsChunkNode *node );
119
120 void startJobs();
121 QgsChunkQueueJob *startJob( QgsChunkNode *node );
122
123 int unloadNodes();
124
125 private slots:
126 void onActiveJobFinished();
127
128 protected:
130 QgsChunkNode *mRootNode = nullptr;
132 bool mNeedsUpdate = false;
133
141 float mTau;
143 QgsChunkLoaderFactory *mChunkLoaderFactory = nullptr;
145 bool mOwnsFactory = true;
147 QgsChunkList *mChunkLoaderQueue = nullptr;
149 QgsChunkList *mReplacementQueue = nullptr;
151 QList<QgsChunkNode *> mActiveNodes;
153 int mFrustumCulled = 0;
154
155 // TODO: max. length for loading queue
156
157 QTime mCurrentTime;
158
160 QgsChunkBoundsEntity *mBboxesEntity = nullptr;
161
163 QList<QgsChunkQueueJob *> mActiveJobs;
164
165 bool mIsValid = true;
166
167 int mPrimitivesBudget = std::numeric_limits<int>::max();
168};
169
171
172#endif // QGSCHUNKEDENTITY_H
A template based class for storing ranges (lower to upper values).
Definition qgsrange.h:46
Helper struct to store ray casting parameters.