Skip to content

Commit

Permalink
Removed couts, comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hansfilipelo committed May 25, 2016
1 parent ad3bb1f commit c6e34f7
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ void Utils::flood_fill(vector< vector<int> >* map, int start_x, int start_y, int
int width = map->at(0).size();
int height = map->size();

//The scanline floodfill algorithm using our own stack routines, faster
if(old_color == new_color) return;
stack.clear();

int curr_x;
bool traverse_above, traverse_below;
coord_t current_coord = {start_x, start_y};


// Push the start position on stack
stack.push_back(current_coord);

while(!stack.empty())
{
cout << "Stack length: " << stack.size() << endl;
current_coord = stack.back();
stack.pop_back();

curr_x = current_coord.x;


// Start "from left" in memory so that all writes occour in order
while(curr_x >= 0 && map->at(current_coord.y).at(curr_x) == old_color) curr_x--;

curr_x++;
traverse_above = traverse_below = false;

while(curr_x < width && map->at(current_coord.y).at(curr_x) == old_color )
{
map->at(current_coord.y).at(curr_x) = new_color;
Expand All @@ -47,7 +47,6 @@ void Utils::flood_fill(vector< vector<int> >* map, int start_x, int start_y, int
}
if(!traverse_below && current_coord.y < height - 1 && map->at(current_coord.y + 1).at(curr_x) == old_color)
{
cout << "In span below" << endl;
stack.push_back({curr_x, current_coord.y + 1});
traverse_below = true;
}
Expand Down

0 comments on commit c6e34f7

Please sign in to comment.