Hi guys, I'm getting a segfault and I don't really understand why.. Here is the code
n, i, quadcount, quadPerVert and quadindex are all (arrays of) unsigned integers.
unsigned int *quadsPerVert = new unsigned int[quadcount * 4];
//(...)
vector<vector<unsigned int> > quadsPerVertIndex;
quadsPerVertIndex.reserve(quadcount * 4);
for (n = 0; n < quadcount * 4; n++) {
//find vertex with >= 2 quads
if (quadsPerVert[n] >= 2) {
for (i = 0; i < quadcount * 4; i++) {
if ((unsigned int)quadindex[i] == n) {
quadsPerVertIndex[n].push_back(i/4); //it segfaults here
}
}
}
}
I'm guessing that quadPerVertIndex[n] doesn't exist yet, but how can that be when I reserved it? And how would I fix this? I've looked at the vector methods, but I don't understand why this doesn't work.
TIA,
Nick