From e06a78df824abd831cd68361045f5255b5a771fb Mon Sep 17 00:00:00 2001 From: Yoann Date: Wed, 18 Jan 2012 18:17:08 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20bool=C3=A9ens=20pour=20d=C3=A9tect?= =?UTF-8?q?ion=20des=20maison=20compl=C3=A8tement=20encercl=C3=A9es.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rules/architecture/batiment.cpp | 20 +++++++++++++++----- rules/architecture/batiment.hh | 3 ++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/rules/architecture/batiment.cpp b/rules/architecture/batiment.cpp index a9162dd..fceb11d 100644 --- a/rules/architecture/batiment.cpp +++ b/rules/architecture/batiment.cpp @@ -1,20 +1,30 @@ #include "all_includes.hh" -BatimentQuad_::BatimentQuad_(Quad _c, bool _isSub) : Chose(), c(_c), isSub(_isSub) { +BatimentQuad_::BatimentQuad_(Quad _c, bool _isSub, bool _we, bool _ws, bool _ww, bool _wn) + : Chose(), c(_c), isSub(_isSub), we(_we), ws(_ws), ww(_ww), wn(_wn) { addEntropy(c); } bool BatimentQuad_::split() { int minSurface = 100 * 100 * 100; - Quad q = c << c.maxLengthSide(); - if(q.surface() > 2 * minSurface) { + Quad q = c; + //Quad q = c << c.maxLengthSide(); + if(c.maxLengthNS() < c.maxLengthEW()) { + q = c >> 1; + bool t = we; + we = wn; wn = ww; ww = ws; ws = t; + } + + std::cout << "w : " << we << " " << ws << " " << ww << " " << wn << std::endl; + if((we || ws || ww || wn) && 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)); + addChild(new BatimentQuad_(Quad(q[NE], q[SE], s, n), true,we&&true,ws&&true,false,wn&&true)); + addChild(new BatimentQuad_(Quad(q[SW], q[NW], n, s), true,false,ws&&true,ww&&true,wn&&true)); } else { Quad ch = c.offsetNormal(Dimensions::hauteurEtage); + ch = ch.insetNESW(80); addChild(new ToitQuad(ch, Dimensions::hauteurToit)); } diff --git a/rules/architecture/batiment.hh b/rules/architecture/batiment.hh index 107b241..e1fe5a0 100644 --- a/rules/architecture/batiment.hh +++ b/rules/architecture/batiment.hh @@ -6,9 +6,10 @@ class BatimentQuad_ : public Chose { Quad c; bool isSub; + bool we, ws, ww, wn; public: - BatimentQuad_(Quad _c, bool _isSub = false); + BatimentQuad_(Quad _c, bool _isSub=false, bool _we=true, bool _ws=true, bool _ww=true, bool _wn=true); virtual bool split(); virtual void triangulation(); virtual void getBoundingBoxPoints();