| 1642 | } |
| 1643 | |
| 1644 | void CEditor::DoQuadPoint(int LayerIndex, const std::shared_ptr<CLayerQuads> &pLayer, CQuad *pQuad, int QuadIndex, int V) |
| 1645 | { |
| 1646 | const void *pId = &pQuad->m_aPoints[V]; |
| 1647 | const vec2 Center = vec2(fx2f(pQuad->m_aPoints[V].x), fx2f(pQuad->m_aPoints[V].y)); |
| 1648 | const bool IgnoreGrid = Input()->AltIsPressed(); |
| 1649 | |
| 1650 | // draw selection background |
| 1651 | if(Map()->IsQuadPointSelected(QuadIndex, V)) |
| 1652 | { |
| 1653 | Graphics()->SetColor(0, 0, 0, 1); |
| 1654 | IGraphics::CQuadItem QuadItem(Center.x, Center.y, 7.0f * m_MouseWorldScale, 7.0f * m_MouseWorldScale); |
| 1655 | Graphics()->QuadsDraw(&QuadItem, 1); |
| 1656 | } |
| 1657 | |
| 1658 | enum |
| 1659 | { |
| 1660 | OP_NONE = 0, |
| 1661 | OP_SELECT, |
| 1662 | OP_MOVEPOINT, |
| 1663 | OP_MOVEUV, |
| 1664 | OP_CONTEXT_MENU |
| 1665 | }; |
| 1666 | |
| 1667 | static int s_Operation = OP_NONE; |
| 1668 | static vec2 s_MouseStart = vec2(0.0f, 0.0f); |
| 1669 | static CPoint s_OriginalPoint; |
| 1670 | static std::vector<SAlignmentInfo> s_Alignments; // Alignments |
| 1671 | static ivec2 s_LastOffset; |
| 1672 | |
| 1673 | auto &&GetDragOffset = [&]() -> ivec2 { |
| 1674 | vec2 Pos = Ui()->MouseWorldPos(); |
| 1675 | if(MapView()->MapGrid()->IsEnabled() && !IgnoreGrid) |
| 1676 | { |
| 1677 | MapView()->MapGrid()->SnapToGrid(Pos); |
| 1678 | } |
| 1679 | return ivec2(f2fx(Pos.x) - s_OriginalPoint.x, f2fx(Pos.y) - s_OriginalPoint.y); |
| 1680 | }; |
| 1681 | |
| 1682 | if(Ui()->CheckActiveItem(pId)) |
| 1683 | { |
| 1684 | if(m_MouseDeltaWorld != vec2(0.0f, 0.0f)) |
| 1685 | { |
| 1686 | if(s_Operation == OP_SELECT) |
| 1687 | { |
| 1688 | if(length_squared(s_MouseStart - Ui()->MousePos()) > 20.0f) |
| 1689 | { |
| 1690 | if(!Map()->IsQuadPointSelected(QuadIndex, V)) |
| 1691 | Map()->SelectQuadPoint(QuadIndex, V); |
| 1692 | |
| 1693 | if(Input()->ShiftIsPressed()) |
| 1694 | { |
| 1695 | s_Operation = OP_MOVEUV; |
| 1696 | Ui()->EnableMouseLock(pId); |
| 1697 | } |
| 1698 | else |
| 1699 | { |
| 1700 | s_Operation = OP_MOVEPOINT; |
| 1701 | // Save original positions before moving |
nothing calls this directly
no test coverage detected