Page 1 of 1

Move selected Bodies to cursor position.

Posted: Tue Mar 05, 2013 1:42 pm
by dAlex65
See the title ;)

Re: Move selected Bodies to cursor position.

Posted: Tue Mar 05, 2013 2:45 pm
by iforce2d
aha... there is something in Blender a bit like this, I think it's called 'Selection to cursor', so it's the reverse of the 'Cursor to selection'.

I was thinking of adding it someday, but in Blender it moves the selection as a whole to the cursor. In RUBE the selection is the white cross shown when more than one item is selected. So 'Selection to cursor' would move all the bodies so that the white cross moves to the cursor, which I think is a bit more useful than clumping all selected bodies at the same place. The white cross is simply the average of the currently selected body positions. I will add this eventually, but if you feel like doing it don't let me stop you :D

Re: Move selected Bodies to cursor position.

Posted: Thu Apr 11, 2013 2:53 pm
by dAlex65
Align one axis. Use cursor position too, but adjust Y or X, and move selected bodies to horizontal or vertical line.

Code: Select all

vec2 pb = getCursor();
body[] sb = getSelectedBodies();

int n = sb.length;
for (int i = 0; i < n; i++) {
  sb[i].setPos(pb.x, sb[i].pos.y);
}

Code: Select all

vec2 pb = getCursor();
body[] sb = getSelectedBodies();

int n = sb.length;
for (int i = 0; i < n; i++) {
  sb[i].setPos(sb[i].pos.x, pb.y);
}