HMP: Fix override during copying position data

- Fix override
- closes https://github.com/assimp/assimp/issues/4235
pull/4359/head
Kim Kulling 2022-01-26 19:22:52 +01:00 committed by GitHub
parent 5698d41bf9
commit 50b00d33b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -373,12 +373,16 @@ void HMPImporter::CreateOutputFaceList(unsigned int width, unsigned int height)
aiVector3D *pcUVOut(pcUVs); aiVector3D *pcUVOut(pcUVs);
// Build the terrain square // Build the terrain square
const unsigned int upperBound = pcMesh->mNumVertices;
unsigned int iCurrent = 0; unsigned int iCurrent = 0;
for (unsigned int y = 0; y < height - 1; ++y) { for (unsigned int y = 0; y < height - 1; ++y) {
for (unsigned int x = 0; x < width - 1; ++x, ++pcFaceOut) { for (unsigned int x = 0; x < width - 1; ++x, ++pcFaceOut) {
pcFaceOut->mNumIndices = 4; pcFaceOut->mNumIndices = 4;
pcFaceOut->mIndices = new unsigned int[4]; pcFaceOut->mIndices = new unsigned int[4];
if ((y * width + x + 1) >= upperBound){
continue;
}
ai_assert(upperBound
*pcVertOut++ = pcMesh->mVertices[y * width + x]; *pcVertOut++ = pcMesh->mVertices[y * width + x];
*pcVertOut++ = pcMesh->mVertices[(y + 1) * width + x]; *pcVertOut++ = pcMesh->mVertices[(y + 1) * width + x];
*pcVertOut++ = pcMesh->mVertices[(y + 1) * width + x + 1]; *pcVertOut++ = pcMesh->mVertices[(y + 1) * width + x + 1];