QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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
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
105 virtual QVector<QgsRayCastingUtils::RayHit> rayIntersection( const QgsRayCastingUtils::Ray3D &ray, const QgsRayCastingUtils::RayCastContext &context ) const;
106
107 protected:
109 void cancelActiveJob( QgsChunkQueueJob *job );
110 void cancelActiveJobs();
112 void setNeedsUpdate( bool needsUpdate ) { mNeedsUpdate = needsUpdate; }
113
114 private:
115 void update( QgsChunkNode *node, const SceneState &state );
116
118 void pruneLoaderQueue( const SceneState &state );
119
121 void requestResidency( QgsChunkNode *node );
122
123 void startJobs();
124 QgsChunkQueueJob *startJob( QgsChunkNode *node );
125
126 int unloadNodes();
127
128 private slots:
129 void onActiveJobFinished();
130
131 protected:
133 QgsChunkNode *mRootNode = nullptr;
135 bool mNeedsUpdate = false;
136
144 float mTau;
146 QgsChunkLoaderFactory *mChunkLoaderFactory = nullptr;
148 bool mOwnsFactory = true;
150 QgsChunkList *mChunkLoaderQueue = nullptr;
152 QgsChunkList *mReplacementQueue = nullptr;
154 QList<QgsChunkNode *> mActiveNodes;
156 int mFrustumCulled = 0;
157
158 // TODO: max. length for loading queue
159
160 QTime mCurrentTime;
161
163 QgsChunkBoundsEntity *mBboxesEntity = nullptr;
164
166 QList<QgsChunkQueueJob *> mActiveJobs;
167
168 bool mIsValid = true;
169
170 int mPrimitivesBudget = std::numeric_limits<int>::max();
171};
172
174
175#endif // QGSCHUNKEDENTITY_P_H
A template based class for storing ranges (lower to upper values).
Definition qgsrange.h:47