mkdir png && make city && ./city > statistics.plt && pv statistics.plt | tail -n +2 | gnuplot # This will generate some statistics about SplitBox/MergeBox boundaries using gnuplot.
This commit is contained in:
parent
d15ef280f6
commit
7a37f4fbc2
|
@ -15,3 +15,8 @@ How to run this program ?
|
|||
=========================
|
||||
|
||||
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 <iostream>
|
||||
#include <iomanip> // DEBUG
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
|
11
heap.cpp
11
heap.cpp
|
@ -26,3 +26,14 @@ Chose* Heap::popIfLessThan(float key) {
|
|||
}
|
||||
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);
|
||||
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
|
||||
friend std::ostream& operator<<(std::ostream& os, const Heap& v);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
28
lod.cpp
28
lod.cpp
|
@ -13,6 +13,8 @@ Lod::Lod(Vertex _camera, Chose* root) {
|
|||
setCamera(_camera);
|
||||
}
|
||||
|
||||
int debug_printlod_axis;
|
||||
|
||||
void Lod::setCamera(Vertex newCamera) {
|
||||
this->camera[0] = newCamera.x;
|
||||
this->camera[1] = newCamera.y;
|
||||
|
@ -55,6 +57,32 @@ void Lod::setCamera(Vertex newCamera) {
|
|||
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) {
|
||||
|
|
2
lod.hh
2
lod.hh
|
@ -26,6 +26,8 @@ struct LodNode {
|
|||
float mergeBox[6];
|
||||
int inCounter;
|
||||
bool firstBBPoint;
|
||||
float splitDistance[3];
|
||||
float center[3];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
16077
points/test.plt
Normal file
16077
points/test.plt
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -147,8 +147,11 @@ void Chose::updateAABB() {
|
|||
lod.firstBBPoint = true;
|
||||
getBoundingBoxPoints();
|
||||
float size[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
float center[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
size[i] = lod.aabb[2*i+1] - lod.aabb[2*i];
|
||||
center[i] = (lod.aabb[2*i] + lod.aabb[2*i+1])/2.f;
|
||||
}
|
||||
float areaFacing[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
areaFacing[i] = size[(i+1)%3]*size[(i+1)%3];
|
||||
|
@ -160,6 +163,8 @@ void Chose::updateAABB() {
|
|||
lod.splitBox[2*i+1] = center[i] + splitDistance;
|
||||
lod.mergeBox[2*i] = 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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
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.setCamera();
|
||||
// std::cout << std::endl << "lod.setCamera(" << camera.cameraCenter << ")" << std::endl;
|
||||
lod.setCamera(camera.cameraCenter);
|
||||
|
||||
setLight();
|
||||
|
@ -351,9 +352,11 @@ void Camera::keyboard(const SDL_KeyboardEvent &eventKey) {
|
|||
}
|
||||
}
|
||||
|
||||
int Camera::debug_frame = 0;
|
||||
void Camera::animation(int elapsedTime) {
|
||||
static unsigned int frame = 0;
|
||||
frame++;
|
||||
Camera::debug_frame = frame;
|
||||
float diff = ((float)(elapsedTime+1)/1000.f)*(float)moveSensitivity;
|
||||
|
||||
if (autoPilot) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user