Skip to content

Commit

Permalink
Use additive strategy for point clouds
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk authored and nyalldawson committed Oct 26, 2020
1 parent 66ce1a6 commit c0f5089
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/3d/chunks/qgschunkedentity_p.cpp
Expand Up @@ -271,6 +271,14 @@ void QgsChunkedEntity::update( QgsChunkNode *node, const SceneState &state )
{
// error is not acceptable and children are ready to be used - recursive descent

if ( mAdditiveStrategy )
{
// With additive strategy enabled, also all parent nodes are added to active nodes.
// This is desired when child nodes add more detailed data rather than just replace
// coarser data in parents. We use this e.g. with point cloud data.
mActiveNodes << node;
}

QgsChunkNode *const *children = node->children();
for ( int i = 0; i < node->childCount(); ++i )
update( children[i], state );
Expand Down
16 changes: 16 additions & 0 deletions src/3d/chunks/qgschunkedentity_p.h
Expand Up @@ -100,6 +100,16 @@ class QgsChunkedEntity : public Qt3DCore::QEntity
//! Returns whether object picking is currently enabled
bool hasPickingEnabled() const { return mPickingEnabled; }

//! Sets whether additive strategy is enabled - see usingAditiveStrategy()
void setUsingAdditiveStrategy( bool additive ) { mAdditiveStrategy = additive; }

/**
* Returns whether additive strategy is enabled.
* With additive strategy enabled, also all parent nodes are added to active nodes.
* This is desired when child nodes add more detailed data rather than just replace coarser data in parents.
*/
bool usingAditiveStrategy() const { return mAdditiveStrategy; }

protected:
//! Cancels the background job that is currently in progress
void cancelActiveJob( QgsChunkQueueJob *job );
Expand Down Expand Up @@ -174,6 +184,12 @@ class QgsChunkedEntity : public Qt3DCore::QEntity
//! If picking is enabled, QObjectPicker objects will be assigned to chunks and pickedObject() signals fired on mouse click
bool mPickingEnabled = false;

/**
* With additive strategy enabled, also all parent nodes are added to active nodes.
* This is desired when child nodes add more detailed data rather than just replace coarser data in parents.
*/
bool mAdditiveStrategy = false;

bool mIsValid = true;
};

Expand Down
1 change: 1 addition & 0 deletions src/3d/qgspointcloudlayerchunkloader_p.cpp
Expand Up @@ -333,6 +333,7 @@ QgsPointCloudLayerChunkedEntity::QgsPointCloudLayerChunkedEntity( QgsPointCloudI
: QgsChunkedEntity( 5, // max. allowed screen error (in pixels) -- // TODO
new QgsPointCloudLayerChunkLoaderFactory( map, pc ), true )
{
setUsingAdditiveStrategy( true );
setShowBoundingBoxes( true );
}

Expand Down

0 comments on commit c0f5089

Please sign in to comment.