Skip to content

Commit

Permalink
fix damaged cells
Browse files Browse the repository at this point in the history
  • Loading branch information
averrin committed Sep 10, 2017
1 parent aabe3f3 commit b901876
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/MapGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,12 @@ int MapGenerator::getRelax() {
return _relax;
}

bool damagedCell(Cell* c)
{
// return c->discarded;
return c->pointIntersection(c->site.p.x, c->site.p.y) == -1;
}

void MapGenerator::regenDiagram() {
currentOperation = "Making nothing...";
_bbox = sf::Rect<double>(0,0,_w, _h);
Expand All @@ -645,9 +651,15 @@ void MapGenerator::regenDiagram() {
currentOperation = "Relaxing...";
makeRelax();
}

while (std::count_if(_diagram->cells.begin(), _diagram->cells.end(), damagedCell) != 0) {
_relax++;
makeRelax();
}
delete _sites;

std::sort(_diagram->cells.begin(), _diagram->cells.end(), cellsOrdered);
std::cout << "Diagram generation finished: " << _pointsCount << "\n" << std::flush;
std::cout << "Diagram generation finished: " << _diagram->cells.size() << "\n" << std::flush;
}

void MapGenerator::genRandomSites(std::vector<sf::Vector2<double>>& sites, sf::Rect<double>& bbox, unsigned int dx, unsigned int dy, unsigned int numSites) {
Expand Down
3 changes: 3 additions & 0 deletions src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ class Application {
void drawInfo() {
sf::Vector2<float> pos = window->mapPixelToCoords(sf::Mouse::getPosition(*window));
Region* currentRegion = mapgen->getRegion(pos);
if (currentRegion == nullptr) {
return;
}
// char p[100];
// sprintf(p,"%p\n",currentRegion);
// std::cout<<p<<std::flush;
Expand Down

0 comments on commit b901876

Please sign in to comment.