Better 2D Snapping
Consolidated duplicate snapping functions into CanvasItemEditor. Allow non-square grids. Add grid origin offsets. Allow seperate toggling of grid display. Add rotation snapping. Add offset snapping.
This commit is contained in:
parent
2185c018f6
commit
e2c8aecb3d
13 changed files with 294 additions and 254 deletions
|
|
@ -69,17 +69,6 @@ void Polygon2DEditor::_node_removed(Node *p_node) {
|
|||
}
|
||||
|
||||
|
||||
Vector2 Polygon2DEditor::snap_point(const Vector2& p_point) const {
|
||||
|
||||
if (canvas_item_editor->is_snap_active()) {
|
||||
|
||||
return p_point.snapped(Vector2(1,1)*canvas_item_editor->get_snap());
|
||||
|
||||
} else {
|
||||
return p_point;
|
||||
}
|
||||
}
|
||||
|
||||
void Polygon2DEditor::_menu_option(int p_option) {
|
||||
|
||||
switch(p_option) {
|
||||
|
|
@ -201,7 +190,7 @@ bool Polygon2DEditor::forward_input_event(const InputEvent& p_event) {
|
|||
|
||||
Vector2 gpoint = Point2(mb.x,mb.y);
|
||||
Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
|
||||
cpoint=snap_point(cpoint);
|
||||
cpoint=canvas_item_editor->snap_point(cpoint);
|
||||
cpoint = node->get_global_transform().affine_inverse().xform(cpoint);
|
||||
|
||||
|
||||
|
|
@ -405,7 +394,7 @@ bool Polygon2DEditor::forward_input_event(const InputEvent& p_event) {
|
|||
|
||||
Vector2 gpoint = Point2(mm.x,mm.y);
|
||||
Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
|
||||
cpoint=snap_point(cpoint);
|
||||
cpoint=canvas_item_editor->snap_point(cpoint);
|
||||
edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint);
|
||||
|
||||
canvas_item_editor->get_viewport_control()->update();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue