www

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

commit 683f3bfa3e6bf15cecc48101b378b9907b693b07
parent 61ea30e35dbd1a7f63c9a92c142f99ef14df0c07
Author: Yoann <yoann.b87@voila.fr>
Date:   Mon,  5 Dec 2011 15:05:59 +0100

Version de départ de LOD.

Diffstat:
Alod.cpp | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alod.hh | 26++++++++++++++++++++++++++
2 files changed, 88 insertions(+), 0 deletions(-)

diff --git a/lod.cpp b/lod.cpp @@ -0,0 +1,62 @@ +#include "all_includes.hh" + +Abr::Abr() { +} + +Abr::insert(int key, Chose* value) { + map.insert(key,value); +} + +Abr::remove(int key, Chose* value) { + pair<multimap<int,Chose*>::iterator,multimap<int,Chose*>::iterator> ret; + ret = map.equal_range(key); + for (it=ret.first; it!=ret.second; ++it) { + if ((*it).second == value) { + map.erase(it); + break; + } + } +} + +Abr::popIfLessThan(int key) { + std::multimap<int,Chose*>::iterator it = map.begin(); + + if((*it).first < key) { + map.erase(it); + return (*it).second; + } else { + return NULL; + } +} + + +#define NegateEven(v, i) ((v)*(((i)&1) ? 1 : -1)) + +Lod::Lod(float[3] camera) { + this->camera = camera; +} + +void Lod::setCamera(float[3] camera) { + this->camera = camera; + + for(int i = 0; i < 5; i++) { + Chose* c; + int pos = NegateEven(camera[i>>1], i); + while(c = merge[i].popIfLessThan(pos)) { + for(int j = 0; j < 5; j++) { + if(i == j) break; + // TODO : sera merge[j].remove(c->mergeCube[j]); + merge[j].remove(NegateEven(c->mergeCube[j], j), c); + } + } + } +} + +void Lod::addMergeCube(Chose* chose, int[6] limits) { + for(int i = 0; i < 5; i++) + merge.insert(NegateEven(limits[i], i), chose); +} + +void Lod::addSplitCube(int[6] limits) { + +} diff --git a/lod.hh b/lod.hh @@ -0,0 +1,26 @@ +#include "all_includes.hh" + +class Abr { + private : + std::multimap<int, Chose*> map; + + public : + Abr(); + void insert(int key, Chose* value); //TODO Retourne un item*. + void remove(int key, Chose* value); //TODO Prend un item*. + Chose* popIfLessThan(int key); +}; + + +class Lod { + private : + Abr merge[6]; + Abr split[12]; + float camera[3]; + + public : + Lod(float[3] camera); + void addMergeCube(Chose* chose, int[6] limits); + void addSplitCube(Chose* chose, int[6] limits); + void setCamera(float[3] camera); +};