#include "stdafx.h" #include "clumpplacer.h" #include "random.h" using namespace std; ClumpPlacer::ClumpPlacer(float size, float coherence, float smoothness, int x, int y) { this->size = size; this->coherence = coherence; this->smoothness = smoothness; this->x = x; this->y = y; } ClumpPlacer::~ClumpPlacer() { } bool ClumpPlacer::place(class Map* m, Constraint* constr, std::vector& ret) { if(!m->validT(x, y) || !constr->allows(m, x, y)) { return false; } float radius = sqrt(size / PI); float perim = 3 * radius * 2 * PI; int intPerim = (int)(ceil(perim)); vector noise(intPerim); //cout << "Starting with s=" << smoothness << ", p=" << perim << endl; //cout << "Ctrl Vals: " << endl; int ctrlPts = 1 + (int)(1.0/max(smoothness,1.0f/intPerim)); if(ctrlPts > radius * 2 * PI) ctrlPts = (int) (radius * 2 * PI) + 1; vector ctrlCoords(ctrlPts+1); vector ctrlVals(ctrlPts+1); for(int i=0; ivalidT(i, j) && constr->allows(m, i, j)) { ret.push_back(Point(i, j)); } else { failed++; } xx += s; yy += c; } } return failed > 0 ? false : true; /*if(m->validT(x,y)) { ret.push_back(Point(x,y)); } else { return false; } return true;*/ }