Shuffling the indices of an ofMesh in update

I might be phrasing that poorly, but what I have is a point cloud, and using OF_PRIMITIVE_LINES, I just want to have the points stay in place, but all of the lines shuffle upon a keypress. What might be the first step of going about this?


Hi there!

You could simply apply a Fisher-Yates shuffle to the indices. Something like this:

for (int i = mesh.getNumIndices() - 1; i >= 0; i --) {
    int index = (int)ofRandom(i);
    int tempIndex = mesh.getIndex(index);
    mesh.setIndex(index, mesh.getIndex(i));
    mesh.setIndex(i, tempIndex);

This is perfect, thank you!