Check that all face indices of a mesh exist in the vertex array.

PiperOrigin-RevId: 532049715
Change-Id: Ic42f6ef49f136aa89fb83527db0867afa8be7f08
This commit is contained in:
Alessio Quaglino
2023-05-15 02:55:00 -07:00
committed by Copybara-Service
parent 39723891ce
commit 871a2a7c8e
+7
View File
@@ -280,6 +280,13 @@ void mjCMesh::Compile(int vfs_provider) {
throw mjCError(this, "face data must be a multiple of 3");
}
// check vertices exist
for (int i=0; i<userface.size(); i++) {
if (userface[i] >= nvert || userface[i] < 0) {
throw mjCError(this, "index in face does not exist in vertex array");
}
}
// create half-edge structure (if mesh was in XML)
if (useredge.empty()) {
for (int i=0; i<userface.size()/3; i++) {