Skip to content
Permalink
Browse files

fix additive strategy and speed up requestResidency ordering

  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Feb 10, 2021
1 parent d0314b1 commit a3af7b71210df8693dd389333c807cdaa86fb6ad
Showing with 18 additions and 16 deletions.
  1. +18 −15 src/3d/chunks/qgschunkedentity_p.cpp
  2. +0 −1 src/3d/qgspointcloudlayer3drenderer.cpp
@@ -247,10 +247,10 @@ int QgsChunkedEntity::pendingJobsCount() const

void QgsChunkedEntity::update( QgsChunkNode *root, const SceneState &state )
{
QVector<QgsChunkNode *> nodes;
QSet<QgsChunkNode *> nodes;

using slot = std::pair<QgsChunkNode *, float>;
auto cmp_funct = []( std::pair<QgsChunkNode *, float> p1, std::pair<QgsChunkNode *, float> p2 )
auto cmp_funct = []( slot &p1, slot &p2 )
{
return p1.second < p2.second;
};
@@ -275,10 +275,17 @@ void QgsChunkedEntity::update( QgsChunkNode *root, const SceneState &state )
QgsChunkNode *const *children = node->children();
for ( int i = 0; i < node->childCount(); ++i )
pq.push( std::make_pair( children[i], screenSpaceError( children[i], state ) ) );
// We won't render the primitives of the parent unless we are using additive strategy
if ( !mAdditiveStrategy && node->parent() )
{
nodes.remove( node->parent() );
renderedCount -= mChunkLoaderFactory->primitivesCount( node->parent() );
}
renderedCount += mChunkLoaderFactory->primitivesCount( node );
nodes.push_back( node );
nodes.insert( node );
}

QVector<std::pair<QgsChunkNode *, float>> residencyRequests;
for ( QgsChunkNode *node : nodes )
{
// ensure we have child nodes (at least skeletons) available, if any
@@ -289,7 +296,7 @@ void QgsChunkedEntity::update( QgsChunkNode *root, const SceneState &state )

// make sure all nodes leading to children are always loaded
// so that zooming out does not create issues
requestResidency( node );
residencyRequests.push_back( std::make_pair( node, node->bbox().distanceFromPoint( state.cameraPos ) ) );

if ( !node->entity() )
{
@@ -326,20 +333,16 @@ void QgsChunkedEntity::update( QgsChunkNode *root, const SceneState &state )
mActiveNodes << node;

QgsChunkNode *const *children = node->children();
// load the closest nodes to the camera first
QVector<std::pair<QgsChunkNode *, float>> childrenVector;
for ( int i = 0; i < node->childCount(); ++i )
childrenVector.push_back( std::make_pair( children[i], children[i]->bbox().distanceFromPoint( state.cameraPos ) ) );
std::sort( childrenVector.begin(), childrenVector.end(), [&]( std::pair<QgsChunkNode *, float> n1, std::pair<QgsChunkNode *, float> n2 )
{
return n1.second > n2.second;
} );
for ( int i = 0; i < node->childCount(); ++i )
requestResidency( childrenVector[i].first );
// for ( int i = 0; i < node->childCount(); ++i )
// requestResidency( children[i] );
residencyRequests.push_back( std::make_pair( children[i], children[i]->bbox().distanceFromPoint( state.cameraPos ) ) );
}
}
std::sort( residencyRequests.begin(), residencyRequests.end(), [&]( std::pair<QgsChunkNode *, float> n1, std::pair<QgsChunkNode *, float> n2 )
{
return n1.second > n2.second;
} );
for ( std::pair<QgsChunkNode *, float> n : residencyRequests )
requestResidency( n.first );
}


@@ -191,6 +191,5 @@ void QgsPointCloudLayer3DRenderer::setShowBoundingBoxes( bool showBoundingBoxes

void QgsPointCloudLayer3DRenderer::setPointRenderingBudget( int budget )
{
qDebug() << budget;
mPointBudget = budget;
}

0 comments on commit a3af7b7

Please sign in to comment.