www

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

commit 1c2a7c4270ddb7f0be67515a55b36d2dad73fce3
parent 5bdeb93442bfea801a1266bec4ee0a917a6c77f9
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date:   Wed, 18 Jan 2012 17:07:53 +0100

Correction sur la découp des bâtiments en sous-bâtiments.

Diffstat:
Mrules/architecture/batiment.cpp | 43++++++++++++++++---------------------------
Mrules/architecture/batiment.hh | 1+
2 files changed, 17 insertions(+), 27 deletions(-)

diff --git a/rules/architecture/batiment.cpp b/rules/architecture/batiment.cpp @@ -4,38 +4,27 @@ BatimentQuad_::BatimentQuad_(Quad _c) : Chose(), c(_c) { addEntropy(c); } -bool BatimentQuad_::split() { - Quad q; - - if(!isSub) - q = c >> ((c.maxLengthNS() < c.maxLengthEW()) ? 1 : 0); - else - q = c; - - int minSurface = 1000000; - - if(q.surface() > 2* minSurface) { - Vertex c1 = q[NW] + Vertex(q[NE] - q[NW])/2; - Vertex c2 = q[SW] + Vertex(q[SE] - q[SW])/2; - Quad q1 = Quad(c1,c2,q[SW],q[NW]).inset(E,30); - Quad q2 = Quad(q[NE],q[SE],c2,c1).inset(W,30); +BatimentQuad_::BatimentQuad_(Quad _c, bool _isSub) : Chose(), c(_c), isSub(_isSub) { + addEntropy(c); +} - addChild((new BatimentQuad_(q1))->isSubdivision(true)); - addChild((new BatimentQuad_(q2))->isSubdivision(true)); - } - else { - Quad ch = c.offsetNormal(Dimensions::hauteurEtage); - addChild(new ToitQuad(ch, Dimensions::hauteurToit)); - } +bool BatimentQuad_::split() { + int minSurface = 100 * 100 * 100; + Quad q = c << c.maxLengthSide(); + if(q.surface() > 2 * minSurface) { + Vertex n = Segment(q[NW], q[NE]).randomPos(seed, 0, 3.f/8.f, 5.f/8.f); + Vertex s = Segment(q[SE], q[SW]).randomPos(seed, 1, 3.f/8.f, 5.f/8.f); + + addChild(new BatimentQuad_(Quad(q[NE], q[SE], s, n), true)); + addChild(new BatimentQuad_(Quad(q[SW], q[NW], n, s), true)); + } else { + Quad ch = c.offsetNormal(Dimensions::hauteurEtage); + addChild(new ToitQuad(ch, Dimensions::hauteurToit)); + } return true; } -BatimentQuad_* BatimentQuad_::isSubdivision(bool val) { - this->isSub = val; - return this; -} - void BatimentQuad_::triangulation() { Quad ch = c.offsetNormal(Dimensions::hauteurEtage + Dimensions::hauteurToit); addGPUQuad(ch, Couleurs::toit); diff --git a/rules/architecture/batiment.hh b/rules/architecture/batiment.hh @@ -9,6 +9,7 @@ class BatimentQuad_ : public Chose { public: BatimentQuad_(Quad _c); + BatimentQuad_(Quad _c, bool _isSub); virtual bool split(); virtual void triangulation(); virtual void getBoundingBoxPoints();