diff --git a/heap.cpp b/heap.cpp index ca0f7aa..69b7997 100644 --- a/heap.cpp +++ b/heap.cpp @@ -6,14 +6,6 @@ Heap::Heap() void Heap::init(int id, int factor) { this->id = id; this->factor = factor; } void Heap::insert(float key, Chose* value) { - // { // DEBUG - // int _d_node = value->lod.heaps[id]; - // if (_d_node <= lastNode && _d_node >= 0 && - // buckets[getBucket(_d_node)][getIndex(_d_node)].value == value) { - // std::cout << "ERROR ! Trying to insert " << value; - // std::cout << " but it is already here." << std::endl; - // } - // } ++lastNode; if (getBucket(lastNode) > lastAllocatedBucket) { allocateBucket(); @@ -21,26 +13,11 @@ void Heap::insert(float key, Chose* value) { buckets[getBucket(lastNode)][getIndex(lastNode)].key = key; buckets[getBucket(lastNode)][getIndex(lastNode)].value = value; siftUp(lastNode); - for (int i = 0; i <= lastNode; i++) { - std::cout << id << " "; - std::cout << buckets[getBucket(lastNode)][getIndex(lastNode)].key << " "; - std::cout << buckets[getBucket(lastNode)][getIndex(lastNode)].value; - std::cout << typeid(*(buckets[getBucket(lastNode)][getIndex(lastNode)].value)).name(); - std::cout << std::endl; - } } void Heap::remove(Chose* value) { int node = value->lod.heaps[id]; - // { // DEBUG - // if (buckets[getBucket(node)][getIndex(node)].value != value) { - // std::cout << "ERROR ! Trying to remove " << value; - // std::cout << " but found " << buckets[getBucket(node)][getIndex(node)].value; - // std::cout << std::endl; - // } - // } - if (node == lastNode) { // On a supprimé le dernier noeud. --lastNode; // + 1 pour garder au moins un bucket "en cache". @@ -84,7 +61,7 @@ void Heap::siftUp(int node) { break; int p = parent(node); np = &(buckets[getBucket(p)][getIndex(p)]); - if (n->key * factor <= np->key * factor) + if (n->key * factor >= np->key * factor) //!!!!! break; HeapNode temp = *n; *n = *np; @@ -111,9 +88,9 @@ void Heap::siftDown(int node) { nrc = &(buckets[getBucket(rc)][getIndex(rc)]); // exchLeft et exchRight peuvent être tout deux true. Dans ce // cas, c'est exchRight qui gagne. - bool exchLeft = (lc <= lastNode) && (n->key * factor < nlc->key * factor); - bool exchRight = (rc <= lastNode) && (n->key * factor < nrc->key * factor); - exchRight = exchRight && (nlc->key * factor < nrc->key * factor); + bool exchLeft = (lc <= lastNode) && (n->key * factor > nlc->key * factor); + bool exchRight = (rc <= lastNode) && (n->key * factor > nrc->key * factor); + exchRight = exchRight && (nlc->key * factor > nrc->key * factor); if ((!exchLeft) && (!exchRight)) break; HeapNode temp = *n; diff --git a/lod.cpp b/lod.cpp index 023d88f..fd0bca0 100644 --- a/lod.cpp +++ b/lod.cpp @@ -33,7 +33,6 @@ void Lod::setCamera(Vertex newCamera) { for(int i = 0; i < 6; i++) { Chose* c; while((c = splitOut[i].popIfLessThan(camera[i>>1]))) { - std::cout<<"soi "<lod.inCounter+1<<" "<lod.inCounter == 5) { for(int j = 0; j < 6; j++) { if(i == j) continue; @@ -52,7 +51,6 @@ void Lod::setCamera(Vertex newCamera) { for(int i = 0; i < 6; i++) { Chose* c; while((c = splitIn[i].popIfLessThan(camera[i>>1]))) { - std::cout<<"SIO "<lod.inCounter-1<<" "<lod.inCounter--; splitOut[i].insert(c->lod.splitBox[i], c); } @@ -61,20 +59,21 @@ void Lod::setCamera(Vertex newCamera) { void Lod::doSplit(Chose* c) { // TODO - if (c->split() && c->children.size() > 0) { + if (c->split()) { std::vector::iterator it; for (it = c->children.begin(); it != c->children.end(); ++it) { (*it)->triangulation(); (*it)->updateAABB(); - (*it)->drawAABB(); + // (*it)->drawAABB(); addSplitCube((*it)); } - } else { - // Pour debug : quand on tente de split un objet qui ne peut - // pas l'être, on vire le dessin de sa splitBox. - c->triangles.clear(); - c->triangulation(); } + // else { + // // Pour debug : quand on tente de split un objet qui ne peut + // // pas l'être, on vire le dessin de sa splitBox. + // c->triangles.clear(); + // c->triangulation(); + // } } void Lod::addMergeCube(Chose* chose) { @@ -85,9 +84,6 @@ void Lod::addMergeCube(Chose* chose) { void Lod::addSplitCube(Chose* chose) { chose->lod.inCounter = 0; for(int i = 0; i < 6; i++) { - // std::cout << chose->lod.splitBox[i] << " " << camera[i>>1] << " " << splitOut[i].factor; - // std::cout << " " << (splitOut[i].lessThan(chose->lod.splitBox[i], camera[i>>1]) ? "t" : "f"); - // std::cout << std::endl; if(splitOut[i].lessThan(chose->lod.splitBox[i], camera[i>>1])) { chose->lod.inCounter++; splitIn[i].insert(chose->lod.splitBox[i], chose); @@ -101,5 +97,4 @@ void Lod::addSplitCube(Chose* chose) { splitIn[i].remove(chose); doSplit(chose); } - std::cout<<"insert "<lod.inCounter<<" "<