diff options
Diffstat (limited to 'ToolRotate.cpp')
-rw-r--r-- | ToolRotate.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/ToolRotate.cpp b/ToolRotate.cpp index 65bf334..d933882 100644 --- a/ToolRotate.cpp +++ b/ToolRotate.cpp @@ -21,13 +21,13 @@ void ToolRotate::activate() { editManager->setSelectedObject(NULL); } -bool ToolRotate::buttonPress(unsigned int button) { - if(button != 1 || !editManager->getHoveredObject()) +bool ToolRotate::buttonPress(unsigned int button, const Vertex *v) { + if(button != 1 || !v) return false; pressed = true; valid = false; - v0 = v = *editManager->getHoveredVertex(); + vertexRot = vertex = *v; editManager->setSelectedObject(editManager->getHoveredObject()); @@ -37,7 +37,7 @@ bool ToolRotate::buttonPress(unsigned int button) { return true; } -bool ToolRotate::buttonRelease(unsigned int button) { +bool ToolRotate::buttonRelease(unsigned int button, const Vertex *v) { if(button != 1) return false; @@ -51,22 +51,22 @@ bool ToolRotate::buttonRelease(unsigned int button) { return true; } -bool ToolRotate::motion() { +bool ToolRotate::motion(const Vertex *v, float scale) { if(!pressed) { editManager->highlightHoveredObject(); return true; } - if(!editManager->getHoveredVertex()) + if(!v) return false; - v = *editManager->getHoveredVertex(); + vertex = *v; - float a = atan2((v-v0).getY(), (v-v0).getX()); + float a = atan2((vertex-vertexRot).getY(), (vertex-vertexRot).getX()); - if(v0.distanceSq(v) > 0.04f) { + if(vertexRot.distanceSq(vertex) > (10*10)/(scale*scale)) { if(valid) - editManager->getSelectedObject()->rotate(v0, a-angle); + editManager->getSelectedObject()->rotate(vertexRot, a-angle); else valid = true; @@ -85,14 +85,14 @@ void ToolRotate::render(const Level &level, const Rectangle &rect, float scale) if(pressed && valid) { glLineWidth(1.0f); glColor4f(1.0f, 1.0f, 1.0f, 0.7f); - drawCircleDotted(v0, v0.distance(v), 64, 16, angle); + drawCircleDotted(vertexRot, vertexRot.distance(vertex), 64, 16, angle); glLineWidth(2.0f); glBegin(GL_LINES); - glVertex2f(v0.getX(), v0.getY()); - glVertex2f(v.getX(), v.getY()); + glVertex2f(vertexRot.getX(), vertexRot.getY()); + glVertex2f(vertex.getX(), vertex.getY()); glEnd(); } |