www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 70a210018b1edbf46a2f629ccfcd01cbd6789fec
parent 35181a4b2d16674530dcaf954bceeb32a3f5d8a9
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date:   Wed, 21 Dec 2011 18:34:32 +0100

Nettoyage rapide de quelques classes.

Diffstat:
Mrules/batiment/batimentquadmaisonblock.cpp | 12------------
Mrules/batiment/batimentquadmaisonblock.hh | 2--
Mrules/batiment/batimentquadmaisonpont.cpp | 73++++++++++++++++++++++++++++++-------------------------------------------
Mrules/batiment/batimentquadmaisonpont.hh | 7+------
Mrules/batiment/batimentquadpont.cpp | 65++++++++++++++++++++++++++---------------------------------------
Mrules/batiment/batimentquadpont.hh | 7+------
Mrules/terrain/terrainquadherbe.cpp | 1-
7 files changed, 58 insertions(+), 109 deletions(-)

diff --git a/rules/batiment/batimentquadmaisonblock.cpp b/rules/batiment/batimentquadmaisonblock.cpp @@ -1,8 +1,5 @@ #include "all_includes.hh" -BatimentQuadMaisonBlock::BatimentQuadMaisonBlock() { -} - BatimentQuadMaisonBlock::BatimentQuadMaisonBlock(Vertex ne, Vertex se, Vertex sw, Vertex nw, int height) : Chose() { addEntropy(ne, se, sw, nw); lctr = Vertex(ne.x-nw.x,se.y-ne.y,0.0f); @@ -11,7 +8,6 @@ BatimentQuadMaisonBlock::BatimentQuadMaisonBlock(Vertex ne, Vertex se, Vertex sw this-> sw = sw-lctr; this->nw = nw-lctr; this->height = height; - triangulation(); } BatimentQuadMaisonBlock::~BatimentQuadMaisonBlock() { @@ -27,14 +23,6 @@ bool BatimentQuadMaisonBlock::split() { return false; } -bool BatimentQuadMaisonBlock::merge() { - for(unsigned int i = 0; i < children.size(); i++) - delete(children[i]); - children.clear(); - triangles.clear(); - return true; -} - void BatimentQuadMaisonBlock::triangulation() { //triangles.reserve(2); Vertex seh = se + Vertex(0,0,height); diff --git a/rules/batiment/batimentquadmaisonblock.hh b/rules/batiment/batimentquadmaisonblock.hh @@ -14,11 +14,9 @@ class BatimentQuadMaisonBlock : public Chose { public : - BatimentQuadMaisonBlock(); BatimentQuadMaisonBlock(Vertex ne, Vertex se, Vertex sw, Vertex nw, int height); virtual ~BatimentQuadMaisonBlock(); virtual bool split(); - virtual bool merge(); virtual void triangulation(); Chose* factory(int seed, int n, Vertex ne, Vertex se, Vertex sw, Vertex nw); virtual void getBoundingBoxPoints(); diff --git a/rules/batiment/batimentquadmaisonpont.cpp b/rules/batiment/batimentquadmaisonpont.cpp @@ -1,17 +1,12 @@ #include "all_includes.hh" -BatimentQuadMaisonPont::BatimentQuadMaisonPont() { -} - BatimentQuadMaisonPont::BatimentQuadMaisonPont(Vertex ne, Vertex se, Vertex sw, Vertex nw, int height) : Chose() { addEntropy(ne, se, sw, nw); - lctr = Vertex(ne.x-nw.x,se.y-ne.y,0.0f); - this->ne = ne-lctr; - this->se = se-lctr; - this-> sw = sw-lctr; - this->nw = nw-lctr; + c[NE] = ne; + c[SE] = se; + c[SW] = sw; + c[NW] = nw; this->height = height; - triangulation(); } BatimentQuadMaisonPont::~BatimentQuadMaisonPont() { @@ -25,7 +20,7 @@ void BatimentQuadMaisonPont::getBoundingBoxPoints() { bool BatimentQuadMaisonPont::split() { - Quad q = Quad(ne,se,sw,nw); + Quad q = Quad(c[NE],c[SE],c[SW],c[NW]); q.makeParallelogram(); if(Segment(q.corner[0],q.corner[3]).length() < Segment(q.corner[0],q.corner[1]).length()) q = Quad(q.corner[1],q.corner[2],q.corner[3],q.corner[0]); @@ -40,33 +35,33 @@ bool BatimentQuadMaisonPont::split() { qc.offset(E, -partLength); qc.offset(W, -partLength); - se = lctr+qa.corner[0]; - sw = lctr+qa.corner[1]; - nw = lctr+qa.corner[2]; - ne = lctr+qa.corner[3]; + c[SE] = qa.corner[0]; + c[SW] = qa.corner[1]; + c[NW] = qa.corner[2]; + c[NE] = qa.corner[3]; - addChild(new BatimentQuadMaisonBlock(ne,se,sw,nw,partHeight)); + addChild(new BatimentQuadMaisonBlock(c[NE],c[SE],c[SW],c[NW],partHeight)); - se = lctr+qb.corner[0]; - sw = lctr+qb.corner[1]; - nw = lctr+qb.corner[2]; - ne = lctr+qb.corner[3]; + c[SE] = qb.corner[0]; + c[SW] = qb.corner[1]; + c[NW] = qb.corner[2]; + c[NE] = qb.corner[3]; - addChild(new BatimentQuadMaisonBlock(ne,se,sw,nw,partHeight)); + addChild(new BatimentQuadMaisonBlock(c[NE],c[SE],c[SW],c[NW],partHeight)); - se = lctr+qh.corner[0] + Vertex(0,0,partHeight); - sw = lctr+qh.corner[1] + Vertex(0,0,partHeight); - nw = lctr+qh.corner[2] + Vertex(0,0,partHeight); - ne = lctr+qh.corner[3] + Vertex(0,0,partHeight); + c[SE] = qh.corner[0] + Vertex(0,0,partHeight); + c[SW] = qh.corner[1] + Vertex(0,0,partHeight); + c[NW] = qh.corner[2] + Vertex(0,0,partHeight); + c[NE] = qh.corner[3] + Vertex(0,0,partHeight); - addChild(new BatimentQuadMaisonBlock(ne,se,sw,nw,partHeight)); + addChild(new BatimentQuadMaisonBlock(c[NE],c[SE],c[SW],c[NW],partHeight)); - se = lctr+qc.corner[0]; - sw = lctr+qc.corner[1]; - nw = lctr+qc.corner[2]; - ne = lctr+qc.corner[3]; + c[SE] = qc.corner[0]; + c[SW] = qc.corner[1]; + c[NW] = qc.corner[2]; + c[NE] = qc.corner[3]; - addChild(new BatimentQuadPont(se,sw,nw,ne,partHeight)); + addChild(new BatimentQuadPont(c[SE],c[SW],c[NW],c[NE],partHeight)); /* Vertex seh = qh.corner[0] + Vertex(0,0,partHeight); Vertex swh = qh.corner[1] + Vertex(0,0,partHeight); @@ -85,23 +80,15 @@ bool BatimentQuadMaisonPont::split() { return true; } -bool BatimentQuadMaisonPont::merge() { - for(unsigned int i = 0; i < children.size(); i++) - delete(children[i]); - children.clear(); - triangles.clear(); - return true; -} - void BatimentQuadMaisonPont::triangulation() { //triangles.reserve(2); float h = 2.5*height/3.; - Vertex seh = se + Vertex(0,0,h); - Vertex swh = sw + Vertex(0,0,h); - Vertex nwh = nw + Vertex(0,0,h); - Vertex neh = ne + Vertex(0,0,h); + Vertex seh = c[SE] + Vertex(0,0,h); + Vertex swh = c[SW] + Vertex(0,0,h); + Vertex nwh = c[NW] + Vertex(0,0,h); + Vertex neh = c[NE] + Vertex(0,0,h); - addOcto(ne,se,sw,nw,neh,seh,swh,nwh,0xDD,0xDD,0xDD); + addOcto(c[NE],c[SE],c[SW],c[NW],neh,seh,swh,nwh,0xDD,0xDD,0xDD); Vertex ce = seh + (neh - seh)/2 + Vertex(0,0,0.5*height/3.); Vertex cw = swh + (nwh - swh)/2 + Vertex(0,0,0.5*height/3.); diff --git a/rules/batiment/batimentquadmaisonpont.hh b/rules/batiment/batimentquadmaisonpont.hh @@ -6,19 +6,14 @@ // RectangleRoutes est un quadrilatère de routes avec des angles aux coins égaux à 90°. class BatimentQuadMaisonPont: public Chose { private : - Vertex ne; - Vertex se; - Vertex sw; - Vertex nw; + Vertex c[4]; int height; public : - BatimentQuadMaisonPont(); BatimentQuadMaisonPont(Vertex ne, Vertex se, Vertex sw, Vertex nw, int height); virtual ~BatimentQuadMaisonPont(); virtual bool split(); - virtual bool merge(); virtual void triangulation(); Chose* factory(int seed, int n, Vertex ne, Vertex se, Vertex sw, Vertex nw); virtual void getBoundingBoxPoints(); diff --git a/rules/batiment/batimentquadpont.cpp b/rules/batiment/batimentquadpont.cpp @@ -1,17 +1,12 @@ #include "all_includes.hh" -BatimentQuadPont::BatimentQuadPont() { -} - BatimentQuadPont::BatimentQuadPont(Vertex ne, Vertex se, Vertex sw, Vertex nw, int height) : Chose() { addEntropy(ne, se, sw, nw); - lctr = Vertex(ne.x-nw.x,se.y-ne.y,0.0f); - this->ne = ne-lctr; - this->se = se-lctr; - this-> sw = sw-lctr; - this->nw = nw-lctr; + c[NE] = ne; + c[SE] = se; + c[SW] = sw; + c[NW] = nw; this->height = height; - triangulation(); } BatimentQuadPont::~BatimentQuadPont() { @@ -27,14 +22,6 @@ bool BatimentQuadPont::split() { return true; } -bool BatimentQuadPont::merge() { - for(unsigned int i = 0; i < children.size(); i++) - delete(children[i]); - children.clear(); - triangles.clear(); - return true; -} - float ct(float x) { return -(1.*cosh(x/1.))+1; } @@ -46,17 +33,17 @@ float nt(double x, int height) { void BatimentQuadPont::triangulation() { //triangles.reserve(2); float var; - Quad q = Quad(ne,se,sw,nw); + Quad q = Quad(c[NE],c[SE],c[SW],c[NW]); Vertex a,b; height -= 20; - Vertex pa = nw; - Vertex pb = sw; - Vertex neh = ne + Vertex(0,0,height+20); - Vertex seh = se + Vertex(0,0,height+20); - Vertex swh = sw + Vertex(0,0,height+20); - Vertex nwh = nw + Vertex(0,0,height+20); - Vertex l1 = ne - nw; - Vertex l2 = sw - se; + Vertex pa = c[NW]; + Vertex pb = c[SW]; + Vertex neh = c[NE] + Vertex(0,0,height+20); + Vertex seh = c[SE] + Vertex(0,0,height+20); + Vertex swh = c[SW] + Vertex(0,0,height+20); + Vertex nwh = c[NW] + Vertex(0,0,height+20); + Vertex l1 = c[NE] - c[NW]; + Vertex l2 = c[SW] - c[SE]; float pas = 0.1; int steps = (2*1.7/pas); @@ -65,35 +52,35 @@ void BatimentQuadPont::triangulation() { int middle = steps/2; int n; - addTriangle(new Triangle(lctr+pb,lctr+sw,lctr+swh,0xD0,0xD0,0xD0)); - addTriangle(new Triangle(lctr+pa,lctr+nw,lctr+nwh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(pb,c[SW],swh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(pa,c[NW],nwh,0xD0,0xD0,0xD0)); for(var=-1.7,n=0; var <= 1.7; var+=pas,n++) { q.offset(W,-n2); a = q.corner[3] + Vertex(0,0,nt(var,height)); b = q.corner[2] + Vertex(0,0,nt(var,height)); - addQuad(lctr+b,lctr+a,lctr+pa,lctr+pb,0xD0,0xD0,0xD0); + addQuad(b,a,pa,pb,0xD0,0xD0,0xD0); if( n < middle) { - addTriangle(new Triangle(lctr+a,lctr+pa,lctr+nwh,0xD0,0xD0,0xD0)); - addTriangle(new Triangle(lctr+pb,lctr+b,lctr+swh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(a,pa,nwh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(pb,b,swh,0xD0,0xD0,0xD0)); } else if(n == middle) { - addTriangle(new Triangle(lctr+a,lctr+pa,lctr+nwh,0xD0,0xD0,0xD0)); - addTriangle(new Triangle(lctr+pb,lctr+b,lctr+swh,0xD0,0xD0,0xD0)); - addTriangle(new Triangle(lctr+a,lctr+nwh,lctr+neh,0xD0,0xD0,0xD0)); - addTriangle(new Triangle(lctr+b,lctr+seh,lctr+swh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(a,pa,nwh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(pb,b,swh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(a,nwh,neh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(b,seh,swh,0xD0,0xD0,0xD0)); } else { - addTriangle(new Triangle(lctr+a,lctr+pa,lctr+neh,0xD0,0xD0,0xD0)); - addTriangle(new Triangle(lctr+pb,lctr+b,lctr+seh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(a,pa,neh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(pb,b,seh,0xD0,0xD0,0xD0)); } pa = a; pb = b; } - addTriangle(new Triangle(lctr+se,lctr+pb,lctr+seh,0xD0,0xD0,0xD0)); - addTriangle(new Triangle(lctr+ne,lctr+pa,lctr+neh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(c[SE],pb,seh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(c[NE],pa,neh,0xD0,0xD0,0xD0)); } diff --git a/rules/batiment/batimentquadpont.hh b/rules/batiment/batimentquadpont.hh @@ -6,19 +6,14 @@ // RectangleRoutes est un quadrilatère de routes avec des angles aux coins égaux à 90°. class BatimentQuadPont: public Chose { private : - Vertex ne; - Vertex se; - Vertex sw; - Vertex nw; + Vertex c[4]; int height; public : - BatimentQuadPont(); BatimentQuadPont(Vertex ne, Vertex se, Vertex sw, Vertex nw, int height); virtual ~BatimentQuadPont(); virtual bool split(); - virtual bool merge(); virtual void triangulation(); Chose* factory(int seed, int n, Vertex ne, Vertex se, Vertex sw, Vertex nw); virtual void getBoundingBoxPoints(); diff --git a/rules/terrain/terrainquadherbe.cpp b/rules/terrain/terrainquadherbe.cpp @@ -31,7 +31,6 @@ TerrainQuadHerbe::TerrainQuadHerbe(int red, Vertex ne, Vertex se, Vertex sw, Ver corner[SE] = se; corner[SW] = sw; corner[NW] = nw; - triangulation(); } bool TerrainQuadHerbe::split() {