|
@@ -2,6 +2,9 @@
|
|
#include <GLFW/glfw3.h>
|
|
#include <GLFW/glfw3.h>
|
|
#include <iostream>
|
|
#include <iostream>
|
|
#include <algorithm>
|
|
#include <algorithm>
|
|
|
|
+#include <chrono>
|
|
|
|
+#include <fstream>
|
|
|
|
+#include <cmath>
|
|
|
|
|
|
#include "Game.h"
|
|
#include "Game.h"
|
|
#include "utils/Random.h"
|
|
#include "utils/Random.h"
|
|
@@ -27,11 +30,29 @@ Game::Game(Keys& keys, const char* file, bool steps) : keys(keys), keyNext(keys.
|
|
state(SPLIT) {
|
|
state(SPLIT) {
|
|
if(file == nullptr) {
|
|
if(file == nullptr) {
|
|
Random r;
|
|
Random r;
|
|
- int amount = steps ? 50 : 1000000;
|
|
+ int amount = steps ? 50 : 100000;
|
|
for(int i = 0; i < amount; i++) {
|
|
for(int i = 0; i < amount; i++) {
|
|
data.push_back({r.nextFloat(), r.nextFloat()});
|
|
data.push_back({r.nextFloat(), r.nextFloat()});
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
|
|
+ std::ifstream in;
|
|
|
|
+ in.open(file);
|
|
|
|
+ if(!in.good()) {
|
|
|
|
+ std::cout << "cannot read '" << file << "'\n";
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ int count;
|
|
|
|
+ in >> count;
|
|
|
|
+ while(in.get() != '\n');
|
|
|
|
+ for(int i = 0; i < count; i++) {
|
|
|
|
+ float x;
|
|
|
|
+ float y;
|
|
|
|
+ in >> x;
|
|
|
|
+ in.get();
|
|
|
|
+ in >> y;
|
|
|
|
+ while(!in.eof() && in.get() != '\n');
|
|
|
|
+ data.push_back({x, y});
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if(data.size() > 0) {
|
|
if(data.size() > 0) {
|
|
@@ -341,12 +362,15 @@ void Game::renderGroup(Renderer& renderer, const std::vector<Point>& group, uint
|
|
}
|
|
}
|
|
|
|
|
|
void Game::skip() {
|
|
void Game::skip() {
|
|
|
|
+ long time = std::chrono::high_resolution_clock::now().time_since_epoch().count();
|
|
split();
|
|
split();
|
|
while(merge()) {
|
|
while(merge()) {
|
|
while(findLowerTangent());
|
|
while(findLowerTangent());
|
|
while(findUpperTangent());
|
|
while(findUpperTangent());
|
|
finalizeMerge();
|
|
finalizeMerge();
|
|
}
|
|
}
|
|
|
|
+ time = std::chrono::high_resolution_clock::now().time_since_epoch().count() - time;
|
|
|
|
+ std::cout << "Took " << (time / 1000000.0) << "ms\n";
|
|
state = END;
|
|
state = END;
|
|
hullA.clear();
|
|
hullA.clear();
|
|
hullB.clear();
|
|
hullB.clear();
|