@@ -141,17 +141,17 @@ static QByteArray createIndexData( const QgsTriangularMesh &mesh, const QgsRecta
141
141
142
142
// count non void faces
143
143
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 () )
146
146
nonVoidFaces++;
147
147
148
148
QByteArray indexBytes;
149
149
indexBytes.resize ( int ( nonVoidFaces * 3 * sizeof ( quint32 ) ) );
150
150
quint32 *indexPtr = reinterpret_cast <quint32 *>( indexBytes.data () );
151
151
152
- for ( const int nativeFaceIndex : facesInExtent )
152
+ for ( const int triangleFaceIndex : facesInExtent )
153
153
{
154
- const QgsMeshFace &face = mesh.triangles ().at ( nativeFaceIndex );
154
+ const QgsMeshFace &face = mesh.triangles ().at ( triangleFaceIndex );
155
155
if ( face.isEmpty () )
156
156
continue ;
157
157
for ( int j = 0 ; j < 3 ; ++j )
@@ -171,9 +171,10 @@ static QByteArray createDatasetIndexData( const QgsTriangularMesh &mesh, const Q
171
171
activeFaceCount = facesInExtent.count ();
172
172
else
173
173
{
174
- for ( const int nativeFaceIndex : facesInExtent )
174
+ for ( const int triangleFaceIndex : facesInExtent )
175
175
{
176
- if ( mActiveFaceFlagValues .active ( nativeFaceIndex ) )
176
+ const int nativeIndex = mesh.trianglesToNativeFaces ()[triangleFaceIndex];
177
+ if ( mActiveFaceFlagValues .active ( nativeIndex ) )
177
178
activeFaceCount++;
178
179
}
179
180
}
@@ -183,12 +184,13 @@ static QByteArray createDatasetIndexData( const QgsTriangularMesh &mesh, const Q
183
184
indexBytes.resize ( int ( indices * sizeof ( quint32 ) ) );
184
185
quint32 *indexPtr = reinterpret_cast <quint32 *>( indexBytes.data () );
185
186
186
- for ( const int nativeFaceIndex : facesInExtent )
187
+ for ( const int triangleFaceIndex : facesInExtent )
187
188
{
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 );
189
191
if ( !isActive )
190
192
continue ;
191
- const QgsMeshFace &face = mesh.triangles ().at ( nativeFaceIndex );
193
+ const QgsMeshFace &face = mesh.triangles ().at ( triangleFaceIndex );
192
194
for ( int j = 0 ; j < 3 ; ++j )
193
195
*indexPtr++ = quint32 ( face.at ( j ) );
194
196
}
0 commit comments