Skip to content

Commit

Permalink
Add shape reflection to Polygon2D UV editor
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoon1506 committed Mar 30, 2019
1 parent 5b00cd8 commit 4dc2ca8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion editor/plugins/polygon_2d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,11 +886,13 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
if (from_dist < 2)
break;

Vector2 rel_center = uv_drag_to - mtx.xform(center);
Vector2 reflect = Vector2((rel_center.x >= 0) ? 1 : -1, (rel_center.y >= 0) ? 1 : -1);
float scale = to_dist / from_dist;

for (int i = 0; i < uv_new.size(); i++) {
Vector2 rel = points_prev[i] - center;
rel = rel * scale;
rel = rel * scale * reflect;
uv_new.set(i, center + rel);
}

Expand Down

0 comments on commit 4dc2ca8

Please sign in to comment.