www

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

commit 9d8a85afd69a7ef92c895efd67bfb451fbdf639e
parent 8b2d8ad14bfba6d49b6401c22d62f016e1bf8883
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date:   Fri,  9 Dec 2011 23:46:34 +0100

Merge branch 'master' of github:jsmaniac/2011-m2s3-city-builder

Diffstat:
Mlod.cpp | 47++++++++++++++++++++++++++++++++++++++++++-----
Mlod.hh | 4++--
Mrules/chose.hh | 3+++
3 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/lod.cpp b/lod.cpp @@ -39,24 +39,61 @@ Lod::Lod(float[3] camera) { void Lod::setCamera(float[3] camera) { this->camera = camera; - for(int i = 0; i < 5; i++) { + // Merge. + for(int i = 0; i < 6; i++) { Chose* c; int pos = NegateEven(camera[i>>1], i); while(c = merge[i].popIfLessThan(pos)) { - for(int j = 0; j < 5; j++) { + for(int j = 0; j < 6; j++) { if(i == j) break; // TODO : sera merge[j].remove(c->mergeCube[j]); merge[j].remove(NegateEven(c->mergeCube[j], j), c); } } } + // Split out vers split in. + for(int i = 0; i < 6; i++) { + Chose* c; + int pos = NegateEven(camera[i>>1], i+1); + while(c = split[2*i+1].popIfLessThan(pos)) { + if(c->inCounter = 5) { + for(int j = 0; j < 6; j++) { + if(i == j) break; + // TODO : sera split[2*j].remove(c->splitCube[j]); + split[2*j].remove(NegateEven(c->splitCube[j], j), c); + } + } + else { + c->inCounter++; + split[2*i].insert(c->splitCube[i], c); + } + } + } + + // Split in vers split out. + for(int i = 0; i < 6; i++) { + Chose* c; + int pos = NegateEven(camera[i>>1], i); + while(c = split[2*i].popIfLessThan(pos)) { + c->inCounter--; + split[2*i+1].insert(c->splitCube[i], c); + } + } } void Lod::addMergeCube(Chose* chose, int[6] limits) { for(int i = 0; i < 5; i++) - merge.insert(NegateEven(limits[i], i), chose); + merge[i].insert(NegateEven(limits[i], i), chose); } -void Lod::addSplitCube(int[6] limits) { - +void Lod::addSplitCube(Chose* chose, int[6] limits) { + chose->inCounter = 0; + for(int i = 0; i < 5; i++) + if(NegateEven(limits[i],i) > camera[i>>1]) { + chose->inCounter++; + split[2*i].insert(NegateEven(limits[i],i), chose); + } + else { + split[2*i+1].insert(NegateEven(limits[i],i+1), chose); + } } diff --git a/lod.hh b/lod.hh @@ -14,8 +14,8 @@ class Abr { class Lod { private : - Abr merge[6]; - Abr split[12]; + Abr merge[6]; // {xMin, xMax, yMin, yMax, zMin, zMax}. + Abr split[12]; // {xMinIn, xMinOut, xMaxIn, xMaxOut, yMinIn, yMaxOut, yMaxIn, yMaxOut, zMinIn, zMinOut, zMaxIn, zMaxOut}. float camera[3]; public : diff --git a/rules/chose.hh b/rules/chose.hh @@ -10,6 +10,9 @@ public: unsigned int seed; std::vector<Chose*> children; std::vector<Triangle*> triangles; + int inCounter; + int splitCube[6]; + int mergeCube[6]; public: Chose(); inline void addEntropy(unsigned int x1) { seed = hash2(seed, x1); }