Skip to content

Commit 18cf4f4

Browse files
authored
Merge pull request #60936 from vcloarec/fix3dMeshCrash
fix confusion between native face and triangle face in 3D mesh layer
2 parents cf5320a + 03d5021 commit 18cf4f4

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/3d/mesh/qgsmesh3dgeometry_p.cpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,17 @@ static QByteArray createIndexData( const QgsTriangularMesh &mesh, const QgsRecta
141141

142142
// count non void faces
143143
int nonVoidFaces = 0;
144-
for ( const int nativeFaceIndex : facesInExtent )
145-
if ( !mesh.triangles().at( nativeFaceIndex ).isEmpty() )
144+
for ( const int triangleFaceIndex : facesInExtent )
145+
if ( !mesh.triangles().at( triangleFaceIndex ).isEmpty() )
146146
nonVoidFaces++;
147147

148148
QByteArray indexBytes;
149149
indexBytes.resize( int( nonVoidFaces * 3 * sizeof( quint32 ) ) );
150150
quint32 *indexPtr = reinterpret_cast<quint32 *>( indexBytes.data() );
151151

152-
for ( const int nativeFaceIndex : facesInExtent )
152+
for ( const int triangleFaceIndex : facesInExtent )
153153
{
154-
const QgsMeshFace &face = mesh.triangles().at( nativeFaceIndex );
154+
const QgsMeshFace &face = mesh.triangles().at( triangleFaceIndex );
155155
if ( face.isEmpty() )
156156
continue;
157157
for ( int j = 0; j < 3; ++j )
@@ -171,9 +171,10 @@ static QByteArray createDatasetIndexData( const QgsTriangularMesh &mesh, const Q
171171
activeFaceCount = facesInExtent.count();
172172
else
173173
{
174-
for ( const int nativeFaceIndex : facesInExtent )
174+
for ( const int triangleFaceIndex : facesInExtent )
175175
{
176-
if ( mActiveFaceFlagValues.active( nativeFaceIndex ) )
176+
const int nativeIndex = mesh.trianglesToNativeFaces()[triangleFaceIndex];
177+
if ( mActiveFaceFlagValues.active( nativeIndex ) )
177178
activeFaceCount++;
178179
}
179180
}
@@ -183,12 +184,13 @@ static QByteArray createDatasetIndexData( const QgsTriangularMesh &mesh, const Q
183184
indexBytes.resize( int( indices * sizeof( quint32 ) ) );
184185
quint32 *indexPtr = reinterpret_cast<quint32 *>( indexBytes.data() );
185186

186-
for ( const int nativeFaceIndex : facesInExtent )
187+
for ( const int triangleFaceIndex : facesInExtent )
187188
{
188-
const bool isActive = mActiveFaceFlagValues.active().isEmpty() || mActiveFaceFlagValues.active( nativeFaceIndex );
189+
const int nativeIndex = mesh.trianglesToNativeFaces()[triangleFaceIndex];
190+
const bool isActive = mActiveFaceFlagValues.active().isEmpty() || mActiveFaceFlagValues.active( nativeIndex );
189191
if ( !isActive )
190192
continue;
191-
const QgsMeshFace &face = mesh.triangles().at( nativeFaceIndex );
193+
const QgsMeshFace &face = mesh.triangles().at( triangleFaceIndex );
192194
for ( int j = 0; j < 3; ++j )
193195
*indexPtr++ = quint32( face.at( j ) );
194196
}

0 commit comments

Comments
 (0)