QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
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
63class QgsChunkedEntity : public Qgs3DMapSceneEntity
64{
65 Q_OBJECT
66 public:
68 QgsChunkedEntity( float tau, QgsChunkLoaderFactory *loaderFactory, bool ownsFactory,
69 int primitivesBudget = std::numeric_limits<int>::max(),
70 Qt3DCore::QNode *parent = nullptr );
71 ~QgsChunkedEntity() override;
72
74 void handleSceneUpdate( const SceneContext &sceneContext ) override;
75
77 int pendingJobsCount() const override;
78
80 bool needsUpdate() const override { return mNeedsUpdate; }
81
82 QgsRange<float> getNearFarPlaneRange( const QMatrix4x4 &viewMatrix ) const override;
83
85 void setShowBoundingBoxes( bool enabled );
86
88 void updateNodes( const QList<QgsChunkNode *> &nodes, QgsChunkQueueJobFactory *updateJobFactory );
89
91 QList<QgsChunkNode *> activeNodes() const { return mActiveNodes; }
93 QgsChunkNode *rootNode() const { return mRootNode; }
94
104 virtual QVector<QgsRayCastingUtils::RayHit> rayIntersection( const QgsRayCastingUtils::Ray3D &ray, const QgsRayCastingUtils::RayCastContext &context ) const;
105
106 protected:
108 void cancelActiveJob( QgsChunkQueueJob *job );
109 void cancelActiveJobs();
111 void setNeedsUpdate( bool needsUpdate ) { mNeedsUpdate = needsUpdate; }
112
113 private:
114 void update( QgsChunkNode *node, const SceneContext &sceneContext );
115
117 void pruneLoaderQueue( const SceneContext &sceneContext );
118
120 void requestResidency( QgsChunkNode *node );
121
122 void startJobs();
123 QgsChunkQueueJob *startJob( QgsChunkNode *node );
124
125 int unloadNodes();
126
127 private slots:
128 void onActiveJobFinished();
129
130 protected:
132 QgsChunkNode *mRootNode = nullptr;
134 bool mNeedsUpdate = false;
135
143 float mTau;
145 QgsChunkLoaderFactory *mChunkLoaderFactory = nullptr;
147 bool mOwnsFactory = true;
149 QgsChunkList *mChunkLoaderQueue = nullptr;
151 QgsChunkList *mReplacementQueue = nullptr;
153 QList<QgsChunkNode *> mActiveNodes;
155 int mFrustumCulled = 0;
156
157 // TODO: max. length for loading queue
158
159 QTime mCurrentTime;
160
162 QgsChunkBoundsEntity *mBboxesEntity = nullptr;
163
165 QList<QgsChunkQueueJob *> mActiveJobs;
166
167 bool mIsValid = true;
168
169 int mPrimitivesBudget = std::numeric_limits<int>::max();
170};
171
173
174#endif // QGSCHUNKEDENTITY_P_H
A template based class for storing ranges (lower to upper values).
Definition qgsrange.h:46
Helper struct to store ray casting parameters.