Skip to content

Commit

Permalink
Fix NifFile::DeleteVertsForShape not updating other blocks with all v…
Browse files Browse the repository at this point in the history
…erts deleted

When deleting all vertices using NifFile::DeleteVertsForShape, the vertex data wasn't removed from other blocks like partitions and skin data.
  • Loading branch information
ousnius committed Sep 28, 2024
1 parent bfe6567 commit a6bbbeb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/NifFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4117,12 +4117,14 @@ bool NifFile::DeleteVertsForShape(NiShape* shape, const std::vector<uint16_t>& i
if (!shape)
return false;

bool allVertsDeleted = false;

auto geomData = hdr.GetBlock<NiTriBasedGeomData>(shape->DataRef());
if (geomData) {
geomData->notifyVerticesDelete(indices);
if (geomData->GetNumVertices() == 0 || geomData->GetNumTriangles() == 0) {
// Deleted all verts or tris
return true;
allVertsDeleted = true;
}
}

Expand All @@ -4131,7 +4133,7 @@ bool NifFile::DeleteVertsForShape(NiShape* shape, const std::vector<uint16_t>& i
bsTriShape->notifyVerticesDelete(indices);
if (bsTriShape->GetNumVertices() == 0 || bsTriShape->GetNumTriangles() == 0) {
// Deleted all verts or tris
return true;
allVertsDeleted = true;
}
}

Expand Down Expand Up @@ -4182,7 +4184,7 @@ bool NifFile::DeleteVertsForShape(NiShape* shape, const std::vector<uint16_t>& i
}
}

return false;
return allVertsDeleted;
}

int NifFile::CalcShapeDiff(NiShape* shape,
Expand Down

0 comments on commit a6bbbeb

Please sign in to comment.