diff options
| author | oy <Tom_Adams@web.de> | 2011-08-04 23:34:29 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-08-05 19:52:37 +0200 |
| commit | e5395f00b39b6a7e1beca405c33c6155e83d3b5a (patch) | |
| tree | 76d1311470e366cdfc9859c38095cf43e1c2fa18 /src/game/editor | |
| parent | fee2c2c45207df99d6908059ec06b0d8b5ec272c (diff) | |
| download | zcatch-e5395f00b39b6a7e1beca405c33c6155e83d3b5a.tar.gz zcatch-e5395f00b39b6a7e1beca405c33c6155e83d3b5a.zip | |
fixed that activating a quad point doesn't align it on the grid and made moving the pivot use the grid. Closes#792
Diffstat (limited to 'src/game/editor')
| -rw-r--r-- | src/game/editor/editor.cpp | 105 |
1 files changed, 64 insertions, 41 deletions
diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 889cafdd..4dfda743 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1056,58 +1056,82 @@ void CEditor::DoQuad(CQuad *q, int Index) if(UI()->ActiveItem() == pID) { - // check if we only should move pivot - if(s_Operation == OP_MOVE_PIVOT) + if(m_MouseDeltaWx*m_MouseDeltaWx+m_MouseDeltaWy*m_MouseDeltaWy > 0.5f) { - q->m_aPoints[4].x += f2fx(wx-s_LastWx); - q->m_aPoints[4].y += f2fx(wy-s_LastWy); - } - else if(s_Operation == OP_MOVE_ALL) - { - // move all points including pivot - if(m_GridActive) + // check if we only should move pivot + if(s_Operation == OP_MOVE_PIVOT) { - int LineDistance = GetLineDistance(); + if(m_GridActive) + { + 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 - x = (int)((wx-(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); - if(wy >= 0) - y = (int)((wy+(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + 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 + x = (int)((wx-(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + if(wy >= 0) + 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); + + q->m_aPoints[4].x = f2fx(x); + q->m_aPoints[4].y = f2fx(y); + } else - y = (int)((wy-(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); - - int OldX = q->m_aPoints[4].x; - int OldY = q->m_aPoints[4].y; - q->m_aPoints[4].x = f2fx(x); - q->m_aPoints[4].y = f2fx(y); - int DiffX = q->m_aPoints[4].x - OldX; - int DiffY = q->m_aPoints[4].y - OldY; - - for(int v = 0; v < 4; v++) { - q->m_aPoints[v].x += DiffX; - q->m_aPoints[v].y += DiffY; + q->m_aPoints[4].x += f2fx(wx-s_LastWx); + q->m_aPoints[4].y += f2fx(wy-s_LastWy); } } - else + else if(s_Operation == OP_MOVE_ALL) { - for(int v = 0; v < 5; v++) + // move all points including pivot + if(m_GridActive) + { + 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 + x = (int)((wx-(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + if(wy >= 0) + 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 OldX = q->m_aPoints[4].x; + int OldY = q->m_aPoints[4].y; + q->m_aPoints[4].x = f2fx(x); + q->m_aPoints[4].y = f2fx(y); + int DiffX = q->m_aPoints[4].x - OldX; + int DiffY = q->m_aPoints[4].y - OldY; + + for(int v = 0; v < 4; v++) + { + q->m_aPoints[v].x += DiffX; + q->m_aPoints[v].y += DiffY; + } + } + else { - q->m_aPoints[v].x += f2fx(wx-s_LastWx); - q->m_aPoints[v].y += f2fx(wy-s_LastWy); + for(int v = 0; v < 5; v++) + { + q->m_aPoints[v].x += f2fx(wx-s_LastWx); + q->m_aPoints[v].y += f2fx(wy-s_LastWy); + } } } - } - else if(s_Operation == OP_ROTATE) - { - for(int v = 0; v < 4; v++) + else if(s_Operation == OP_ROTATE) { - q->m_aPoints[v] = s_RotatePoints[v]; - Rotate(&q->m_aPoints[4], &q->m_aPoints[v], s_RotateAngle); + for(int v = 0; v < 4; v++) + { + q->m_aPoints[v] = s_RotatePoints[v]; + Rotate(&q->m_aPoints[4], &q->m_aPoints[v], s_RotateAngle); + } } } @@ -1335,7 +1359,6 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) m_SelectedPoints |= 1<<V; else m_SelectedPoints = 1<<V; - s_Moved = true; } m_SelectedQuad = QuadIndex; |