Version de départ de LOD.
This commit is contained in:
parent
61ea30e35d
commit
683f3bfa3e
62
lod.cpp
Normal file
62
lod.cpp
Normal file
|
@ -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) {
|
||||
|
||||
}
|
26
lod.hh
Normal file
26
lod.hh
Normal file
|
@ -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);
|
||||
};
|
Loading…
Reference in New Issue
Block a user