Set body angle to zero without moving vertices
Posted: Thu Apr 16, 2015 6:40 am
Sometimes it's necessary to set the angle of a body to zero, but leave all the vertices of the body in their current positions. This script will do that for all selected bodies:
Code: Select all
vec2 originalCursorPosition = getCursor();
body[] bs = sb();
for (uint i = 0; i < bs.length; i++) {
body b = bs[i];
setCursor( b.pos );
fixture[] fs = b.getFixtures();
for (uint k = 0; k < fs.length; k++) {
fixture f = fs[k];
rotate( f.getVertices(), 0, b.getAngle() );
}
b.setAngle( 0 );
}
setCursor( originalCursorPosition );