diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index d7847f472..df7b0c2bb 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1469,14 +1469,13 @@ void CEditor::DoQuad(CQuad *pQuad, int Index) } else if(s_Operation == OP_MOVE_ALL) { - CLayerQuads *pLayer = (CLayerQuads *)GetSelectedLayerType(0, LAYERTYPE_QUADS); + float x = wx; + float y = wy; // move all points including pivot if(m_GridActive && !IgnoreGrid) { int LineDistance = GetLineDistance(); - float x = 0.0f; - float y = 0.0f; if(wx >= 0) x = (int)((wx + (LineDistance / 2) * m_GridFactor) / (LineDistance * m_GridFactor)) * (LineDistance * m_GridFactor); else @@ -1485,33 +1484,19 @@ void CEditor::DoQuad(CQuad *pQuad, int Index) y = (int)((wy + (LineDistance / 2) * m_GridFactor) / (LineDistance * m_GridFactor)) * (LineDistance * m_GridFactor); else y = (int)((wy - (LineDistance / 2) * m_GridFactor) / (LineDistance * m_GridFactor)) * (LineDistance * m_GridFactor); - - int OffsetX = f2fx(x) - pQuad->m_aPoints[4].x; - int OffsetY = f2fx(y) - pQuad->m_aPoints[4].y; - - for(auto &Selected : m_vSelectedQuads) - { - CQuad *pCurrentQuad = &pLayer->m_vQuads[Selected]; - for(auto &Point : pCurrentQuad->m_aPoints) - { - Point.x += OffsetX; - Point.y += OffsetY; - } - } } - else - { - int OffsetX = f2fx(wx) - pQuad->m_aPoints[4].x; - int OffsetY = f2fx(wy) - pQuad->m_aPoints[4].y; - for(auto &Selected : m_vSelectedQuads) + int OffsetX = f2fx(x) - pQuad->m_aPoints[4].x; + int OffsetY = f2fx(y) - pQuad->m_aPoints[4].y; + + CLayerQuads *pLayer = (CLayerQuads *)GetSelectedLayerType(0, LAYERTYPE_QUADS); + for(auto &Selected : m_vSelectedQuads) + { + CQuad *pCurrentQuad = &pLayer->m_vQuads[Selected]; + for(auto &Point : pCurrentQuad->m_aPoints) { - CQuad *pCurrentQuad = &pLayer->m_vQuads[Selected]; - for(auto &Point : pCurrentQuad->m_aPoints) - { - Point.x += OffsetX; - Point.y += OffsetY; - } + Point.x += OffsetX; + Point.y += OffsetY; } } } @@ -1700,13 +1685,12 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) { if(s_Operation == OP_MOVEPOINT) { - CLayerQuads *pLayer = (CLayerQuads *)GetSelectedLayerType(0, LAYERTYPE_QUADS); + float x = wx; + float y = wy; if(m_GridActive && !IgnoreGrid) { int LineDistance = GetLineDistance(); - float x = 0.0f; - float y = 0.0f; if(wx >= 0) x = (int)((wx + (LineDistance / 2) * m_GridFactor) / (LineDistance * m_GridFactor)) * (LineDistance * m_GridFactor); else @@ -1715,35 +1699,22 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) y = (int)((wy + (LineDistance / 2) * m_GridFactor) / (LineDistance * m_GridFactor)) * (LineDistance * m_GridFactor); else y = (int)((wy - (LineDistance / 2) * m_GridFactor) / (LineDistance * m_GridFactor)) * (LineDistance * m_GridFactor); - - int OffsetX = f2fx(x) - pQuad->m_aPoints[V].x; - int OffsetY = f2fx(y) - pQuad->m_aPoints[V].y; - - for(auto &Selected : m_vSelectedQuads) - { - CQuad *pCurrentQuad = &pLayer->m_vQuads[Selected]; - for(int m = 0; m < 4; m++) - if(m_SelectedPoints & (1 << m)) - { - pCurrentQuad->m_aPoints[m].x += OffsetX; - pCurrentQuad->m_aPoints[m].y += OffsetY; - } - } } - else - { - int OffsetX = f2fx(wx) - pQuad->m_aPoints[V].x; - int OffsetY = f2fx(wy) - pQuad->m_aPoints[V].y; - for(auto &Selected : m_vSelectedQuads) + int OffsetX = f2fx(x) - pQuad->m_aPoints[V].x; + int OffsetY = f2fx(y) - pQuad->m_aPoints[V].y; + + CLayerQuads *pLayer = (CLayerQuads *)GetSelectedLayerType(0, LAYERTYPE_QUADS); + for(auto &Selected : m_vSelectedQuads) + { + CQuad *pCurrentQuad = &pLayer->m_vQuads[Selected]; + for(int m = 0; m < 4; m++) { - CQuad *pCurrentQuad = &pLayer->m_vQuads[Selected]; - for(int m = 0; m < 4; m++) - if(m_SelectedPoints & (1 << m)) - { - pCurrentQuad->m_aPoints[m].x += OffsetX; - pCurrentQuad->m_aPoints[m].y += OffsetY; - } + if(m_SelectedPoints & (1 << m)) + { + pCurrentQuad->m_aPoints[m].x += OffsetX; + pCurrentQuad->m_aPoints[m].y += OffsetY; + } } } }