From 683f3bfa3e6bf15cecc48101b378b9907b693b07 Mon Sep 17 00:00:00 2001 From: Yoann Date: Mon, 5 Dec 2011 15:05:59 +0100 Subject: [PATCH] =?UTF-8?q?Version=20de=20d=C3=A9part=20de=20LOD.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lod.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lod.hh | 26 ++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 lod.cpp create mode 100644 lod.hh diff --git a/lod.cpp b/lod.cpp new file mode 100644 index 0000000..f8f69a7 --- /dev/null +++ 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::iterator,multimap::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::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 new file mode 100644 index 0000000..57b9b80 --- /dev/null +++ b/lod.hh @@ -0,0 +1,26 @@ +#include "all_includes.hh" + +class Abr { + private : + std::multimap 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); +};