-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestTree.cpp
78 lines (71 loc) · 2.4 KB
/
testTree.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <glm/glm.hpp>
#include "Octree.hpp"
#include "AABB.hpp"
#include "Util.hpp"
#include <thread>
#include <iostream>
#include <set>
#include <algorithm>
#include <cstdlib>
int main() {
vv3Id posIds;
static const float areaSize = 10000.0f;
static const float seperator = 1.03f;
static const float floor_mass = 1.0f;
static const float scaleFactor = 1.0f;
int id = 0;
const int n = 1000;
Octree tree(zeroV, areaSize);
for (int i=0; i<n; ++i) {
const v3 position(v3(i,i,i));
tree.insert(position,id);
posIds.push_back(std::make_pair(position,id));
++id;
}
for (auto& p: posIds) {
std::cout << "Pair " << p.second << "," << printV(p.first) << "\n";
}
static long fps_max = 60l;
int frame = 0;
long currentTime = timeNowMicros();
srand (static_cast <unsigned> (timeNowMicros()));
while (true) {
long newTime = timeNowMicros();
//std::cout << "TIme start " << newTime << "\n";
long frameTime = newTime - currentTime;
currentTime = newTime;
std::cout << "frame:" << frame++ << "\n";
// sleep if fps would be > fps_max
// move them
// /*
static bool b = false;
const v3 c(1.0f,1.0f,1.0f);
for (auto& p: posIds) {
const bool deleted = tree.del(p.first, p.second);
assert(deleted && "Should always be able to delete last cube position");
float r = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
if (b) {
p.first += c;
} else {
p.first += -c;
}
tree.insert(p.first, p.second);
//std::cout << "Pair " << p.second << "," << printV(p.first) << "\n";
}
b = !b;
//1.73205
// retrieve them
//
// do stuff
//std::cout << "Frametime " << frameTime << "\n";
//std::cout << "TIme now " << timeNowMicros() << "\n";
long diff = timeNowMicros() - newTime;
std::cout << "Diff " << diff << "\n";
//long spareFrameTime = (1e6l / fps_max) - (timeNowMicros() - newTime);
if (diff > 10000l) {
//std::cout << "---\t---- Spare frame time " << spareFrameTime << "---\t---\n";
}
//std::this_thread::sleep_for(std::chrono::microseconds(std::max(0l,spareFrameTime)));
}
std::cout << "asd\n";
}