Compare commits
1 Commits
master
...
statistics
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7a37f4fbc2 |
2
Makefile
2
Makefile
|
@ -24,7 +24,7 @@ $(EXECUTABLE): $(SOURCES) all_includes.hh.gch Makefile
|
||||||
@echo "#define _ALL_CPP_">> all.cpp
|
@echo "#define _ALL_CPP_">> all.cpp
|
||||||
@$(foreach FILE,$(SOURCES),echo '#include "'"$(FILE)"'"' >> all.cpp;)
|
@$(foreach FILE,$(SOURCES),echo '#include "'"$(FILE)"'"' >> all.cpp;)
|
||||||
@echo "#endif">> all.cpp
|
@echo "#endif">> all.cpp
|
||||||
$(CXX) all.cpp $(LIBS) $(CFLAGS) -o $@
|
$(CXX) $(LIBS) $(CFLAGS) all.cpp -o $@
|
||||||
@rm all.cpp
|
@rm all.cpp
|
||||||
|
|
||||||
all_includes.hh.gch: $(HEADERS) Makefile
|
all_includes.hh.gch: $(HEADERS) Makefile
|
||||||
|
|
|
@ -15,3 +15,8 @@ How to run this program ?
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
make
|
make
|
||||||
|
|
||||||
|
How to run the statistics ?
|
||||||
|
===========================
|
||||||
|
|
||||||
|
mkdir -p png && make city && ./city > statistics.plt && pv statistics.plt | tail -n +2 | gnuplot
|
||||||
|
|
|
@ -7,6 +7,7 @@ class Chose;
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <iomanip> // DEBUG
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
11
heap.cpp
11
heap.cpp
|
@ -26,3 +26,14 @@ Chose* Heap::popIfLessThan(float key) {
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern int debug_printlod_axis;
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& os, const Heap& h) {
|
||||||
|
for (std::set<HeapNode>::iterator it = h.bst.begin(); it != h.bst.end(); ++it) {
|
||||||
|
int i = debug_printlod_axis;
|
||||||
|
// TODO : put a color instead of "1"
|
||||||
|
os << it->value->lod.center[i] << ", " << (it->value->lod.splitDistance[i])/(Dimensions::splitFactor) << ", " << 1 << std::endl;
|
||||||
|
}
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
1
heap.hh
1
heap.hh
|
@ -24,6 +24,7 @@ public:
|
||||||
Chose* popIfLessThan(float key);
|
Chose* popIfLessThan(float key);
|
||||||
bool lessThan(float a, float b); // Renvoie true ssi a < b dans l'ordre du tas.
|
bool lessThan(float a, float b); // Renvoie true ssi a < b dans l'ordre du tas.
|
||||||
void init(int factor); // factor = -1 pour tas Min, 1 pour tas max
|
void init(int factor); // factor = -1 pour tas Min, 1 pour tas max
|
||||||
|
friend std::ostream& operator<<(std::ostream& os, const Heap& v);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
32
lod.cpp
32
lod.cpp
|
@ -13,6 +13,8 @@ Lod::Lod(Vertex _camera, Chose* root) {
|
||||||
setCamera(_camera);
|
setCamera(_camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int debug_printlod_axis;
|
||||||
|
|
||||||
void Lod::setCamera(Vertex newCamera) {
|
void Lod::setCamera(Vertex newCamera) {
|
||||||
this->camera[0] = newCamera.x;
|
this->camera[0] = newCamera.x;
|
||||||
this->camera[1] = newCamera.y;
|
this->camera[1] = newCamera.y;
|
||||||
|
@ -55,14 +57,40 @@ void Lod::setCamera(Vertex newCamera) {
|
||||||
splitOut[i].insert(c->lod.splitBox[i], c);
|
splitOut[i].insert(c->lod.splitBox[i], c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Statistics
|
||||||
|
Heap* heaps[3] = { merge, splitIn, splitOut };
|
||||||
|
const char* heapNames[3] = { "merge", "splitIn", "splitOut" };
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
for (int j = 0; j < 3; j++) {
|
||||||
|
debug_printlod_axis = i/2;
|
||||||
|
std::cout << "set term png" << std::endl
|
||||||
|
<< "set output 'png/"
|
||||||
|
<< heapNames[j] << " " << ((i & 1) ? '+' : '-') << (char)('x' + debug_printlod_axis) << " frame " << std::setfill('0') << std::setw(5) << Camera::debug_frame
|
||||||
|
<< ".png'" << std::endl
|
||||||
|
<< "unset arrow" << std::endl
|
||||||
|
<< "set arrow from "
|
||||||
|
<< camera[debug_printlod_axis] << "," << 0 <<" to "
|
||||||
|
<< (camera[debug_printlod_axis] + 10000000*((i & 1) ? -1 : 1)) << "," << 10000000*(Dimensions::splitFactor)
|
||||||
|
<< " nohead linecolor rgb 'blue'" << std::endl
|
||||||
|
<< "plot '-' title '"
|
||||||
|
<< heapNames[j] << " " << ((i & 1) ? '+' : '-') << (char)('x' + debug_printlod_axis) << " frame " << std::setfill('0') << std::setw(5) << Camera::debug_frame
|
||||||
|
<< "' with dots linecolor variable" << std::endl
|
||||||
|
<< "0, 0, 0" << std::endl
|
||||||
|
<< heaps[j][i]
|
||||||
|
<< "end" << std::endl;
|
||||||
|
}
|
||||||
|
// std::cout << "merge[" << i << "] = {" << merge[i] << "}" << std::endl;
|
||||||
|
// std::cout << "splitIn[" << i << "] = {" << splitIn[i] << "}" << std::endl;
|
||||||
|
// std::cout << "splitOut[" << i << "] = {" << splitOut[i] << "}" << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lod::doSplit(Chose* c) {
|
void Lod::doSplit(Chose* c) {
|
||||||
c->split();
|
c->split();
|
||||||
std::vector<Chose*>::iterator it;
|
std::vector<Chose*>::iterator it;
|
||||||
////bool mergeCube = false; // Started to work again on the project, a new warning detected this.
|
bool mergeCube = false;
|
||||||
for (it = c->children.begin(); it != c->children.end(); ++it) {
|
for (it = c->children.begin(); it != c->children.end(); ++it) {
|
||||||
////mergeCube = true; // Started to work again on the project, a new warning detected this.
|
mergeCube = true;
|
||||||
(*it)->triangulation();
|
(*it)->triangulation();
|
||||||
(*it)->updateAABB();
|
(*it)->updateAABB();
|
||||||
// (*it)->drawAABB();
|
// (*it)->drawAABB();
|
||||||
|
|
2
lod.hh
2
lod.hh
|
@ -26,6 +26,8 @@ struct LodNode {
|
||||||
float mergeBox[6];
|
float mergeBox[6];
|
||||||
int inCounter;
|
int inCounter;
|
||||||
bool firstBBPoint;
|
bool firstBBPoint;
|
||||||
|
float splitDistance[3];
|
||||||
|
float center[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
16077
points/test.plt
Normal file
16077
points/test.plt
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -163,6 +163,8 @@ void Chose::updateAABB() {
|
||||||
lod.splitBox[2*i+1] = center[i] + splitDistance;
|
lod.splitBox[2*i+1] = center[i] + splitDistance;
|
||||||
lod.mergeBox[2*i] = center[i] - mergeDistance;
|
lod.mergeBox[2*i] = center[i] - mergeDistance;
|
||||||
lod.mergeBox[2*i+1] = center[i] + mergeDistance;
|
lod.mergeBox[2*i+1] = center[i] + mergeDistance;
|
||||||
|
lod.splitDistance[i] = splitDistance; // TODO : Remove, this is here just for Statistics
|
||||||
|
lod.center[i] = center[i]; // TODO : Remove, this is here just for Statistics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ protected :
|
||||||
virtual void getBoundingBoxPoints() = 0;
|
virtual void getBoundingBoxPoints() = 0;
|
||||||
virtual float LODFactor();
|
virtual float LODFactor();
|
||||||
Chose();
|
Chose();
|
||||||
virtual ~Chose();
|
~Chose();
|
||||||
inline void addEntropy(unsigned int x1) {
|
inline void addEntropy(unsigned int x1) {
|
||||||
seed = hash2(seed, x1);
|
seed = hash2(seed, x1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const unsigned int Couleurs::fog = mix(cielHaut, cielBas, 0.5);
|
const unsigned int Couleurs::fog = mix(cielHaut, cielBas, 0.5);
|
||||||
|
|
||||||
const float Dimensions::splitFactor = 3.f;
|
const float Dimensions::splitFactor = 1.f;
|
||||||
const float Dimensions::mergeFactor = 4.f;
|
const float Dimensions::mergeFactor = 1.25f;
|
||||||
const float Dimensions::frontFrustum = 1.f;
|
const float Dimensions::frontFrustum = 1.f;
|
||||||
const float Dimensions::backFrustum = 4000 * 100; // 4km
|
const float Dimensions::backFrustum = 4000 * 100; // 4km
|
||||||
|
|
|
@ -45,7 +45,7 @@ void MurQuad::split() {
|
||||||
Quad righth = Quad(windowPosh[NW],windowPosh[SW],ch[SW],ch[NW]);
|
Quad righth = Quad(windowPosh[NW],windowPosh[SW],ch[SW],ch[NW]);
|
||||||
Quad left = Quad(c[NE],c[SE],windowPos[SE],windowPos[NE]);
|
Quad left = Quad(c[NE],c[SE],windowPos[SE],windowPos[NE]);
|
||||||
Quad lefth = Quad(ch[NE],ch[SE],windowPosh[SE],windowPosh[NE]);
|
Quad lefth = Quad(ch[NE],ch[SE],windowPosh[SE],windowPosh[NE]);
|
||||||
////Quad top = Quad(windowPosh[NE],windowPosh[NW],windowPosh[SW],windowPosh[SE]); // Started to work again on the project, a new warning detected this.
|
Quad top = Quad(windowPosh[NE],windowPosh[NW],windowPosh[SW],windowPosh[SE]);
|
||||||
|
|
||||||
if (!door) addChild(new MurQuad(c,windowPos,false, true, false));
|
if (!door) addChild(new MurQuad(c,windowPos,false, true, false));
|
||||||
addChild(new MurQuad(windowPosh,ch, false, false, true));
|
addChild(new MurQuad(windowPosh,ch, false, false, true));
|
||||||
|
|
3
view.cpp
3
view.cpp
|
@ -144,6 +144,7 @@ void View::renderScene(int lastTime, int currentTime) {
|
||||||
|
|
||||||
camera.animation(std::min(100, currentTime-lastTime));
|
camera.animation(std::min(100, currentTime-lastTime));
|
||||||
camera.setCamera();
|
camera.setCamera();
|
||||||
|
// std::cout << std::endl << "lod.setCamera(" << camera.cameraCenter << ")" << std::endl;
|
||||||
lod.setCamera(camera.cameraCenter);
|
lod.setCamera(camera.cameraCenter);
|
||||||
|
|
||||||
setLight();
|
setLight();
|
||||||
|
@ -351,9 +352,11 @@ void Camera::keyboard(const SDL_KeyboardEvent &eventKey) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Camera::debug_frame = 0;
|
||||||
void Camera::animation(int elapsedTime) {
|
void Camera::animation(int elapsedTime) {
|
||||||
static unsigned int frame = 0;
|
static unsigned int frame = 0;
|
||||||
frame++;
|
frame++;
|
||||||
|
Camera::debug_frame = frame;
|
||||||
float diff = ((float)(elapsedTime+1)/1000.f)*(float)moveSensitivity;
|
float diff = ((float)(elapsedTime+1)/1000.f)*(float)moveSensitivity;
|
||||||
|
|
||||||
if (autoPilot) {
|
if (autoPilot) {
|
||||||
|
|
1
view.hh
1
view.hh
|
@ -22,6 +22,7 @@ private :
|
||||||
bool autoPilot;
|
bool autoPilot;
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
static int debug_frame;
|
||||||
Camera(Vertex pos, float xA, float yA, int moveSensitivity, float mouseSensitivity);
|
Camera(Vertex pos, float xA, float yA, int moveSensitivity, float mouseSensitivity);
|
||||||
void setCamera();
|
void setCamera();
|
||||||
void mouseMotion(const SDL_MouseMotionEvent &event);
|
void mouseMotion(const SDL_MouseMotionEvent &event);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user