Code: Select all
float minDist = 0.1;
bool selectOnly = false;
fixture[] fs = sf();
for (uint i = 0; i < fs.length; i++) {
fixture f = fs[i];
vertex[] vs = f.getVertices();
uint[] indices;
for (uint k = 0; k < vs.length; k++) {
vertex v0 = vs[k];
vertex v1 = vs[ (k+1) % vs.length ];
float d = v0.pos.distanceTo( v1.pos );
if ( d < minDist ) {
indices.insertLast( k );
if ( selectOnly )
v1.select();
}
}
if ( selectOnly )
continue;
// iterate from highest to lowest to preserve index validity
uint numVerticesBefore = f.getNumVertices();
for ( int m = indices.length - 1; m >= 0; m-- )
f.deleteVertex( indices[m] );
uint removedCount = numVerticesBefore - f.getNumVertices();
if ( removedCount > 0 )
print( "Removed "+removedCount+" vertices from fixture "+f.getName() );
}