Moved distance limiting code to a smarter location, refactored related code

This commit is contained in:
2011-06-22 23:06:23 -04:00
parent 1606dfb058
commit ecb16a4b5c
4 changed files with 13 additions and 23 deletions

View File

@ -4,6 +4,7 @@
using std::abs;
int Graph::MAX_MOVE_DISTANCE = 100;
Graph::Graph()
{
@ -75,10 +76,11 @@ void Graph::select_vertex(int x, int y)
void Graph::add_vertex(int x, int y, int size)
{
Vertex* v = new Vertex();
v->x = x;
v->y = y;
if (current_vertex != NULL &&
(Vertex::distance(*current_vertex, Vertex(x, y)) > MAX_MOVE_DISTANCE))
return;
Vertex* v = new Vertex(x, y);
v->x_min = x - size/2;
v->x_max = x + size/2;
v->y_min = y - size/2;