Skip to content
Permalink
Browse files
fix crash with 3D mesh terrain
  • Loading branch information
vcloarec authored and wonder-sk committed Jun 14, 2021
1 parent cbe2678 commit 94e9b33a4269e7e7188f23aeaf9a286f9149d0a8
Showing with 7 additions and 8 deletions.
  1. +4 −6 src/3d/mesh/qgsmeshterraingenerator.cpp
  2. +3 −2 src/3d/terrain/qgsterraintexturegenerator_p.cpp
@@ -86,18 +86,13 @@ void QgsMeshTerrainGenerator::rootChunkHeightRange( float &hMin, float &hMax ) c

void QgsMeshTerrainGenerator::resolveReferences( const QgsProject &project )
{
mLayer = QgsMapLayerRef( project.mapLayer( mLayer.layerId ) );
updateTriangularMesh();
setLayer( qobject_cast<QgsMeshLayer *>( project.mapLayer( mLayer.layerId ) ) );
}

void QgsMeshTerrainGenerator::setLayer( QgsMeshLayer *layer )
{
mLayer = QgsMapLayerRef( layer );
mIsValid = layer != nullptr;

if ( layer )
mTerrainTilingScheme = QgsTilingScheme( layer->extent(), layer->crs() );

updateTriangularMesh();
}

@@ -185,7 +180,10 @@ void QgsMeshTerrainGenerator::updateTriangularMesh()
QgsCoordinateTransform transform( mCrs, meshLayer()->crs(), mTransformContext );
meshLayer()->updateTriangularMesh( transform );
mTriangularMesh = *meshLayer()->triangularMeshByLodIndex( mSymbol->levelOfDetailIndex() );
mTerrainTilingScheme = QgsTilingScheme( mTriangularMesh.extent(), mCrs );
}
else
mTerrainTilingScheme = QgsTilingScheme();
}

QgsMesh3DSymbol *QgsMeshTerrainGenerator::symbol() const
@@ -43,7 +43,6 @@ int QgsTerrainTextureGenerator::render( const QgsRectangle &extent, QgsChunkNode

QgsMapRendererSequentialJob *job = new QgsMapRendererSequentialJob( mapSettings );
connect( job, &QgsMapRendererJob::finished, this, &QgsTerrainTextureGenerator::onRenderingFinished );
job->start();

JobData jobData;
jobData.jobId = ++mLastJobId;
@@ -52,7 +51,9 @@ int QgsTerrainTextureGenerator::render( const QgsRectangle &extent, QgsChunkNode
jobData.extent = extent;
jobData.debugText = debugText;

mJobs.insert( job, jobData );
mJobs.insert( job, jobData ); //store job data just before launching the job
job->start();

// QgsDebugMsgLevel( QStringLiteral("added job: %1 .... in queue: %2").arg( jobData.jobId ).arg( jobs.count() ), 2);
return jobData.jobId;
}

0 comments on commit 94e9b33

Please sign in to comment.