commit 5a91abe732b2b7e8aafa9ad58b7b7406cc412c11
parent bf7ecfa18a07d31ff0387a5284551d0b19d1d01b
Author: Yoann <yoann.b87@voila.fr>
Date: Wed, 14 Dec 2011 19:25:20 +0100
Ajout d'une fonction d'offset globale et non individuelle.
Diffstat:
5 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/quad.cpp b/quad.cpp
@@ -15,6 +15,13 @@ void Quad::offset(Cardinal side, int offset) {
corner[NW + side] = corner[NW + side] + voffset.projectOn(corner[NW + side]-corner[SW + side]);
}
+void Quad::offsetNESW(int offsetN, int offsetE, int offsetS, int offsetW) {
+ this->offset(N,offsetN);
+ this->offset(E,offsetE);
+ this->offset(S,offsetS);
+ this->offset(W,offsetW);
+}
+
int Quad::minLengthNS() {
return std::min(
Segment(corner[NW],corner[NE]).length(),
diff --git a/quad.hh b/quad.hh
@@ -12,6 +12,7 @@ class Quad {
Quad();
Quad(Vertex ne, Vertex se, Vertex sw, Vertex nw);
void offset(Cardinal side, int offset);
+ void offsetNESW(int offsetN, int offsetE, int offsetS, int offsetW);
int minLengthNS();
int minLengthEW();
int maxLengthNS();
diff --git a/rules/batiment/batimentquad.cpp b/rules/batiment/batimentquad.cpp
@@ -1,13 +1,16 @@
#include "all_includes.hh"
-BatimentQuad::BatimentQuad(Vertex ne, Vertex se, Vertex sw, Vertex nw/*, Cardinal door*/) : Chose(), ne(ne), se(se), sw(sw), nw(nw) {
+BatimentQuad::BatimentQuad(Vertex ne, Vertex se, Vertex sw, Vertex nw, Cardinal entry) : Chose(), ne(ne) {
addEntropy(ne, se, sw, nw);
- //this->door = door;
+ this->ne = ne;
+ this->se = se;
+ this-> sw = sw;
+ this->nw = nw;
+ this->entry = entry;
triangulation();
}
int BatimentQuad::width() { return this->ne.x - this->sw.x; }
-
int BatimentQuad::height() { return this->ne.y - this->sw.y; }
std::vector<Vertex*> BatimentQuad::getBoundingBoxPoints() const {
@@ -42,10 +45,7 @@ Chose* BatimentQuad::factory(int seed, int n, Vertex ne, Vertex se, Vertex sw, V
addChild(new BatimentQuadJardin(q.corner[0],q.corner[1],q.corner[2],q.corner[3]));
- q.offset(N,-100);
- q.offset(E,-100);
- q.offset(S,-400);
- q.offset(W,-100);
+ q.offset(this->entry,-400);
addChild(new BatimentQuadMaison(q.corner[0],q.corner[1],q.corner[2],q.corner[3]));
return NULL; // pour compilation, à virer.
diff --git a/rules/batiment/batimentquad.hh b/rules/batiment/batimentquad.hh
@@ -10,13 +10,13 @@ class BatimentQuad : public Chose {
Vertex se;
Vertex sw;
Vertex nw;
- Cardinal door;
+ Cardinal entry;
public :
static const int minHeight = 400;
static const int maxHeight = 800;
- BatimentQuad(Vertex ne, Vertex se, Vertex sw, Vertex nw/*, Cardinal door*/);
+ BatimentQuad(Vertex ne, Vertex se, Vertex sw, Vertex nw, Cardinal door);
int width();
int height();
virtual bool subdivide();
diff --git a/rules/quartier/quartierquad.cpp b/rules/quartier/quartierquad.cpp
@@ -24,7 +24,7 @@ Chose* QuartierQuad::factory(int seed, int n, Vertex ne, Vertex se, Vertex sw, V
if (!big && proba(seed, n, 1, 20)) {
return new TerrainQuadHerbe(ne, se, sw, nw);
} else if (small && anglesAcceptable) {
- return new BatimentQuad(ne, se, sw, nw);
+ return new BatimentQuad(ne, se, sw, nw, N);
} else if (!small && !anglesOk) {
return new QuartierQuadAngle(ne, se, sw, nw);
} else if (!small && tooWideY) {